mirror of
				https://github.com/open5gs/open5gs.git
				synced 2025-11-04 05:53:18 +00:00 
			
		
		
		
	[asn1c] rework aper from mouse07410/asn1c#94
Merge @pespin the following work - mouse07410/asn1c#93 - mouse07410/asn1c#100
This commit is contained in:
		@@ -32,6 +32,11 @@ asn_TYPE_operation_t asn_OP_ANY = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    ANY_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,10 @@ extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
 | 
			
		||||
xer_type_encoder_f ANY_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f ANY_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
per_type_decoder_f ANY_decode_uper;
 | 
			
		||||
per_type_encoder_f ANY_encode_uper;
 | 
			
		||||
 
 | 
			
		||||
@@ -132,7 +132,7 @@ ANY_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
        int ret;
 | 
			
		||||
 | 
			
		||||
        /* Get the PER length */
 | 
			
		||||
        raw_len = aper_get_length(pd, -1, 0, &repeat);
 | 
			
		||||
        raw_len = aper_get_length(pd, -1, -1, 0, &repeat);
 | 
			
		||||
        if(raw_len < 0) RETURN(RC_WMORE);
 | 
			
		||||
        if(raw_len == 0 && st->buf) break;
 | 
			
		||||
 | 
			
		||||
@@ -173,7 +173,7 @@ ANY_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
    size = st->size;
 | 
			
		||||
    do {
 | 
			
		||||
        int need_eom = 0;
 | 
			
		||||
        ssize_t may_save = aper_put_length(po, -1, size, &need_eom);
 | 
			
		||||
        ssize_t may_save = aper_put_length(po, -1, -1, size, &need_eom);
 | 
			
		||||
        if(may_save < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
        ret = per_put_many_bits(po, buf, may_save * 8);
 | 
			
		||||
@@ -182,7 +182,7 @@ ANY_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
        buf += may_save;
 | 
			
		||||
        size -= may_save;
 | 
			
		||||
        assert(!(may_save & 0x07) || !size);
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0))
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, -1, 0, NULL))
 | 
			
		||||
            ASN__ENCODE_FAILED; /* End of Message length */
 | 
			
		||||
    } while(size);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								lib/asn1c/common/ANY_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								lib/asn1c/common/ANY_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <ANY.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
ANY_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 | 
			
		||||
               enum jer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
 | 
			
		||||
               void *app_key) {
 | 
			
		||||
  ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
  /* Dump as binary */
 | 
			
		||||
  return OCTET_STRING_encode_jer(td, sptr, ilevel, flags, cb, app_key);
 | 
			
		||||
}
 | 
			
		||||
@@ -38,6 +38,11 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    BIT_STRING_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    BIT_STRING_decode_oer,
 | 
			
		||||
    BIT_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,10 @@ asn_constr_check_f BIT_STRING_constraint;
 | 
			
		||||
xer_type_encoder_f BIT_STRING_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f BIT_STRING_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f BIT_STRING_decode_oer;
 | 
			
		||||
oer_type_encoder_f BIT_STRING_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										70
									
								
								lib/asn1c/common/BIT_STRING_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								lib/asn1c/common/BIT_STRING_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <BIT_STRING.h>
 | 
			
		||||
 | 
			
		||||
