From patchwork Wed Mar 12 13:05:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chemeris X-Patchwork-Id: 329435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3D90E2C00A4 for ; Thu, 13 Mar 2014 00:06:25 +1100 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WNirJ-0003iI-V1; Wed, 12 Mar 2014 14:06:11 +0100 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by ganesha.gnumonks.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from ) id 1WNir1-0003hL-4M for openbsc@lists.osmocom.org; Wed, 12 Mar 2014 14:05:56 +0100 Received: by mail-pd0-f177.google.com with SMTP id y10so392683pdj.36 for ; Wed, 12 Mar 2014 06:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=SUkXQdhZbCsjNScn+g+nDfDiP1/Ua4SgstxIGuQnRlk=; b=S2JoW4onWr8mAI3F50NpTvtj+vVOlONHOWlFMSpF/JnmH3QFJGPs0k7b7OOeGnfc1P zksN6VQ9M4HAhCKG4bFhbGddQDrMfHioXi2Q6DqIxpaeFO5uj9veqXfgSZO7nSEaqF1h yC3LA32KkXVwkdmr2br+eaajmASrH+/NlvufuVCLIHzVLm2KtzMvuHdTlqv/RcWvtOUF 99TS9GAhvmFk17c3C/ztuIGvY+314c9awWkwitQWbfRn1h4tA4Yzmo6YRDlxvftJhbhR bKC376cbRKI/cTzdbjNQcLKdeAOH5k8QRIhGWKyT+lKA491ikZWRVW+S92ctMLEBqJqp Vfcw== X-Received: by 10.66.171.76 with SMTP id as12mr4963854pac.52.1394629547848; Wed, 12 Mar 2014 06:05:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.70.88.239 with HTTP; Wed, 12 Mar 2014 06:05:26 -0700 (PDT) In-Reply-To: <20140312123702.GD2460@xiaoyu.lan> References: <20140309182323.GA17965@xiaoyu.lan> <20140311142626.GH17965@xiaoyu.lan> <20140312123702.GD2460@xiaoyu.lan> From: Alexander Chemeris Date: Wed, 12 Mar 2014 17:05:26 +0400 Message-ID: Subject: Re: [PATCH] sms: Rename gsm340_gen_oa() to gsm340_gen_address_field(). To: Holger Hans Peter Freyther X-Spam-Score: -0.1 (/) Cc: OpenBSC Mailing List X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org On Wed, Mar 12, 2014 at 4:37 PM, Holger Hans Peter Freyther wrote: > On Tue, Mar 11, 2014 at 08:16:49PM +0400, Alexander Chemeris wrote: >> > You are using OSMO_DEPRECTAED >> > but you do not directly/indirectly the header file defining it. In fact >> > gsm0411_smc.c fails to compile due this. >> >> Oops, forgot to include this in the patch, my apologies. >> Updated patch is attached. > > wrong patch. I merged this one anyway after grepping my checkouts > for the typo. Sorry, the correct patch attached. From 29ae9c7465a13f8b3fa31fa0928263f68530432d Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sun, 9 Mar 2014 01:33:28 +0100 Subject: [PATCH] sms: Rename gsm340_gen_oa() to gsm340_gen_address_field(). According to 03.40 9.1.2.5 Address fields, this function generates different types of addresses and not only originating addresses. --- include/osmocom/gsm/gsm0411_utils.h | 3 +++ src/gsm/gsm0411_utils.c | 9 ++++++++- src/gsm/libosmogsm.map | 1 + tests/sms/sms_test.c | 16 ++++++++-------- tests/sms/sms_test.ok | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/osmocom/gsm/gsm0411_utils.h b/include/osmocom/gsm/gsm0411_utils.h index cad3625..2895a8d 100644 --- a/include/osmocom/gsm/gsm0411_utils.h +++ b/include/osmocom/gsm/gsm0411_utils.h @@ -2,6 +2,7 @@ #define _GSM0411_UTILS_H #include +#include /* Default SMS validity period is 2 days */ #define SMS_DEFAULT_VALIDITY_PERIOD (2 * 24 * 60 * 60) @@ -28,6 +29,8 @@ enum sms_alphabet gsm338_get_sms_alphabet(uint8_t dcs); /* generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 */ int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type, + uint8_t plan, const char *number) OSMO_DEPRECATED("Use gsm340_gen_address_field() instead"); +int gsm340_gen_address_field(uint8_t *oa, unsigned int oa_len, uint8_t type, uint8_t plan, const char *number); /* Prefix msg with a RP header */ diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c index 12f45d6..e897136 100644 --- a/src/gsm/gsm0411_utils.c +++ b/src/gsm/gsm0411_utils.c @@ -275,7 +275,7 @@ enum sms_alphabet gsm338_get_sms_alphabet(uint8_t dcs) } /* generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 */ -int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type, +int gsm340_gen_address_field(uint8_t *oa, unsigned int oa_len, uint8_t type, uint8_t plan, const char *number) { int len_in_bytes; @@ -304,6 +304,13 @@ int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type, return len_in_bytes; } +/* DEPRECATED: use gsm340_gen_address_field() instead */ +int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type, + uint8_t plan, const char *number) +{ + return gsm340_gen_address_field(oa, oa_len, type, plan, number); +} + /* Prefix msg with a RP header */ int gsm411_push_rp_header(struct msgb *msg, uint8_t rp_msg_type, uint8_t rp_msg_ref) diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 9d15d66..46be0ca 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -63,6 +63,7 @@ gsm0808_prepend_dtap_header; gsm338_get_sms_alphabet; gsm340_gen_oa; +gsm340_gen_address_field; gsm340_gen_scts; gsm340_scts; gsm340_validity_period; diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index 6681ba0..7414d16 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -233,37 +233,37 @@ static void test_octet_return() printf("Done\n"); } -static void test_gen_oa(void) +static void test_gsm340_gen_address_field(void) { uint8_t oa[12]; int len; - printf("Testing gsm340_gen_oa\n"); + printf("Testing gsm340_gen_address_field\n"); /* first try... */ - len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_UNKNOWN, + len = gsm340_gen_address_field(oa, ARRAY_SIZE(oa), GSM340_TYPE_UNKNOWN, GSM340_PLAN_ISDN, "12345678901234567891"); OSMO_ASSERT(len == 12); printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); - len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_NATIONAL, + len = gsm340_gen_address_field(oa, ARRAY_SIZE(oa), GSM340_TYPE_NATIONAL, GSM340_PLAN_ISDN, "12345678901234567891"); OSMO_ASSERT(len == 12); printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); /* long input.. will fail and just prints the header*/ - len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_INTERNATIONAL, + len = gsm340_gen_address_field(oa, ARRAY_SIZE(oa), GSM340_TYPE_INTERNATIONAL, GSM340_PLAN_ISDN, "123456789123456789120"); OSMO_ASSERT(len == 2); printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); /* try the alpha numeric encoding */ - len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, + len = gsm340_gen_address_field(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, GSM340_PLAN_UNKNOWN, "OpenBSC"); OSMO_ASSERT(len == 9); printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); /* long alpha numeric text */ - len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, + len = gsm340_gen_address_field(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, GSM340_PLAN_UNKNOWN, "OpenBSCabcdefghijklm"); OSMO_ASSERT(len == 12); printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); @@ -541,7 +541,7 @@ int main(int argc, char** argv) } test_octet_return(); - test_gen_oa(); + test_gsm340_gen_address_field(); test_validity_period(); printf("OK\n"); diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok index 5ff3e0b..77b22ec 100644 --- a/tests/sms/sms_test.ok +++ b/tests/sms/sms_test.ok @@ -20,7 +20,7 @@ Decode case 5: return value 40 (expected 40) Encoding some tests and printing number of septets/octets SEPTETS: 8 OCTETS: 7 Done -Testing gsm340_gen_oa +Testing gsm340_gen_address_field Result: len(12) data(14 81 21 43 65 87 09 21 43 65 87 19 ) Result: len(12) data(14 a1 21 43 65 87 09 21 43 65 87 19 ) Result: len(2) data(00 91 ) -- 1.7.9.5