vlm / asn1c Goto Github PK
View Code? Open in Web Editor NEWThe ASN.1 Compiler
Home Page: http://lionet.info/asn1c/
License: BSD 2-Clause "Simplified" License
The ASN.1 Compiler
Home Page: http://lionet.info/asn1c/
License: BSD 2-Clause "Simplified" License
Tried examples/sample.source.PKIX1, but failed.
Compiled just fine with usual 'make'. Then tried to use 'x509dump' executable with 'sample-Certificate-1.der' as argument, which gave me an error 'sample-Certificate-1.der: Decode failed past byte 4: Input processing error'. Also tried other certificates, self-signed and real (from the cache of Firefox). Examples from 'http://csrc.nist.gov/groups/ST/crypto_apps_infra/documents/pkixtools/' worked OK. 'Microsoft Internet Authority' certificate from the cache of Firefox forked wine, but several others failed. Self-signed certificates generated with OpenSSL and with IIS7 failed.
The following patch is needed to extract ASN.1 from RFCs when the syntax is under joint-iso-itu-t(2)
diff --git a/examples/crfc2asn1.pl b/examples/crfc2asn1.pl
index 0b086f6..5a57f2d 100755
--- a/examples/crfc2asn1.pl
+++ b/examples/crfc2asn1.pl
@@ -42,8 +42,8 @@ while(<>) {
$modName = $1;
$currentFname = $rfcid . $modName . ".asn1";
$inasn = 1;
- } elsif(/^[ \t]*([A-Z][A-Za-z0-9-]*).*{[ \t]*iso/
- || /^[ \t]*{[ \t]*iso/) {
+ } elsif(/^[ \t]*([A-Z][A-Za-z0-9-]*).*{[ \t]*(?:joint-)?iso/
+ || /^[ \t]*{[ \t]*(?:joint-)?iso/) {
my @a = ($_);
$modName = $1;
unless(length($modName)) {
Hi,
I use asn1c as below,
../asn1c -gen-PER RANAP-CommonDataTypes.asn RANAP-Constants.asn RANAP-Containers.asn RANAP-IEs.asn RANAP-PDU-Contents.asn RANAP-PDU-Descriptions.asn
ASN.1 grammar parse error near line 137 (token "{"): parse error, unexpected '{'
Cannot parse "RANAP-IEs.asn"
RANAP*.asn is from 3gpp.org,
3GPP TS 25.413 V9.4.0 (2010-09)
http://www.3gpp.org/ftp/Specs/html-info/25413.htm
I will email the 6 ranap asn file to your email.
Thank you very much!
Hi Lev,
I've found a problem with the XER Encoder thats causing me a little bit of grief, I hope you can fix it.
XER Encoder has an issue with ENUMERATED types that are extensible.
If a value is not in the ASN.1 definition then the XER encoder will stop at that value.
Something like
SomeObj ::= SEQUENCE
{
obj-type [0] ENUMERATED
{
string(0),
int(1),
bool(2),
...
},
{otherstuff}
}
If obj-type has a value outside 0,1 or 2 then calling xer_fprint( stdout, &asn_DEF_SomeObj, c_obj ); will output something like:
Thanks
My ASN.1 grammar :
MyModule DEFINITIONS ::=
BEGIN
MyTypes ::= SEQUENCE {
myNumber INTEGER,
mySeqOf SEQUENCE OF MyInt
}
MyInt ::= INTEGER (0..255)
END
When I compile ...
$ asn1c -fno-constraints MyModule.asn1
...
$ make -f Makefile.am.sample CFLAGS="-DPDU=MyTypes -I."
cc -DPDU=MyTypes -I. -o MyTypes.o -c MyTypes.c
cc -DPDU=MyTypes -I. -o MyInt.o -c MyInt.c
cc -DPDU=MyTypes -I. -o INTEGER.o -c INTEGER.c
cc -DPDU=MyTypes -I. -o NativeEnumerated.o -c NativeEnumerated.c
cc -DPDU=MyTypes -I. -o NativeInteger.o -c NativeInteger.c
cc -DPDU=MyTypes -I. -o asn_SEQUENCE_OF.o -c asn_SEQUENCE_OF.c
cc -DPDU=MyTypes -I. -o asn_SET_OF.o -c asn_SET_OF.c
cc -DPDU=MyTypes -I. -o constr_SEQUENCE.o -c constr_SEQUENCE.c
cc -DPDU=MyTypes -I. -o constr_SEQUENCE_OF.o -c constr_SEQUENCE_OF.c
cc -DPDU=MyTypes -I. -o constr_SET_OF.o -c constr_SET_OF.c
constr_SET_OF.c: In function ‘SET_OF_decode_uper’:
constr_SET_OF.c:907:18: attention : transtypage d'un pointeur vers un entier de taille différente [-Wpointer-to-int-cast]
(int)nelems, (int)ct ? ct->effective_bits : -1);
^
cc -DPDU=MyTypes -I. -o OCTET_STRING.o -c OCTET_STRING.c
cc -DPDU=MyTypes -I. -o BIT_STRING.o -c BIT_STRING.c
cc -DPDU=MyTypes -I. -o asn_codecs_prim.o -c asn_codecs_prim.c
cc -DPDU=MyTypes -I. -o ber_tlv_length.o -c ber_tlv_length.c
cc -DPDU=MyTypes -I. -o ber_tlv_tag.o -c ber_tlv_tag.c
cc -DPDU=MyTypes -I. -o ber_decoder.o -c ber_decoder.c
cc -DPDU=MyTypes -I. -o der_encoder.o -c der_encoder.c
cc -DPDU=MyTypes -I. -o constr_TYPE.o -c constr_TYPE.c
cc -DPDU=MyTypes -I. -o constraints.o -c constraints.c
cc -DPDU=MyTypes -I. -o xer_support.o -c xer_support.c
cc -DPDU=MyTypes -I. -o xer_decoder.o -c xer_decoder.c
cc -DPDU=MyTypes -I. -o xer_encoder.o -c xer_encoder.c
cc -DPDU=MyTypes -I. -o per_support.o -c per_support.c
cc -DPDU=MyTypes -I. -o per_decoder.o -c per_decoder.c
cc -DPDU=MyTypes -I. -o per_encoder.o -c per_encoder.c
cc -DPDU=MyTypes -I. -o converter-sample.o -c converter-sample.c
cc -DPDU=MyTypes -I. -o progname MyTypes.o MyInt.o INTEGER.o NativeEnumerated.o NativeInteger.o asn_SEQUENCE_OF.o asn_SET_OF.o constr_SEQUENCE.o constr_SEQUENCE_OF.o constr_SET_OF.o OCTET_STRING.o BIT_STRING.o asn_codecs_prim.o ber_tlv_length.o ber_tlv_tag.o ber_decoder.o der_encoder.o constr_TYPE.o constraints.o xer_support.o xer_decoder.o xer_encoder.o per_support.o per_decoder.o per_encoder.o converter-sample.o
MyInt.o:(.data+0x60): référence indéfinie vers « MyInt_constraint »
collect2: erreur: ld a retourné 1 code d'état d'exécution
Makefile.am.sample:74: recipe for target 'progname' failed
make: *** [progname] Error 1
MyInt_constraint is used but not defined due to -fno-constraints.
Is it normal ?
Hi,
The generated code for 3GPP RRC compiles on linux (gcc), but I fails to compile. The problem is with the A_SET_OF
macro, apparently, which defines a free
function that has a structure definition as the parameter. Here is more info about the problem: http://stackoverflow.com/questions/26207145
As the documentation of asn1c says with minor teaks it possible to compile the generated on VC++, I wanted to ask if there is workaround to this issue.
Hello.
I'm trying to use compiler with specification with x64 integer and get this error:
Value "18446744073709551615" at line 163 is too large for this compiler! Please contact the asn1c author.
ASN.1 grammar parse error near line 163 (token "18446744073709551615"): syntax error, unexpected $end
asn.1 file was like:
DataContent ::= SEQUENCE {
...
bytes-count INTEGER (0 .. 18446744073709551615),
...
}
how can I compile huge numbers like this one?
asn_codecs_prim.c(220): error C2036: 'const void *' : unknown size
chunk_buf += lead_wsp_size;
Version brackets were introduced in later versions of ASN.1 and are used in 3gpp LTE RRC.
When trying to compile the Master Branch 0.9.24 from Mid March, Cygwin fails to compile the asn1c compiler itself.
When downloading an earlier version, it compiled properly under the same target environment.
unber.exe is not neccesary, but I am a bit worried when it fails...
`_xer_whitespace_span' is the offending symbol
---- 8< ----- 8< -----
Making all in asn1c
make[2]: Entering directory /cygdrive/d/code/asn1c/asn1c-master/asn1c' Making all in . make[3]: Entering directory
/cygdrive/d/code/asn1c/asn1c-master/asn1c'
/bin/sh ../libtool --tag=CC --mode=link gcc -DWIN32 -Wall -Wshadow -Wcast-qua
l -Wcast-align -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -
o unber.exe unber.o
libtool: link: gcc -DWIN32 -Wall -Wshadow -Wcast-qual -Wcast-align -Wchar-subscr
ipts -Wmissing-prototypes -Wmissing-declarations -o .libs/unber.exe unber.o
unber.o:unber.c:(.text+0x3d02): undefined reference to _xer_whitespace_span' unber.o:unber.c:(.text+0x3d4c): undefined reference to
_xer_whitespace_span'
collect2: ld returned 1 exit status
make[3]: *** [unber.exe] Error 1
---- 8< ----- 8< -----
Also, the compiler complains about "time.h", but I don't think this will affect much;
---- 8< ----- 8< -----
In file included from /usr/include/sys/stat.h:9,
from sys-common.h:46,
from unber.c:28:
/usr/include/time.h:6:2: warning: #warning time.h from Cygwin...
In file included from /usr/include/sys/select.h:24,
from /usr/include/cygwin/sys_time.h:13,
from /usr/include/sys/time.h:28,
from /usr/include/sys/socket.h:17,
from /usr/include/cygwin/if.h:19,
from /usr/include/asm/socket.h:14,
from /usr/include/cygwin/socket.h:48,
from /usr/include/cygwin/in.h:21,
from /usr/include/netinet/in.h:14,
from ../skeletons/asn_system.h:88,
from ../skeletons/asn_application.h:11,
from unber.c:34:
/usr/include/time.h:6:2: warning: #warning time.h from Cygwin...
In file included from unber.c:41:
../skeletons/asn_codecs_prim.c: In function 'xer_decode__primitive_body':
../skeletons/asn_codecs_prim.c:220: warning: cast discards qualifiers from point
er target type
---- 8< ----- 8< -----
In connection with the time issue above, the make check fails with the following error:
---- 8< ----- 8< -----
In file included from /usr/include/sys/select.h:24,
from /usr/include/cygwin/sys_time.h:13,
from /usr/include/sys/time.h:28,
from /usr/include/sys/socket.h:17,
from /usr/include/cygwin/if.h:19,
from /usr/include/asm/socket.h:14,
from /usr/include/cygwin/socket.h:48,
from /usr/include/cygwin/in.h:21,
from /usr/include/netinet/in.h:14,
from ./asn_system.h:88,
from ./asn_application.h:11,
from ./asn_internal.h:12,
from GeneralizedTime.c:7:
/usr/include/time.h:6:2: warning: #warning time.h from Cygwin...
In file included from GeneralizedTime.c:12:
/usr/include/time.h:6:2: warning: #warning time.h from Cygwin...
GeneralizedTime.c:71:2: warning: #warning "PLEASE STOP AND READ!"
GeneralizedTime.c:72:2: warning: #warning " timegm() is implemented via getenv(
"TZ")/setenv("TZ"), which may be not thread-safe."
GeneralizedTime.c:73:2: warning: #warning " "
GeneralizedTime.c:74:2: warning: #warning " You must fix the code by inserting
appropriate locking"
GeneralizedTime.c:75:2: warning: #warning " if you want to use asn_GT2time() or
asn_UT2time()."
GeneralizedTime.c:76:2: warning: #warning "PLEASE STOP AND READ!"
GeneralizedTime.c: In function 'GMTOFF':
GeneralizedTime.c:87: warning: unused variable 'zone'
GeneralizedTime.c: At top level:
GeneralizedTime.c:132: error: static declaration of 'timegm' follows non-static
declaration
/usr/include/cygwin/time.h:23: error: previous declaration of 'timegm' was here
make[3]: *** [GeneralizedTime.lo] Error 1
make[3]: Leaving directory /cygdrive/d/code/asn1c/asn1c-master/skeletons' make[2]: *** [check-am] Error 2 make[2]: Leaving directory
/cygdrive/d/code/asn1c/asn1c-master/skeletons'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/cygdrive/d/code/asn1c/asn1c-master/skeletons'
make: *** [check-recursive] Error 1
---- 8< ----- 8< -----
Hi, and thanks for the great software!
I just stumbled upon an error I think.
I'm using 0.9.26
around line 738 of INTEGER.c there is a variable declaration. If ASN_DEBUG is used it will break the function I think.
Hi,
I have the rare case of two identical systems of Ubuntu 9.10, but one is x86_64
and the other one is i386. I have a network protocol specified in ASN1 in which
those two boxes should talk to each other. This currently only works when I
compile my program on the 64 bit box using -m32 -arch=i386, but I need native
binaries.
I am using SHA cf6c1e2 which is the commit marked as 0.9.23.
on both systems$ ./configure --prefix=/usr/local && make && sudo make install
So far so good, also checks on 64bit seem to pass:
64bit$ make check
.... lotsa output
===================
All 34 tests passed
===================
make[3]: Leaving directory `/tmp/asn1c_sacane/asn1c/tests'
make[2]: Leaving directory `/tmp/asn1c_sacane/asn1c/tests'
make[1]: Leaving directory `/tmp/asn1c_sacane/asn1c'
make[1]: Entering directory `/tmp/asn1c_sacane'
make[1]: Leaving directory `/tmp/asn1c_sacane'
But 32 bit is not so hot:
32 bit$ make check 2>&1 | tee make_check.txt
.... lotsa output
[<!--blah]:8
chunk sizes: 8 vs 8, chunk types: 2 vs 2
[<!--blah-]:9
chunk sizes: 0 vs 9, chunk types: 2 vs -1
[<!--blah--]:10
chunk sizes: 0 vs 10, chunk types: 2 vs -1
[<!--blah-->]:11
chunk sizes: 11 vs 11, chunk types: 2 vs 2
PASS: check-XER
PASS: check-PER
================================
2 of 11 tests failed
Please report to [email protected]
================================
make[3]: *** [check-TESTS] Error 1
make[3]: Leaving directory `/tmp/asn1c_vlm/skeletons/tests'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/tmp/asn1c_vlm/skeletons/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/tmp/asn1c_vlm/skeletons'
make: *** [check-recursive] Error 1
The complete output of the run on the 32 bit system can be found in this gist:
https://gist.github.com/796703
Can you help me with that? Could this be the problem I see with my
communications?
Kind regards,
Holger
For ex: when in uper mode, a value of 43980465111903 gives out -1 when compiled and linked in 32 bit mode (gcc -m32) or on an embedded box.
the problem is with the asn_per_constraints_t structure being treating the lower bound and upper bounds as 'long' data types than 64 bit generic data types in both machine architectures.
Trying to build asn1c on Windows using latest MinGW + MSYS packages from http://nuwen.net/ , seems there is no mkstemp function in MinGW:
In function `asn1c_open_file':
d:\MyProgram\asn1c-master\libasn1compiler/asn1c_compat.c:46: undefined reference
to `mkstemp'
At https://github.com/vlm/asn1c/blob/master/libasn1compiler/asn1c_C.c#L1778 and 1779, the construct "&& !thing == SOME_CONSTANT". This should be "&& !(thing == SOME_CONSTANT)" as the ! has higher precedence than the ==.
I tried to parse the X2AP (from the TS36.423 Rel11.2). Here is the error output:
ASN.1 grammar parse error near line 421 (token "id-E-RAB-Item"): syntax error, unexpected TOK_identifier, expecting '}'
Cannot parse "X2AP-IEs.asn"
I'm using the asn1c version 0.9.27.
I use the ASN.1 files for GSM MAP from Wireshark sources (I also tested some others) and I always have errors when decoding SendRoutingInfo and InsertSubscriberData. (BER decoder)
I can send the examples if needed.
The version I use is 0.9.27.
echo 'MAMBAQA=' | base64 -d | certlint-x509helper -p BasicConstraints -oder - | openssl asn1parse -inform DER
The structure is defined as
BasicConstraints ::= SEQUENCE {
cA BOOLEAN DEFAULT FALSE,
pathLenConstraint INTEGER (0..MAX) OPTIONAL }
According to DER
11.5 Set and sequence components with default value
The encoding of a set value or sequence value shall not include an encoding for any component value which is equal to its default value.
What is observed is that the DER output contains false, which is the default value. The output in this example should be an empty sequence.
As soon as ASN_THREAD_SAFE and EMIT_ASN_DEBUG=1 is set, asn_debug_indent is defined to '0' in asn_internal.h (line 39). per_opentype.c does not compile anymore in line 21, 104, 106, 156 and 158.
My setup:
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
vlm-asn1c-3d6fcfe.tar.gz
CFLAGS += -DEMIT_ASN_DEBUG=1 -D_REENTRANT
To get my compiler working I replace the asn_debug_indent variable in per_opentype.c with asn_debug_indentX. But I don't know if there are negative side-effect with the generated code now.
At the top of each .c and .h file generated by asn1c, there is a commented line like asn1c -fcompound-names
, ostensibly showing the options used to generate them. This information is slightly misleading, however, since the last option is always missing; running asn1c -fcompound-names -fno-include-deps *.asn
will produce a comment in each file reading asn1c -fcompound-names
.
I know that this issue was already notified some years ago, but somehow it is not opened here and it is not fixed yet. Perhaps it has been missed when the project moved from sourceforge to github.
Function prototype SET_OF_encode_uper() is defined in constr_SET_OF.h
but does not have a implementation in constr_SET_OF.c resulting in an error on linking time.
SET_OF are nearly the same as SEQUENCE_OF excepting by the order of elements, so SEQUENCE_OF_encode_uper implementation could fix this issue, there are some patches over there like this [1] that could also be applied to master branch.
Regards
[1]https://gitorious.org/freerdp/mainline/commit/e4bd3ca5681cf76fa948a9c3a0301df5bbcfa813?format=patch
The included documentation files does not indicate where there aligned PER encoding/decoding is supported by asn1c. My reading of the code, gave me the understanding that aligned PER encoding/decoding is not supported.
In per_support.c : per_data_string()
snprintf(buf[n], sizeof(buf),
should be
snprintf(buf[n], sizeof(buf[n]),
In OCTET_STRING.c : OCTET_STING_free()
Checking "if(!td || !st) return;" after dereferencing td earlier.
I'm trying to encode a structure as PER using uper_encode_to_buffer. However, when it comes to encode the following asn1 structure it fails. If you initialise the BST into a single mandApplications with aid=electronic-fee-collection, no nonmandApplications and no profileList, when I read the PER encoded buffer instead of
0000 0001 (1 application)
0000 0001 (aid = 1)
0000 0000 (no profileList)
I get
0000 0010 (it seems that it's shifted left once)
0000 0010 (it seems that it's shifted left once)
0000 0000
The problem seems to come from the definition of ApplicationList that has a size of up to 127 (7-bit field) and this information is used internally by SEQUENCE_OF_encode_uper from the variable ct->effective_bits that has the value of 7.
Does this mean that the encoding is UNALIGNED when I need ALIGNED?
BST::= SEQUENCE
{ mandApplications ApplicationList,
nonmandApplications ApplicationList OPTIONAL,
profileList ProfileList
}
ProfileList::= SEQUENCE SIZE( 0..127, ...) OF Profile
Profile::= INTEGER( 0..127, ...)
ApplicationList::= SEQUENCE SIZE( 0..127, ...) OF Application
Application::= SEQUENCE
{ aid DSRCApplicationEntityID,
eid Dsrc-EID OPTIONAL,
parameter ApplicationContextMark OPTIONAL
}
Dsrc-EID::= INTEGER( 0..127, ...)
ApplicationContextMark::= Container
DSRCApplicationEntityID::= INTEGER
{ system ( 0),
electronic-fee-collection ( 1),
freight-fleet-management ( 2),
public-transport ( 3),
traffic-traveller-information ( 4),
traffic-control ( 5),
parking-management ( 6),
geographic-road-database ( 7),
medium-range-preinformation ( 8),
man-machine-interface ( 9),
intersystem-interface ( 10),
automatic-vehicle-identification ( 11),
emergency-warning ( 12),
private ( 13),
multi-purpose-payment ( 14),
dsrc-resource-manager ( 15),
after-theft-systems ( 16)
}( 0..31, ...)
Container::= CHOICE
{ integer [0] INTEGER,
bitstring [1] BIT STRING,
octetstring [2] OCTET STRING(SIZE( 0..127)),
univesralString [3] UniversalString,
beaconId [4] BeaconID,
t-apdu [5] T-APDUs,
dsrcApplicationEntityId [6] DSRCApplicationEntityID,
dsrc-Ase-Id [7] Dsrc-EID,
attrIdList [8] AttributeIdList,
attrList [9] AttributeList,
broadcastPool [10] BroadcastPool,
directory [11] Directory,
file [12] File,
fileType [13] OCTET STRING,
record [14] Record,
time [15] Time,
vector [16] SEQUENCE SIZE( 0..255) OF INTEGER( 0..127, ...),
gstrq [17] GetStampedRq,
gstrs [18] GetStampedRs,
sstrq [19] SetStampedRq,
ginrq [20] GetInstanceRq,
ginrs [21] GetInstanceRs,
sinrq [22] SetInstanceRq,
charq [23] ChannelRq,
chars [24] ChannelRs,
cpprq [25] CopyRq,
subrq [26] SubRq,
addrq [27] AddRq,
debrq [28] DebitRq,
debrs [29] DebitRs,
crerq [30] CreditRq,
crers [31] CreditRs,
efccontext [32] EFC-ContextMark,
contser [33] Int4,
contval [34] ContractValidity,
contveh [35] LPN,
contauth [36] ContractAuthenticator,
recspt [37] ReceiptServicePart,
sessioncls [38] SessionClass,
recservserialno [39] Int3,
recfinptENV [40] NULL,
reccont [41] ReceiptContract,
recOBUId [42] ReceiptOBUId,
recICCId [43] ICC-Id,
rectext [44] ReceiptText,
recauth [45] ReceiptAuthenticator,
recdist [46] Int3,
vehlpn [47] LPN,
vehid [48] CS5,
vehclass [49] Int1,
vehdims [50] VehicleDimensions,
vehaxles [51] VehicleAxles,
vehwtlims [52] VehicleWeightLimits,
vehwtladen [53] Int2,
vehspchars [54] VehicleSpecificCharacteristics,
vehauth [55] VehicleAuthenticator,
equOBUId [56] EquipmentOBUId,
equICCId [57] ICC-Id,
equstat [58] EquipmentStatus,
dvrchars [59] DriverCharacteristics,
paymeansENV [60] NULL,
paymbal [61] SignedValue,
paymunit [62] PayUnit,
paysecdata [63] PaymentSecurityData,
paymeans [64] PaymentMeans,
recdata1 [65] ReceiptData,
recdata2 [66] NULL,
valofcon [67] ValidityOfContract,
recfinpt [68] ReceiptFinancialPart,
setmmirq [69] SetMMIRq,
rfuCenISO37 [70] NULL,
rfuCenISO38 [71] NULL,
rfuCenISO39 [72] NULL,
rfuCenISO40 [73] NULL,
rfuCenISO41 [74] NULL,
rfuCenISO42 [75] NULL,
rfuCenISO43 [76] NULL,
rfuCenISO44 [77] NULL,
rfuCenISO45 [78] NULL,
rfuCenISO46 [79] NULL,
rfuCenISO47 [80] NULL,
rfuCenISO48 [81] NULL,
rfuCenISO49 [82] NULL,
rfuCenISO50 [83] NULL,
rfuCenISO51 [84] NULL,
rfuCenISO52 [85] NULL,
rfuCenISO53 [86] NULL,
...
}
I'm working on LPP(3gpp 36.355).I found that UL message contain following structs
-- ASN1START
GNSS-ReferenceLocationSupport ::= SEQUENCE {
...
}
-- ASN1STOP
if variable of GNSS-ReferenceLocationSupport is not null, the encoded PDU using asn1c will be not decode correctly by server.
the encoded PDU using asn1c is :
f001814208781017401c00ba620b80004003319fde
the encoded PDU using other encoder is :
f001814208781017401c00ba620b8000200198cfef
the struct miss 1bit of Extension marks 0
I wonder how to free the memory after using uper_encode_to_new_buffer().
Is it correct to use the FREEMEM macro according to the following code?
int encodeIt()
{
int ret;
void *buf = 0;
SlpSessionID_t *slp;
slp= ...;
ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *) slp, &buf);
if (ret == -1) return -1;
/* do something with buf */
FREEMEM(buf);
/* do it again with another entity */
slp= ...;
ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *) slp, &buf);
if (ret == -1) return -1;
/* do something with buf */
FREEMEM(buf);
return 0;
}
I would appreciate some more complex examples on
http://lionet.info/asn1c/examples.html
and
http://lionet.info/asn1c/asn1c-usage.html#SECTION02300000000000000000
or best one sample for each type in
http://lionet.info/asn1c/asn1c-usage.html#SECTION03000000000000000000
Thank you very much.
Regards Heiko
Hello!
I get those errors while compiling the project (ubuntu 14.04, x64); automake is nice enough to suggest the fix :-)
(...)
automake: warnings are treated as errors
/usr/share/automake-1.14/am/ltlibrary.am: warning: 'libasn1compiler.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
libasn1compiler/Makefile.am:8: while processing Libtool library 'libasn1compiler.la'
/usr/share/automake-1.14/am/ltlibrary.am: warning: 'libasn1fix.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
libasn1fix/Makefile.am:6: while processing Libtool library 'libasn1fix.la'
/usr/share/automake-1.14/am/ltlibrary.am: warning: 'libasn1parser.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
libasn1parser/Makefile.am:6: while processing Libtool library 'libasn1parser.la'
/usr/share/automake-1.14/am/ltlibrary.am: warning: 'libasn1print.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
libasn1print/Makefile.am:7: while processing Libtool library 'libasn1print.la'
/usr/share/automake-1.14/am/ltlibrary.am: warning: 'libasn1cskeletons.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
skeletons/Makefile.am:21: while processing Libtool library 'libasn1cskeletons.la'
(...)
Using ASN.1 from https://anonsvn.wireshark.org/wireshark/trunk/asn1/lte-rrc/EUTRA-RRC-Definitions.asn I generate file for the converter (with -gen-PER and -fcompound-names flags), then build converter sample with:
export PDU=BCCH_DL_SCH_Message; make -f Makefile.am.sample
I try to decode data:
00801c31186fe122e055859ce2d001040054de772cb5509b9858307620dfe93f51ba4f01413ba549200000000000000000
(binary file here: https://www.dropbox.com/s/o13dyoff18y0xnu/bcch-dl-sch.per?dl=0) by executing the resulting progname. I'm getting:
$ ./progname -iper -dd ~/bcch-dl-sch.per
AD: Processing /home/user/bcch-dl-sch.per
AD: Decoding 64 bytes
AD: decode(0) consumed 0+0b (64), code 2
AD: Clean up partially decoded structure
AD: ofp 1, no=0, oo=0, dbl=0
/home/user/bcch-dl-sch.per: Decode failed past byte 0: Input processing error
I investigated it a bit, and it fails in per_get_few_bits(), trying to read from data that has zero bits left. Stack at that point looks like:
(gdb) bt
#0 per_get_few_bits (pd=0x7fffffffd2f0, nbits=1) at per_support.c:117
#1 0x000000000049e3be in SEQUENCE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x7991e0 <asn_DEF_SystemInformationBlockType17_r12>, constraints=0x0, sptr=0x7fffffffd3d0, pd=0x7fffffffd2f0) at constr_SEQUENCE.c:1054
#2 0x00000000004af7e5 in uper_open_type_get_simple (ctx=0x7fffffffdab0, td=0x7991e0 <asn_DEF_SystemInformationBlockType17_r12>, constraints=0x0, sptr=0x7fffffffd3d0, pd=0x7fffffffdad0) at per_opentype.c:103
#3 0x00000000004b0115 in uper_open_type_get (ctx=0x7fffffffdab0, td=0x7991e0 <asn_DEF_SystemInformationBlockType17_r12>, constraints=0x0, sptr=0x7fffffffd3d0, pd=0x7fffffffdad0) at per_opentype.c:248
#4 0x000000000049a75b in CHOICE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x784380 <asn_DEF_Member_3>, constraints=0x0, sptr=0x7fffffffd4b0, pd=0x7fffffffdad0) at constr_CHOICE.c:898
#5 0x00000000004a2f0e in SET_OF_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x784460 <asn_DEF_sib_TypeAndInfo_2>, constraints=0x4c7820 <asn_PER_memb_sib_TypeAndInfo_constr_2>, sptr=0x7fffffffd590, pd=0x7fffffffdad0) at constr_SET_OF.c:925
#6 0x000000000049e774 in SEQUENCE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x784580 <asn_DEF_SystemInformation_r8_IEs>, constraints=0x0, sptr=0x7fffffffd660, pd=0x7fffffffdad0) at constr_SEQUENCE.c:1121
#7 0x000000000049a723 in CHOICE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x783d80 <asn_DEF_criticalExtensions_2>, constraints=0x0, sptr=0x7fffffffd770, pd=0x7fffffffdad0) at constr_CHOICE.c:895
#8 0x000000000049e774 in SEQUENCE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x783e60 <asn_DEF_SystemInformation>, constraints=0x0, sptr=0x7fffffffd840, pd=0x7fffffffdad0) at constr_SEQUENCE.c:1121
#9 0x000000000049a723 in CHOICE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x768440 <asn_DEF_c1_2>, constraints=0x0, sptr=0x7fffffffd8e0, pd=0x7fffffffdad0) at constr_CHOICE.c:895
#10 0x000000000049a723 in CHOICE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x768600 <asn_DEF_BCCH_DL_SCH_MessageType>, constraints=0x0, sptr=0x7fffffffd9f0, pd=0x7fffffffdad0) at constr_CHOICE.c:895
#11 0x000000000049e774 in SEQUENCE_decode_uper (opt_codec_ctx=0x7fffffffdab0, td=0x768320 <asn_DEF_BCCH_DL_SCH_Message>, constraints=0x0, sptr=0x7fffffffdbb8, pd=0x7fffffffdad0) at constr_SEQUENCE.c:1121
#12 0x00000000004aec12 in uper_decode (opt_codec_ctx=0x7fffffffdab0, td=0x768320 <asn_DEF_BCCH_DL_SCH_Message>, sptr=0x7fffffffdbb8, buffer=0x7e2250, size=64, skip_bits=0, unused_bits=0) at per_decoder.c:79
#13 0x00000000004ae994 in uper_decode_complete (opt_codec_ctx=0x0, td=0x768320 <asn_DEF_BCCH_DL_SCH_Message>, sptr=0x7fffffffdbb8, buffer=0x7e2250, size=64) at per_decoder.c:14
#14 0x00000000004b1f30 in data_decode_from_file (pduType=0x768320 <asn_DEF_BCCH_DL_SCH_Message>, file=0x7e2010, name=0x7fffffffe227 "/home/user/bcch-dl-sch.per", suggested_bufsize=8192, on_first_pdu=1) at converter-sample.c:644
#15 0x00000000004b0cdc in main (ac=1, av=0x7fffffffde40) at converter-sample.c:263
So it looks like it tries to decode SIB17, however when I use http://www.marben-products.com/cgi-bin/asn1tools/free-online-asn1-decoder.pl (direct input), I get valid SIB2 and SIB3.
It looks like per_get_few_bits has read only 25 bits out of the 64-bit file. Could you help investigate whether the problem is in asn1c or the EUTRA-RRC-Definitions.asn code?
Just got a core dump while using the generated converter with simple asn1 and xml files, here is the gdb backtrace. It looks like sptr gets out of bound.
#0 0x0804e7b1 in _fetch_present_idx (struct_ptr=0x10004, pres_offset=0, pres_size=4) at constr_CHOICE.c:1085
#1 0x0804e07d in CHOICE_encode_uper (td=0x806e2a0, constraints=0x0, sptr=0x10004, po=0xbf93a634) at constr_CHOICE.c:925
#2 0x08051cc9 in SEQUENCE_encode_uper (td=0x806e5c0, constraints=0x0, sptr=0x80731d4, po=0xbf93a634) at constr_SEQUENCE.c:1396
#3 0x0804e39c in CHOICE_encode_uper (td=0x806ee20, constraints=0x0, sptr=0x80731d0, po=0xbf93a634) at constr_CHOICE.c:972
#4 0x08052ac6 in SEQUENCE_OF_encode_uper (td=0x806eec0, constraints=0x0, sptr=0x807317c, po=0xbf93a634) at constr_SEQUENCE_OF.c:199
#5 0x08051cc9 in SEQUENCE_encode_uper (td=0x806efe0, constraints=0x0, sptr=0x8073178, po=0xbf93a634) at constr_SEQUENCE.c:1396
#6 0x0805fcf6 in uper_encode_internal (td=0x806efe0, constraints=0x0, sptr=0x8073178, cb=0x8056a10 <write_out>, app_key=0xb76904e0)
at per_encoder.c:136
#7 0x0805f922 in uper_encode (td=0x806efe0, sptr=0x8073178, cb=0x8056a10 <write_out>, app_key=0xb76904e0) at per_encoder.c:9
#8 0x0805574f in main (ac=1, av=0xbf93a870) at converter-sample.c:316
running on linux 32 bits, opensuse 2012.2
The asn1 from TS 36.413 does not parse correctly. Specifically, the class definition:
S1AP-PROTOCOL-IES ::= CLASS { &id ProtocolIE-ID UNIQUE, &criticality Criticality, &Value, &presence Presence } WITH SYNTAX { ID &id CRITICALITY &criticality TYPE &Value PRESENCE &presence }
produces the output:
S1AP-PROTOCOL-IES ::= CLASS { &id ProtocolIE-ID UNIQUE, &criticality Criticality, &Value , &presence Presence }RESENCE &presencecality
I am getting an "error redefinition of" though I am using -fcompound-names when compiling the asn sources:
In file included from messages/SystemInformation.h:15:0,
from messages/BCCH-DL-SCH-MessageType.h:15,
from messages/BCCH-DL-SCH-Message.h:15,
from SIBTest.cpp:2:
messages/SystemInformation-r8-IEs.h:66:3: error: redefinition of ‘struct SystemInformation_r8_IEs::SystemInformation_r8_IEs__sib_TypeAndInfo::::SystemInformation_r8_IEs__sib_TypeAndInfo__Member’
messages/SystemInformation-r8-IEs.h:66:3: error: previous definition of ‘struct SystemInformation_r8_IEs::SystemInformation_r8_IEs__sib_TypeAndInfo::::SystemInformation_r8_IEs__sib_TypeAndInfo__Member
There seems to be a problem when the PER decoder hits an unknown element in an extensible type
that was added in a later version of the ASN.1 spec.
This is my sample spec:
SomeModule
DEFINITIONS
AUTOMATIC TAGS ::= BEGIN
CurrentId::= INTEGER (1)
MyMessage ::= SEQUENCE {
id INTEGER(0 .. 255),
msg SomeMessage
}
SomeMessage ::= SEQUENCE {
messageIdentifier INTEGER(0 .. 255),
vehicleType VehicleType,
...
}
VehicleType ::= ENUMERATED{
car (1),
bus (2),
lorry (3),
motorcycle (4),
...
}
END
When I add an enum like so:
VehicleType ::= ENUMERATED{
car (1),
bus (2),
lorry (3),
motorcycle (4),
...,
ship ( 5 )
}
The original decoder aborts with the following error if it encounters an UPER input with the new enum value:
Decoding member vehicleType in SomeMessage (constr_SEQUENCE.c:1120)
Decoding VehicleType as NativeEnumerated (NativeEnumerated.c:95)
Failed to decode element VehicleType (NativeEnumerated.c:119)
Failed decode vehicleType in SomeMessage (constr_SEQUENCE.c:1125)
Failed decode msg in MyMessage (constr_SEQUENCE.c:1125)
Also, when I extend a sequence like so:
SomeMessage ::= SEQUENCE {
messageIdentifier INTEGER(0 .. 255),
vehicleType VehicleType,
...,
someinteger INTEGER(0 .. 128)
}
If the original decoder encounters the new element, it aborts with this:
Decoding member vehicleType in SomeMessage (constr_SEQUENCE.c:1120)
Decoding VehicleType as NativeEnumerated (NativeEnumerated.c:95)
Decoded VehicleType = 4 (NativeEnumerated.c:123)
Getting normally small length (per_support.c:199)
l=1 (per_support.c:204)
Extensions 1 present in SomeMessage (constr_SEQUENCE.c:1145)
Read in extensions bitmap for SomeMessage of 1 bits (80..) (constr_SEQUENCE.c:1158)
Getting overflow extensions (constr_SEQUENCE.c:1198)
Getting open type ... (per_opentype.c:70)
Getting open type encoded in 1 bytes (per_opentype.c:96)
Too large padding 8 in open type (per_opentype.c:119)
Failed to decode element (per_opentype.c:120)
Failed decode msg in MyMessage (constr_SEQUENCE.c:1125)
To my knowledge, the decoder should skip unknown elements.
When I try this with BER encoded data, it works but unfortunately I am stuck with UPER.
It would be great to have access to unknown parts i.e.:
My task is to generate a (probably nonstandard) XER from UPER input.
With access to unknown values I could put them in the XML output as well.
That way, even if my app doesn't know new values the next entity (where the XML is handed to)
might be able to make sense of it.
Are there any chances of getting the decoder fixed?
I took the code from master.
I tested against data generated from here:
http://asn1-playground.oss.com/
Please let me know if I can help with anything.
I'm afraid my knowledge of PER encoding is extremely limited,
which is why I am seeking help here.
I’ve have a problem that the UPER encoder and decoder neither consume nor insert the extension bit for data types with no members except the extension marker.
MyModule DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
MyType ::= SEQUENCE {
...
}
END
I haven’t tested the behavior for any of the other decoders.
[asn1fix_cws.c:55]: (warning) Comparison of a boolean expression with an integer other than 0 or 1
Source code is
LOG((ret < 0),
"Cannot parse %s of CLASS %s found at line %d",
expr->Identifier, eclass->Identifier, expr->_lineno);
Maybe
LOG(ret,
"Cannot parse %s of CLASS %s found at line %d",
expr->Identifier, eclass->Identifier, expr->_lineno);
Using the tests/99-class-sample-OK.asn1 file, we can generate the file 99-class-sample-OK.asn1.-EFprint-class-matrix correctly (option -EF is enough).
But, very surprizing, the generated file can't be compiled because the line:
SampleClassObjectSet SAMPLE-CLASS ::= {
request-Whatever | respond-Stuff | request-Status | request-Salt
}
Become expensed into:
SampleClassObjectSet SAMPLE-CLASS ::= {{ IDENTIFIED BY request-whatever } | { WITH CODE 1 IDENTIFIED BY response-stuff } | { TYPE Samp
leType WITH CODE 2 IDENTIFIED BY request-id } | { TYPE Salt IDENTIFIED BY request-salt }}
That looks also ok, but doesn't compile, producing the error several people noted down on 3GPP standards grammars:
ASN.1 grammar parse error near line 24 (token "BY"): syntax error, unexpected TOK_BY, expecting '}'
Maybe, someone knowing the source code can fix it easily, else I'll try myself
Below is the make log:
make all-recursive
make[1]: Entering directory /home/sandipg/openair/trunk/openair2/RRC/LITE/MESSAGES/asn1c/asn1c' Making all in libasn1parser make[2]: Entering directory
/home/sandipg/openair/trunk/openair2/RRC/LITE/MESSAGES/asn1c/asn1c/libasn1parser'
/bin/bash ../ylwrap asn1p_l.l .c asn1p_l.c -- /bin/bash /home/sandipg/openair/trunk/openair2/RRC/LITE/MESSAGES/asn1c/asn1c/missing --run flex -s -p -Cem -Pasn1p_ -olex.yy.c
%option yylineno entails a performance penalty ONLY on rules that can match newline characters
REJECT entails a large performance penalty
make[2]: *** [asn1p_l.c] Error 1
make[2]: Leaving directory /home/sandipg/openair/trunk/openair2/RRC/LITE/MESSAGES/asn1c/asn1c/libasn1parser' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/home/sandipg/openair/trunk/openair2/RRC/LITE/MESSAGES/asn1c/asn1c'
make: *** [all] Error 2
ASN notation:
testvalue ::= REAL
Origin double: -1204.102;
Encode REAL, see T-REC-X.690-200811 chapter 8.5
Sign: 1
Exponent: -42 (FFFFFFD6)
Mantissa: 5295606600113349 (0012D06872B020C5);
Base: 0
Binary scale factor: 0
BER HEX code: 090EC304FFFFFFD60012D06872B020C5;
in function:
int
asn_REAL2double(const REAL_t st, double *dbl_value)
{
.....
/ Fetch the multibyte exponent /
// elen = 4;
expval = (int)((int8_t *)ptr);
end = ptr + elen + 1;
for(ptr++; ptr < end; ptr++)
expval = (expval * 256) + *ptr;
.......
}
after cycle "for(ptr..." expval equals 0xFFFFD600, but should be 0xFFFFFFD6;
fix:
expval = (int)(*(int8_t *)ptr);
end = ptr + elen;
for(ptr++; ptr < end; ptr++)
expval = (expval * 256) + *ptr;
It seems the wireshark bug 6199 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6199) is present in asn1c, too.
Here my input data:
00801c31186fe0c43846069ce2d001020054ce772cb5509b985818628c5709d6b481413aa519200000
This is an BCCH-DL-SCH-Message according to 3GPP R11. The ASN.1 is here:
https://anonsvn.wireshark.org/wireshark/trunk/asn1/lte-rrc/EUTRA-RRC-Definitions.asn
The web-decoder here (http://www.marben-products.com/asn.1/services/decoder-asn1-lte.html) has no problems with the input.
I did decode the bits manually. The result:
0b100000000001110000110001000110000110111111100000110001000011100001000110000001101001110011100010110100000000000100000010000000000101010011001110011101110010110010110101010100001001101110011000010110000001100001100010100011000101011100001001
110101
10101
1 #PresenceAntennaPort1
01 #neighCellConfig
001 #t-ReselectionEUTRA
0 000001 01 00000100
1110 #4 bits bitmap (0b1110) prefix to the extension addition
10101 00101 00011 00100 10000 00000000 000000000
The output from asn1c:
NativeInteger T-Reselection got value 1 (NativeInteger.c:263)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
[PER got 1<= 1 bits => span 4 +0[4..4]:c0 (0) => 0x0] (per_support.c:114)
Member intraFreqCellReselectionInfo->t-ReselectionEUTRA-SF is optional, p=0 (4->4) (constr_SEQUENCE.c:1102)
Getting normally small length (per_support.c:199)
[PER got 1<=63 bits => span 266 +9[2..64]:81 (62) => 0x0] (per_support.c:114)
[PER got 6<=62 bits => span 272 +9[8..64]:81 (56) => 0x1] (per_support.c:114)
l=2 (per_support.c:204)
Extensions 2 present in SystemInformationBlockType3 (constr_SEQUENCE.c:1145)
[PER got 2<=56 bits => span 274 +10[2..56]:41 (54) => 0x1] (per_support.c:114)
Read in extensions bitmap for SystemInformationBlockType3 of 2 bits (40..) (constr_SEQUENCE.c:1158)
[PER got 1<= 2 bits => span 1 +0[1..2]:40 (1) => 0x0] (per_support.c:114)
[PER got 1<= 1 bits => span 2 +0[2..2]:40 (0) => 0x1] (per_support.c:114)
Decoding member s-IntraSearch-v920 in SystemInformationBlockType3 00000000 (constr_SEQUENCE.c:1186)
Getting open type s-IntraSearch-v920... (per_opentype.c:70)
[PER got 8<=54 bits => span 282 +10[10..56]:41 (46) => 0x4] (per_support.c:114)
[PER got 24<=46 bits => span 306 +11[26..48]:3a (22) => 0xea9464] (per_support.c:114)
[PER got 8<=22 bits => span 314 +14[10..24]:20 (14) => 0x80] (per_support.c:114)
Getting open type s-IntraSearch-v920 encoded in 4 bytes (per_opentype.c:96)
Decoding s-IntraSearch-v920 as SEQUENCE (UPER) (constr_SEQUENCE.c:1050)
Decoding member s-IntraSearchP-r9 in s-IntraSearch-v920 (constr_SEQUENCE.c:1120)
Decoding NativeInteger ReselectionThreshold (UPER) (NativeInteger.c:246)
Integer with range 5 bits (INTEGER.c:601)
[PER got 5<=32 bits => span 5 +0[5..32]:ea (27) => 0x1d] (per_support.c:114)
Got value 29 + low 0 (INTEGER.c:622)
NativeInteger ReselectionThreshold got value 29 (NativeInteger.c:263)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding member s-IntraSearchQ-r9 in s-IntraSearch-v920 (constr_SEQUENCE.c:1120)
Decoding NativeInteger ReselectionThresholdQ-r9 (UPER) (NativeInteger.c:246)
Integer with range 5 bits (INTEGER.c:601)
[PER got 5<=27 bits => span 10 +0[10..32]:ea (22) => 0xa] (per_support.c:114)
Got value 10 + low 0 (INTEGER.c:622)
NativeInteger ReselectionThresholdQ-r9 got value 10 (NativeInteger.c:263)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Too large padding 22 in open type (per_opentype.c:119)
Failed to decode element s-IntraSearch-v920 (per_opentype.c:120)
OCTET_STRING.c: APPEND() macro:
...
/* Be nice and round to the memory allocator */ \
do { _ns = _ns ? _ns << 1 : 16; } \
while(_ns <= _es); \
...
When size requested is already power of two, it performs extra shift which results in double size. So, when data is 2048 bytes, it will allocate 4096 bytes.
This issue becomes very nasty on embedded systems where memory allocator uses pool based implemetation with pools sizes originated from bounded asn.1 definitions.
I got the latest spec of 25331 (C10) Rel 12 and copied it into my directory. After several minutes of successful compiled code, it blows up at:
cc -DJUNKTEST -DPDU=DL_DCCH_Message -DASN_PDU_COLLECTION -I. -o PLMNIdentitiesOfNeighbourCells-v860ext.o -c PLMNIdentitiesOfNeighbourCells-v860ext.c
In file included from PLMNIdentitiesOfNeighbourCells-v860ext.h:42:0,
from PLMNIdentitiesOfNeighbourCells-v860ext.c:8:
MultiplePLMNsOfIntraFreqCellsList.h:28:528: warning: anonymous struct declared inside parameter list [enabled by default]
MultiplePLMNsOfIntraFreqCellsList.h:28:528: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
MultiplePLMNsOfIntraFreqCellsList.h:28:528: warning: ‘struct multiplePLMN_list’ declared inside parameter list [enabled by default]
MultiplePLMNsOfIntraFreqCellsList.h:28:528: warning: ‘struct MultiplePLMNsOfIntraFreqCellsList__Member’ declared inside parameter list [enabled by default]
In file included from PLMNIdentitiesOfNeighbourCells-v860ext.h:43:0,
from PLMNIdentitiesOfNeighbourCells-v860ext.c:8:
MultiplePLMNsOfInterFreqCellsList.h:28:69: error: redefinition of ‘struct multiplePLMN_list’
In file included from PLMNIdentitiesOfNeighbourCells-v860ext.h:42:0,
from PLMNIdentitiesOfNeighbourCells-v860ext.c:8:
MultiplePLMNsOfIntraFreqCellsList.h:28:69: note: originally defined here
In file included from PLMNIdentitiesOfNeighbourCells-v860ext.h:43:0,
from PLMNIdentitiesOfNeighbourCells-v860ext.c:8:
MultiplePLMNsOfInterFreqCellsList.h:28:528: warning: anonymous struct declared inside parameter list [enabled by default]
MultiplePLMNsOfInterFreqCellsList.h:28:528: warning: ‘struct multiplePLMN_list’ declared inside parameter list [enabled by default]
MultiplePLMNsOfInterFreqCellsList.h:28:528: warning: ‘struct MultiplePLMNsOfInterFreqCellsList__Member’ declared inside parameter list [enabled by default]
make: *** [PLMNIdentitiesOfNeighbourCells-v860ext.o] Error 1
I got it compiled by fixing the code, but I just wanted to make it known here.
I have an ASN.1 ISO specification where structures are duplicated within different modules. This causes clashes when I run asn1c even with the -fcompound-names option. I'm requesting an additional option where modules names can be prepended to the structure names as discussed on the sourceforge website:
http://sourceforge.net/p/asn1c/discussion/357921/thread/034be54d/#07ad
Encounter ASN.1 BER encoded files with TLV records seperated by "\xFF" cannot be decoded either by unber or function ber_decode() with error "Fatal error decoding tag at xxxx" and "Decode failed past byte XXX: Input processing error"
The TLV records are packed into 2048 bytes block size with one file containing many 2048 blocks. If each block has remaining space left after packing the TLV records, it wil be filled with "\xFF" before the next block starts. Once the decoder reach this point, it will crash out with the above error meessage.
Is there a way for the ber_decoder() function to skip over this gap fillers and move the next start of record ?
The -flink-skeleton command line option (asn1c.c:112) is neither mentioned in the man-pages, nor in the Usage message (asn1c -h). Is this by intention (and should the option be avoided)?
Somehow all output files (except Makefile.am.sample
) end up being world-writeable when using asn1c
on Linux.
I am developing for a space constrained system and I only want support for BER parsing. Is there a way to accomplish this with the asn1c generator?
When using asn1c to check a SubjectAltName PDU (as defined in RFC3280/5280), given the input string of {0x30,0x00} as DER, it returns no errors. However the syntax is defined as:
SubjectAltName ::= GeneralNames
GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
GeneralName ::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER }
It seems like that input should not be valid.
I'm trying to compile asn1c on Ubuntu 12.04.3 and 5 of 36 tests fail.
We've encountered a bug in the decoding of tag definitions of the type SEQUENCE OF INTEGER, where a context ID is given for the integer... Provided below is an example of such an anonymous repeating integer;
BugReport DEFINITIONS IMPLICIT TAGS ::=
BEGIN
BuggyExample ::= [0] SEQUENCE {
regularInteger [0] INTEGER OPTIONAL,
buggySequence [1] SEQUENCE OF [0] INTEGER OPTIONAL
}
END
An example payload encoded according to this for this would be A0 0E 80 01 7F A1 09 80 01 01 80 01 02 80 01 03
.
I've managed to track down where I believe the issues are, and part of it is in the constr_SET_OF.c skeleton code. That it on the SET_OF I assume is because it's a "simplified" sequence of only a single element type, so that part seems plausible.
Line 208 in the current master branch reads:
rval = elm->type->ber_decoder(opt_codec_ctx,
elm->type, &ctx->ptr, ptr, LEFT, 0);
The last parameter in this should most likely be altered to elm->tag_mode
, as to not always state tag_mode to be 0.
In addition in the generated asn_TYPE_member_t
definition for the buggySequence members gives that tag_mode for the anonymous integer is +1, whereas the generated code for the regularInteger states that tag_mode is -1. I would be assuming that they should be the same, as they are both defined as [0] INTEGER.
Now, my assumptions may be entirely whack, as I've only had quite short time debugging and understanding what's happening, but changing the above listed "oddities" (which would have to be done manually each time the code is regenerated) made sure that everything decoded properly.
See https://sourceforge.net/projects/asn1c/forums/forum/357921/topic/5450713:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.