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.
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_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 @@
{
OSMO_ASSERT(in && in->size == 3);
- return *(uint32_t *)in->buf;
+ return ntohl(*(uint32_t *)in->buf) >> 8;
}