Git Product home page Git Product logo

asn1c's People

Contributors

akire avatar boskywsmfn avatar brchiu avatar cedricrouxeurecom avatar danyafilatov avatar dfranusic avatar eisaev avatar elfring avatar fei4xu avatar johvik avatar mattipee avatar mkhon avatar mouse07410 avatar mtfurlan avatar nkout avatar pespin avatar riebl avatar ringlej avatar rkubik avatar robstradling avatar sancane avatar shadansari avatar simo5 avatar spfoos avatar tangzhikun avatar theirix avatar v0-e avatar velichkov avatar vlm avatar wiml avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asn1c's Issues

Error in decoding of the X2AP "Handover Request" message

Hello mouse07410

I have downloaded the latest asn1c code from your branch.
I am decoding the X2AP "Handover Request" message but it is giving error in its decoding.
Buffer is
"00000081EF000008000A00020D6D000540020000000B00080004F413E133D010001700070004F41383F158000E0081A2660841852718000C0000F6899974B8E1CCADC61FEB2C40D6AF053F53C0914DA80831B2D221A902FF6FDF030BEBC20060017D784000000004400E4500070501F00ACEFA05803E22C681440B305CC9980070938650002074A1E3FF8DFE3FF8DFE3FF8DFE3FF8DFE3FF8DFE3FF8DFE3FF8DFE3FF8DFDFF3FFA7A204021C329D2A4A91C5FB00000001C07FCFFEBEC0000000709FF3FFA7B000000002A8008000161100100000880080000020F33035758A6601404E28810F121E5003211B93432B2596621E4000D8000378718CC43C8001B0000690CB19887900036000089500000402AB22906320108B841068D00E2101C553C0D3A81D3AE44F9C9273840050870A401025228420113DB8800004011004D6C052EE910C1E0E052EE910C9C00FA89A00A5DD22072333E8013A229AFC5D83211F0CAA20DC3205402EC0260DF99434000240A14088CCC910000205010630024E23450382350860272300448632140514185E70D85FE324E03410A20180CC020480CEDA6A20500781E6E86974C81C204060105560501204ABC0024FEC8A214004F4134004F40104F42904F51504F46104F565000F400C000004F413E23450310000000024400100FFFA400900E234503619006C39"

If I use any online tool to decode the same message, it get decode perfectly.

Can you please check, what is the problem.

Regards
Sandeep

Where is ATS_ALIGNED_BASIC_PER?

Trying to encode to APER but there is no option for it in asn_transfer_syntax enum.

I tried all sort of "-gen-xxx" flags and recompiled vlm_master at several points in the history to no avail.

I see a lot of per_type_encoder_f instances in headers ending in ..._aper, and they disappear when compiling with "-no-gen-APER".

Note: Compiling with -fcompound-names flag

Unsigned long should be used for 0 <= value <= 18446744073709551615

Compiler is rightly complaining about 18446744073709551615L used in this constraint:

	usageCountUL					INTEGER (0..18446744073709551615),

==>

