Max has submitted this change and it was merged.

Change subject: Use existing function for TLLI encoding
......................................................................


Use existing function for TLLI encoding

Use bssgp_msgb_tlli_put() instead of copy-pasted code.

Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77
---
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_bss.c
M tests/gb/gprs_bssgp_test.c
3 files changed, 9 insertions(+), 19 deletions(-)

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



diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 7228263..4c0bb8a 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -160,14 +160,12 @@
        struct msgb *msg = bssgp_msgb_alloc();
        struct bssgp_normal_hdr *bgph =
                (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
-       uint32_t _tlli;
 
        msgb_nsei(msg) = nsei;
        msgb_bvci(msg) = 0; /* Signalling */
        bgph->pdu_type = BSSGP_PDUT_SUSPEND_ACK;
 
-       _tlli = osmo_htonl(tlli);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli);
+       bssgp_msgb_tlli_put(msg, tlli);
        bssgp_msgb_ra_put(msg, ra_id);
        msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref);
 
@@ -182,14 +180,12 @@
        struct msgb *msg = bssgp_msgb_alloc();
        struct bssgp_normal_hdr *bgph =
                (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
-       uint32_t _tlli;
 
        msgb_nsei(msg) = nsei;
        msgb_bvci(msg) = 0; /* Signalling */
        bgph->pdu_type = BSSGP_PDUT_SUSPEND_NACK;
 
-       _tlli = osmo_htonl(tlli);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli);
+       bssgp_msgb_tlli_put(msg, tlli);
        bssgp_msgb_ra_put(msg, ra_id);
 
        if (cause)
@@ -205,14 +201,12 @@
        struct msgb *msg = bssgp_msgb_alloc();
        struct bssgp_normal_hdr *bgph =
                (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
-       uint32_t _tlli;
 
        msgb_nsei(msg) = nsei;
        msgb_bvci(msg) = 0; /* Signalling */
        bgph->pdu_type = BSSGP_PDUT_RESUME_ACK;
 
-       _tlli = osmo_htonl(tlli);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli);
+       bssgp_msgb_tlli_put(msg, tlli);
        bssgp_msgb_ra_put(msg, ra_id);
 
        return gprs_ns_sendmsg(bssgp_nsi, msg);
@@ -225,14 +219,12 @@
        struct msgb *msg = bssgp_msgb_alloc();
        struct bssgp_normal_hdr *bgph =
                (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
-       uint32_t _tlli;
 
        msgb_nsei(msg) = nsei;
        msgb_bvci(msg) = 0; /* Signalling */
        bgph->pdu_type = BSSGP_PDUT_SUSPEND_NACK;
 
-       _tlli = osmo_htonl(tlli);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli);
+       bssgp_msgb_tlli_put(msg, tlli);
        bssgp_msgb_ra_put(msg, ra_id);
 
        if (cause)
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index c7e5e4d..487286c 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -396,7 +396,6 @@
        struct msgb *msg;
        struct bssgp_normal_hdr *bgph;
        uint16_t e_bucket_size, e_leak_rate;
-       uint32_t e_tlli;
 
        if ((ms_bucket_size / 100) > 0xffff)
                return -EINVAL;
@@ -412,8 +411,7 @@
        msgb_bvci(msg) = bctx->bvci;
        bgph->pdu_type = BSSGP_PDUT_FLOW_CONTROL_MS;
 
-       e_tlli = osmo_htonl(tlli);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(e_tlli), (uint8_t *)&e_tlli);
+       bssgp_msgb_tlli_put(msg, tlli);
        msgb_tvlv_put(msg, BSSGP_IE_TAG, sizeof(tag), (uint8_t *)&tag);
        msgb_tvlv_put(msg, BSSGP_IE_MS_BUCKET_SIZE,
                      sizeof(e_bucket_size), (uint8_t *) &e_bucket_size);
diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c
index 1624a31..c38e180 100644
--- a/tests/gb/gprs_bssgp_test.c
+++ b/tests/gb/gprs_bssgp_test.c
@@ -98,11 +98,11 @@
 static void send_bssgp_supend(enum bssgp_pdu_type pdu_type, uint32_t tlli)
 {
        struct msgb *msg = bssgp_msgb_alloc();
-       uint32_t tlli_be = htonl(tlli);
        uint8_t rai[] = {0x0f, 0xf1, 0x80, 0x20, 0x37, 0x00};
 
        msgb_v_put(msg, pdu_type);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(tlli_be), (uint8_t *)&tlli_be);
+
+       bssgp_msgb_tlli_put(msg, tlli);
        msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, sizeof(rai), &rai[0]);
 
        msgb_bssgp_send_and_free(msg);
@@ -111,12 +111,12 @@
 static void send_bssgp_resume(enum bssgp_pdu_type pdu_type, uint32_t tlli)
 {
        struct msgb *msg = bssgp_msgb_alloc();
-       uint32_t tlli_be = htonl(tlli);
        uint8_t rai[] = {0x0f, 0xf1, 0x80, 0x20, 0x37, 0x00};
        uint8_t suspend_ref = 1;
 
        msgb_v_put(msg, pdu_type);
-       msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(tlli_be), (uint8_t *)&tlli_be);
+
+       bssgp_msgb_tlli_put(msg, tlli);
        msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, sizeof(rai), &rai[0]);
        msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref);
 

-- 
To view, visit https://gerrit.osmocom.org/5655
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <[email protected]>

Reply via email to