diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2015-12-09 19:04:33 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2015-12-14 10:36:36 +0100 |
commit | 9224731379265fa91500ce7e761c1bfc300a38ab (patch) | |
tree | f6b75b5efc89d0da247c5784dcb35f2c73585d1e /src | |
parent | 4e31250367c7f80907c9a25c281fffbe24e4dae0 (diff) |
asn1helpers: Fix 24 bit conversion function and use it in hnbgw_hnbap
The 32 bit int needs to be shifted left one byte so the correct bytes
end up at the beginning of the bit string buffer.
Diffstat (limited to 'src')
-rw-r--r-- | src/asn1helpers.c | 4 | ||||
-rw-r--r-- | src/hnbgw_hnbap.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/asn1helpers.c b/src/asn1helpers.c index 791d0ed..dafbf7f 100644 --- a/src/asn1helpers.c +++ b/src/asn1helpers.c @@ -43,7 +43,7 @@ void asn1_u28_to_bitstring(BIT_STRING_t *bitstr, uint32_t *buf, uint32_t in) void asn1_u24_to_bitstring(BIT_STRING_t *bitstr, uint32_t *buf, uint32_t in) { - *buf = htonl(in); + *buf = htonl(in<<8); bitstr->buf = (uint8_t *) buf; bitstr->size = 24/8; bitstr->bits_unused = 0; @@ -106,5 +106,5 @@ uint32_t asn1bitstr_to_u24(const BIT_STRING_t *in) { OSMO_ASSERT(in && in->size == 3); - return *(uint32_t *)in->buf; + return ntohl(*(uint32_t *)in->buf) >> 8; } diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c index 97cb32b..b74cdad 100644 --- a/src/hnbgw_hnbap.c +++ b/src/hnbgw_hnbap.c @@ -79,6 +79,7 @@ static int hnbgw_tx_ue_register_acc(struct ue_context *ue) UERegisterAcceptIEs_t accept; struct msgb *msg; uint8_t encoded_imsi[10]; + uint32_t ctx_id; size_t encoded_imsi_len; int rc; @@ -89,8 +90,7 @@ static int hnbgw_tx_ue_register_acc(struct ue_context *ue) accept.uE_Identity.present = UE_Identity_PR_iMSI; OCTET_STRING_fromBuf(&accept.uE_Identity.choice.iMSI, (const char *)encoded_imsi, encoded_imsi_len); - asn1_u32_to_bitstring(&accept.context_ID, &ue->context_id); - accept.context_ID.size = 3; /* 24bit field */ + asn1_u24_to_bitstring(&accept.context_ID, &ctx_id, ue->context_id); memset(&accept_out, 0, sizeof(accept_out)); rc = hnbap_encode_ueregisteraccepties(&accept_out, &accept); |