pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/39994?usp=email )


Change subject: Fix RAC size in struct umts_cell_id
......................................................................

Fix RAC size in struct umts_cell_id

RANAP_IEs.asn:
"""
RAC                                     ::= OCTET STRING (SIZE (1))
"""

Change-Id: Ide7dfd5d0ae87826cb7759d283be6da81dae90f4
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
M tests/umts_cell_id/umts_cell_id_test.c
M tests/umts_cell_id/umts_cell_id_test.ok
4 files changed, 10 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/94/39994/1

diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index fc110c0..04e6e4e 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -174,7 +174,7 @@
 struct umts_cell_id {
        struct osmo_plmn_id plmn;       /*!< Mobile Country Code and Mobile 
Network Code (000-00 to 999-999) */
        uint16_t lac;   /*!< Locaton Area Code (1-65534) */
-       uint16_t rac;   /*!< Routing Area Code (0-255) */
+       uint8_t rac;    /*!< Routing Area Code (0-255) */
        uint16_t sac;   /*!< Service Area Code */
        uint32_t cid;   /*!< Cell ID */
 };
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index d4515a8..0a2f670 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -19,6 +19,8 @@
  *
  */

+#include <inttypes.h>
+
 #include <netinet/in.h>
 #include <netinet/sctp.h>

@@ -207,7 +209,8 @@
        pos = end + 1;

        /* parse the rest, where leading zeros do not matter */
-       rc = sscanf(pos, "L%hu-R%hu-S%hu-C%u", &ucid->lac, &ucid->rac, 
&ucid->sac, &ucid->cid);
+       rc = sscanf(pos, "L%" SCNu16 "-R%" SCNu8 "-S%" SCNu16 "-C%" SCNu32 "",
+                   &ucid->lac, &ucid->rac, &ucid->sac, &ucid->cid);
        if (rc < 0)
                return -errno;

diff --git a/tests/umts_cell_id/umts_cell_id_test.c 
b/tests/umts_cell_id/umts_cell_id_test.c
index a25b3d1..18c176a 100644
--- a/tests/umts_cell_id/umts_cell_id_test.c
+++ b/tests/umts_cell_id/umts_cell_id_test.c
@@ -68,7 +68,7 @@
        },

        {
-               .id_str = "999-999-L65534-R65535-S65535-C268435455",
+               .id_str = "999-999-L65534-R255-S65535-C268435455",
                .id = {
                        .plmn = {
                                .mcc = 999,
@@ -76,7 +76,7 @@
                                .mnc_3_digits = true,
                        },
                        .lac = 65534,
-                       .rac = 65535,
+                       .rac = 255,
                        .sac = 65535,
                        .cid = (1 << 28) - 1,
                },
@@ -92,7 +92,7 @@
        },
        /* TODO? There is no bounds checking on RAC and SAC.
        {
-               .id_str = "001-001-L1-R65536-S1-C1",
+               .id_str = "001-001-L1-R256-S1-C1",
                .expect_rc = -EINVAL,
        },
        {
diff --git a/tests/umts_cell_id/umts_cell_id_test.ok 
b/tests/umts_cell_id/umts_cell_id_test.ok
index 2c1992f..7232ca1 100644
--- a/tests/umts_cell_id/umts_cell_id_test.ok
+++ b/tests/umts_cell_id/umts_cell_id_test.ok
@@ -18,10 +18,10 @@
   -> umts_cell_id_to_str_buf(): ok
   -> "001-99-L1-R1-S1-C1"
   umts_cell_id_equal(expected, parsed): ok
-"999-999-L65534-R65535-S65535-C268435455"
+"999-999-L65534-R255-S65535-C268435455"
   -> umts_cell_id_from_str(): ok
   -> umts_cell_id_to_str_buf(): ok
-  -> "999-999-L65534-R65535-S65535-C268435455"
+  -> "999-999-L65534-R255-S65535-C268435455"
   umts_cell_id_equal(expected, parsed): ok
 "1000-001-L1-R1-S1-C1"
   expected rc != 0: ok

--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39994?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ide7dfd5d0ae87826cb7759d283be6da81dae90f4
Gerrit-Change-Number: 39994
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>

Reply via email to