make asn1bitstr_to_u32() work for sub-32bit bit-strings
IF the ASN1 Bit-string is only 24 bits or even less long, we might still want to retrieve it as an uint32_t.
This commit is contained in:
parent
77847ad020
commit
4dd16b9643
|
@ -59,6 +59,14 @@ uint8_t asn1str_to_u8(const OCTET_STRING_t *in)
|
|||
|
||||
uint32_t asn1bitstr_to_u32(const BIT_STRING_t *in)
|
||||
{
|
||||
OSMO_ASSERT(in && in->size >= sizeof(uint32_t));
|
||||
return *(uint32_t *)in->buf;
|
||||
uint32_t ret = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (in->size < i)
|
||||
break;
|
||||
ret <<= 8;
|
||||
ret |= in->buf[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue