diff options
author | Max <msuraev@sysmocom.de> | 2018-01-05 14:30:22 +0100 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2018-01-08 14:07:47 +0100 |
commit | e29ec85375f004e63c650e69a9fe5910b15a00eb (patch) | |
tree | a5d2485f29fa92fe5db21413594bbd07be413a1e | |
parent | f1ad60e4d861d5ff462a8d7ab481ad082360f346 (diff) |
Use existing function for TLLI encoding
Use bssgp_msgb_tlli_put() instead of copy-pasted code.
Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77
-rw-r--r-- | src/gb/gprs_bssgp.c | 16 | ||||
-rw-r--r-- | src/gb/gprs_bssgp_bss.c | 4 | ||||
-rw-r--r-- | tests/gb/gprs_bssgp_test.c | 8 |
3 files changed, 9 insertions, 19 deletions
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 72282636..4c0bb8a9 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -160,14 +160,12 @@ int bssgp_tx_suspend_ack(uint16_t nsei, uint32_t tlli, 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 @@ int bssgp_tx_suspend_nack(uint16_t nsei, uint32_t tlli, 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 @@ int bssgp_tx_resume_ack(uint16_t nsei, uint32_t tlli, 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 @@ int bssgp_tx_resume_nack(uint16_t nsei, uint32_t tlli, 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 c7e5e4d6..487286c4 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -396,7 +396,6 @@ int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag, 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 @@ int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag, 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 1624a31e..c38e1801 100644 --- a/tests/gb/gprs_bssgp_test.c +++ b/tests/gb/gprs_bssgp_test.c @@ -98,11 +98,11 @@ static void msgb_bssgp_send_and_free(struct msgb *msg) 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_supend(enum bssgp_pdu_type pdu_type, uint32_t tlli) 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); |