diff mbox

sms: Rename gsm340_gen_oa() to gsm340_gen_address_field().

Message ID CABmJbFVaGSnKNR+h=WWjvusc0TT49Pec8r0Bqv8qA2GFhZVWSg@mail.gmail.com
State New
Headers show

Commit Message

Alexander Chemeris March 12, 2014, 1:05 p.m. UTC
On Wed, Mar 12, 2014 at 4:37 PM, Holger Hans Peter Freyther
<holger@freyther.de> 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.

Comments

Alexander Chemeris March 16, 2014, 9:50 a.m. UTC | #1
Hi Holger,

It seems there are no more comments on this code. Could you please merge it?
It is independent of other changes.

On Wed, Mar 12, 2014 at 5:05 PM, Alexander Chemeris
<alexander.chemeris@gmail.com> wrote:
> On Wed, Mar 12, 2014 at 4:37 PM, Holger Hans Peter Freyther
> <holger@freyther.de> 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.
>
> --
> Regards,
> Alexander Chemeris.
> CEO, Fairwaves, Inc. / ООО УмРадио
> https://fairwaves.co
Holger Freyther March 26, 2014, 7:22 p.m. UTC | #2
On Sun, Mar 16, 2014 at 01:50:10PM +0400, Alexander Chemeris wrote:
> Hi Holger,
> 
> It seems there are no more comments on this code. Could you please merge it?
> It is independent of other changes.

Hi!

in Osmocom we prefer shorted/abbreviated names. Do you mind if we call
it gsm340_gen_addr_field instead? This way some of the lines from the
testcase get closer to 80 chars.


holger
Holger Freyther April 17, 2014, 9:30 p.m. UTC | #3
On Thu, Mar 27, 2014 at 09:14:26AM +0400, Alexander Chemeris wrote:

> Good idea. I'll update the patch during the next week.

Did I miss your follow-up patch?
diff mbox

Patch

From 29ae9c7465a13f8b3fa31fa0928263f68530432d Mon Sep 17 00:00:00 2001
From: Alexander Chemeris <Alexander.Chemeris@gmail.com>
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 <time.h>
+#include <osmocom/core/defs.h>
 
 /* 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