]> git.stg.codes - stg.git/blobdiff - libs/smux/BIT_STRING.c
Remove extra debug.
[stg.git] / libs / smux / BIT_STRING.c
index 6469d4fd2c8782048e228c19e67950f3b2dc1305..997ff41619e35b6632bcbd27a44ae50684bc433c 100644 (file)
@@ -9,13 +9,13 @@
 /*
  * BIT STRING basic type description.
  */
-static ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
+static const ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
        (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
 };
 static asn_OCTET_STRING_specifics_t asn_DEF_BIT_STRING_specs = {
        sizeof(BIT_STRING_t),
        offsetof(BIT_STRING_t, _asn_ctx),
-       1,      /* Special indicator that this is a BIT STRING type */
+       ASN_OSUBV_BIT
 };
 asn_TYPE_descriptor_t asn_DEF_BIT_STRING = {
        "BIT STRING",
@@ -50,14 +50,15 @@ BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
        const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 
        if(st && st->buf) {
-               if(st->size == 1 && st->bits_unused) {
-                       _ASN_CTFAIL(app_key, td,
+               if((st->size == 0 && st->bits_unused)
+               || st->bits_unused < 0 || st->bits_unused > 7) {
+                       ASN__CTFAIL(app_key, td, sptr,
                                "%s: invalid padding byte (%s:%d)",
                                td->name, __FILE__, __LINE__);
                        return -1;
                }
        } else {
-               _ASN_CTFAIL(app_key, td,
+               ASN__CTFAIL(app_key, td, sptr,
                        "%s: value not given (%s:%d)",
                        td->name, __FILE__, __LINE__);
                return -1;
@@ -85,7 +86,7 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
        uint8_t *end;
 
        if(!st || !st->buf)
-               _ASN_ENCODE_FAILED;
+               ASN__ENCODE_FAILED;
 
        er.encoded = 0;
 
@@ -100,9 +101,9 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
                int nline = xcan?0:(((buf - st->buf) % 8) == 0);
                if(p >= scend || nline) {
                        er.encoded += p - scratch;
-                       _ASN_CALLBACK(scratch, p - scratch);
+                       ASN__CALLBACK(scratch, p - scratch);
                        p = scratch;
-                       if(nline) _i_ASN_TEXT_INDENT(1, ilevel);
+                       if(nline) ASN__TEXT_INDENT(1, ilevel);
                }
                memcpy(p + 0, _bit_pattern[v >> 4], 4);
                memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
@@ -110,9 +111,9 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
        }
 
        if(!xcan && ((buf - st->buf) % 8) == 0)
-               _i_ASN_TEXT_INDENT(1, ilevel);
+               ASN__TEXT_INDENT(1, ilevel);
        er.encoded += p - scratch;
-       _ASN_CALLBACK(scratch, p - scratch);
+       ASN__CALLBACK(scratch, p - scratch);
        p = scratch;
 
        if(buf == end) {
@@ -122,14 +123,14 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
                for(i = 7; i >= ubits; i--)
                        *p++ = (v & (1 << i)) ? 0x31 : 0x30;
                er.encoded += p - scratch;
-               _ASN_CALLBACK(scratch, p - scratch);
+               ASN__CALLBACK(scratch, p - scratch);
        }
 
-       if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
+       if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
 
-       _ASN_ENCODED_OK(er);
+       ASN__ENCODED_OK(er);
 cb_failed:
-       _ASN_ENCODE_FAILED;
+       ASN__ENCODE_FAILED;
 }
 
 
@@ -139,7 +140,7 @@ cb_failed:
 int
 BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
                asn_app_consume_bytes_f *cb, void *app_key) {
-       static const char *h2c = "0123456789ABCDEF";
+       const char * const h2c = "0123456789ABCDEF";
        char scratch[64];
        const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
        uint8_t *buf;