Change in libosmocore[master]: gsm48_encode_bcd_number(): clarify optional LHV header initialization

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed May 29 08:48:46 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/14189 )

Change subject: gsm48_encode_bcd_number(): clarify optional LHV header initialization
......................................................................

gsm48_encode_bcd_number(): clarify optional LHV header initialization

Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
---
M src/gsm/gsm48_ie.c
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
3 files changed, 16 insertions(+), 6 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c
index 688698d..59f931b 100644
--- a/src/gsm/gsm48_ie.c
+++ b/src/gsm/gsm48_ie.c
@@ -132,7 +132,13 @@
  *  \param[in] max_len Maximum Length of \a bcd_lv
  *  \param[in] h_len Length of an optional heder between L and V portion
  *  \param[in] input phone number as 0-terminated ASCII
- *  \returns number of bytes used in \a bcd_lv */
+ *  \returns number of bytes used in \a bcd_lv
+ *
+ * Depending on a context (e.g. called or calling party BCD number), the
+ * optional header between L and V parts can contain TON (Type Of Number),
+ * NPI (Numbering Plan Indication), presentation or screening indicator.
+ * NOTE: it is up to the caller to initialize this header!
+ */
 int gsm48_encode_bcd_number(uint8_t *bcd_lv, uint8_t max_len,
 		      int h_len, const char *input)
 {
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index d7bae77..b5f8061 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -654,7 +654,7 @@
 
 		/* Encoding test */
 		.enc_ascii = "123456",
-		.enc_hex   = "0700000000214365",
+		.enc_hex   = "07ffffffff214365",
 		.enc_h_len = 4, /* LHV */
 		.enc_rc    = 4 + 4,
 
@@ -732,8 +732,8 @@
 static void test_bcd_number_encode_decode()
 {
 	const struct bcd_number_test *test;
-	uint8_t buf_enc[0xff] = { 0 };
-	char buf_dec[0xff] = { 0 };
+	uint8_t buf_enc[0xff] = { 0xff };
+	char buf_dec[0xff] = { 0xff };
 	size_t buf_len, i;
 	int rc;
 
@@ -780,6 +780,10 @@
 			printf("    -   Actual: (rc=%d) '%s'\n",
 			       rc, (rc == 0 || rc == -ENOSPC) ? buf_dec : "(none)");
 		}
+
+		/* Poison buffers between the test iterations */
+		memset(buf_enc, 0xff, sizeof(buf_enc));
+		memset(buf_dec, 0xff, sizeof(buf_dec));
 	}
 
 	printf("\n");
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 075886e..844c201 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -149,8 +149,8 @@
     -   Actual: (rc=0) '123456789'
 - Running test: regular 6-digit MSISDN with optional header (LHV)
   - Encoding ASCII (buffer limit=0) '123456'...
-    - Expected: (rc=8) '0700000000214365'
-    -   Actual: (rc=8) '0721436587214365'
+    - Expected: (rc=8) '07ffffffff214365'
+    -   Actual: (rc=8) '07ffffffff214365'
   - Decoding HEX (buffer limit=0) '07deadbeef214365'...
     - Expected: (rc=0) '123456'
     -   Actual: (rc=0) '123456'

-- 
To view, visit https://gerrit.osmocom.org/14189
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
Gerrit-Change-Number: 14189
Gerrit-PatchSet: 5
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190529/c573cf22/attachment.htm>


More information about the gerrit-log mailing list