memb_usageCountUL_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
			asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	const INTEGER_t *st = (const INTEGER_t *)sptr;
	long value;
	
	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	if(asn_INTEGER2long(st, &value)) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value too large (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	if((value >= 0L && value <= 18446744073709551615L)) {
		/* Constraint check succeeded */
		return 0;
	} else {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: constraint failed (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
}

Instead, the value should be unsigned long, parsed with asn_INTEGER2ulong, and the number written with UL suffix.

Note: 18446744073709551615 == max 64-bits value = ULONG_MAX

Compiling with J2735

Just wanted to hear a little more about the work you did to get your fork work for J2735. We're doing the same and would love to pick your brain.

it is fail to compile the generated code

Hello, @mouse07410
I generate the codes within the latest version in this repo , the data files are under wireshare(dissectors/asn1/s1ap). But I get many errors when compiling the codes, just like bellow:
```
from ../src/HandoverRequired.c:8:
../include/ProtocolIE-SingleContainer.h:21:1: error: unknown type name ‘Bearers_SubjectToStatusTransfer_ItemIEs_t’
typedef Bearers_SubjectToStatusTransfer_ItemIEs_t ProtocolIE_SingleContainer_127P0_t;
^
../include/ProtocolIE-SingleContainer.h:22:1: error: unknown type name ‘E_RABInformationListIEs_t’
typedef E_RABInformationListIEs_t ProtocolIE_SingleContainer_127P1_t;
^
../include/ProtocolIE-SingleContainer.h:23:1: error: unknown type name ‘E_RABItemIEs_t’
typedef E_RABItemIEs_t ProtocolIE_SingleContainer_127P2_t;
^
../include/ProtocolIE-SingleContainer.h:24:1: error: unknown type name ‘MDTMode_ExtensionIE_t’
typedef MDTMode_ExtensionIE_t ProtocolIE_SingleContainer_127P3_t;

^
../include/ProtocolIE-SingleContainer.h:25:1: error: unknown type name ‘RecommendedCellItemIEs_t’
typedef RecommendedCellItemIEs_t ProtocolIE_SingleContainer_127P4_t;
^
../include/ProtocolIE-SingleContainer.h:26:1: error: unknown type name ‘RecommendedENBItemIEs_t’
typedef RecommendedENBItemIEs_t ProtocolIE_SingleContainer_127P5_t;

I move the header files to incldue, source files to src, the Makefile is working under dir build. the file path:
gencode----build
|
----include
|
----src

Can you help me how to fix it. Thank you so much.

Wrong encoding of SBc-AP Write-Replace Warning Request (APER enc)

Hi,

I'm introducing SBc-AP protocol support [1] to osmo-cbc [2] project. For that, I'm using code generated with asn1c commit 2cf625c (mouse07410 branch "vlm_master" including last fix of mine merged yesterday/today).

I'm validating the generated output using several methods:

  • wireshark analysis of pcap files:
    ** Pcap file of another existing external implementation found here.
    ** Pcap file generated by osmo-cbc when running TTCN3 tests [3]
  • libfftranscode decoding [4]
  • https://asn1.io/asn1playground/default.aspx?

I'm adding the SBc-AP support in osmo-cbc.git branch "pespin/sbcap".

First commit adds the skeletons + generated asn1c code (from asn files found in same repo in src/sbcap/asn1/*.asn) with mouse07410/vlm_master plus all the boilerplate to build the content in a library (the Makefile also modified slightly some headers to avoid some circular dependency issues, but that's another topic):
https://cgit.osmocom.org/osmo-cbc/commit/?h=pespin/sbcap&id=469ab793be1d1fe4924a971ad0b6fb84a2ce8d20
asn1c code can be regenerated by calling "make -C src/ regen".

Second commit adds a unit test to encode SBc-AP Write-Replace Warning Request (you can run it with "make check"):
https://cgit.osmocom.org/osmo-cbc/commit/?h=pespin/sbcap&id=8ff4fed49b63d184521aebb3cb3730651c9e49af
It can be seen that the encoded output is:
00 00 00 0e 00 02 00 05 00 02 ab 01 00 0b 00 02 ab cd
When decoding with wireshark, libfftranscode or asn1.io, there seems to be issues parsing the length of the item list (the IE list). When comparing to the message in the existing implementation (available above), it also doesn't match, it starts with 00 00 00 5f 00 00 0b, where of course values 5f and 0b are different since those contain the length of the message and the 11 IEs it contains. However, you can see how in between those there's an extra 00 byte.

In third commit, I apply the proposed changes in my asn1c PR [5]:
https://cgit.osmocom.org/osmo-cbc/commit/?h=pespin/sbcap&id=2c54d1d135018ad57de70a7be47bc701b0a4970f
You can see how the output of the unit test changes to something correct:

-Encoded message: 00 00 00 0e 00 02 00 05 00 02 ab 01 00 0b 00 02 ab cd 
+Encoded message: 00 00 00 0f 00 00 02 00 05 00 02 ab 01 00 0b 00 02 ab cd 

Once this change is applied, wireshark, fftranscode and as1n.io are happy with the message.

[1] 3GPP TS 29.168, https://www.etsi.org/deliver/etsi_ts/129100_129199/129168/16.00.00_60/ts_129168v160000p.pdf
[2] https://osmocom.org/projects/osmo-cbc/wiki
[3] https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks/src/branch/pespin/sbcap
[4] https://osmocom.org/projects/cellular-infrastructure/wiki/Titan_TTCN3_Testsuites#Proprietary-APERBER-transcoding-library-for-Iu-tests
[5] #93

object instance with NULL type does not produce valid C structure

I have an ASN which basically do something like this.

`ModuleTestClassSimple { iso org(3) dod(6) internet(1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 34 }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN

MY-TYPE ::= CLASS {
&Type
}
WITH SYNTAX { TYPE &Type}

Node ::= SEQUENCE {
type MY-TYPE.&Type({DefTypes})
}

DefTypes MY-TYPE ::= {{ TYPE NULL }}

END
`

This translates to union member named NULL of type NULL_t. This will not compile as NULL is defined usually as void*.

APER problems

Hello,

I am using asn1c to generate the code for the sbc-ap protocol based on the asn1 in 3GPP 29.168 Release 14

In my tests, I am encoding the write-replace-warning-request (aper), and checking the encoding in wireshark.

I faced 2 problems

1- In encoding in OCTET_STRING_encode_aper: an extra 1bit length with value 0 was added in cases where it should not be present (based on APER encoding, if the tag has a fixed length, there is no need to add the length)

I modified the code as follows:

1954         if(csiz->effective_bits >= 0) {
1955                 ASN_DEBUG("Encoding %d bytes (%lld), length in %d bits",
1956                                 st->size, sizeinunits - csiz->lower_bound,
1957                                 csiz->effective_bits);
                   if(csiz->effective_bits) // added line
                   { // added line
1958                 ret = aper_put_length(po, csiz->upper_bound - csiz->lower_bound + 1, sizeinunits - csiz->lower_bound);
1959                 if(ret) ASN__ENCODE_FAILED;
                   } // added line
1960                 if (st->size > 2) { /* X.691 #16 NOTE 1 */
1961                         if (aper_put_align(po) < 0)
1962                                 ASN__ENCODE_FAILED;
1963                 }

You can check test1.pcap (without the fix), test2.pcap (after the fix)

2- the decoding of the Warning-Area-List was failing
the encoding was giving the following data:
00 00 01 00 43 65 87 31 32 33 30 43 65 87 41 42 43 30
the decoding was considering the PDU not complete

I am attaching the output: out_err.log

The problem seems to be in SEQUENCE_decode_aper.
The last field in a sequence is a bitstring (CellIdentity ::= BIT STRING (SIZE (28))), and the next sequence should start with a bitstring (for the extension). There should not be any padding after the Cell-Id.

I did the following modifications in constr_SEQUENCE.c:

1318                 if(padding > 0)
1319                   ASN_DEBUG("For element %s,offset= %d Padding bits = %d", td->name, pd->moved, padding);
1320                 per_get_few_bits(pd, padding);

instead of line 1320, I added the following:

      if(edx != (td->elements_count-1))
         per_get_few_bits(pd, padding);
      else //
      {
         if(specs->roms_count && (padding > 0))
            ASN_DEBUG(">>>>> not skipping padding of %d bits for element:%d out of %d", padding, edx, td->elements_count);
         else
            per_get_few_bits(pd, padding);
      }

I am not an expert in APER, so I would appreciate if you can check if what I've done is correct

test_pcap.zip

Thx and best regards

CHOICE_decode_aper: 'value' may be used uninitialized [-Wmaybe-uninitialized]

When compiling osmo-cbc.git branch pespin/sbcap, which contains mouse07410/asn1c generated code (asn1c.git current vlm_master, 30219de).

git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c: In function 'CHOICE_decode_aper':
git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c:67:44: warning: 'value' may be used uninitialized [-Wmaybe-uninitialized]
   67 |         value = specs->from_canonical_order[value];
      |                                            ^
git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c:21:9: note: 'value' was declared here
   21 |     int value;
      |         ^~~~~
 $ gcc --version
gcc (GCC) 12.1.0

Compile time errors after using -no-gen-* options

Some of the code compiles with errors after generated with -no-gen-BER -no-gen-OER -no-gen-APER options:

ANY_ber.c
ANY_aper.c
BIT_STRING_oer.c
BOOLEAN_ber.c
INTEGER_aper.c
INTEGER_ber.c
INTEGER_oer.c
NativeEnumerated_oer.c
NativeInteger_aper.c
NativeInteger_ber.c
NativeInteger_oer.c
OCTET_STRING_ber.c
OCTET_STRING_oer.c
OPEN_TYPE_ber.c
OPEN_TYPE_oer.c
asn_codecs_prim_ber.c
ber_decoder.c
constr_CHOICE_ber.c
constr_CHOICE_oer.c
constr_SEQUENCE_OF_ber.c
constr_SEQUENCE_aper.c
constr_SEQUENCE_ber.c
constr_SEQUENCE_oer.c
constr_SET_OF_aper.c
constr_SET_OF_ber.c
constr_SET_OF_oer.c
der_encoder.c
oer_encoder.c

Needs #if !defined(ASN_DISABLE_*ER_SUPPORT) / #endif around the code!

Compiling the example failed when compiling the ASN1 files with -fcompound-names (complex names for variable types)

Hello,

I've been able to compile the ASN file from 3GPP TS 38.413 (NGAP) v16.5.0 using asn1c from the vlm_master branch of this fork by running the following command:

asn1c -fcompound-names -gen-APER ngap-v16.5.0.asn

The result is:

  • a set of .h and .c file for each type
  • a set of skeleton headers (.h) and c programs
  • converter-example.mk
  • 2 Makefiles

Q1: My first question is: is it possible to get only one .h file for that protocol (NGAP)?
I want then to use that library for parsing NGAP messages in C language.

Then when I try to compile the example using cc or make I have the following errors:

cc -DPDU=NGAP-PDU -o NgapDecoder.o *.c
compilation terminated.
uper_encoder.c:1:10: fatal error: asn_application.h: No such file or directory
 #include <asn_application.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
uper_opentype.c:5:10: fatal error: asn_internal.h: No such file or directory
 #include <asn_internal.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
uper_support.c:5:10: fatal error: asn_system.h: No such file or directory
 #include <asn_system.h>
          ^~~~~~~~~~~~~~
compilation terminated.
xer_decoder.c:5:10: fatal error: asn_application.h: No such file or directory
 #include <asn_application.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
xer_encoder.c:5:10: fatal error: asn_internal.h: No such file or directory
 #include <asn_internal.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
xer_support.c:7:10: fatal error: asn_system.h: No such file or directory
 #include <asn_system.h>
          ^~~~~~~~~~~~~~

while I can see that these headers are available in the current directory.
Q2: So how to make the compiler aware of the location of these local headers?

SEQUENCE OF constrained INTEGER error

test.asn1

TEST

DEFINITIONS IMPLICIT TAGS ::=

BEGIN

TestINT ::= INTEGER (0..4294967295)

TestPDU ::= SEQUENCE {
  one   [0] SEQUENCE OF INTEGER (0..4294967295),
  two   [1] INTEGER (0..4294967295),
  three [2] TestINT
}

END

Compile:

$ ../asn1c/asn1c -S ../skeletons -pdu=all -no-gen-PER -no-gen-OER -fcompound-names test.asn1

Compile example converter:

$ make -f converter-example.mk
cc -DASN_DISABLE_OER_SUPPORT -DASN_DISABLE_PER_SUPPORT  -DASN_PDU_COLLECTION -I. -o TestPDU.o -c TestPDU.c
TestPDU.c:66:4: error: ‘asn_DEF_Member_3’ undeclared here (not in a function); did you mean ‘asn_TYPE_member_t’?
   &asn_DEF_Member_3,
    ^~~~~~~~~~~~~~~~
    asn_TYPE_member_t
make: *** [converter-example.mk:23: TestPDU.o] Error 1

TestPDU.c

/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "TEST"
 *      found in "/tmp/asn1/test.asn1"
 *      `asn1c -S ../skeletons -pdu=all -Wdebug-lexer -Wdebug-parser -Wdebug-fixer -Wdebug-compiler -no-gen-PER -no-gen-OER -fcompound-names`
 */

#include "TestPDU.h"

static int
memb_NativeInteger_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
                        asn_app_constraint_failed_f *ctfailcb, void *app_key) {

        if(!sptr) {
                ASN__CTFAIL(app_key, td, sptr,
                        "%s: value not given (%s:%d)",
                        td->name, __FILE__, __LINE__);
                return -1;
        }


        /* Constraint check succeeded */
        return 0;
}

static int
two_4_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
                        asn_app_constraint_failed_f *ctfailcb, void *app_key) {

        if(!sptr) {
                ASN__CTFAIL(app_key, td, sptr,
                        "%s: value not given (%s:%d)",
                        td->name, __FILE__, __LINE__);
                return -1;
        }


        /* Constraint check succeeded */
        return 0;
}

/*
 * This type is implemented using NativeInteger,
 * so here we adjust the DEF accordingly.
 */
static int
memb_two_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
                        asn_app_constraint_failed_f *ctfailcb, void *app_key) {

        if(!sptr) {
                ASN__CTFAIL(app_key, td, sptr,
                        "%s: value not given (%s:%d)",
                        td->name, __FILE__, __LINE__);
                return -1;
        }


        /* Constraint check succeeded */
        return 0;
}

static asn_TYPE_member_t asn_MBR_one_2[] = {
        { ATF_POINTER, 0, 0,
                (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
                0,
                &asn_DEF_Member_3,
                0,
                { 0, 0,  memb_NativeInteger_constraint_2 },
                0, 0, /* No default value */
                ""
                },
};
static const ber_tlv_tag_t asn_DEF_one_tags_2[] = {
        (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
        (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_one_specs_2 = {
        sizeof(struct TestPDU__one),
        offsetof(struct TestPDU__one, _asn_ctx),
        0,      /* XER encoding is XMLDelimitedItemList */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_one_2 = {
        "one",
        "one",
        &asn_OP_SEQUENCE_OF,
        asn_DEF_one_tags_2,
        sizeof(asn_DEF_one_tags_2)
                /sizeof(asn_DEF_one_tags_2[0]) - 1, /* 1 */
        asn_DEF_one_tags_2,     /* Same as above */
        sizeof(asn_DEF_one_tags_2)
                /sizeof(asn_DEF_one_tags_2[0]), /* 2 */
        { 0, 0, SEQUENCE_OF_constraint },
        asn_MBR_one_2,
        1,      /* Single element */
        &asn_SPC_one_specs_2    /* Additional specs */
};

static const asn_INTEGER_specifics_t asn_SPC_two_specs_4 = {
        0,      0,      0,      0,      0,
        0,      /* Native long size */
        1       /* Unsigned representation */
};
static const ber_tlv_tag_t asn_DEF_two_tags_4[] = {
        (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
        (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_two_4 = {
        "two",
        "two",
        &asn_OP_NativeInteger,
        asn_DEF_two_tags_4,
        sizeof(asn_DEF_two_tags_4)
                /sizeof(asn_DEF_two_tags_4[0]) - 1, /* 1 */
        asn_DEF_two_tags_4,     /* Same as above */
        sizeof(asn_DEF_two_tags_4)
                /sizeof(asn_DEF_two_tags_4[0]), /* 2 */
        { 0, 0, two_4_constraint },
        0, 0,   /* No members */
        &asn_SPC_two_specs_4    /* Additional specs */
};

static asn_TYPE_member_t asn_MBR_TestPDU_1[] = {
        { ATF_NOFLAGS, 0, offsetof(struct TestPDU, one),
                (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
                0,
                &asn_DEF_one_2,
                0,
                { 0, 0, 0 },
                0, 0, /* No default value */
                "one"
                },
        { ATF_NOFLAGS, 0, offsetof(struct TestPDU, two),
                (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
                -1,     /* IMPLICIT tag at current level */
                &asn_DEF_two_4,
                0,
                { 0, 0,  memb_two_constraint_1 },
                0, 0, /* No default value */
                "two"
                },
        { ATF_NOFLAGS, 0, offsetof(struct TestPDU, three),
                (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
                -1,     /* IMPLICIT tag at current level */
                &asn_DEF_TestINT,
                0,
                { 0, 0, 0 },
                0, 0, /* No default value */
                "three"
                },
};
static const ber_tlv_tag_t asn_DEF_TestPDU_tags_1[] = {
        (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_TestPDU_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* one */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* two */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* three */
};
static asn_SEQUENCE_specifics_t asn_SPC_TestPDU_specs_1 = {
        sizeof(struct TestPDU),
        offsetof(struct TestPDU, _asn_ctx),
        asn_MAP_TestPDU_tag2el_1,
        3,      /* Count of tags in the map */
        0, 0, 0,        /* Optional elements (not needed) */
        -1,     /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_TestPDU = {
        "TestPDU",
        "TestPDU",
        &asn_OP_SEQUENCE,
        asn_DEF_TestPDU_tags_1,
        sizeof(asn_DEF_TestPDU_tags_1)
                /sizeof(asn_DEF_TestPDU_tags_1[0]), /* 1 */
        asn_DEF_TestPDU_tags_1, /* Same as above */
        sizeof(asn_DEF_TestPDU_tags_1)
                /sizeof(asn_DEF_TestPDU_tags_1[0]), /* 1 */
        { 0, 0, SEQUENCE_constraint },
        asn_MBR_TestPDU_1,
        3,      /* Elements count */
        &asn_SPC_TestPDU_specs_1        /* Additional specs */
};

It seems that SEQUENCE OF does not like constraints following the type. The previous example works if I create a separate type for SEQUENCE OF.

This doesn't work: SEQUENCE OF INTEGER (0..4294967295)
This works: SEQUENCE OF TestINT

TestINT.c and TestINT.h files are present so I assume that asn_DEF_Member_3 should have been generated also.

I noticed this while compiling some ETSI definitions for Lawful Interceptions and fixed the issues by creating explicit types like I mentioned earlier. Not a big deal but this is probably enough to diagnose the problem or at least to be aware of it.

APER issues

Hi @mouse07410
I am using ASN1C to decode the APER messages and while testing the ASN1C I found out the below 3 issues which I fixed. I am sharing what I fixed in the code to get the decoder working

  1. Decoding of large Enumerated Values by which I mean if the no. of elements in enum type lies between 255 and 66535 This issue is divided into 2 parts
    a. Calculation of Padding bits: In this Padding bits will be there, So those bits need to be discarded.
`Function NativeEnumerated_decode_aper

	if(ct->flags & APC_EXTENSIBLE) {
		int inext = per_get_few_bits(pd, 1);
		if(inext < 0) ASN__DECODE_STARVED;
		if(inext) ct = 0;
	}

	/*Changes Start */
    if(ct && ct->upper_bound >= 255)
    {
        padding = (8 - (pd->moved % 8)) % 8;
	    ASN_DEBUG("For NativeEnumerated %s,offset= %d Padding bits = %d", td->name, pd->moved, padding);
	    ASN_DEBUG("For NativeEnumerated %s, upper bound = %lld", td->name, ct->upper_bound);
		if(padding > 0)
            per_get_few_bits(pd, padding);
    }
	/*Changes end*/

`
b. No. of Bits to be used for decoding.
For this I put a hack in the code. This issue has to be fixed while code is getting generated. Currently enumeration takes the range_bits from the generated code. For large Enumerated Values, No. of bits to be decoded should be 16. I didn't know the proper fix, So I put the hack in generated code and change the value to 16 there.

  1. Open Source ASN.1 decoder was not expecting Padding bits after Extension Fields, Because of which sometime decoder was failing.
    `
in function, SEQUENCE_decode_aper
	    for(edx = specs->ext_after + 1; edx < td->elements_count; edx++) {
		asn_TYPE_member_t *elm = &td->elements[edx];
		void *memb_ptr;		/* Pointer to the member */
		void **memb_ptr2;	/* Pointer to that pointer */
		int present;

		if(!IN_EXTENSION_GROUP(specs, edx)) {
			ASN_DEBUG("%d is not extension", edx);
			continue;
		}

		/* Fetch the pointer to this member */
		if(elm->flags & ATF_POINTER) {
			memb_ptr2 = (void **)((char *)st + elm->memb_offset);
		} else {
			memb_ptr = (void *)((char *)st + elm->memb_offset);
			memb_ptr2 = &memb_ptr;
		}
		
		/*Changes Start*/
        /*Get Padding*/
        int padding = 0;
        padding = (8 - (pd->moved % 8)) % 8;
		if(padding > 0)
	    ASN_DEBUG("For element %s,offset= %d Padding bits = %d", td->name, pd->moved, padding);
            per_get_few_bits(pd, padding);
		/*Changes End*/
		
        present = per_get_few_bits(&epmd, 1);
		if(present <= 0) {
			if(present < 0) break;	/* No more extensions */
			continue;
		}


		ASN_DEBUG("Decoding member %s in %s %p", elm->name, td->name, *memb_ptr2);
		rv = uper_open_type_get(opt_codec_ctx, elm->type,
			elm->per_constraints, memb_ptr2, pd);
		if(rv.code != RC_OK) {
			FREEMEM(epres);
			return rv;
		}
	    }

`

  1. For Integer type decoding, Decoder was calling “UPER” function, instead of “APER” function, because of which sometimes values were not coming correctly
`in function, SEQUENCE_decode_aper()
		
		rv = uper_open_type_get(opt_codec_ctx, elm->type,
			elm->per_constraints, memb_ptr2, pd);
		
asn_dec_rval_t
uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
	asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {

	return uper_open_type_get_simple(ctx, td, constraints, sptr, pd);
}

uper_open_type_get_simple()
and this function calls the 
	rv = td->op->uper_decoder(ctx, td, constraints, sptr, &spd`

As it is calling the uper_decoder function to decode the APER message, it is causing the issues and values are getting mismatch
So the code needs to be changed and for APER decoder it is better to have 2 different functions

`aper_open_type_get 
aper_open_type_get_simple() and this function calls the
	rv = td->op->aper_decoder(ctx, td, constraints, sptr, &spd);

and 
in function, SEQUENCE_decode_aper()		
		rv = aper_open_type_get(opt_codec_ctx, elm->type,
			elm->per_constraints, memb_ptr2, pd);`

I have gone through the Python ASN.1 APER decoder https://github.com/mitshell/libmich and it also suggested the same fix.
All the changes are marked in /*Changes start */ /Changes End/

PrintableString inside a sequence fails to decode and encode

Greetings,
I somehow get a failure in APER encoding of a very simple example (more complex ones worked fine for me so far).

TestAsnString DEFINITIONS ::= BEGIN

StatusReport ::= SEQUENCE {
    report PrintableString(SIZE(2..3))
}

END

If you take this XER:

<StatusReport>
	<report>ok</report>
</StatusReport>

it should be encoded as 0x00 0x6F 0x6B (checked on ASN.1 playground). What I get instead is 0x37 0xb5 0x80, which looks like the same sequence shifted 7 bits to the left.
With decoding I have a symmetric problem where 0x00 0x6F 0x6B doesn't get decoded properly.

Can encode but fails to decode 5g N2 38.413 Dec version

Hi,

I'm working on 5g N2 interface and using your asn1c.
It seems that there is some bug because I'm not able to decode message the asn1c just encoded.
The ASN file is this: 38413-f20.txt
The message: PDUSessionResourceSetupRequestTransfer
The resulting hex is this:
00000400820008081e8480203d09000086000100008b001a09f0114610103ffe0000000000000000000011461010400101050088000700050000052000
as file that can be put into converter-example.c:
in.txt

as C array:
char theData[] = { 0x00, 0x00, 0x04, 0x00, 0x82, 0x00, 0x08, 0x08, 0x1e, 0x84, 0x80, 0x20, 0x3d, 0x09, 0x00, 0x00, 0x86, 0x00, 0x01, 0x00, 0x00, 0x8b, 0x00, 0x1a, 0x09, 0xf0, 0x11, 0x46, 0x10, 0x10, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x46, 0x10, 0x10, 0x40, 0x01, 0x01, 0x05, 0x00, 0x88, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x05, 0x20, 0x00 };

The whole program:
https://gist.github.com/jkalmar/963cf317a9ba58f9d64396fee394c657

You can build the sample with:

  1. asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all 38413-f20.txt -D .
  2. with following cmake file: CMakeLists.txt

Or you can also build the above program.
It seems that in PDUSessionResourceSetupRequestTransfer the QosFlowSetupRequestList is the troubling element.
You can see the log from run with PDU=PDUSessionResourceSetupRequestTransfer ASN_EMIT_DEBUG=1 here: https://gist.github.com/jkalmar/a3ff06aa64162de90a0105ff8a198fa1
check lines: 270, 272, 277

I have debugged it and found out that the error happens in constr_CHOICE.c:1408

Breakpoint 1, CHOICE_variant_set_presence (td=0x53ef50 <asn_DEF_value_116>, sptr=0x552840, present=8) at /home/jkalmar/projects/5g/app/constr_CHOICE.c:1409

(gdb) p present
$1 = 8

(gdb) p td->elements_count
$2 = 7

Could you please check this
I have testet the code on GCC 4.8.4, GCC 7.2.1 and GCC 8.3.1 on Centos7 and on OpenSuse Tumbleweed and also tried clang 7.0.1 and the result was the same.

Thank you for your help

Encoding to Aligned PER

New to asn1c and trying to use as a sanity check for testing.

Running revision 1a900ebfand following a simple ASN.1 document from asnlab.com getting started

Using the following as the ASN.1 Schema

MyHTTP DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN

   GetRequest ::= SEQUENCE {
      header-only   BOOLEAN,
      lock          BOOLEAN,
      accept-types  AcceptTypes,
      url           Url,
      ...,
      timestamp     GeneralizedTime
   }

   AcceptTypes ::= SEQUENCE {
      standards   BIT STRING { html(0), plain-text(1), gif(2), jpeg(3) } (SIZE(4)) OPTIONAL,
      others      SEQUENCE OF VisibleString (SIZE(4)) OPTIONAL
   }

   Url ::= VisibleString (FROM("a".."z"|"A".."Z"|"0".."9"|"./-_~%#"))

END

Code generated via

/path/to/asn1c -gen-PER -pdu=all myhttp.asn1

converter-sample built using:

make -f converter-sample.mk

Using the ASN1 Playground I can generate various outputs and I grab the XML version

<?xml version="1.0" encoding="UTF-8"?>
<GetRequest>
  <header-only><true/></header-only>
  <lock><false/></lock>
  <accept-types>
    <standards>11</standards>
  </accept-types>
  <url>www.asnlab.org</url>
  <timestamp>20121221121221Z</timestamp>
</GetRequest>

Using the XML, attempt to output the Aligned PER:

./converter-example -ixer myhttp.xml -oaper -p GetRequest > myhttp.test.per

and receive the error: myhttp.xml: Cannot convert GetRequest into <?>

So the <?> is because ATS_ALIGNED_BASIC_PER and ATS_ALIGNED_CANONICAL_PER are missing from the ats_simple_name within converter-sample.c but in my novice attempts to track down the actual error, it appears to do with the SIZE(4) constraint and the generated code in OCTET_STRING.c where testing for "visible constraint" within OCTET_STRING_encode_aper

If I modify the ASN.1 to have standards { html, plain-text, gif, jpeg } and grab the XML from the playground which changed <standards>11</standards> to <standards>1111</standards>, the encoding doesn't fail, but it doesn't line up with the PER from the playground.

./converter-example -iaper myhttp.ossnokalva2.per -otext -p GetRequest
GetRequest ::= {
    header-only: TRUE
    lock: FALSE
    accept-types: AcceptTypes ::= {
        standards: F0 (4 bits unused)
    }
    url: www.asnlab.org
    timestamp: 2012-12-21 12:12:21 (GMT)
}

vs the converter-example using the XML from the playground

./converter-example -ixer myhttp.ossnokalva2.xml -oaper -p GetRequest > myhttp.test2.per
./converter-example -iaper myhttp.test2.per -otext -p GetRequest
GetRequest ::= {
    header-only: TRUE
    lock: FALSE
    accept-types: AcceptTypes ::= {
        standards: 10 (4 bits unused)
    }
    url: www.asnlab.org
    timestamp: 2012-12-21 12:12:21 (GMT)
}

which the playground shows as

GetRequest ::= 
{
  header-only TRUE,
  lock FALSE,
  accept-types 
  {
    standards { jpeg }
  },
  url "www.asnlab.org",
  timestamp "20121221121221.000Z"
}

Of note, decoding of the APER seems to be fine.

PER encoding of INTEGER type is not possible

hello.
I found a problem with encoding/decoding 64 bit integers.
The ASN definition is as follows:

Request ::= SEQUENCE {
channelId ChannelNumber,
timeSlot TimeSlot,
dataRate DataRate,
transmitPowerLevel TXpower,
channelLoad Opaque OPTIONAL,
infoElementIndicator WaveElementsIncluded,
userPriority UserPriority,
expiryTime Time64
}

Time64 ::= INTEGER (0..9223372036854775807)

For testing, I put a value in Time64 as below and performed encoding/decoding for BER, DER, OER, and PER.

asn_uint642INTEGER(&request->expiryTime, UINT64_MAX);

As a result of the test, there is a problem that only PER is not performed.
Is there any way to solve this problem?

V2X library Test(ATS_BER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding success.(35bytes)
Decoding success.(consumed = 35bytes)

V2X library Test(ATS_DER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding success.(35bytes)
Decoding success.(consumed = 35bytes)

V2X library Test(ATS_BASIC_OER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding success.(18bytes)
Decoding success.(consumed = 18bytes)

V2X library Test(ATS_CANONICAL_OER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding success.(18bytes)
Decoding success.(consumed = 18bytes)

V2X library Test(ATS_UNALIGNED_BASIC_PER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding failed.(Time64)
Decoding failed.(consumed = 0bytes)

V2X library Test(ATS_UNALIGNED_CANONICAL_PER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding failed.(Time64)
Decoding failed.(consumed = 0bytes)

V2X library Test(ATS_ALIGNED_BASIC_PER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding failed.(Time64)
Decoding failed.(consumed = 0bytes)

V2X library Test(ATS_ALIGNED_CANONICAL_PER)

172 6 10 0000001000000000000 3 00:FF:FF:FF:FF:FF:FF:FF:FF

Encoding failed.(Time64)
Decoding failed.(consumed = 0bytes)

converter-sample : compile errors

Hi mouse07410,

i am using your latest buid https://github.com/mouse07410/asn1c/tree/vlm_master.
I compiled my asn1 files. it is successfully compiled and generated .c and .h for the asn structures.
when i try to build the converter-sample which is generated with make, it is giving error. below is the compiler output.

[root@localhost pcap]# make -f converter-example.mk
cc -I/usr/src/ovl/pcap3/asn1c-vlm_master/libasn1parser/ -I/usr/src/ovl/pcap3/asn1c-vlm_master/libasn1fix/ -I/usr/src/ovl/pcap3/asn1c-vlm_master/libasn1print/ -I/usr/src/ovl/pcap3/asn1c-vlm_master/libasn1compiler -I/usr/src/ovl/pcap3/asn1c-vlm_master/skeletons -DASN_PDU_COLLECTION -I. -o ProtocolIE-Container.o -c ProtocolIE-Container.c
In file included from Extension-GANSS-AlmanacModel.h:15:0,
from GANSS-AlmanacModel.h:16,
from GANSS-AlmanacAndSatelliteHealth.h:16,
from GANSSGenericAssistanceData.h:68,
from GANSS-GenericAssistanceDataList.h:44,
from ProtocolExtensionField.h:68,
from ProtocolExtensionContainer.h:2750,
from UC-ID.h:49,
from UTRAN-GANSSReferenceTimeResult.h:17,
from ProtocolIE-Field.h:19,
from ProtocolIE-Container.h:264,
from ProtocolIE-Container.c:8:
ProtocolIE-Single-Container.h:30:1: error: unknown type name ‘Extension_ReferenceTimeChoice_IE_t’
typedef Extension_ReferenceTimeChoice_IE_t ProtocolIE_Single_Container_104P0_t;
^
ProtocolIE-Single-Container.h:31:1: error: unknown type name ‘Extension_GANSS_AlmanacModel_IE_t’
typedef Extension_GANSS_AlmanacModel_IE_t ProtocolIE_Single_Container_104P1_t;
^
ProtocolIE-Single-Container.h:32:1: error: unknown type name ‘Extension_InformationExchangeObjectType_InfEx_RqstIE_t’
typedef Extension_InformationExchangeObjectType_InfEx_RqstIE_t ProtocolIE_Single_Container_104P2_t;
^
make: *** [ProtocolIE-Container.o] Error 1
[root@localhost pcap]#

i am attaching the asn1 files which i am compiling.

PCAP-ASNs.zip

Please let me know if you require any other info to fix it. thanks.

SET_OF encoding

I'm getting a segfault when encoding data containing "SET OF"s. In the code there is a zero in place of encoding function for SET_OF.

Is it just not yet implemented, or is it intended and my problem is somewhere else?

Thanks!

some puzzles about v1.0.0 and latest repo

@mouse07410 @velichkov @brchiu
The asn data file was copied from 36413 vsersion f40,like bellow:
s1ap-f40.zip
The cmdline:
asn1c -pdu=S1AP-PDU -pdu=all -fcompound-names -findirect-choice -fno-include-deps -flink-skeletons -gen-PER ../36413/s1ap-f40.asn
Within v1.0.0 (https://github.com/mouse07410/asn1c/releases)
it works wrong, for details:(I adjust the integer(bit64) from 18446744073709551615 to 922337203685477580, line 4758 and line 4759 in s1ap-f40.asn)
asn1c_gen_code.zip
the v1.0.0 works well within asn data (https://github.com/ikarso/3GPPTS36.413_AuthenticEshkinKot/tree/master/ASN)

The latest repo works well within s1ap-f40.asn.
But latest repo decoder the packet recurively, after aper_decode(), everything will be parsed. But I just wanna parse the IEs I care about or all of IEs, this leads to performance issue (700Mbps).
In v1.0.0, IEs were parsed by ANY_to_type_aper, in this way , I can ignore the IEs donot care about.
How to make the v1.0.0 work properly within s1ap-f40.asn.
Or, How to keep the latest version from recursive parsing IEs?
Thanks so much.

Circular headers dependency compiling XnAP or E1AP

I am getting circular header dependency in XnAP v15.10, trying all combinations of -fno-include-deps, -fcompound, etc.

For example:

$ asn1c -fcompound-names -fincludes-quoted -fno-include-deps -funnamed-unions -no-gen-example -no-gen-BER -no-gen-OER -no-gen-UPER

$ gcc -std=c99 -D_GNU_SOURCE -fPIC -DPIC -Wall -Werror -Wfatal-errors -Wno-error=narrowing -Wno-unused -Wno-error=array-bounds -Wno-error=misleading-indentation -I. -DASN_DISABLE_BER_SUPPORT -DASN_DISABLE_OER_SUPPORT -DASN_DISABLE_UPER_SUPPORT ServedCells-ToModify-E-UTRA.c
In file included from ProtocolIE-Field.h:25:0,
                 from ProtocolIE-Single-Container.h:15,
                 from ServedCellInformation-E-UTRA-ModeInfo.h:17,
                 from ServedCellInformation-E-UTRA.h:19,
                 from ServedCells-ToModify-E-UTRA-Item.h:16,
                 from ServedCells-ToModify-E-UTRA.c:10:
Cause.h:44:3: error: unknown type name ‘ProtocolIE_Single_Container_6337P7_t’
   ProtocolIE_Single_Container_6337P7_t  choice_extension;
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.

$ grep ProtocolIE_Single_Container_6337P7_t *.h
Cause.h:                ProtocolIE_Single_Container_6337P7_t     choice_extension;
ProtocolIE-Single-Container.h:typedef Cause_ExtIEs_t     ProtocolIE_Single_Container_6337P7_t;

Compilation is impossible because the type ProtocolIE_Single_Container_6337P7_t is defined in ProtocolIE-Single-Container.h which requires Cause.h which requires the other header.

I avoided similar issues in the past by tweaking include order but cannot find an easy/generic way here.

The spec:
xnap-v15.10.asn.gz

ASN1C fails to decode some packets on an ARM cortex m4

We noticed an issue with decoding UPER encoded numbers into a long on an arm cortex-m4.

Problem Description

Our ASN field is

Longitude ::= INTEGER (-1799999999..1800000001)

asn1c typed Longitude as a long, which is reasonable, a long is

at least the [−2,147,483,647, +2,147,483,647] range

Notably, it can be bigger.

We noticed that we couldn't decode some UPER encoded longitudes, some quick
experimentation later:

  • -1799999999 to 347483648 can be encoded and decoded,
  • 347483649 to 1800000001 cannot be decoded.
    (not everything in this range was checked, one value every 5000 till the split
    was found, and then more granular at that point)
Working : 0x14B62E00
non :     0x14B62E01

It seems likely this is an issue with the size of a long.

amd64 (everything works as expected):  sizeof(long) = 8
arm cortex m4 nRf52840 (doesn't work): sizeof(long) = 4

If we change a cast from long to intmax_t, we can decode any valid value as
expected.

diff --git a/test-asn/per_support.c b/test-asn/per_support.c
index f060f57..7e6eccf 100644
--- a/test-asn/per_support.c
+++ b/test-asn/per_support.c
@@ -294,7 +294,7 @@ per_imax_range_unrebase(uintmax_t inp, intmax_t lb, intmax_t ub, intmax_t *outp)
     }

     if(inp <= INTMAX_MAX) {
-        *outp = (long)inp + lb;
+        *outp = (intmax_t)inp + lb;
     } else {
         *outp = (lb + INTMAX_MAX + 1) + (intmax_t)((inp - INTMAX_MAX) - 1);
     }

The values around this cast are all intmax_t (or uintmax_t), which is
defined as a long long, so at least 64 bits.

Made a repo to make reproducing this as easy as I can: https://github.com/tomeinc/nordic-asn1c-long-issue
This does require you to have a nordic nRF52840-DK, if needed I can arrange getting one to somebody.

Cannot compile S1AP ASN.1 Files into libasncodec.a or converter-example

When attempting to use asn1c to compile the ASN.1 files for S1AP, the files will compile, but the resulting output cannot be used to produce the libasncodec.a file and/or converter example.

Attempting to run make to produce these files returns a bunch of compiler errors with the ProtocolIE-Field.c file, most of them redefinition errors. The compilation process then terminates after dumping the compiler errors to the terminal and fails to produce the libasncodec.a file.

OCTET_STRING encoding problem

I'm using the SAE J2735-2016 .ASN file. I'm trying to encode an RTCM message (decode works), but it's failing on the OCTET_STRING_uper.c (line 268). As you can see there's a really big number in this debug message which doesn't look right:

Encoding RTCMmessage into 17179869185 units of 8 bits (1..1023, effective 10) (OCTET_STRING_uper.c:252)
Failed to encode element RTCMmessage (OCTET_STRING_uper.c:268)
Failed to encode element RTCMmessageList (constr_SEQUENCE_OF_uper.c:82)
Failed to encode element value (OPEN_TYPE_uper.c:114)
J2735 Encoded: out=-1
Freeing RTCMmessage as OCTET STRING (/home/neal/ProbeStar/GitHub/libj2735v2016/src/OCTET_STRING.c:102)

The C code is here:

#include "MessageFrame.h"

static int msg_count = 1;

int j2735_encode(const char *raw, int size, char *buf, int max)
{
  MessageFrame_t  frame;
  memset(&frame, 0, sizeof(frame));

  RTCMcorrections_t *rtcm = &frame.value.choice.RTCMcorrections;

  A_SEQUENCE_OF(RTCMmessageList_t) list;
  memset(&list, 0, sizeof(list));

  if (!raw || !buf)
    return 0;
  
  // clip
  if (size > 1023)
    size = 1023;

  printf("J2735 Encoded: in=%d, max=%d\n", size, max);

  // build message
  RTCMmessage_t *oct = OCTET_STRING_new_fromBuf(&asn_DEF_RTCMmessage, raw, size);
  ASN_SEQUENCE_ADD(&list, oct);

  // build correction
  rtcm->msgCnt = msg_count++;
  if (msg_count>=128)
    msg_count = 1;
  rtcm->rev = RTCM_Revision_rtcmRev2;
  rtcm->timeStamp = NULL;
  rtcm->anchorPoint = NULL;
  rtcm->rtcmHeader = NULL;
  rtcm->regional = NULL;
  ASN_SEQUENCE_ADD(&rtcm->msgs, &list);

  // build frame
  frame.messageId = 28;   // RTCM
  frame.value.present = MessageFrame__value_PR_RTCMcorrections;

  // encode
  asn_enc_rval_t rc;
  rc = uper_encode_to_buffer(&asn_DEF_MessageFrame, NULL, &frame, buf, max);

  printf("J2735 Encoded: out=%ld\n", rc.encoded);

  free(oct);

  // check
  if (rc.encoded == -1)
    return -1;

  return rc.encoded;
}

APER decoding failure for SEQUENCE

@mouse07410 , @mhanna123
I am using the version https://github.com/mouse07410/asn1c.git suggested by @mouse07410 to encode/decode APER PDUs.
I have performed a basic test with a SEQUENCE with Extension Marker contains 2 MANDATORY ENUMS with Extension Marker and 2 OPTIONAL Parameters that are not Present. All the SEQUENCE Parameters are in the Extension Root.
Encoding is successful, but decoding fails.
When debugging I have located a problem in SEQUENCE_decode_aper() function in
constr_SEQUENCE.c dealing withe padding.
After decoding the Extension Marker of the SEQUENCE (1bit) and the 2 Optional Parameters Indicators (2bits) decoding procedure assumes padding of 5 bits before the Extension Marker of the 1st ENUM while there should be no padding in this situation.
I think that this problem has been addressed by @mhanna123 but he did not solve it completely.
I attach a basic code to test this.
Thank you in advance
RequestType.ZIP

APER segfault

When using APER in a CHOICE it segfaults on this line (ct may be NULL):

if(aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start))

For example when encoding ChoiceExtended1 in this asn definition:

Enum ::= ENUMERATED { one, two, three, four }

ChoiceExtended1 ::= CHOICE {                                                              
    a Enum,                                                                               
    ...,                                                                                  
    b Enum                                                                                
}

WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions

Hi,

I am using TS 38.413(Rel 16) NGAP ASN file and trying to generate the .c and .h files for this ASN but seeing lot of warning messages like

WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1
WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1
WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1
WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1
WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1
WARNING: Parameterized type maxProtocolExtensions expected for maxProtocolExtensions at line 9350 in ../latest_updated.asn1

But it is generating the .c and .h files for me. However, when i am trying to compile these generated .c files, i am observing compilation error for many of the structures

error: unknown type name ‘W_AGF_ID_ExtIEs_t’
typedef W_AGF_ID_ExtIEs_t ProtocolIE_SingleContainer_9303P42_t;

error: unknown type name ‘WarningAreaList_ExtIEs_t’
typedef WarningAreaList_ExtIEs_t ProtocolIE_SingleContainer_9303P43_t;

error: unknown type name ‘UserLocationInformation_ExtIEs_t’
typedef UserLocationInformation_ExtIEs_t ProtocolIE_SingleContainer_9303P40_t;

Is this a known issue with this compiler or am i missing something?

I have generated the code by executing the following command
asn1c -fcompound-names -gen-PER -pdu=all <.asn file>

PER is not compiled, use -gen-PER

Hi,
I just started working on this asn1c. I selected this version because i want Aligned PER support. My purpose is to compile TS25.453 for UTRAN-PCAP. when i started understanding of the generated code, i realized " PER is not compiled, use -gen-PER" comments in generated code. i tried giving that as argument while compiling my asn files using asn1c... still same behavior. i didnt see any compile options to add this in the asn1master makefile. Please guide me. Thanks

Grammar Parse Error Token "[[" in Extension Addition Group

I am using 36331-g40.asn1 and get the error:

ASN.1 grammar parse error near 36331-g40.asn1:2886 (token "[["): syntax error, unexpected TOK_VBracketLeft
Cannot parse "36331-g40.asn1"

Your fork has been mentioned in other issues as having a workable implementation of the extension addition group syntax (348, 317) but I'm still getting the same error others have in the past. One difference I've noticed in the newer versions of the .asn1 files from the versions from when you added extension addition group handling, is that the extension addition group syntax parsing errors are within a CHOICE this time and perhaps they weren't before.

I would greatly appreciate any guidance.

Version string is always the same even across forks!

I have been testing a few forks and branches of asn1c and it was quite confusing to distinguish which binary I am running, since they all spit the same version "ASN.1 Compiler, v0.9.29"

It would make sense to include a reference to the repo name, branch and latest commit:

$ asn1c -v
ASN.1 Compiler, v0.9.29 (mouse07410/asn1c vlm_master a6376b4)
Copyright (c) 2003-2017 Lev Walkin <[email protected]> and contributors.

Failed to decode F1AP(38.473) reset Request

Hi,
I am trying to encode / decode Reset message from 38.473 f40 (V15.4.0 (2018-12)) using aper encode/decode.

Reset ::= SEQUENCE {
protocolIEs ProtocolIE-Container { {ResetIEs} },
...
}

ResetIEs F1AP-PROTOCOL-IES ::= {
{ ID id-TransactionID CRITICALITY reject TYPE TransactionID PRESENCE mandatory }|
{ ID id-Cause CRITICALITY ignore TYPE Cause PRESENCE mandatory }|
{ ID id-ResetType CRITICALITY reject TYPE ResetType PRESENCE mandatory },
...
}
ResetType ::= CHOICE {
f1-Interface ResetAll,
partOfF1-Interface UE-associatedLogicalF1-ConnectionListRes,
choice-extension ProtocolIE-SingleContainer { { ResetType-ExtIEs} }
}
UE-associatedLogicalF1-ConnectionListRes ::= SEQUENCE (SIZE(1.. maxnoofIndividualF1ConnectionsToReset)) OF ProtocolIE-SingleContainer { { UE-associatedLogicalF1-ConnectionItemRes } }

UE-associatedLogicalF1-ConnectionItemRes F1AP-PROTOCOL-IES ::= {
{ ID id-UE-associatedLogicalF1-ConnectionItem CRITICALITY reject TYPE UE-associatedLogicalF1-ConnectionItem PRESENCE mandatory},
...
}

UE-associatedLogicalF1-ConnectionItem ::= SEQUENCE {
gNB-CU-UE-F1AP-ID GNB-CU-UE-F1AP-ID OPTIONAL,
gNB-DU-UE-F1AP-ID GNB-DU-UE-F1AP-ID OPTIONAL,
iE-Extensions ProtocolExtensionContainer { { UE-associatedLogicalF1-ConnectionItemExtIEs} } OPTIONAL,
...
}

Aper Encoding is success and it gives the encoded hex buffer as below

00 00 00 1e 00 00 03 00 4e 00 02 00 12 00 00 40
01 01 00 30 00 0c 40 01 00 50 00 06 64 b2 04 40
24 24

But when I try to decode the same hex buffer using aper decode it fails

Debug logs shows decoding fails UE-associatedLogicalF1-ConnectionItemRes

Decoded Criticality = 0 (skeletons/NativeEnumerated.c:293)
Decoding member "value" in ProtocolIE-SingleContainer (skeletons/constr_SEQUENCE.c:1599)
Failed to decode element ProtocolIE-SingleContainer (skeletons/OPEN_TYPE.c:421)
Failed decode value in ProtocolIE-SingleContainer skeletons/constr_SEQUENCE.c:1609)
UE-associatedLogicalF1-ConnectionListRes SET OF ProtocolIE-SingleContainer decoded 2, 0xa09590 (skeletons/constr_SET_OF.c:1262)
Failed decoding ProtocolIE-SingleContainer of UE-associatedLogicalF1-ConnectionListRes (SET OF) (skeletons/constr_SET_OF.c:1272)

Is this something known bug and is there any fix available? Please suggest.

Thanks

make check fails for 32bit crossdev environment

I am using crossdev enviroment to compile for 32bit armv7a SoC board on my 64bit Intel i5 Gentoo Linux system. As you are probably aware, compiling directly on arm boards is notoriously slow and this is the preferred way.

Although asn1c works great for my needs (I have tested the compiler and decoder in DER mode and everything works fine) and I don't need PER support, it seems that some of the tests concerning PER are buggy. I have tested this with qemu_binfmt environment and also on the real board with Marvell ARMADA A388 ARM A9. The problem seems to be related to tests using readdir and other filesystem functions when run on a 64bit host.

$ ./configure --disable-test-asan --disable-test-ubsan --host=armv7a-hardfloat-linux-gnueabi
$ make -j4
$ make check

Tests that fail are some from the tests/tests-c-compiler directory, the ones reading from the filesystem:

  • test-check-119.-fwide-types.-gen-PER
  • test-check-119.-gen-PER
  • test-check-126.-gen-PER
  • test-check-62
  • test-check-70
  • test-check-70.-fwide-types

I have made the necessary changes and will create a pull request. The changes in the pull request deal with all these issues and will allow asn1c to be compatible with crossdev environments and also with qemu_binfmt

The same process works without issues when target host is unchanged (64bit -> 64bit)

$ ./configure --disable-test-asan --disable-test-ubsan
$ make -j4
$ make check

All tests are successful.

Master branch fails `make check`

After successful compilation (fully up-to-date Linux Mint 20.2) running make check fails badly:

...
Making check in tests
make[1]: Entering directory '/tmp/asn1c/tests'
Making check in tests-asn1c-compiler
make[2]: Entering directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make  check-parsing.sh
make[3]: Entering directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make[3]: Nothing to be done for 'check-parsing.sh'.
make[3]: Leaving directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make  check-TESTS
make[3]: Entering directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make[4]: Entering directory '/tmp/asn1c/tests/tests-asn1c-compiler'
FAIL: check-parsing.sh
============================================================================
Testsuite summary for asn1c 0.9.29
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/tests-asn1c-compiler/test-suite.log
Please report to [email protected]
============================================================================
make[4]: *** [Makefile:544: test-suite.log] Error 1
make[4]: Leaving directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make[3]: *** [Makefile:652: check-TESTS] Error 2
make[3]: Leaving directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make[2]: *** [Makefile:726: check-am] Error 2
make[2]: Leaving directory '/tmp/asn1c/tests/tests-asn1c-compiler'
make[1]: *** [Makefile:387: check-recursive] Error 1
make[1]: Leaving directory '/tmp/asn1c/tests'
make: *** [Makefile:491: check-recursive] Error 1

What am I doing wrong?

Usage of ASN_STRUCT_FREE and filling the 'ie' and freeing it.

I have a query regarding filling the structure:
For example, if I need to fill one ngap structure NG reset, which has a 'cause' and 'reset type' as mandatory fields. So for filling the first 'ie cause', it requires allocating memory and then fills the structure based on procedure id, criticality, and so on. So before filling the second ie reset type if I'm trying to free the pointer then while executing the program is crashing. Why does this happen? I can free the pointer after filling all the 'ie's', this won't throw any error and encoding works perfectly.
This might be a simple problem but I'm not able to find an appropriate answer. Instead of freeing the ie, can I just use ASN_STRUCT_FREE_CONTENTS _ONLY()? When I tried with ASN_STRUCT_FREE() my program was crashing. But with ASN_STRUCT_FREE_CONTENTS _ONLY() it worked.


The program crashes if I do in the following way:

NGResetIEs_t *ie;
/**cause */
ie = ( NGResetIEs_t * ) calloc ( 1, sizeof ( NGResetIEs_t )
/** fill the required field like id, criticality etc*/
 ASN_SEQUENCE_ADD ( &ngRset->protocolIEs.list, ie );
free (ie);   
/**reset type */
ie = ( NGResetIEs_t * ) calloc ( 1, sizeof ( NGResetIEs_t )
/** fill the required field like id, criticality etc*/
 ASN_SEQUENCE_ADD ( &ngRset->protocolIEs.list, ie );
free (ie)
asn_encode() //crashes the program

Working code

NGResetIEs_t *ie;
/**cause */
ie = ( NGResetIEs_t * ) calloc ( 1, sizeof ( NGResetIEs_t )
/** fill the required field like id, criticality etc*/
 ASN_SEQUENCE_ADD ( &ngRset->protocolIEs.list, ie );
/**reset type */
ie = ( NGResetIEs_t * ) calloc ( 1, sizeof ( NGResetIEs_t )
/** fill the required field like id, criticality etc*/
 ASN_SEQUENCE_ADD ( &ngRset->protocolIEs.list, ie );
asn_encode() 
free (ie) // works 

the codes generated by asn1c compiled error(S1AP)

@mouse07410 At first, thank you for your hard working, this issue I ever asked. Now I just want to decode the S1AP signalling (3GPP R15 36.413).

  1. I cloned the code from: https://github.com/mouse07410/asn1c.git vlm_master
  2. compile the project;(make, make install)
  3. put the asn data files into one asn file, then put it under dir example( s1ap-14.4.0.zip)
  4. under example/sample.source.S1AP : make regen-makefile
  5. after step 4, execute make
    lots of errors like below:
make
cc -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE  -DPDU=S1AP_PDU -DASN_PDU_COLLECTION -I. -o ProtocolIE-Field.o -c ProtocolIE-Field.c
ProtocolIE-Field.c:17649:1: error: redefinition of ‘memb_id_constraint_0’
 memb_id_constraint_0(const asn_TYPE_descriptor_t *td, const void *sptr,
 ^
ProtocolIE-Field.c:17631:1: note: previous definition of ‘memb_id_constraint_0’ was here
 memb_id_constraint_0(const asn_TYPE_descriptor_t *td, const void *sptr,
 ^
ProtocolIE-Field.c:17655:1: error: redefinition of ‘memb_criticality_constraint_0’
 memb_criticality_constraint_0(const asn_TYPE_descriptor_t *td, const void *sptr,
 ^
ProtocolIE-Field.c:17637:1: note: previous definition of ‘memb_criticality_constraint_0’ was here
 memb_criticality_constraint_0(const asn_TYPE_descriptor_t *td, const void *sptr,
 ^
ProtocolIE-Field.c:17661:1: error: redefinition of ‘memb_value_constraint_0’
 memb_value_constraint_0(const asn_TYPE_descriptor_t *td, const void *sptr,_
```____________________________________________________________________________________________
**the details** 
[compile_errors.log](https://github.com/mouse07410/asn1c/files/3058830/compile_errors.log)
________________________________________________________________________________________________
Meanwhile, generating code with cmdline "asn1c -fcompound-names -findirect-choice  -gen-PER -no-gen-example -pdu=all -fno-include-deps ../s1ap-14.4.0.asn", compile errors are the same.

Could you help me ? thank you very very very much. 

Build Failure due to missing asn1p_l.c

I am trying to build the compiler but make gives the following error,

make[3]:
Entering directory '/home/ubx/usha_workspace/git/asn1c/libasn1parser'
LEX asn1p_l.c
%option yylineno entails a performance penalty ONLY on rules that can match newline characters
REJECT entails a large performance penalty
lex.yyasn1p_l.c is unchanged
CC asn1p_l.lo
gcc: error: asn1p_l.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

@mouse07410 Kindly check if the build is successful locally on your system.

Not able to generate substructure for NGAP.

I am using asn1 version asn1c-0.9.29 to generate .c and .h for NGAP protocol. I am able to generate .c and .h but substructure are absent while try to generate with PER .
Command to run is $ asn1c file.asn -fcompound-names -gen-PER -pdu=all

codes generated by asn1c crashed whiling decoding aper

@velichkov Hello ,velichkov I got a strange problem, Could you help me ?
Now the codes generated by asn1c can be compiled successfully, but it works wrong. the stack likes bellow:
0x0000000000c30cd4 in asn_get_few_bits (pd=0x7fffffffdd30, nbits=1) at ../src/asn_bit_data.c:108 #1 0x0000000000c3fc87 in SEQUENCE_decode_aper (opt_codec_ctx=0x7fffffffdd70, td=0x12cd980 <asn_DEF_Reset>, constraints=0x0, sptr=0x7fffffffddc8, pd=0x7fffffffdd30) at ../src/constr_SEQUENCE.c:1515 #2 0x0000000000bffeb2 in aper_decode (opt_codec_ctx=0x7fffffffdd70, td=0x12cd980 <asn_DEF_Reset>, sptr=0x7fffffffddc8, buffer=0xa, size=165352176, skip_bits=0, unused_bits=0) at ../src/per_decoder.c:171 #3 0x0000000000c0194b in ANY_to_type_aper (st=0x9db27f0, td=0x12cd980 <asn_DEF_Reset>, struct_ptr=0x7fffffffde08) at ../src/ANY.c:237 #4 0x0000000000500a59 in procInitReset (pc=14, value=0x9db27f0) at /mnt/hgfs/DPI/BC-DPI/src/http-parser/src/s1_mme_parser.c:1663 #5 0x000000000050300a in parseInitialMessage (in_msg=0x9db0a08) at /mnt/hgfs/DPI/BC-DPI/src/http-parser/src/s1_mme_parser.c:2359 #6 0x0000000000503416 in sctp_parse_s1ap (data=0x7fffe14001fe, len=28) at /mnt/hgfs/DPI/BC-DPI/src/http-parser/src
the pcap is partOfS1_reset.zip
It's same with sample-S1AP-PDU-8.aper (reset), but convert-example -iaper sample-S1AP-PDU-8.aper ,everything goes well.
But, I make the codes to be static lib ,makefile is Makefile.zip I splite src & hdr file into src and include.

In my code (64bit platform), decoding : `" S1AP_PDU_t *pdu_t = NULL;
asn_dec_rval_t rval = {0};

/* parse S1AP header */
rval = aper_decode(NULL, &asn_DEF_S1AP_PDU, (void **)&pdu_t,
                   data, len, 0, 0);"`

In GDB mode ,I found the pointer malloc in static lib within 32bit not 64bit....
the coredump runtime stack like above.
Does anyting go wrong when generate static lib or invoking the interfaces of asn1c codes ?
thank you so much.

Question: How to compile just a subset of a big spec?

It would be nice if asn1c -pdu=PDU would only generate code for the dependencies of the given PDU. Or at least list them...

Using asn1c for 5G development sometimes we just need a small part of a huge spec. I am using gcc generated dependencies to scrub all unused code, and would like to avoid that.

Thanks for maintaining this fork of asn1c, the best Open Source compiler for 3GPP specs.

BIT_STRING example

Hello,

Anyone have an example of BIT_STRING encoding and decoding with asn1c?

For example using the below definition:

/* Dependencies */
typedef enum TestValue {
Test_Value_unavailable = 0,
Test_Value_1 = 1,
Test_Value_2 = 2,
} e_TestValue;

/* TestValue */
typedef BIT_STRING_t TestValue_t;

Thanks,

Compilation failure for GSM_MAP protocol

Hi Mouse,

Back to Issue 185 in the vlm's asn1c repository, with regard to the problem in compiling "Information Object Set", the problem seems solved and S1AP, RANAP, X2AP, M3AP, LPPa, PCAP, XwAP are successfully compiled. However, when compiling the GSM_MAP protocol, that issue still rises.

asn1c -fcompound-names -gen-PER GSMMAP.asn MAP-MS-DataTypes.asn MAP-SS-DataTypes.asn MAP-CommonDataTypes.asn MAP-ExtensionDataTypes.asn MAP-SS-Code.asn MAP-BS-Code.asn MAP-TS-Code.asn MAP-ER-DataTypes.asn MAP-OM-DataTypes.asn MAP-CH-DataTypes.asn MAP-DialogueInformation.asn MAP-SM-DataTypes.asn

Do you have any clue that how this can be resolved? Maybe with similar approach which addressed the problem for S1AP?

Thanks

x64 integer

Hello,

I have downloaded the latest asn1c code from your branch and the asn1c compiler with specification with x64 integer is giving this error

Value "18446744073709551615" at line 9 is too large for this compiler! Please contact the asn1c author.
ASN.1 grammar parse error near line 9 (token "18446744073709551615"): syntax error, unexpected $end

I was going through the "vlm/asn1c" issue list and saw that you have marked this issue as fixed.

asn.1 file was like:
DEFINITIONS AUTOMATIC TAGS ::=

BEGIN
-- size = 64 bits
Id ::= INTEGER (0..18446744073709551615)

-- size = 8 bits
Interface ::= INTEGER (0..255)

-- size = 8 bits
Targeted ::= INTEGER (0..255)

how can I compile huge numbers like this one?

Ignore duplicate definitions from different files (Feature request)

Hello I am often compiling together different 3GPP specs that include duplicate definitions of the same object.

Here is a very popular one, found in many 3G/4G/5G specs:

PLMN-Identity ::= OCTET STRING (SIZE(3))

Would it be too hard to allow duplicate definitions when they are exactly the same?

Issues and odd things found via clang warnings

Hello!
I'm using SAE J2735 201603, and putting the output from ASN1C through clang with -Weverything.
While going through and disabling specific warnings, I saw what might be bugs, or at least things that can be improved.
There is stuff like -Wconditional-uninitialized that I couldn't easily follow the code enough to know if it's an issue, I'm just going to list stuff I can understand or at least kinda follow.

I'm going to link to output examples in an unrelated repo that has output for J2735 from an unknown version of ASN1c, though the output I reference matches the output from the current `vlm_master branch. (dcf963c)

The full list of warnings I ended up with is:

-Wall \
-Wextra \
-Weverything \
-Werror \
-Wno-missing-field-initializers \
-Wno-unused-parameter \
-Wno-parentheses-equality \
-Wno-switch-enum \
-Wno-conversion \
-Wno-switch-default \
-Wno-reserved-id-macro \
-Wno-shorten-64-to-32 \ 
-Wno-gnu-empty-struct \ 
-Wno-c++-compat \ 
-Wno-cast-align \ 
-Wno-used-but-marked-unused \ 
-Wno-assign-enum \ 
-Wno-conditional-uninitialized \
-Wno-unreachable-code-break \
-Wno-covered-switch-default \
-Wno-comma \
-Wno-unreachable-code \
-Wno-unused-macros \
-Wno-padded

Going to call out the ones I think can be easily fixed or I understand well enough to say they look suspicious.

  • -Wunreachable-code:
  • -Wused-but-marked-unused:
    • In a few places like things are marked unused with CC_NOTUSED, but are then used.
    • example
    • I can try to make a minmal test case if anyone who wants to look into this doesn't have J2735.
  • -Wstring-conversion: A few places convert a string to a bool like INTEGER.c:657
    • It looks like this is just an assert that will always fail and giving a reason why, but I feel like assert(0) //Unreachable would be better, I can do a PR for this.
  • -Wshorten-64-to-32 -Wconversion: Several places do stuff like
  • -Wcomma: A bunch of things in asn_bit_data.c use commas instead of semicolons, such as line 171
    • I don't think there is any benefit to using commas instead of semicolons here? I can create a PR to change this if there isn't any reason for this to stay as commas.
  • -Wparentheses-equality

Should I make PRs to clean up the items I have mentioned above?
If you can give guidance on how the code generation works I may be able to make PRs for the other things.

asn_imax2INTEGER: warning: array subscript 0 is outside array bounds

while building osmo-cbc [1] code with current mouse07410 vlm_master (24247e2)

/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c: In function ‘asn_imax2INTEGER’:
/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c:364:22: warning: array subscript 0 is outside array bounds of ‘intmax_t[1]’ {aka ‘long long int[1]’} [-Warray-bounds]
  364 |  for(bp = buf, pend1 += add; p != pend1; p += add)
      |                ~~~~~~^~~~~~
/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c:320:42: note: while referencing ‘value’
  320 | asn_imax2INTEGER(INTEGER_t *st, intmax_t value) {
      |

This happens when building on a 32bit system (raspbian 10, armv7l).

# gcc --version
gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110

Using build flags CPPFLAGS="-ggdb3 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -std=gnu11 -Wall"

[1] https://gitea.osmocom.org/cellular-infrastructure/osmo-cbc/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.