static const char *_bit_pattern[16] = {
 | 
			
		||||
    "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
 | 
			
		||||
    "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                      int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                      asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0, 0, 0};
 | 
			
		||||
    char scratch[128];
 | 
			
		||||
    char *p = scratch;
 | 
			
		||||
    char *scend = scratch + (sizeof(scratch) - 10);
 | 
			
		||||
    const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 | 
			
		||||
    int xcan = 0;
 | 
			
		||||
    uint8_t *buf;
 | 
			
		||||
    uint8_t *end;
 | 
			
		||||
 | 
			
		||||
    if(!st || !st->buf)
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
 | 
			
		||||
    buf = st->buf;
 | 
			
		||||
    end = buf + st->size - 1;  /* Last byte is special */
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Binary dump
 | 
			
		||||
     */
 | 
			
		||||
    for(; buf < end; buf++) {
 | 
			
		||||
        int v = *buf;
 | 
			
		||||
        int nline = xcan?0:(((buf - st->buf) % 8) == 0);
 | 
			
		||||
        if(p >= scend || nline) {
 | 
			
		||||
            ASN__CALLBACK(scratch, p - scratch);
 | 
			
		||||
            p = scratch;
 | 
			
		||||
            if(nline) ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
        }
 | 
			
		||||
        memcpy(p + 0, _bit_pattern[v >> 4], 4);
 | 
			
		||||
        memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
 | 
			
		||||
        p += 8;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!xcan && ((buf - st->buf) % 8) == 0)
 | 
			
		||||
        ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
    ASN__CALLBACK(scratch, p - scratch);
 | 
			
		||||
    p = scratch;
 | 
			
		||||
 | 
			
		||||
    if(buf == end) {
 | 
			
		||||
        int v = *buf;
 | 
			
		||||
        int ubits = st->bits_unused;
 | 
			
		||||
        int i;
 | 
			
		||||
        for(i = 7; i >= ubits; i--)
 | 
			
		||||
            *p++ = (v & (1 << i)) ? 0x31 : 0x30;
 | 
			
		||||
        ASN__CALLBACK(scratch, p - scratch);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
@@ -34,6 +34,11 @@ asn_TYPE_operation_t asn_OP_GraphicString = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer,  /* Can't expect it to be ASCII/UTF8 */
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_decode_oer,
 | 
			
		||||
    OCTET_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,10 @@ extern asn_TYPE_operation_t asn_OP_GraphicString;
 | 
			
		||||
#define GraphicString_encode_xer OCTET_STRING_encode_xer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define GraphicString_encode_jer OCTET_STRING_encode_jer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
#define GraphicString_decode_uper OCTET_STRING_decode_uper
 | 
			
		||||
#define GraphicString_encode_uper OCTET_STRING_encode_uper
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,11 @@ asn_TYPE_operation_t asn_OP_INTEGER = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    INTEGER_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    INTEGER_decode_oer,  /* OER decoder */
 | 
			
		||||
    INTEGER_encode_oer,  /* Canonical OER encoder */
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,10 @@ xer_type_decoder_f INTEGER_decode_xer;
 | 
			
		||||
xer_type_encoder_f INTEGER_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f INTEGER_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f INTEGER_decode_oer;
 | 
			
		||||
oer_type_encoder_f INTEGER_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
@@ -129,7 +129,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
        int ret;
 | 
			
		||||
 | 
			
		||||
        /* Get the PER length */
 | 
			
		||||
        len = aper_get_length(pd, -1, -1, &repeat);
 | 
			
		||||
        len = aper_get_length(pd, -1, -1, -1, &repeat);
 | 
			
		||||
        if(len < 0) ASN__DECODE_STARVED;
 | 
			
		||||
 | 
			
		||||
        p = REALLOC(st->buf, st->size + len + 1);
 | 
			
		||||
@@ -291,13 +291,14 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
 | 
			
		||||
    for(buf = st->buf, end = st->buf + st->size; buf < end;) {
 | 
			
		||||
        int need_eom = 0;
 | 
			
		||||
        ssize_t mayEncode = aper_put_length(po, -1, end - buf, &need_eom);
 | 
			
		||||
        ssize_t mayEncode = aper_put_length(po, -1, -1, end - buf, &need_eom);
 | 
			
		||||
        if(mayEncode < 0)
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
        if(per_put_many_bits(po, buf, 8 * mayEncode))
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
        buf += mayEncode;
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0)) ASN__ENCODE_FAILED;
 | 
			
		||||
        if(need_eom && (aper_put_length(po, -1, -1, 0, NULL) < 0))
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								lib/asn1c/common/INTEGER_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								lib/asn1c/common/INTEGER_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <INTEGER.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
INTEGER_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                   int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                   asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const INTEGER_t *st = (const INTEGER_t *)sptr;
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
 | 
			
		||||
    (void)ilevel;
 | 
			
		||||
    (void)flags;
 | 
			
		||||
 | 
			
		||||
    if(!st || !st->buf)
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = INTEGER__dump(td, st, cb, app_key, 1);
 | 
			
		||||
    if(er.encoded < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
@@ -33,6 +33,11 @@ asn_TYPE_operation_t asn_OP_NULL = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    NULL_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    NULL_decode_oer,
 | 
			
		||||
    NULL_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,10 @@ xer_type_decoder_f NULL_decode_xer;
 | 
			
		||||
xer_type_encoder_f NULL_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f NULL_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f NULL_decode_oer;
 | 
			
		||||
oer_type_encoder_f NULL_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								lib/asn1c/common/NULL_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								lib/asn1c/common/NULL_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <asn_codecs_prim.h>
 | 
			
		||||
#include <NULL.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
NULL_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 | 
			
		||||
                enum jer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
 | 
			
		||||
                void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
 | 
			
		||||
    (void)td;
 | 
			
		||||
    (void)sptr;
 | 
			
		||||
    (void)ilevel;
 | 
			
		||||
    (void)flags;
 | 
			
		||||
    (void)cb;
 | 
			
		||||
    (void)app_key;
 | 
			
		||||
 | 
			
		||||
    /* XMLNullValue is empty */
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
@@ -40,6 +40,11 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    NativeEnumerated_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    NativeEnumerated_decode_oer,
 | 
			
		||||
    NativeEnumerated_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,10 @@ extern asn_TYPE_operation_t asn_OP_NativeEnumerated;
 | 
			
		||||
xer_type_encoder_f NativeEnumerated_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f NativeEnumerated_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f NativeEnumerated_decode_oer;
 | 
			
		||||
oer_type_encoder_f NativeEnumerated_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								lib/asn1c/common/NativeEnumerated_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								lib/asn1c/common/NativeEnumerated_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <NativeEnumerated.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
NativeEnumerated_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                            int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                            asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const asn_INTEGER_specifics_t *specs =
 | 
			
		||||
        (const asn_INTEGER_specifics_t *)td->specifics;
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    const long *native = (const long *)sptr;
 | 
			
		||||
    const asn_INTEGER_enum_map_t *el;
 | 
			
		||||
 | 
			
		||||
    (void)ilevel;
 | 
			
		||||
    (void)flags;
 | 
			
		||||
 | 
			
		||||
    if(!native) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    el = INTEGER_map_value2enum(specs, *native);
 | 
			
		||||
    if(el) {
 | 
			
		||||
        er.encoded =
 | 
			
		||||
            asn__format_to_callback(cb, app_key, "\"%s\"", el->enum_name);
 | 
			
		||||
        if(er.encoded < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
        ASN__ENCODED_OK(er);
 | 
			
		||||
    } else {
 | 
			
		||||
        ASN_DEBUG(
 | 
			
		||||
            "ASN.1 forbids dealing with "
 | 
			
		||||
            "unknown value of ENUMERATED type");
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -41,6 +41,11 @@ asn_TYPE_operation_t asn_OP_NativeInteger = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    NativeInteger_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    NativeInteger_decode_oer,  /* OER decoder */
 | 
			
		||||
    NativeInteger_encode_oer,  /* Canonical OER encoder */
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,10 @@ xer_type_decoder_f NativeInteger_decode_xer;
 | 
			
		||||
xer_type_encoder_f NativeInteger_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f NativeInteger_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f NativeInteger_decode_oer;
 | 
			
		||||
oer_type_encoder_f NativeInteger_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								lib/asn1c/common/NativeInteger_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								lib/asn1c/common/NativeInteger_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <NativeInteger.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
NativeInteger_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                         int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                         asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const asn_INTEGER_specifics_t *specs =
 | 
			
		||||
        (const asn_INTEGER_specifics_t *)td->specifics;
 | 
			
		||||
    char scratch[32];  /* Enough for 64-bit int */
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    const long *native = (const long *)sptr;
 | 
			
		||||
 | 
			
		||||
    (void)ilevel;
 | 
			
		||||
    (void)flags;
 | 
			
		||||
 | 
			
		||||
    if(!native) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = snprintf(scratch, sizeof(scratch),
 | 
			
		||||
                          (specs && specs->field_unsigned)
 | 
			
		||||
                              ? "%lu" : "%ld", *native);
 | 
			
		||||
    if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch)
 | 
			
		||||
        || cb(scratch, er.encoded, app_key) < 0)
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
@@ -38,6 +38,11 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OBJECT_IDENTIFIER_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OBJECT_IDENTIFIER_decode_oer,
 | 
			
		||||
    OBJECT_IDENTIFIER_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,10 @@ xer_type_decoder_f OBJECT_IDENTIFIER_decode_xer;
 | 
			
		||||
xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f OBJECT_IDENTIFIER_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
#define OBJECT_IDENTIFIER_decode_oer oer_decode_primitive
 | 
			
		||||
#define OBJECT_IDENTIFIER_encode_oer oer_encode_primitive
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								lib/asn1c/common/OBJECT_IDENTIFIER_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								lib/asn1c/common/OBJECT_IDENTIFIER_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <OBJECT_IDENTIFIER.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
OBJECT_IDENTIFIER_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                             int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                             asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
 | 
			
		||||
    (void)ilevel;
 | 
			
		||||
    (void)flags;
 | 
			
		||||
 | 
			
		||||
    if(!st || !st->buf) {
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    er.encoded = OBJECT_IDENTIFIER__dump_body(st, cb, app_key);
 | 
			
		||||
    if(er.encoded < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
@@ -40,6 +40,11 @@ asn_TYPE_operation_t asn_OP_OCTET_STRING = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_decode_oer,
 | 
			
		||||
    OCTET_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,11 @@ xer_type_encoder_f OCTET_STRING_encode_xer;
 | 
			
		||||
xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f OCTET_STRING_encode_jer;
 | 
			
		||||
jer_type_encoder_f OCTET_STRING_encode_jer_utf8;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f OCTET_STRING_decode_oer;
 | 
			
		||||
oer_type_encoder_f OCTET_STRING_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
@@ -173,9 +173,10 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
        /* Get the PER length */
 | 
			
		||||
        if (csiz->upper_bound - csiz->lower_bound == 0)
 | 
			
		||||
            /* Indefinite length case */
 | 
			
		||||
            raw_len = aper_get_length(pd, -1, csiz->effective_bits, &repeat);
 | 
			
		||||
            raw_len = aper_get_length(pd, -1, -1, csiz->effective_bits, &repeat);
 | 
			
		||||
        else
 | 
			
		||||
            raw_len = aper_get_length(pd, csiz->upper_bound - csiz->lower_bound + 1, csiz->effective_bits, &repeat);
 | 
			
		||||
            raw_len = aper_get_length(pd, csiz->lower_bound, csiz->upper_bound,
 | 
			
		||||
                                      csiz->effective_bits, &repeat);
 | 
			
		||||
        if(raw_len < 0) RETURN(RC_WMORE);
 | 
			
		||||
        raw_len += csiz->lower_bound;
 | 
			
		||||
 | 
			
		||||
@@ -342,10 +343,9 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
                  st->size, sizeinunits - csiz->lower_bound,
 | 
			
		||||
                  csiz->effective_bits);
 | 
			
		||||
        if (csiz->effective_bits > 0) {
 | 
			
		||||
                ret = aper_put_length(po,
 | 
			
		||||
                                      csiz->upper_bound - csiz->lower_bound + 1,
 | 
			
		||||
                                      sizeinunits - csiz->lower_bound, 0);
 | 
			
		||||
                if(ret) ASN__ENCODE_FAILED;
 | 
			
		||||
                ret = aper_put_length(po, csiz->lower_bound, csiz->upper_bound,
 | 
			
		||||
                                      sizeinunits - csiz->lower_bound, NULL);
 | 
			
		||||
                if(ret < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        if (csiz->effective_bits > 0 || (st->size > 2)
 | 
			
		||||
            || (csiz->upper_bound > (2 * 8 / unit_bits))
 | 
			
		||||
@@ -372,7 +372,7 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
    ASN_DEBUG("Encoding %lu bytes", st->size);
 | 
			
		||||
 | 
			
		||||
    if(sizeinunits == 0) {
 | 
			
		||||
        if(aper_put_length(po, -1, 0, 0))
 | 
			
		||||
        if(aper_put_length(po, -1, -1, 0, NULL) < 0)
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
        ASN__ENCODED_OK(er);
 | 
			
		||||
    }
 | 
			
		||||
@@ -380,7 +380,7 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
    buf = st->buf;
 | 
			
		||||
    while(sizeinunits) {
 | 
			
		||||
        int need_eom = 0;
 | 
			
		||||
        ssize_t maySave = aper_put_length(po, -1, sizeinunits, &need_eom);
 | 
			
		||||
        ssize_t maySave = aper_put_length(po, -1, -1, sizeinunits, &need_eom);
 | 
			
		||||
 | 
			
		||||
        if(maySave < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
@@ -404,7 +404,7 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
            buf += maySave >> 3;
 | 
			
		||||
        sizeinunits -= maySave;
 | 
			
		||||
        assert(!(maySave & 0x07) || !sizeinunits);
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0))
 | 
			
		||||
        if(need_eom && (aper_put_length(po, -1, -1, 0, NULL) < 0))
 | 
			
		||||
            ASN__ENCODE_FAILED; /* End of Message length */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										151
									
								
								lib/asn1c/common/OCTET_STRING_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								lib/asn1c/common/OCTET_STRING_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,151 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <OCTET_STRING.h>
 | 
			
		||||
#include <BIT_STRING.h>  /* for .bits_unused member */
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
OCTET_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                        int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                        asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const char * const h2c = "0123456789ABCDEF";
 | 
			
		||||
    const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 | 
			
		||||
    asn_enc_rval_t er = { 0, 0, 0 };
 | 
			
		||||
    char scratch[16 * 3 + 4];
 | 
			
		||||
    char *p = scratch;
 | 
			
		||||
    uint8_t *buf;
 | 
			
		||||
    uint8_t *end;
 | 
			
		||||
    size_t i;
 | 
			
		||||
 | 
			
		||||
    if(!st || (!st->buf && st->size))
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Dump the contents of the buffer in hexadecimal.
 | 
			
		||||
     */
 | 
			
		||||
    buf = st->buf;
 | 
			
		||||
    end = buf + st->size;
 | 
			
		||||
    for(i = 0; buf < end; buf++, i++) {
 | 
			
		||||
      if(!(i % 16) && (i || st->size > 16)) {
 | 
			
		||||
        ASN__CALLBACK(scratch, p-scratch);
 | 
			
		||||
        p = scratch;
 | 
			
		||||
        ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
      }
 | 
			
		||||
      *p++ = h2c[(*buf >> 4) & 0x0F];
 | 
			
		||||
      *p++ = h2c[*buf & 0x0F];
 | 
			
		||||
      *p++ = 0x20;
 | 
			
		||||
    }
 | 
			
		||||
    if(p - scratch) {
 | 
			
		||||
      p--;  /* Remove the tail space */
 | 
			
		||||
      ASN__CALLBACK3("\"", 1, scratch, p-scratch, "\"", 1);  /* Dump the rest */
 | 
			
		||||
      if(st->size > 16)
 | 
			
		||||
        ASN__TEXT_INDENT(1, ilevel-1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct OCTET_STRING__jer_escape_table_s {
 | 
			
		||||
    const char *string;
 | 
			
		||||
    int size;
 | 
			
		||||
} OCTET_STRING__jer_escape_table[] = {
 | 
			
		||||
#define	OSXET(s)	{ s, sizeof(s) - 1 }
 | 
			
		||||
    OSXET("\074\156\165\154\057\076"),  /* <nul/> */
 | 
			
		||||
    OSXET("\074\163\157\150\057\076"),  /* <soh/> */
 | 
			
		||||
    OSXET("\074\163\164\170\057\076"),  /* <stx/> */
 | 
			
		||||
    OSXET("\074\145\164\170\057\076"),  /* <etx/> */
 | 
			
		||||
    OSXET("\074\145\157\164\057\076"),  /* <eot/> */
 | 
			
		||||
    OSXET("\074\145\156\161\057\076"),  /* <enq/> */
 | 
			
		||||
    OSXET("\074\141\143\153\057\076"),  /* <ack/> */
 | 
			
		||||
    OSXET("\074\142\145\154\057\076"),  /* <bel/> */
 | 
			
		||||
    OSXET("\074\142\163\057\076"),      /* <bs/> */
 | 
			
		||||
    OSXET("\011"),                      /* \t */
 | 
			
		||||
    OSXET("\012"),                      /* \n */
 | 
			
		||||
    OSXET("\074\166\164\057\076"),      /* <vt/> */
 | 
			
		||||
    OSXET("\074\146\146\057\076"),      /* <ff/> */
 | 
			
		||||
    OSXET("\015"),                      /* \r */
 | 
			
		||||
    OSXET("\074\163\157\057\076"),      /* <so/> */
 | 
			
		||||
    OSXET("\074\163\151\057\076"),      /* <si/> */
 | 
			
		||||
    OSXET("\074\144\154\145\057\076"),  /* <dle/> */
 | 
			
		||||
    OSXET("\074\144\143\061\057\076"),  /* <de1/> */
 | 
			
		||||
    OSXET("\074\144\143\062\057\076"),  /* <de2/> */
 | 
			
		||||
    OSXET("\074\144\143\063\057\076"),  /* <de3/> */
 | 
			
		||||
    OSXET("\074\144\143\064\057\076"),  /* <de4/> */
 | 
			
		||||
    OSXET("\074\156\141\153\057\076"),  /* <nak/> */
 | 
			
		||||
    OSXET("\074\163\171\156\057\076"),  /* <syn/> */
 | 
			
		||||
    OSXET("\074\145\164\142\057\076"),  /* <etb/> */
 | 
			
		||||
    OSXET("\074\143\141\156\057\076"),  /* <can/> */
 | 
			
		||||
    OSXET("\074\145\155\057\076"),      /* <em/> */
 | 
			
		||||
    OSXET("\074\163\165\142\057\076"),  /* <sub/> */
 | 
			
		||||
    OSXET("\074\145\163\143\057\076"),  /* <esc/> */
 | 
			
		||||
    OSXET("\074\151\163\064\057\076"),  /* <is4/> */
 | 
			
		||||
    OSXET("\074\151\163\063\057\076"),  /* <is3/> */
 | 
			
		||||
    OSXET("\074\151\163\062\057\076"),  /* <is2/> */
 | 
			
		||||
    OSXET("\074\151\163\061\057\076"),  /* <is1/> */
 | 
			
		||||
    { 0, 0 },                           /* " " */
 | 
			
		||||
    { 0, 0 },                           /* ! */
 | 
			
		||||
    { 0, 0 },                           /* \" */
 | 
			
		||||
    { 0, 0 },                           /* # */
 | 
			
		||||
    { 0, 0 },                           /* $ */
 | 
			
		||||
    { 0, 0 },                           /* % */
 | 
			
		||||
    OSXET("\046\141\155\160\073"),      /* & */
 | 
			
		||||
    { 0, 0 },                           /* ' */
 | 
			
		||||
    {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},  /* ()*+,-./ */
 | 
			
		||||
    {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},  /* 01234567 */
 | 
			
		||||
    {0,0},{0,0},{0,0},{0,0},            /* 89:; */
 | 
			
		||||
    OSXET("\046\154\164\073"),          /* < */
 | 
			
		||||
    { 0, 0 },                           /* = */
 | 
			
		||||
    OSXET("\046\147\164\073"),          /* > */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
OCTET_STRING_encode_jer_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                             int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                             asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 | 
			
		||||
    asn_enc_rval_t er = { 0, 0, 0 };
 | 
			
		||||
    uint8_t *buf, *end;
 | 
			
		||||
    uint8_t *ss;  /* Sequence start */
 | 
			
		||||
    ssize_t encoded_len = 0;
 | 
			
		||||
 | 
			
		||||
    (void)ilevel;  /* Unused argument */
 | 
			
		||||
    (void)flags;  /* Unused argument */
 | 
			
		||||
 | 
			
		||||
    if(!st || (!st->buf && st->size))
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    buf = st->buf;
 | 
			
		||||
    end = buf + st->size;
 | 
			
		||||
    for(ss = buf; buf < end; buf++) {
 | 
			
		||||
        unsigned int ch = *buf;
 | 
			
		||||
        int s_len;	/* Special encoding sequence length */
 | 
			
		||||
 | 
			
		||||
        /*
 | 
			
		||||
         * Escape certain characters: X.680/11.15
 | 
			
		||||
         */
 | 
			
		||||
        if(ch < sizeof(OCTET_STRING__jer_escape_table)
 | 
			
		||||
            / sizeof(OCTET_STRING__jer_escape_table[0])
 | 
			
		||||
        && (s_len = OCTET_STRING__jer_escape_table[ch].size)) {
 | 
			
		||||
            if(((buf - ss) && cb(ss, buf - ss, app_key) < 0)
 | 
			
		||||
            || cb(OCTET_STRING__jer_escape_table[ch].string, s_len, app_key) < 0)
 | 
			
		||||
                ASN__ENCODE_FAILED;
 | 
			
		||||
            encoded_len += (buf - ss) + s_len;
 | 
			
		||||
            ss = buf + 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    encoded_len += (buf - ss);
 | 
			
		||||
    if((buf - ss) && cb(ss, buf - ss, app_key) < 0)
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = encoded_len;
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -28,6 +28,11 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OPEN_TYPE_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OPEN_TYPE_decode_oer,
 | 
			
		||||
    OPEN_TYPE_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,10 @@ asn_dec_rval_t OPEN_TYPE_xer_get(
 | 
			
		||||
#define OPEN_TYPE_encode_xer CHOICE_encode_xer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define OPEN_TYPE_encode_jer CHOICE_encode_jer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
asn_dec_rval_t OPEN_TYPE_oer_get(
 | 
			
		||||
    const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
 
 | 
			
		||||
@@ -146,7 +146,7 @@ OPEN_TYPE_aper_unknown_type_discard_bytes (asn_per_data_t *pd) {
 | 
			
		||||
    rv.code = RC_FAIL;
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        bytes = aper_get_length(pd, -1, -1, &repeat);
 | 
			
		||||
        bytes = aper_get_length(pd, -1, -1, -1, &repeat);
 | 
			
		||||
        if (bytes > 10 * ASN_DUMMY_BYTES)
 | 
			
		||||
        {
 | 
			
		||||
            return rv;
 | 
			
		||||
@@ -171,4 +171,3 @@ OPEN_TYPE_aper_unknown_type_discard_bytes (asn_per_data_t *pd) {
 | 
			
		||||
     return rv;
 | 
			
		||||
#undef ASN_DUMMY_BYTES
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,11 @@ asn_TYPE_operation_t asn_OP_ObjectDescriptor = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer_utf8,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,10 @@ extern asn_TYPE_operation_t asn_OP_ObjectDescriptor;
 | 
			
		||||
#define ObjectDescriptor_encode_xer OCTET_STRING_encode_xer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define ObjectDescriptor_encode_jer OCTET_STRING_encode_jer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
#define ObjectDescriptor_decode_uper OCTET_STRING_decode_uper
 | 
			
		||||
#define ObjectDescriptor_encode_uper OCTET_STRING_encode_uper
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,11 @@ asn_TYPE_operation_t asn_OP_PrintableString = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer_utf8,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_decode_oer,
 | 
			
		||||
    OCTET_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,10 @@ asn_constr_check_f PrintableString_constraint;
 | 
			
		||||
#define PrintableString_encode_xer OCTET_STRING_encode_xer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define PrintableString_encode_jer OCTET_STRING_encode_jer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
#define PrintableString_decode_uper OCTET_STRING_decode_uper
 | 
			
		||||
#define PrintableString_encode_uper OCTET_STRING_encode_uper
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,11 @@ asn_TYPE_operation_t asn_OP_UTF8String = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer_utf8,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_decode_oer,
 | 
			
		||||
    OCTET_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,10 @@ asn_constr_check_f UTF8String_constraint;
 | 
			
		||||
#define UTF8String_encode_xer OCTET_STRING_encode_xer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define UTF8String_encode_jer OCTET_STRING_encode_jer_utf8
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
#define UTF8String_decode_uper OCTET_STRING_decode_uper
 | 
			
		||||
#define UTF8String_encode_uper OCTET_STRING_encode_uper
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,11 @@ asn_TYPE_operation_t asn_OP_VisibleString = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_encode_jer_utf8,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    OCTET_STRING_decode_oer,
 | 
			
		||||
    OCTET_STRING_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,10 @@ asn_constr_check_f VisibleString_constraint;
 | 
			
		||||
#define VisibleString_encode_xer OCTET_STRING_encode_xer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#define VisibleString_encode_jer OCTET_STRING_encode_jer
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT)
 | 
			
		||||
#define VisibleString_decode_uper OCTET_STRING_decode_uper
 | 
			
		||||
#define VisibleString_encode_uper OCTET_STRING_encode_uper
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ aper_open_type_get_simple(const asn_codec_ctx_t *ctx,
 | 
			
		||||
	ASN_DEBUG("Getting open type %s...", td->name);
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
	        chunk_bytes = aper_get_length(pd, -1, -1, &repeat);
 | 
			
		||||
	        chunk_bytes = aper_get_length(pd, -1, -1, -1, &repeat);
 | 
			
		||||
		if(chunk_bytes < 0) {
 | 
			
		||||
			FREEMEM(buf);
 | 
			
		||||
			ASN__DECODE_STARVED;
 | 
			
		||||
@@ -101,12 +101,12 @@ aper_open_type_put(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
 | 
			
		||||
	for(bptr = buf, toGo = size; toGo;) {
 | 
			
		||||
        int need_eom = 0;
 | 
			
		||||
		ssize_t maySave = aper_put_length(po, -1, toGo, &need_eom);
 | 
			
		||||
		ssize_t maySave = aper_put_length(po, -1, -1, toGo, &need_eom);
 | 
			
		||||
		if(maySave < 0) break;
 | 
			
		||||
		if(per_put_many_bits(po, bptr, maySave * 8)) break;
 | 
			
		||||
		bptr = (char *)bptr + maySave;
 | 
			
		||||
		toGo -= maySave;
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0)) {
 | 
			
		||||
        if(need_eom && (aper_put_length(po, -1, -1, 0, NULL) < 0)) {
 | 
			
		||||
            FREEMEM(buf);
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,26 +17,17 @@ aper_get_align(asn_per_data_t *pd) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t
 | 
			
		||||
aper_get_length(asn_per_data_t *pd, int range, int ebits, int *repeat) {
 | 
			
		||||
aper_get_length(asn_per_data_t *pd, ssize_t lb, ssize_t ub,
 | 
			
		||||
		int ebits, int *repeat) {
 | 
			
		||||
	int constrained = (lb >= 0) && (ub >= 0);
 | 
			
		||||
	ssize_t value;
 | 
			
		||||
 | 
			
		||||
	*repeat = 0;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * ITU-T X.691(08/2015)
 | 
			
		||||
     * #11.9.4.2
 | 
			
		||||
     *
 | 
			
		||||
     * If the length determinant "n" to be encoded is a normally small length,
 | 
			
		||||
     * or a constrained whole number with "ub" greater than or equal to 64K,
 | 
			
		||||
     * or is a semi-constrained whole number, then "n" shall be encoded
 | 
			
		||||
     * as specified in 11.9.3.4 to 11.9.3.8.4.
 | 
			
		||||
     *
 | 
			
		||||
     * NOTE – Thus, if "ub" is greater than or equal to 64K,
 | 
			
		||||
     * the encoding of the length determinant is the same as it would be
 | 
			
		||||
     * if the length were unconstrained.
 | 
			
		||||
     */
 | 
			
		||||
	if (range <= 65535 && range >= 0)
 | 
			
		||||
	if (constrained && ub < 65536) {
 | 
			
		||||
		int range = ub - lb + 1;
 | 
			
		||||
		return aper_get_nsnnwn(pd, range);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (aper_get_align(pd) < 0)
 | 
			
		||||
		return -1;
 | 
			
		||||
@@ -72,13 +63,12 @@ aper_get_nslength(asn_per_data_t *pd) {
 | 
			
		||||
		return length;
 | 
			
		||||
	} else {
 | 
			
		||||
		int repeat;
 | 
			
		||||
		length = aper_get_length(pd, -1, -1, &repeat);
 | 
			
		||||
		length = aper_get_length(pd, -1, -1, -1, &repeat);
 | 
			
		||||
		if(length >= 0 && !repeat) return length;
 | 
			
		||||
		return -1; /* Error, or do not support >16K extensions */
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if !defined(USE_OLDER_APER_NSNNWN)
 | 
			
		||||
ssize_t
 | 
			
		||||
aper_get_nsnnwn(asn_per_data_t *pd, int range) {
 | 
			
		||||
	ssize_t value;
 | 
			
		||||
@@ -130,31 +120,6 @@ aper_get_nsnnwn(asn_per_data_t *pd, int range) {
 | 
			
		||||
	value = per_get_few_bits(pd, 8 * bytes);
 | 
			
		||||
	return value;
 | 
			
		||||
}
 | 
			
		||||
#else /* old APER codec */
 | 
			
		||||
ssize_t
 | 
			
		||||
aper_get_nsnnwn(asn_per_data_t *pd, int dummy_range) {
 | 
			
		||||
       ssize_t value;
 | 
			
		||||
 | 
			
		||||
       ASN_DEBUG("Get the normally small non-negative whole number APER");
 | 
			
		||||
 | 
			
		||||
       value = per_get_few_bits(pd, 7);
 | 
			
		||||
       if(value & 64) {        /* implicit (value < 0) */
 | 
			
		||||
               value &= 63;
 | 
			
		||||
               value <<= 2;
 | 
			
		||||
               value |= per_get_few_bits(pd, 2);
 | 
			
		||||
               if(value & 128) /* implicit (value < 0) */
 | 
			
		||||
                       return -1;
 | 
			
		||||
               if(value == 0)
 | 
			
		||||
                       return 0;
 | 
			
		||||
               if(value >= 3)
 | 
			
		||||
                       return -1;
 | 
			
		||||
               value = per_get_few_bits(pd, 8 * value);
 | 
			
		||||
               return value;
 | 
			
		||||
       }
 | 
			
		||||
 | 
			
		||||
       return value;
 | 
			
		||||
}
 | 
			
		||||
#endif /* don't use old APER */
 | 
			
		||||
 | 
			
		||||
int aper_put_align(asn_per_outp_t *po) {
 | 
			
		||||
 | 
			
		||||
@@ -167,38 +132,42 @@ int aper_put_align(asn_per_outp_t *po) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t
 | 
			
		||||
aper_put_length(asn_per_outp_t *po, int range, size_t length, int *need_eom) {
 | 
			
		||||
aper_put_length(asn_per_outp_t *po, ssize_t lb, ssize_t ub, size_t n, int *need_eom) {
 | 
			
		||||
	int constrained = (lb >= 0) && (ub >= 0);
 | 
			
		||||
	int dummy = 0;
 | 
			
		||||
	if(!need_eom) need_eom = &dummy;
 | 
			
		||||
 | 
			
		||||
	*need_eom = 0;
 | 
			
		||||
 | 
			
		||||
	ASN_DEBUG("APER put length %zu with range %d", length, range);
 | 
			
		||||
 | 
			
		||||
	ASN_DEBUG("APER put length %zu with range (%zd..%zd)", n, lb, ub);
 | 
			
		||||
 | 
			
		||||
	/* 11.9 X.691 Note 2 */
 | 
			
		||||
	if (range <= 65536 && range >= 0)
 | 
			
		||||
		return aper_put_nsnnwn(po, range, length);
 | 
			
		||||
	if (constrained && ub < 65536) {
 | 
			
		||||
		int range = ub - lb + 1;
 | 
			
		||||
		return aper_put_nsnnwn(po, range, n) ? -1 : (ssize_t)n;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (aper_put_align(po) < 0)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	if(length <= 127)	   /* #11.9.3.6 */{
 | 
			
		||||
		return per_put_few_bits(po, length, 8)
 | 
			
		||||
		? -1 : (ssize_t)length;
 | 
			
		||||
	if(n <= 127) { /* #11.9.3.6 */
 | 
			
		||||
		return per_put_few_bits(po, n, 8)
 | 
			
		||||
		? -1 : (ssize_t)n;
 | 
			
		||||
	}
 | 
			
		||||
	else if(length < 16384) /* #11.9.3.7 */
 | 
			
		||||
		return per_put_few_bits(po, length|0x8000, 16)
 | 
			
		||||
		? -1 : (ssize_t)length;
 | 
			
		||||
	else if(n < 16384) /* #11.9.3.7 */
 | 
			
		||||
		return per_put_few_bits(po, n|0x8000, 16)
 | 
			
		||||
		? -1 : (ssize_t)n;
 | 
			
		||||
 | 
			
		||||
    *need_eom = 0 == (length & 16383);
 | 
			
		||||
	length >>= 14;
 | 
			
		||||
	if(length > 4) {
 | 
			
		||||
	*need_eom = 0 == (n & 16383);
 | 
			
		||||
	n >>= 14;
 | 
			
		||||
	if(n > 4) {
 | 
			
		||||
		*need_eom = 0;
 | 
			
		||||
        length = 4;
 | 
			
		||||
		n = 4;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return per_put_few_bits(po, 0xC0 | length, 8)
 | 
			
		||||
	? -1 : (ssize_t)(length << 14);
 | 
			
		||||
	return per_put_few_bits(po, 0xC0 | n, 8)
 | 
			
		||||
	? -1 : (ssize_t)(n << 14);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -210,7 +179,7 @@ aper_put_nslength(asn_per_outp_t *po, size_t length) {
 | 
			
		||||
		if(length == 0) return -1;
 | 
			
		||||
		return per_put_few_bits(po, length-1, 7) ? -1 : 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		if(aper_put_length(po, -1, length, 0) != (ssize_t)length) {
 | 
			
		||||
		if(aper_put_length(po, -1, -1, length, NULL) != (ssize_t)length) {
 | 
			
		||||
			/* This might happen in case of >16K extensions */
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
@@ -219,7 +188,6 @@ aper_put_nslength(asn_per_outp_t *po, size_t length) {
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if !defined(USE_OLDER_APER_NSNNWN)
 | 
			
		||||
int
 | 
			
		||||
aper_put_nsnnwn(asn_per_outp_t *po, int range, int number) {
 | 
			
		||||
	int bytes;
 | 
			
		||||
@@ -245,8 +213,12 @@ aper_put_nsnnwn(asn_per_outp_t *po, int range, int number) {
 | 
			
		||||
		}
 | 
			
		||||
		return per_put_few_bits(po, number, i);
 | 
			
		||||
	} else if(range == 256) {
 | 
			
		||||
		if (number >= range)
 | 
			
		||||
			return -1;
 | 
			
		||||
		bytes = 1;
 | 
			
		||||
	} else if(range <= 65536) {
 | 
			
		||||
		if (number >= range)
 | 
			
		||||
			return -1;
 | 
			
		||||
		bytes = 2;
 | 
			
		||||
	} else { /* Ranges > 64K */
 | 
			
		||||
		int i;
 | 
			
		||||
@@ -265,28 +237,3 @@ aper_put_nsnnwn(asn_per_outp_t *po, int range, int number) {
 | 
			
		||||
*/
 | 
			
		||||
	return per_put_few_bits(po, number, 8 * bytes);
 | 
			
		||||
}
 | 
			
		||||
#else /* preserve old code base in case */
 | 
			
		||||
int
 | 
			
		||||
aper_put_nsnnwn(asn_per_outp_t *po, int dummy_range, int n) {
 | 
			
		||||
       int bytes;
 | 
			
		||||
 | 
			
		||||
       ASN_DEBUG("aper_put_nsnnwn");
 | 
			
		||||
 | 
			
		||||
       if(n <= 63) {
 | 
			
		||||
               if(n < 0) return -1;
 | 
			
		||||
               return per_put_few_bits(po, n, 7);
 | 
			
		||||
       }
 | 
			
		||||
       if(n < 256)
 | 
			
		||||
               bytes = 1;
 | 
			
		||||
       else if(n < 65536)
 | 
			
		||||
               bytes = 2;
 | 
			
		||||
       else if(n < 256 * 65536)
 | 
			
		||||
               bytes = 3;
 | 
			
		||||
       else
 | 
			
		||||
               return -1;      /* This is not a "normally small" value */
 | 
			
		||||
       if(per_put_few_bits(po, bytes, 8))
 | 
			
		||||
               return -1;
 | 
			
		||||
 | 
			
		||||
       return per_put_few_bits(po, n, 8 * bytes);
 | 
			
		||||
}
 | 
			
		||||
#endif /* which aper_put_nsnnwn() */
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ extern "C" {
 | 
			
		||||
 * X.691 (08/2015) #11.9 "General rules for encoding a length determinant"
 | 
			
		||||
 * Get the length "n" from the Aligned PER stream.
 | 
			
		||||
 */
 | 
			
		||||
ssize_t aper_get_length(asn_per_data_t *pd, int range,
 | 
			
		||||
ssize_t aper_get_length(asn_per_data_t *pd, ssize_t lb, ssize_t ub,
 | 
			
		||||
                        int effective_bound_bits, int *repeat);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -31,13 +31,14 @@ ssize_t aper_get_nsnnwn(asn_per_data_t *pd, int range);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * X.691 (08/2015) #11.9 "General rules for encoding a length determinant"
 | 
			
		||||
 * Put the length "whole_length" to the Aligned PER stream.
 | 
			
		||||
 * If (opt_need_eom) is given, it will be set to 1 if final 0-length is needed.
 | 
			
		||||
 * In that case, invoke uper_put_length(po, 0, 0) after encoding the last block.
 | 
			
		||||
 * Put the length "n" to the Aligned PER stream.
 | 
			
		||||
 * If (opt_need_eom) is given, it will be set to 1 if final 0-n is needed.
 | 
			
		||||
 * In that case, invoke aper_put_length(po, -1, -1, 0, NULL) after encoding the
 | 
			
		||||
 * last block.
 | 
			
		||||
 * This function returns the number of units which may be flushed
 | 
			
		||||
 * in the next units saving iteration.
 | 
			
		||||
 */
 | 
			
		||||
ssize_t aper_put_length(asn_per_outp_t *po, int range, size_t length,
 | 
			
		||||
ssize_t aper_put_length(asn_per_outp_t *po, ssize_t lb, ssize_t ub, size_t n,
 | 
			
		||||
                        int *opt_need_eom);
 | 
			
		||||
 | 
			
		||||
/* Align the current bit position to octet bundary */
 | 
			
		||||
 
 | 
			
		||||
@@ -431,6 +431,23 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
        break;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    case ATS_BASIC_JER:
 | 
			
		||||
        if(td->op->jer_encoder) {
 | 
			
		||||
            er = jer_encode(td, sptr, callback, callback_key);
 | 
			
		||||
            if(er.encoded == -1) {
 | 
			
		||||
                if(er.failed_type && er.failed_type->op->jer_encoder) {
 | 
			
		||||
                    errno = EBADF;   /* Structure has incorrect form. */
 | 
			
		||||
                } else {
 | 
			
		||||
                    errno = ENOENT;  /* JER is not defined for this type. */
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            errno = ENOENT;  /* Transfer syntax is not defined for this type. */
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
    default:
 | 
			
		||||
        errno = ENOENT;
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,8 @@ enum asn_transfer_syntax {
 | 
			
		||||
     * CANONICAL-XER is a more strict variant of BASIC-XER.
 | 
			
		||||
     */
 | 
			
		||||
    ATS_BASIC_XER,
 | 
			
		||||
    ATS_CANONICAL_XER
 | 
			
		||||
    ATS_CANONICAL_XER,
 | 
			
		||||
    ATS_BASIC_JER,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,11 @@ asn_TYPE_operation_t asn_OP_CHOICE = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    CHOICE_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    CHOICE_decode_oer,
 | 
			
		||||
    CHOICE_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,10 @@ xer_type_decoder_f CHOICE_decode_xer;
 | 
			
		||||
xer_type_encoder_f CHOICE_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f CHOICE_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f CHOICE_decode_oer;
 | 
			
		||||
oer_type_encoder_f CHOICE_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										79
									
								
								lib/asn1c/common/constr_CHOICE_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								lib/asn1c/common/constr_CHOICE_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <constr_CHOICE.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Return a standardized complex structure.
 | 
			
		||||
 */
 | 
			
		||||
#undef RETURN
 | 
			
		||||
#define RETURN(_code)                     \
 | 
			
		||||
    do {                                  \
 | 
			
		||||
        rval.code = _code;                \
 | 
			
		||||
        rval.consumed = consumed_myself;  \
 | 
			
		||||
        return rval;                      \
 | 
			
		||||
    } while(0)
 | 
			
		||||
 | 
			
		||||
#undef JER_ADVANCE
 | 
			
		||||
#define JER_ADVANCE(num_bytes)                                    \
 | 
			
		||||
    do {                                                          \
 | 
			
		||||
        size_t num = num_bytes;                                   \
 | 
			
		||||
        buf_ptr = (const void *)(((const char *)buf_ptr) + num);  \
 | 
			
		||||
        size -= num;                                              \
 | 
			
		||||
        consumed_myself += num;                                   \
 | 
			
		||||
    } while(0)
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
CHOICE_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 | 
			
		||||
                  enum jer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
 | 
			
		||||
                  void *app_key) {
 | 
			
		||||
    const asn_CHOICE_specifics_t *specs =
 | 
			
		||||
        (const asn_CHOICE_specifics_t *)td->specifics;
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    unsigned present = 0;
 | 
			
		||||
 | 
			
		||||
    if(!sptr)
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Figure out which CHOICE element is encoded.
 | 
			
		||||
     */
 | 
			
		||||
    present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
 | 
			
		||||
 | 
			
		||||
    if(present == 0 || present > td->elements_count) {
 | 
			
		||||
        ASN__ENCODE_FAILED;
 | 
			
		||||
    } else {
 | 
			
		||||
        asn_enc_rval_t tmper = {0,0,0};
 | 
			
		||||
        asn_TYPE_member_t *elm = &td->elements[present-1];
 | 
			
		||||
        const void *memb_ptr = NULL;
 | 
			
		||||
        const char *mname = elm->name;
 | 
			
		||||
        unsigned int mlen = strlen(mname);
 | 
			
		||||
 | 
			
		||||
        if(elm->flags & ATF_POINTER) {
 | 
			
		||||
            memb_ptr =
 | 
			
		||||
                *(const void *const *)((const char *)sptr + elm->memb_offset);
 | 
			
		||||
            if(!memb_ptr) ASN__ENCODE_FAILED;
 | 
			
		||||
        } else {
 | 
			
		||||
            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        er.encoded = 0;
 | 
			
		||||
 | 
			
		||||
        ASN__CALLBACK3("{\n\"", 3, mname, mlen, "\": ", 2);
 | 
			
		||||
 | 
			
		||||
        tmper = elm->type->op->jer_encoder(elm->type, memb_ptr,
 | 
			
		||||
                                           ilevel + 1, flags, cb, app_key);
 | 
			
		||||
        if(tmper.encoded == -1) return tmper;
 | 
			
		||||
        er.encoded += tmper.encoded;
 | 
			
		||||
 | 
			
		||||
        ASN__CALLBACK("}", 1);
 | 
			
		||||
        //        ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
@@ -28,6 +28,11 @@ asn_TYPE_operation_t asn_OP_SEQUENCE = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    SEQUENCE_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    SEQUENCE_decode_oer,
 | 
			
		||||
    SEQUENCE_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,10 @@ xer_type_decoder_f SEQUENCE_decode_xer;
 | 
			
		||||
xer_type_encoder_f SEQUENCE_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f SEQUENCE_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f SEQUENCE_decode_oer;
 | 
			
		||||
oer_type_encoder_f SEQUENCE_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,11 @@ asn_TYPE_operation_t asn_OP_SEQUENCE_OF = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    SEQUENCE_OF_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    SEQUENCE_OF_decode_oer,  /* Same as SET OF decoder. */
 | 
			
		||||
    SEQUENCE_OF_encode_oer,  /* Same as SET OF encoder */
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,10 @@ der_type_encoder_f SEQUENCE_OF_encode_der;
 | 
			
		||||
xer_type_encoder_f SEQUENCE_OF_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f SEQUENCE_OF_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
#define SEQUENCE_OF_decode_oer SET_OF_decode_oer
 | 
			
		||||
#define SEQUENCE_OF_encode_oer SET_OF_encode_oer
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ SEQUENCE_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
*/
 | 
			
		||||
        if (ct->lower_bound == ct->upper_bound && ct->upper_bound < 65536) {
 | 
			
		||||
            /* No length determinant */
 | 
			
		||||
        } else if (aper_put_length(po, ct->upper_bound - ct->lower_bound + 1, list->count - ct->lower_bound, 0) < 0)
 | 
			
		||||
    } else if (aper_put_length(po, ct->lower_bound, ct->upper_bound, list->count - ct->lower_bound, 0) < 0)
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -65,7 +65,7 @@ SEQUENCE_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
        if(ct && ct->effective_bits >= 0) {
 | 
			
		||||
            mayEncode = list->count;
 | 
			
		||||
        } else {
 | 
			
		||||
            mayEncode = aper_put_length(po, -1, list->count - seq, &need_eom);
 | 
			
		||||
            mayEncode = aper_put_length(po, -1, -1, list->count - seq, &need_eom);
 | 
			
		||||
            if(mayEncode < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -79,7 +79,7 @@ SEQUENCE_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
                ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0))
 | 
			
		||||
        if(need_eom && (aper_put_length(po, -1, -1, 0, NULL) < 0))
 | 
			
		||||
            ASN__ENCODE_FAILED;  /* End of Message length */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										65
									
								
								lib/asn1c/common/constr_SEQUENCE_OF_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								lib/asn1c/common/constr_SEQUENCE_OF_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <constr_SEQUENCE_OF.h>
 | 
			
		||||
#include <asn_SEQUENCE_OF.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
SEQUENCE_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                       int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                       asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
 | 
			
		||||
    const asn_TYPE_member_t *elm = td->elements;
 | 
			
		||||
    const asn_anonymous_sequence_ *list = _A_CSEQUENCE_FROM_VOID(sptr);
 | 
			
		||||
    const char *mname = specs->as_XMLValueList
 | 
			
		||||
                            ? 0
 | 
			
		||||
                            : ((*elm->name) ? elm->name : elm->type->xml_tag);
 | 
			
		||||
    size_t mlen = mname ? strlen(mname) : 0;
 | 
			
		||||
    int xcan = 0;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    if(!sptr) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
    ASN__CALLBACK("[", 1);
 | 
			
		||||
 | 
			
		||||
    for(i = 0; i < list->count; i++) {
 | 
			
		||||
        asn_enc_rval_t tmper = {0,0,0};
 | 
			
		||||
        void *memb_ptr = list->array[i];
 | 
			
		||||
        if(!memb_ptr) continue;
 | 
			
		||||
 | 
			
		||||
        if(mname) {
 | 
			
		||||
            if(!xcan) ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
            ASN__CALLBACK3("{\"", 2, mname, mlen, "\":", 2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        tmper = elm->type->op->jer_encoder(elm->type, memb_ptr, ilevel + 1,
 | 
			
		||||
                                           flags, cb, app_key);
 | 
			
		||||
        if(tmper.encoded == -1) return tmper;
 | 
			
		||||
        er.encoded += tmper.encoded;
 | 
			
		||||
        if(tmper.encoded == 0 && specs->as_XMLValueList) {
 | 
			
		||||
            const char *name = elm->type->xml_tag;
 | 
			
		||||
            size_t len = strlen(name);
 | 
			
		||||
            if(!xcan) ASN__TEXT_INDENT(1, ilevel + 1);
 | 
			
		||||
            ASN__CALLBACK3("\"", 1, name, len, "\"", 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(mname) {
 | 
			
		||||
          ASN__CALLBACK("}", 1);
 | 
			
		||||
        }
 | 
			
		||||
        if (i != list->count - 1) {
 | 
			
		||||
          ASN__CALLBACK(",", 1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
 | 
			
		||||
    ASN__CALLBACK("]", 1);
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										84
									
								
								lib/asn1c/common/constr_SEQUENCE_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								lib/asn1c/common/constr_SEQUENCE_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <constr_SEQUENCE.h>
 | 
			
		||||
#include <OPEN_TYPE.h>
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t SEQUENCE_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
                    int ilevel, enum jer_encoder_flags_e flags,
 | 
			
		||||
                    asn_app_consume_bytes_f *cb, void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    int xcan = 0;
 | 
			
		||||
    asn_TYPE_descriptor_t *tmp_def_val_td = 0;
 | 
			
		||||
    void *tmp_def_val = 0;
 | 
			
		||||
    size_t edx;
 | 
			
		||||
 | 
			
		||||
    if(!sptr) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
 | 
			
		||||
    int bAddComma = 0;
 | 
			
		||||
    ASN__CALLBACK("{\n", 2);
 | 
			
		||||
    for(edx = 0; edx < td->elements_count; edx++) {
 | 
			
		||||
        asn_enc_rval_t tmper = {0,0,0};
 | 
			
		||||
        asn_TYPE_member_t *elm = &td->elements[edx];
 | 
			
		||||
        const void *memb_ptr;
 | 
			
		||||
        const char *mname = elm->name;
 | 
			
		||||
        unsigned int mlen = strlen(mname);
 | 
			
		||||
 | 
			
		||||
        if(elm->flags & ATF_POINTER) {
 | 
			
		||||
            memb_ptr =
 | 
			
		||||
                *(const void *const *)((const char *)sptr + elm->memb_offset);
 | 
			
		||||
            if(!memb_ptr) {
 | 
			
		||||
                assert(tmp_def_val == 0);
 | 
			
		||||
                if(elm->default_value_set) {
 | 
			
		||||
                    if(elm->default_value_set(&tmp_def_val)) {
 | 
			
		||||
                        ASN__ENCODE_FAILED;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        memb_ptr = tmp_def_val;
 | 
			
		||||
                        tmp_def_val_td = elm->type;
 | 
			
		||||
                    }
 | 
			
		||||
                } else if(elm->optional) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                } else {
 | 
			
		||||
                    /* Mandatory element is missing */
 | 
			
		||||
                    ASN__ENCODE_FAILED;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (bAddComma == 1) {
 | 
			
		||||
          ASN__CALLBACK(",", 1);
 | 
			
		||||
          bAddComma = 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(!xcan) ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
        ASN__CALLBACK3("\"", 1, mname, mlen, "\": ", 3);
 | 
			
		||||
 | 
			
		||||
        /* Print the member itself */
 | 
			
		||||
        tmper = elm->type->op->jer_encoder(elm->type, memb_ptr, ilevel + 1,
 | 
			
		||||
                                           flags, cb, app_key);
 | 
			
		||||
        if(tmp_def_val) {
 | 
			
		||||
            ASN_STRUCT_FREE(*tmp_def_val_td, tmp_def_val);
 | 
			
		||||
            tmp_def_val = 0;
 | 
			
		||||
        }
 | 
			
		||||
        if(tmper.encoded == -1) return tmper;
 | 
			
		||||
        er.encoded += tmper.encoded;
 | 
			
		||||
        if (edx != td->elements_count - 1) {
 | 
			
		||||
          bAddComma = 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    ASN__CALLBACK("}", 1);
 | 
			
		||||
 | 
			
		||||
    if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
 | 
			
		||||
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
    if(tmp_def_val) ASN_STRUCT_FREE(*tmp_def_val_td, tmp_def_val);
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
@@ -28,6 +28,11 @@ asn_TYPE_operation_t asn_OP_SET_OF = {
 | 
			
		||||
    0,
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
    SET_OF_encode_jer,
 | 
			
		||||
#else
 | 
			
		||||
    0,
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
    SET_OF_decode_oer,
 | 
			
		||||
    SET_OF_encode_oer,
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,10 @@ xer_type_decoder_f SET_OF_decode_xer;
 | 
			
		||||
xer_type_encoder_f SET_OF_encode_xer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
jer_type_encoder_f SET_OF_encode_jer;
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_OER_SUPPORT)
 | 
			
		||||
oer_type_decoder_f SET_OF_decode_oer;
 | 
			
		||||
oer_type_encoder_f SET_OF_encode_oer;
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ SET_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
                            ct->effective_bits))
 | 
			
		||||
            ASN__ENCODE_FAILED;*/
 | 
			
		||||
 | 
			
		||||
        if (aper_put_length(po, ct->upper_bound - ct->lower_bound + 1, list->count - ct->lower_bound, 0) < 0) {
 | 
			
		||||
        if (aper_put_length(po, ct->lower_bound, ct->upper_bound, list->count - ct->lower_bound, 0) < 0) {
 | 
			
		||||
            ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -70,7 +70,7 @@ SET_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
            may_encode = list->count;
 | 
			
		||||
        } else {
 | 
			
		||||
            may_encode =
 | 
			
		||||
                aper_put_length(po, -1, list->count - seq, &need_eom);
 | 
			
		||||
                aper_put_length(po, -1, -1, list->count - seq, &need_eom);
 | 
			
		||||
            if(may_encode < 0) ASN__ENCODE_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -81,7 +81,7 @@ SET_OF_encode_aper(const asn_TYPE_descriptor_t *td,
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if(need_eom && aper_put_length(po, -1, 0, 0))
 | 
			
		||||
        if(need_eom && (aper_put_length(po, -1, -1, 0, NULL) < 0))
 | 
			
		||||
            ASN__ENCODE_FAILED;  /* End of Message length */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -141,8 +141,11 @@ SET_OF_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
 | 
			
		||||
    do {
 | 
			
		||||
        int i;
 | 
			
		||||
        if(nelems < 0) {
 | 
			
		||||
            nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1,
 | 
			
		||||
                                     ct ? ct->effective_bits : -1, &repeat);
 | 
			
		||||
            if (ct)
 | 
			
		||||
                nelems = aper_get_length(pd, ct->lower_bound, ct->upper_bound,
 | 
			
		||||
                                         ct->effective_bits, &repeat);
 | 
			
		||||
            else
 | 
			
		||||
                nelems = aper_get_length(pd, -1, -1, -1, &repeat);
 | 
			
		||||
            ASN_DEBUG("Got to decode %d elements (eff %d)",
 | 
			
		||||
                      (int)nelems, (int)(ct ? ct->effective_bits : -1));
 | 
			
		||||
            if(nelems < 0) ASN__DECODE_STARVED;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										144
									
								
								lib/asn1c/common/constr_SET_OF_jer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										144
									
								
								lib/asn1c/common/constr_SET_OF_jer.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,144 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <constr_SET_OF.h>
 | 
			
		||||
 | 
			
		||||
typedef struct jer_tmp_enc_s {
 | 
			
		||||
    void *buffer;
 | 
			
		||||
    size_t offset;
 | 
			
		||||
    size_t size;
 | 
			
		||||
} jer_tmp_enc_t;
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
SET_OF_encode_jer_callback(const void *buffer, size_t size, void *key) {
 | 
			
		||||
    jer_tmp_enc_t *t = (jer_tmp_enc_t *)key;
 | 
			
		||||
    if(t->offset + size >= t->size) {
 | 
			
		||||
        size_t newsize = (t->size << 2) + size;
 | 
			
		||||
        void *p = REALLOC(t->buffer, newsize);
 | 
			
		||||
        if(!p) return -1;
 | 
			
		||||
        t->buffer = p;
 | 
			
		||||
        t->size = newsize;
 | 
			
		||||
    }
 | 
			
		||||
    memcpy((char *)t->buffer + t->offset, buffer, size);
 | 
			
		||||
    t->offset += size;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
SET_OF_jer_order(const void *aptr, const void *bptr) {
 | 
			
		||||
    const jer_tmp_enc_t *a = (const jer_tmp_enc_t *)aptr;
 | 
			
		||||
    const jer_tmp_enc_t *b = (const jer_tmp_enc_t *)bptr;
 | 
			
		||||
    size_t minlen = a->offset;
 | 
			
		||||
    int ret;
 | 
			
		||||
    if(b->offset < minlen) minlen = b->offset;
 | 
			
		||||
    /* Well-formed UTF-8 has this nice lexicographical property... */
 | 
			
		||||
    ret = memcmp(a->buffer, b->buffer, minlen);
 | 
			
		||||
    if(ret != 0) return ret;
 | 
			
		||||
    if(a->offset == b->offset)
 | 
			
		||||
        return 0;
 | 
			
		||||
    if(a->offset == minlen)
 | 
			
		||||
        return -1;
 | 
			
		||||
    return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
SET_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 | 
			
		||||
                  enum jer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
 | 
			
		||||
                  void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
    const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
 | 
			
		||||
    const asn_TYPE_member_t *elm = td->elements;
 | 
			
		||||
    const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
 | 
			
		||||
    const char *mname = specs->as_XMLValueList
 | 
			
		||||
        ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag);
 | 
			
		||||
    size_t mlen = mname ? strlen(mname) : 0;
 | 
			
		||||
    int xcan = 0;
 | 
			
		||||
    jer_tmp_enc_t *encs = 0;
 | 
			
		||||
    size_t encs_count = 0;
 | 
			
		||||
    void *original_app_key = app_key;
 | 
			
		||||
    asn_app_consume_bytes_f *original_cb = cb;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    if(!sptr) ASN__ENCODE_FAILED;
 | 
			
		||||
 | 
			
		||||
    if(xcan) {
 | 
			
		||||
        encs = (jer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
 | 
			
		||||
        if(!encs) ASN__ENCODE_FAILED;
 | 
			
		||||
        cb = SET_OF_encode_jer_callback;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    er.encoded = 0;
 | 
			
		||||
 | 
			
		||||
    for(i = 0; i < list->count; i++) {
 | 
			
		||||
        asn_enc_rval_t tmper = {0,0,0};
 | 
			
		||||
 | 
			
		||||
        void *memb_ptr = list->array[i];
 | 
			
		||||
        if(!memb_ptr) continue;
 | 
			
		||||
 | 
			
		||||
        if(encs) {
 | 
			
		||||
            memset(&encs[encs_count], 0, sizeof(encs[0]));
 | 
			
		||||
            app_key = &encs[encs_count];
 | 
			
		||||
            encs_count++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(mname) {
 | 
			
		||||
            if(!xcan) ASN__TEXT_INDENT(1, ilevel);
 | 
			
		||||
            ASN__CALLBACK3("\"", 1, mname, mlen, "\"", 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(!xcan && specs->as_XMLValueList == 1)
 | 
			
		||||
            ASN__TEXT_INDENT(1, ilevel + 1);
 | 
			
		||||
        tmper = elm->type->op->jer_encoder(elm->type, memb_ptr,
 | 
			
		||||
                                           ilevel + (specs->as_XMLValueList != 2),
 | 
			
		||||
                                           flags, cb, app_key);
 | 
			
		||||
        if(tmper.encoded == -1) return tmper;
 | 
			
		||||
        er.encoded += tmper.encoded;
 | 
			
		||||
        if(tmper.encoded == 0 && specs->as_XMLValueList) {
 | 
			
		||||
            const char *name = elm->type->xml_tag;
 | 
			
		||||
            size_t len = strlen(name);
 | 
			
		||||
            ASN__CALLBACK3("<", 1, name, len, "/>", 2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /* if(mname) { */
 | 
			
		||||
        /*     ASN__CALLBACK3("</", 2, mname, mlen, ">", 1); */
 | 
			
		||||
        /* } */
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
 | 
			
		||||
 | 
			
		||||
    if(encs) {
 | 
			
		||||
        jer_tmp_enc_t *enc = encs;
 | 
			
		||||
        jer_tmp_enc_t *end = encs + encs_count;
 | 
			
		||||
        ssize_t control_size = 0;
 | 
			
		||||
 | 
			
		||||
        er.encoded = 0;
 | 
			
		||||
        cb = original_cb;
 | 
			
		||||
        app_key = original_app_key;
 | 
			
		||||
        qsort(encs, encs_count, sizeof(encs[0]), SET_OF_jer_order);
 | 
			
		||||
 | 
			
		||||
        for(; enc < end; enc++) {
 | 
			
		||||
            ASN__CALLBACK(enc->buffer, enc->offset);
 | 
			
		||||
            FREEMEM(enc->buffer);
 | 
			
		||||
            enc->buffer = 0;
 | 
			
		||||
            control_size += enc->offset;
 | 
			
		||||
        }
 | 
			
		||||
        assert(control_size == er.encoded);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    goto cleanup;
 | 
			
		||||
cb_failed:
 | 
			
		||||
    ASN__ENCODE_FAILED;
 | 
			
		||||
cleanup:
 | 
			
		||||
    if(encs) {
 | 
			
		||||
        size_t n;
 | 
			
		||||
        for(n = 0; n < encs_count; n++) {
 | 
			
		||||
            FREEMEM(encs[n].buffer);
 | 
			
		||||
        }
 | 
			
		||||
        FREEMEM(encs);
 | 
			
		||||
    }
 | 
			
		||||
    ASN__ENCODED_OK(er);
 | 
			
		||||
}
 | 
			
		||||
@@ -50,6 +50,12 @@ typedef void (xer_type_decoder_f)(void);
 | 
			
		||||
typedef void (xer_type_encoder_f)(void);
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_JER_SUPPORT)
 | 
			
		||||
#include <jer_encoder.h>  /* Encoder into JER (JSON, text) */
 | 
			
		||||
#else
 | 
			
		||||
typedef void (jer_type_encoder_f)(void);
 | 
			
		||||
#endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
 | 
			
		||||
 | 
			
		||||
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
 | 
			
		||||
#include <per_decoder.h>  /* Packet Encoding Rules decoder */
 | 
			
		||||
#include <per_encoder.h>  /* Packet Encoding Rules encoder */
 | 
			
		||||
@@ -171,6 +177,7 @@ typedef struct asn_TYPE_operation_s {
 | 
			
		||||
    der_type_encoder_f *der_encoder;      /* Canonical DER encoder */
 | 
			
		||||
    xer_type_decoder_f *xer_decoder;      /* Generic XER decoder */
 | 
			
		||||
    xer_type_encoder_f *xer_encoder;      /* [Canonical] XER encoder */
 | 
			
		||||
    jer_type_encoder_f *jer_encoder;      /* Generic JER encoder */
 | 
			
		||||
    oer_type_decoder_f *oer_decoder;      /* Generic OER decoder */
 | 
			
		||||
    oer_type_encoder_f *oer_encoder;      /* Canonical OER encoder */
 | 
			
		||||
    per_type_decoder_f *uper_decoder;     /* Unaligned PER decoder */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										69
									
								
								lib/asn1c/common/jer_encoder.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								lib/asn1c/common/jer_encoder.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
/*-
 | 
			
		||||
 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#include <asn_internal.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The JER encoder of any type. May be invoked by the application.
 | 
			
		||||
 */
 | 
			
		||||
asn_enc_rval_t
 | 
			
		||||
jer_encode(const asn_TYPE_descriptor_t *td, const void *sptr,
 | 
			
		||||
           asn_app_consume_bytes_f *cb,
 | 
			
		||||
           void *app_key) {
 | 
			
		||||
    asn_enc_rval_t er = {0, 0, 0};
 | 
			
		||||
	asn_enc_rval_t tmper;
 | 
			
		||||
	const char *mname;
 | 
			
		||||
	size_t mlen;
 | 
			
		||||
 | 
			
		||||
	if(!td || !sptr) goto cb_failed;
 | 
			
		||||
 | 
			
		||||
	mname = td->xml_tag;
 | 
			
		||||
	mlen = strlen(mname);
 | 
			
		||||
 | 
			
		||||
	ASN__CALLBACK3("{\n\"", 3, mname, mlen, "\":", 2);
 | 
			
		||||
 | 
			
		||||
        int xFlag = 0;
 | 
			
		||||
	tmper = td->op->jer_encoder(td, sptr, 1, xFlag, cb, app_key);
 | 
			
		||||
	if(tmper.encoded == -1) return tmper;
 | 
			
		||||
	er.encoded += tmper.encoded;
 | 
			
		||||
 | 
			
		||||
        ASN__CALLBACK("}", 1);
 | 
			
		||||
        //	ASN__CALLBACK3("</", 2, mname, mlen, ">\n", xcan);
 | 
			
		||||
 | 
			
		||||
	ASN__ENCODED_OK(er);
 | 
			
		||||
cb_failed:
 | 
			
		||||
	ASN__ENCODE_FAILED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This is a helper function for jer_fprint, which directs all incoming data
 | 
			
		||||
 * into the provided file descriptor.
 | 
			
		||||
 */
 | 
			
		||||
static int
 | 
			
		||||
jer__print2fp(const void *buffer, size_t size, void *app_key) {
 | 
			
		||||
	FILE *stream = (FILE *)app_key;
 | 
			
		||||
 | 
			
		||||
	if(fwrite(buffer, 1, size, stream) != size)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
jer_fprint(FILE *stream, const asn_TYPE_descriptor_t *td, const void *sptr) {
 | 
			
		||||
	asn_enc_rval_t er = {0,0,0};
 | 
			
		||||
 | 
			
		||||
	if(!stream) stream = stdout;
 | 
			
		||||
	if(!td || !sptr)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	er = jer_encode(td, sptr, jer__print2fp, stream);
 | 
			
		||||
	if(er.encoded == -1)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	return fflush(stream);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										81
									
								
								lib/asn1c/common/jer_encoder.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								lib/asn1c/common/jer_encoder.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
/*-
 | 
			
		||||
 * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
 | 
			
		||||
 * Redistribution and modifications are permitted subject to BSD license.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef	_JER_ENCODER_H_
 | 
			
		||||
#define	_JER_ENCODER_H_
 | 
			
		||||
 | 
			
		||||
#include <asn_application.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct asn_TYPE_descriptor_s;	/* Forward declaration */
 | 
			
		||||
 | 
			
		||||
/* Flags used by the jer_encode() and (*jer_type_encoder_f), defined below */
 | 
			
		||||
enum jer_encoder_flags_e {
 | 
			
		||||
	/* Mode of encoding */
 | 
			
		||||
	JER_F_BASIC	= 0x01,	/* BASIC-JER (pretty-printing) */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The JER encoder of any type. May be invoked by the application.
 | 
			
		||||
 * Produces CANONICAL-JER and BASIC-JER depending on the (jer_flags).
 | 
			
		||||
 */
 | 
			
		||||
asn_enc_rval_t jer_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
 | 
			
		||||
                          const void *struct_ptr, /* Structure to be encoded */
 | 
			
		||||
                          asn_app_consume_bytes_f *consume_bytes_cb,
 | 
			
		||||
                          void *app_key /* Arbitrary callback argument */
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The variant of the above function which dumps the BASIC-JER (JER_F_BASIC)
 | 
			
		||||
 * output into the chosen file pointer.
 | 
			
		||||
 * RETURN VALUES:
 | 
			
		||||
 * 	 0: The structure is printed.
 | 
			
		||||
 * 	-1: Problem printing the structure.
 | 
			
		||||
 * WARNING: No sensible errno value is returned.
 | 
			
		||||
 */
 | 
			
		||||
int jer_fprint(FILE *stream, const struct asn_TYPE_descriptor_s *td,
 | 
			
		||||
               const void *struct_ptr);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * A helper function that uses JER encoding/decoding to verify that:
 | 
			
		||||
 * - Both structures encode into the same BASIC JER.
 | 
			
		||||
 * - Both resulting JER byte streams can be decoded back.
 | 
			
		||||
 * - Both decoded structures encode into the same BASIC JER (round-trip).
 | 
			
		||||
 * All of this verifies equivalence between structures and a round-trip.
 | 
			
		||||
 * ARGUMENTS:
 | 
			
		||||
 *  (opt_debug_stream)  - If specified, prints ongoing details.
 | 
			
		||||
 */
 | 
			
		||||
enum jer_equivalence_e {
 | 
			
		||||
    JEQ_SUCCESS,          /* The only completely positive return value */
 | 
			
		||||
    JEQ_FAILURE,          /* General failure */
 | 
			
		||||
    JEQ_ENCODE1_FAILED,   /* First structure JER encoding failed */
 | 
			
		||||
    JEQ_ENCODE2_FAILED,   /* Second structure JER encoding failed */
 | 
			
		||||
    JEQ_DIFFERENT,        /* Structures encoded into different JER */
 | 
			
		||||
    JEQ_DECODE_FAILED,    /* Decode of the JER data failed */
 | 
			
		||||
    JEQ_ROUND_TRIP_FAILED /* Bad round-trip */
 | 
			
		||||
};
 | 
			
		||||
enum jer_equivalence_e jer_equivalent(
 | 
			
		||||
    const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct1,
 | 
			
		||||
    const void *struct2, FILE *opt_debug_stream);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Type of the generic JER encoder.
 | 
			
		||||
 */
 | 
			
		||||
typedef asn_enc_rval_t(jer_type_encoder_f)(
 | 
			
		||||
    const struct asn_TYPE_descriptor_s *type_descriptor,
 | 
			
		||||
    const void *struct_ptr, /* Structure to be encoded */
 | 
			
		||||
    int ilevel,             /* Level of indentation */
 | 
			
		||||
    enum jer_encoder_flags_e jer_flags,
 | 
			
		||||
    asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
 | 
			
		||||
    void *app_key                              /* Arbitrary callback argument */
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif	/* _JER_ENCODER_H_ */
 | 
			
		||||
@@ -124,6 +124,20 @@ libasn1c_common_sources = files('''
 | 
			
		||||
    constr_CHOICE_rfill.c
 | 
			
		||||
    constr_SEQUENCE_rfill.c
 | 
			
		||||
    constr_SET_OF_rfill.c
 | 
			
		||||
    ANY_jer.c
 | 
			
		||||
	BIT_STRING_jer.c
 | 
			
		||||
	INTEGER_jer.c
 | 
			
		||||
	NULL_jer.c
 | 
			
		||||
	NativeEnumerated_jer.c
 | 
			
		||||
	NativeInteger_jer.c
 | 
			
		||||
	OBJECT_IDENTIFIER_jer.c
 | 
			
		||||
	OCTET_STRING_jer.c
 | 
			
		||||
	jer_encoder.c
 | 
			
		||||
	jer_encoder.h
 | 
			
		||||
	constr_CHOICE_jer.c
 | 
			
		||||
	constr_SEQUENCE_OF_jer.c
 | 
			
		||||
	constr_SEQUENCE_jer.c
 | 
			
		||||
	constr_SET_OF_jer.c
 | 
			
		||||
'''.split())
 | 
			
		||||
 | 
			
		||||
libasn1c_common_cc_flags = ['-DASN_DISABLE_BER_SUPPORT',
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMF_UE_NGAP_ID;
 | 
			
		||||
asn_struct_free_f NGAP_AMF_UE_NGAP_ID_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMF_UE_NGAP_ID_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMF_UE_NGAP_ID_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMF_UE_NGAP_ID_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMF_UE_NGAP_ID_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMF_UE_NGAP_ID_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFName;
 | 
			
		||||
asn_struct_free_f NGAP_AMFName_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFName_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFName_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFName_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFName_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFName_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFNameUTF8String;
 | 
			
		||||
asn_struct_free_f NGAP_AMFNameUTF8String_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFNameUTF8String_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFNameUTF8String_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFNameUTF8String_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFNameUTF8String_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFNameUTF8String_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFNameVisibleString;
 | 
			
		||||
asn_struct_free_f NGAP_AMFNameVisibleString_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFNameVisibleString_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFNameVisibleString_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFNameVisibleString_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFNameVisibleString_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFNameVisibleString_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFPointer;
 | 
			
		||||
asn_struct_free_f NGAP_AMFPointer_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFPointer_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFPointer_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFPointer_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFPointer_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFPointer_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFRegionID;
 | 
			
		||||
asn_struct_free_f NGAP_AMFRegionID_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFRegionID_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFRegionID_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFRegionID_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFRegionID_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFRegionID_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AMFSetID;
 | 
			
		||||
asn_struct_free_f NGAP_AMFSetID_free;
 | 
			
		||||
asn_struct_print_f NGAP_AMFSetID_print;
 | 
			
		||||
asn_constr_check_f NGAP_AMFSetID_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AMFSetID_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AMFSetID_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AMFSetID_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_AdditionalQosFlowInformation_specs_
 | 
			
		||||
asn_struct_free_f AdditionalQosFlowInformation_free;
 | 
			
		||||
asn_struct_print_f AdditionalQosFlowInformation_print;
 | 
			
		||||
asn_constr_check_f AdditionalQosFlowInformation_constraint;
 | 
			
		||||
jer_type_encoder_f AdditionalQosFlowInformation_encode_jer;
 | 
			
		||||
per_type_decoder_f AdditionalQosFlowInformation_decode_aper;
 | 
			
		||||
per_type_encoder_f AdditionalQosFlowInformation_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AlternativeQoSParaSetIndex;
 | 
			
		||||
asn_struct_free_f NGAP_AlternativeQoSParaSetIndex_free;
 | 
			
		||||
asn_struct_print_f NGAP_AlternativeQoSParaSetIndex_print;
 | 
			
		||||
asn_constr_check_f NGAP_AlternativeQoSParaSetIndex_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AlternativeQoSParaSetIndex_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AlternativeQoSParaSetIndex_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AlternativeQoSParaSetIndex_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AlternativeQoSParaSetNotifyIndex;
 | 
			
		||||
asn_struct_free_f NGAP_AlternativeQoSParaSetNotifyIndex_free;
 | 
			
		||||
asn_struct_print_f NGAP_AlternativeQoSParaSetNotifyIndex_print;
 | 
			
		||||
asn_constr_check_f NGAP_AlternativeQoSParaSetNotifyIndex_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AlternativeQoSParaSetNotifyIndex_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AlternativeQoSParaSetNotifyIndex_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AlternativeQoSParaSetNotifyIndex_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AuthenticatedIndication;
 | 
			
		||||
asn_struct_free_f NGAP_AuthenticatedIndication_free;
 | 
			
		||||
asn_struct_print_f NGAP_AuthenticatedIndication_print;
 | 
			
		||||
asn_constr_check_f NGAP_AuthenticatedIndication_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AuthenticatedIndication_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AuthenticatedIndication_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AuthenticatedIndication_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_AveragingWindow;
 | 
			
		||||
asn_struct_free_f NGAP_AveragingWindow_free;
 | 
			
		||||
asn_struct_print_f NGAP_AveragingWindow_print;
 | 
			
		||||
asn_constr_check_f NGAP_AveragingWindow_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_AveragingWindow_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_AveragingWindow_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_AveragingWindow_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_BitRate;
 | 
			
		||||
asn_struct_free_f NGAP_BitRate_free;
 | 
			
		||||
asn_struct_print_f NGAP_BitRate_print;
 | 
			
		||||
asn_constr_check_f NGAP_BitRate_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_BitRate_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_BitRate_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_BitRate_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_BluetoothMeasConfig_specs_1;
 | 
			
		||||
asn_struct_free_f BluetoothMeasConfig_free;
 | 
			
		||||
asn_struct_print_f BluetoothMeasConfig_print;
 | 
			
		||||
asn_constr_check_f BluetoothMeasConfig_constraint;
 | 
			
		||||
jer_type_encoder_f BluetoothMeasConfig_encode_jer;
 | 
			
		||||
per_type_decoder_f BluetoothMeasConfig_decode_aper;
 | 
			
		||||
per_type_encoder_f BluetoothMeasConfig_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_BluetoothName;
 | 
			
		||||
asn_struct_free_f NGAP_BluetoothName_free;
 | 
			
		||||
asn_struct_print_f NGAP_BluetoothName_print;
 | 
			
		||||
asn_constr_check_f NGAP_BluetoothName_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_BluetoothName_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_BluetoothName_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_BluetoothName_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_BurstArrivalTime;
 | 
			
		||||
asn_struct_free_f NGAP_BurstArrivalTime_free;
 | 
			
		||||
asn_struct_print_f NGAP_BurstArrivalTime_print;
 | 
			
		||||
asn_constr_check_f NGAP_BurstArrivalTime_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_BurstArrivalTime_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_BurstArrivalTime_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_BurstArrivalTime_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CAG_ID;
 | 
			
		||||
asn_struct_free_f NGAP_CAG_ID_free;
 | 
			
		||||
asn_struct_print_f NGAP_CAG_ID_print;
 | 
			
		||||
asn_constr_check_f NGAP_CAG_ID_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CAG_ID_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CAG_ID_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CAG_ID_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CEmodeBSupport_Indicator;
 | 
			
		||||
asn_struct_free_f NGAP_CEmodeBSupport_Indicator_free;
 | 
			
		||||
asn_struct_print_f NGAP_CEmodeBSupport_Indicator_print;
 | 
			
		||||
asn_constr_check_f NGAP_CEmodeBSupport_Indicator_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CEmodeBSupport_Indicator_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CEmodeBSupport_Indicator_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CEmodeBSupport_Indicator_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CEmodeBrestricted;
 | 
			
		||||
asn_struct_free_f NGAP_CEmodeBrestricted_free;
 | 
			
		||||
asn_struct_print_f NGAP_CEmodeBrestricted_print;
 | 
			
		||||
asn_constr_check_f NGAP_CEmodeBrestricted_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CEmodeBrestricted_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CEmodeBrestricted_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CEmodeBrestricted_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CNTypeRestrictionsForServing;
 | 
			
		||||
asn_struct_free_f NGAP_CNTypeRestrictionsForServing_free;
 | 
			
		||||
asn_struct_print_f NGAP_CNTypeRestrictionsForServing_print;
 | 
			
		||||
asn_constr_check_f NGAP_CNTypeRestrictionsForServing_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CNTypeRestrictionsForServing_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CNTypeRestrictionsForServing_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CNTypeRestrictionsForServing_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CancelAllWarningMessages;
 | 
			
		||||
asn_struct_free_f NGAP_CancelAllWarningMessages_free;
 | 
			
		||||
asn_struct_print_f NGAP_CancelAllWarningMessages_print;
 | 
			
		||||
asn_constr_check_f NGAP_CancelAllWarningMessages_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CancelAllWarningMessages_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CancelAllWarningMessages_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CancelAllWarningMessages_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CauseMisc_specs_1;
 | 
			
		||||
asn_struct_free_f CauseMisc_free;
 | 
			
		||||
asn_struct_print_f CauseMisc_print;
 | 
			
		||||
asn_constr_check_f CauseMisc_constraint;
 | 
			
		||||
jer_type_encoder_f CauseMisc_encode_jer;
 | 
			
		||||
per_type_decoder_f CauseMisc_decode_aper;
 | 
			
		||||
per_type_encoder_f CauseMisc_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CauseNas_specs_1;
 | 
			
		||||
asn_struct_free_f CauseNas_free;
 | 
			
		||||
asn_struct_print_f CauseNas_print;
 | 
			
		||||
asn_constr_check_f CauseNas_constraint;
 | 
			
		||||
jer_type_encoder_f CauseNas_encode_jer;
 | 
			
		||||
per_type_decoder_f CauseNas_decode_aper;
 | 
			
		||||
per_type_encoder_f CauseNas_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CauseProtocol_specs_1;
 | 
			
		||||
asn_struct_free_f CauseProtocol_free;
 | 
			
		||||
asn_struct_print_f CauseProtocol_print;
 | 
			
		||||
asn_constr_check_f CauseProtocol_constraint;
 | 
			
		||||
jer_type_encoder_f CauseProtocol_encode_jer;
 | 
			
		||||
per_type_decoder_f CauseProtocol_decode_aper;
 | 
			
		||||
per_type_encoder_f CauseProtocol_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -87,6 +87,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CauseRadioNetwork_specs_1;
 | 
			
		||||
asn_struct_free_f CauseRadioNetwork_free;
 | 
			
		||||
asn_struct_print_f CauseRadioNetwork_print;
 | 
			
		||||
asn_constr_check_f CauseRadioNetwork_constraint;
 | 
			
		||||
jer_type_encoder_f CauseRadioNetwork_encode_jer;
 | 
			
		||||
per_type_decoder_f CauseRadioNetwork_decode_aper;
 | 
			
		||||
per_type_encoder_f CauseRadioNetwork_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CauseTransport_specs_1;
 | 
			
		||||
asn_struct_free_f CauseTransport_free;
 | 
			
		||||
asn_struct_print_f CauseTransport_print;
 | 
			
		||||
asn_constr_check_f CauseTransport_constraint;
 | 
			
		||||
jer_type_encoder_f CauseTransport_encode_jer;
 | 
			
		||||
per_type_decoder_f CauseTransport_decode_aper;
 | 
			
		||||
per_type_encoder_f CauseTransport_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_CellSize_specs_1;
 | 
			
		||||
asn_struct_free_f CellSize_free;
 | 
			
		||||
asn_struct_print_f CellSize_print;
 | 
			
		||||
asn_constr_check_f CellSize_constraint;
 | 
			
		||||
jer_type_encoder_f CellSize_encode_jer;
 | 
			
		||||
per_type_decoder_f CellSize_decode_aper;
 | 
			
		||||
per_type_encoder_f CellSize_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CommonNetworkInstance;
 | 
			
		||||
asn_struct_free_f NGAP_CommonNetworkInstance_free;
 | 
			
		||||
asn_struct_print_f NGAP_CommonNetworkInstance_print;
 | 
			
		||||
asn_constr_check_f NGAP_CommonNetworkInstance_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CommonNetworkInstance_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CommonNetworkInstance_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CommonNetworkInstance_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_ConcurrentWarningMessageInd;
 | 
			
		||||
asn_struct_free_f NGAP_ConcurrentWarningMessageInd_free;
 | 
			
		||||
asn_struct_print_f NGAP_ConcurrentWarningMessageInd_print;
 | 
			
		||||
asn_constr_check_f NGAP_ConcurrentWarningMessageInd_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_ConcurrentWarningMessageInd_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_ConcurrentWarningMessageInd_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_ConcurrentWarningMessageInd_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_ConfidentialityProtectionIndication
 | 
			
		||||
asn_struct_free_f ConfidentialityProtectionIndication_free;
 | 
			
		||||
asn_struct_print_f ConfidentialityProtectionIndication_print;
 | 
			
		||||
asn_constr_check_f ConfidentialityProtectionIndication_constraint;
 | 
			
		||||
jer_type_encoder_f ConfidentialityProtectionIndication_encode_jer;
 | 
			
		||||
per_type_decoder_f ConfidentialityProtectionIndication_decode_aper;
 | 
			
		||||
per_type_encoder_f ConfidentialityProtectionIndication_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_ConfidentialityProtectionResult_spe
 | 
			
		||||
asn_struct_free_f ConfidentialityProtectionResult_free;
 | 
			
		||||
asn_struct_print_f ConfidentialityProtectionResult_print;
 | 
			
		||||
asn_constr_check_f ConfidentialityProtectionResult_constraint;
 | 
			
		||||
jer_type_encoder_f ConfidentialityProtectionResult_encode_jer;
 | 
			
		||||
per_type_decoder_f ConfidentialityProtectionResult_decode_aper;
 | 
			
		||||
per_type_encoder_f ConfidentialityProtectionResult_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_ConfiguredNSSAI;
 | 
			
		||||
asn_struct_free_f NGAP_ConfiguredNSSAI_free;
 | 
			
		||||
asn_struct_print_f NGAP_ConfiguredNSSAI_print;
 | 
			
		||||
asn_constr_check_f NGAP_ConfiguredNSSAI_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_ConfiguredNSSAI_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_ConfiguredNSSAI_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_ConfiguredNSSAI_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_ConfiguredTACIndication;
 | 
			
		||||
asn_struct_free_f NGAP_ConfiguredTACIndication_free;
 | 
			
		||||
asn_struct_print_f NGAP_ConfiguredTACIndication_print;
 | 
			
		||||
asn_constr_check_f NGAP_ConfiguredTACIndication_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_ConfiguredTACIndication_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_ConfiguredTACIndication_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_ConfiguredTACIndication_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_CoverageEnhancementLevel;
 | 
			
		||||
asn_struct_free_f NGAP_CoverageEnhancementLevel_free;
 | 
			
		||||
asn_struct_print_f NGAP_CoverageEnhancementLevel_print;
 | 
			
		||||
asn_constr_check_f NGAP_CoverageEnhancementLevel_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_CoverageEnhancementLevel_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_CoverageEnhancementLevel_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_CoverageEnhancementLevel_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_Criticality_specs_1;
 | 
			
		||||
asn_struct_free_f Criticality_free;
 | 
			
		||||
asn_struct_print_f Criticality_print;
 | 
			
		||||
asn_constr_check_f Criticality_constraint;
 | 
			
		||||
jer_type_encoder_f Criticality_encode_jer;
 | 
			
		||||
per_type_decoder_f Criticality_decode_aper;
 | 
			
		||||
per_type_encoder_f Criticality_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NGAP_DL_NAS_MAC;
 | 
			
		||||
asn_struct_free_f NGAP_DL_NAS_MAC_free;
 | 
			
		||||
asn_struct_print_f NGAP_DL_NAS_MAC_print;
 | 
			
		||||
asn_constr_check_f NGAP_DL_NAS_MAC_constraint;
 | 
			
		||||
jer_type_encoder_f NGAP_DL_NAS_MAC_encode_jer;
 | 
			
		||||
per_type_decoder_f NGAP_DL_NAS_MAC_decode_aper;
 | 
			
		||||
per_type_encoder_f NGAP_DL_NAS_MAC_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ extern const asn_INTEGER_specifics_t asn_SPC_DL_NGU_TNLInformationReused_specs_1
 | 
			
		||||
asn_struct_free_f DL_NGU_TNLInformationReused_free;
 | 
			
		||||
asn_struct_print_f DL_NGU_TNLInformationReused_print;
 | 
			
		||||
asn_constr_check_f DL_NGU_TNLInformationReused_constraint;
 | 
			
		||||
jer_type_encoder_f DL_NGU_TNLInformationReused_encode_jer;
 | 
			
		||||
per_type_decoder_f DL_NGU_TNLInformationReused_decode_aper;
 | 
			
		||||
per_type_encoder_f DL_NGU_TNLInformationReused_encode_aper;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user