summaryrefslogtreecommitdiffstats
path: root/src/asn1helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/asn1helpers.c')
-rw-r--r--src/asn1helpers.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/asn1helpers.c b/src/asn1helpers.c
index 8ce9bf4..aca5300 100644
--- a/src/asn1helpers.c
+++ b/src/asn1helpers.c
@@ -22,11 +22,15 @@
#include <errno.h>
#include <arpa/inet.h>
-#include <osmocom/core/utils.h>
-
#include "asn1helpers.h"
#include "asn_internal.h"
+#define ASN1C_ASSERT(exp) \
+ if (!(exp)) { \
+ fprintf(stderr, "Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \
+ abort(); \
+ }
+
void asn1_u32_to_bitstring(BIT_STRING_t *bitstr, uint32_t *buf, uint32_t in)
{
*buf = htonl(in);
@@ -126,39 +130,39 @@ int asn1_strncpy(char *out, const OCTET_STRING_t *in, size_t n)
uint32_t asn1str_to_u32(const OCTET_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == sizeof(uint32_t));
+ ASN1C_ASSERT(in && in->size == sizeof(uint32_t));
return ntohl(*(uint32_t *)in->buf);
}
uint16_t asn1str_to_u16(const OCTET_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == sizeof(uint16_t));
+ ASN1C_ASSERT(in && in->size == sizeof(uint16_t));
return ntohs(*(uint16_t *)in->buf);
}
uint8_t asn1str_to_u8(const OCTET_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == sizeof(uint8_t));
+ ASN1C_ASSERT(in && in->size == sizeof(uint8_t));
return *(uint8_t *)in->buf;
}
uint32_t asn1bitstr_to_u32(const BIT_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == sizeof(uint32_t));
+ ASN1C_ASSERT(in && in->size == sizeof(uint32_t));
return ntohl(*(uint32_t *)in->buf);
}
uint32_t asn1bitstr_to_u28(const BIT_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == sizeof(uint32_t) && in->bits_unused == 4);
+ ASN1C_ASSERT(in && in->size == sizeof(uint32_t) && in->bits_unused == 4);
return ntohl(*(uint32_t *)in->buf) >> 4;
}
uint32_t asn1bitstr_to_u24(const BIT_STRING_t *in)
{
- OSMO_ASSERT(in && in->size == 3);
+ ASN1C_ASSERT(in && in->size == 3);
return ntohl(*(uint32_t *)in->buf) >> 8;
}