Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
725883b2
Commit
725883b2
authored
Oct 09, 2006
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more PER support
parent
7cbbc906
Changes
62
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
62 changed files
with
1752 additions
and
348 deletions
+1752
-348
ChangeLog
ChangeLog
+6
-1
asn1c/tests/Makefile.am
asn1c/tests/Makefile.am
+2
-1
asn1c/tests/Makefile.in
asn1c/tests/Makefile.in
+2
-1
asn1c/tests/check-119.-fnative-types.-gen-PER.c
asn1c/tests/check-119.-fnative-types.-gen-PER.c
+363
-0
asn1c/tests/check-119.-gen-PER.c
asn1c/tests/check-119.-gen-PER.c
+363
-0
asn1c/tests/check-70.c
asn1c/tests/check-70.c
+1
-1
asn1c/tests/data-119/README
asn1c/tests/data-119/README
+13
-0
asn1c/tests/data-119/data-119-01.in
asn1c/tests/data-119/data-119-01.in
+3
-0
asn1c/tests/data-119/data-119-02.in
asn1c/tests/data-119/data-119-02.in
+3
-0
asn1c/tests/data-119/data-119-03.in
asn1c/tests/data-119/data-119-03.in
+3
-0
asn1c/tests/data-119/data-119-04-P.in
asn1c/tests/data-119/data-119-04-P.in
+3
-0
asn1c/tests/data-119/data-119-05.in
asn1c/tests/data-119/data-119-05.in
+4
-0
asn1c/tests/data-119/data-119-06-P.in
asn1c/tests/data-119/data-119-06-P.in
+3
-0
asn1c/tests/data-119/data-119-07-P.in
asn1c/tests/data-119/data-119-07-P.in
+3
-0
asn1c/tests/data-119/data-119-08.in
asn1c/tests/data-119/data-119-08.in
+4
-0
asn1c/tests/data-119/data-119-09.in
asn1c/tests/data-119/data-119-09.in
+8
-0
asn1c/tests/data-119/data-119-10.in
asn1c/tests/data-119/data-119-10.in
+9
-0
asn1c/tests/data-119/data-119-11-P.in
asn1c/tests/data-119/data-119-11-P.in
+3
-0
asn1c/tests/data-119/data-119-12-P.in
asn1c/tests/data-119/data-119-12-P.in
+3
-0
asn1c/tests/data-119/data-119-13-P.in
asn1c/tests/data-119/data-119-13-P.in
+3
-0
asn1c/tests/data-119/data-119-14-P.in
asn1c/tests/data-119/data-119-14-P.in
+3
-0
asn1c/tests/data-119/data-119-15.in
asn1c/tests/data-119/data-119-15.in
+3
-0
asn1c/tests/data-119/data-119-16.in
asn1c/tests/data-119/data-119-16.in
+3
-0
asn1c/tests/data-119/data-119-17.in
asn1c/tests/data-119/data-119-17.in
+3
-0
asn1c/tests/data-70/README
asn1c/tests/data-70/README
+2
-2
asn1c/unber.c
asn1c/unber.c
+4
-0
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+115
-62
libasn1compiler/asn1c_constraint.c
libasn1compiler/asn1c_constraint.c
+4
-1
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+2
-1
libasn1compiler/asn1c_out.h
libasn1compiler/asn1c_out.h
+2
-1
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+3
-1
libasn1fix/asn1fix_constr.c
libasn1fix/asn1fix_constr.c
+4
-0
libasn1parser/asn1p_expr.h
libasn1parser/asn1p_expr.h
+4
-3
skeletons/GeneralString.c
skeletons/GeneralString.c
+2
-1
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+8
-2
skeletons/GraphicString.c
skeletons/GraphicString.c
+2
-1
skeletons/IA5String.c
skeletons/IA5String.c
+8
-2
skeletons/ISO646String.c
skeletons/ISO646String.c
+8
-3
skeletons/NativeReal.c
skeletons/NativeReal.c
+71
-2
skeletons/NativeReal.h
skeletons/NativeReal.h
+3
-1
skeletons/NumericString.c
skeletons/NumericString.c
+29
-3
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+3
-1
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+151
-19
skeletons/ObjectDescriptor.c
skeletons/ObjectDescriptor.c
+2
-1
skeletons/PrintableString.c
skeletons/PrintableString.c
+39
-25
skeletons/REAL.c
skeletons/REAL.c
+18
-2
skeletons/REAL.h
skeletons/REAL.h
+2
-0
skeletons/RELATIVE-OID.c
skeletons/RELATIVE-OID.c
+3
-1
skeletons/T61String.c
skeletons/T61String.c
+2
-1
skeletons/TeletexString.c
skeletons/TeletexString.c
+2
-1
skeletons/UTCTime.c
skeletons/UTCTime.c
+8
-2
skeletons/UTF8String.c
skeletons/UTF8String.c
+2
-1
skeletons/VideotexString.c
skeletons/VideotexString.c
+2
-1
skeletons/VisibleString.c
skeletons/VisibleString.c
+9
-3
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+1
-1
skeletons/per_support.h
skeletons/per_support.h
+2
-0
skeletons/tests/check-OIDs.c
skeletons/tests/check-OIDs.c
+4
-0
skeletons/tests/check-REAL.c
skeletons/tests/check-REAL.c
+4
-0
tests/119-per-strings-OK.asn1
tests/119-per-strings-OK.asn1
+38
-0
tests/50-constraint-OK.asn1.-Pgen-PER
tests/50-constraint-OK.asn1.-Pgen-PER
+233
-122
tests/90-cond-int-type-OK.asn1.-Pgen-PER
tests/90-cond-int-type-OK.asn1.-Pgen-PER
+120
-60
tests/95-choice-per-order-OK.asn1.-Pgen-PER
tests/95-choice-per-order-OK.asn1.-Pgen-PER
+22
-17
No files found.
ChangeLog
View file @
725883b2
0.9.22: 2006-
Sep-22
0.9.22: 2006-
Oct-08
* Added -pdu=all and -pdu=<type> switches to asn1c.
* Added PER support for most known-multiplier string types:
IA5String, VisibleString, PrintableString;
useful types: GeneralizedTime, UTCTime, ObjectDescriptor;
as well as REAL and OBJECT IDENTIFIER.
TODO: SET, UniversalString and BMPString.
0.9.21: 2006-Sep-17
...
...
asn1c/tests/Makefile.am
View file @
725883b2
...
...
@@ -11,7 +11,8 @@ EXTRA_DIST = \
$(check_SCRIPTS)
\
check-
*
.c
*
\
data-62
\
data-70
data-70
\
data-119
dist-hook
:
rm
-rf
`
find
$(distdir)
-name
CVS
-or
-name
.cvsignore
`
...
...
asn1c/tests/Makefile.in
View file @
725883b2
...
...
@@ -165,7 +165,8 @@ EXTRA_DIST = \
$(check_SCRIPTS)
\
check-
*
.c
*
\
data-62
\
data-70
data-70
\
data-119
all
:
all-am
...
...
asn1c/tests/check-119.-fnative-types.-gen-PER.c
0 → 100644
View file @
725883b2
/*
* Mode of operation:
* Each of the *.in files is XER-decoded, then converted into DER,
* then decoded from DER and encoded into XER again. The resulting
* stream is compared with the corresponding .out file.
*/
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
/* for chdir(2) */
#include <string.h>
#include <dirent.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <PDU.h>
enum
expectation
{
EXP_OK
,
/* Encoding/decoding must succeed */
EXP_CXER_EXACT
,
/* Encoding/decoding using CXER must be exact */
EXP_CXER_DIFF
,
/* Encoding/decoding using CXER must be different */
EXP_BROKEN
,
/* Decoding must fail */
EXP_DIFFERENT
,
/* Reconstruction will yield different encoding */
EXP_PER_NOCOMP
,
/* Not PER compatible */
};
static
unsigned
char
buf
[
4096
];
static
int
buf_offset
;
static
int
_buf_writer
(
const
void
*
buffer
,
size_t
size
,
void
*
app_key
)
{
unsigned
char
*
b
,
*
bend
;
(
void
)
app_key
;
assert
(
buf_offset
+
size
<
sizeof
(
buf
));
memcpy
(
buf
+
buf_offset
,
buffer
,
size
);
b
=
buf
+
buf_offset
;
bend
=
b
+
size
;
fprintf
(
stderr
,
"=> ["
);
for
(;
b
<
bend
;
b
++
)
{
if
(
*
b
>=
32
&&
*
b
<
127
&&
*
b
!=
'%'
)
fprintf
(
stderr
,
"%c"
,
*
b
);
else
fprintf
(
stderr
,
"%%%02x"
,
*
b
);
}
fprintf
(
stderr
,
"]:%ld
\n
"
,
(
long
)
size
);
buf_offset
+=
size
;
return
0
;
}
enum
enctype
{
AS_PER
,
AS_DER
,
AS_XER
,
AS_CXER
,
};
static
void
save_object_as
(
PDU_t
*
st
,
enum
expectation
exp
,
enum
enctype
how
)
{
asn_enc_rval_t
rval
;
/* Return value */
buf_offset
=
0
;
/*
* Save object using specified method.
*/
switch
(
how
)
{
case
AS_PER
:
rval
=
uper_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
if
(
exp
==
EXP_PER_NOCOMP
)
assert
(
rval
.
encoded
==
-
1
);
else
assert
(
rval
.
encoded
>
0
);
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
return
;
case
AS_DER
:
rval
=
der_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
break
;
case
AS_XER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_BASIC
,
_buf_writer
,
0
);
break
;
case
AS_CXER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_CANONICAL
,
_buf_writer
,
0
);
break
;
}
if
(
rval
.
encoded
==
-
1
)
{
fprintf
(
stderr
,
"Cannot encode %s: %s
\n
"
,
rval
.
failed_type
->
name
,
strerror
(
errno
));
assert
(
rval
.
encoded
!=
-
1
);
return
;
}
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
}
static
PDU_t
*
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
int
size
,
enum
enctype
how
)
{
asn_dec_rval_t
rval
;
PDU_t
*
st
=
0
;
int
csize
=
1
;
if
(
getenv
(
"INITIAL_CHUNK_SIZE"
))
csize
=
atoi
(
getenv
(
"INITIAL_CHUNK_SIZE"
));
/* Perform multiple iterations with multiple chunks sizes */
for
(;
csize
<
20
;
csize
+=
1
)
{
int
fbuf_offset
=
0
;
int
fbuf_left
=
size
;
int
fbuf_chunk
=
csize
;
fprintf
(
stderr
,
"LOADING OBJECT OF SIZE %d FROM [%s] as %s,"
" chunks %d
\n
"
,
size
,
fname
,
how
==
AS_PER
?
"PER"
:
"XER"
,
csize
);
if
(
st
)
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
st
=
0
;
do
{
fprintf
(
stderr
,
"Decoding bytes %d..%d (left %d)
\n
"
,
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
,
fbuf_left
);
if
(
st
)
{
fprintf
(
stderr
,
"=== currently ===
\n
"
);
asn_fprint
(
stderr
,
&
asn_DEF_PDU
,
st
);
fprintf
(
stderr
,
"=== end ===
\n
"
);
}
switch
(
how
)
{
case
AS_XER
:
rval
=
xer_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
);
break
;
case
AS_PER
:
rval
=
uper_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
,
0
,
0
);
if
(
rval
.
code
==
RC_WMORE
)
{
rval
.
consumed
=
0
;
/* Not restartable */
ASN_STRUCT_FREE
(
asn_DEF_PDU
,
st
);
st
=
0
;
fprintf
(
stderr
,
"-> PER wants more
\n
"
);
}
else
{
fprintf
(
stderr
,
"-> PER ret %d/%d
\n
"
,
rval
.
code
,
rval
.
consumed
);
/* uper_decode() returns _bits_ */
rval
.
consumed
+=
7
;
rval
.
consumed
/=
8
;
}
break
;
}
fbuf_offset
+=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
if
(
rval
.
code
==
RC_WMORE
)
fbuf_chunk
+=
1
;
/* Give little more */
else
fbuf_chunk
=
csize
;
/* Back off */
}
while
(
fbuf_left
&&
rval
.
code
==
RC_WMORE
);
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_PER
)
{
fprintf
(
stderr
,
"[left %d, off %d, size %d]
\n
"
,
fbuf_left
,
fbuf_offset
,
size
);
assert
(
fbuf_offset
==
size
);
}
else
{
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
}
}
else
{
assert
(
rval
.
code
!=
RC_OK
);
fprintf
(
stderr
,
"Failed, but this was expected
\n
"
);
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
st
=
0
;
/* ignore leak for now */
}
}
if
(
st
)
asn_fprint
(
stderr
,
&
asn_DEF_PDU
,
st
);
return
st
;
}
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
if
((
osize
&&
!
nsize
)
||
(
!
osize
&&
nsize
))
return
0
;
/* not equal apriori */
while
(
1
)
{
while
(
obuf
<
oend
&&
isspace
(
*
obuf
))
obuf
++
;
while
(
nbuf
<
nend
&&
isspace
(
*
nbuf
))
nbuf
++
;
if
(
obuf
==
oend
||
nbuf
==
nend
)
{
if
(
obuf
==
oend
&&
nbuf
==
nend
)
break
;
fprintf
(
stderr
,
"%s data in reconstructed encoding
\n
"
,
(
obuf
==
oend
)
?
"More"
:
"Less"
);
return
0
;
}
if
(
*
obuf
!=
*
nbuf
)
{
printf
(
"%c%c != %c%c
\n
"
,
obuf
[
0
],
obuf
[
1
],
nbuf
[
0
],
nbuf
[
1
]);
return
0
;
}
obuf
++
,
nbuf
++
;
}
return
1
;
}
static
void
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
int
size
)
{
PDU_t
*
st
;
int
ret
;
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
if
(
!
st
)
return
;
/* Save and re-load as DER */
save_object_as
(
st
,
expectation
,
AS_PER
);
if
(
expectation
==
EXP_PER_NOCOMP
)
return
;
/* Already checked */
st
=
load_object_from
(
"buffer"
,
expectation
,
buf
,
buf_offset
,
AS_PER
);
assert
(
st
);
save_object_as
(
st
,
expectation
,
(
expectation
==
EXP_CXER_EXACT
||
expectation
==
EXP_CXER_DIFF
)
?
AS_CXER
:
AS_XER
);
fprintf
(
stderr
,
"=== original ===
\n
"
);
fwrite
(
fbuf
,
1
,
size
,
stderr
);
fprintf
(
stderr
,
"=== re-encoded ===
\n
"
);
fwrite
(
buf
,
1
,
buf_offset
,
stderr
);
fprintf
(
stderr
,
"=== end ===
\n
"
);
switch
(
expectation
)
{
case
EXP_DIFFERENT
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
case
EXP_BROKEN
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
case
EXP_CXER_EXACT
:
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
==
buf_offset
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
break
;
case
EXP_CXER_DIFF
:
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
!=
buf_offset
||
memcmp
(
fbuf
,
buf
,
size
));
break
;
case
EXP_OK
:
case
EXP_PER_NOCOMP
:
assert
(
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
}
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
}
/*
* Decode the .der files and try to regenerate them.
*/
static
int
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
int
ret
;
int
rd
;
FILE
*
fp
;
if
(
ext
==
0
||
strcmp
(
ext
,
".in"
))
return
0
;
switch
(
ext
[
-
1
])
{
case
'B'
:
/* The file is intentionally broken */
expectation
=
EXP_BROKEN
;
break
;
case
'D'
:
/* Reconstructing should yield different data */
expectation
=
EXP_DIFFERENT
;
break
;
case
'E'
:
/* Byte to byte exact reconstruction */
expectation
=
EXP_CXER_EXACT
;
break
;
case
'X'
:
/* Should fail byte-to-byte comparison */
expectation
=
EXP_CXER_DIFF
;
break
;
case
'P'
:
/* Incompatible with PER */
expectation
=
EXP_PER_NOCOMP
;
break
;
default:
expectation
=
EXP_OK
;
break
;
}
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
ret
=
chdir
(
"../data-119"
);
assert
(
ret
==
0
);
fp
=
fopen
(
fname
,
"r"
);
ret
=
chdir
(
"../test-check-119.-gen-PER"
);
assert
(
ret
==
0
);
assert
(
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
fprintf
(
stderr
,
"Finished [%s]
\n
"
,
fname
);
return
1
;
}
int
main
()
{
DIR
*
dir
;
struct
dirent
*
dent
;
int
processed_files
=
0
;
char
*
str
;
/* Process a specific test file */
str
=
getenv
(
"DATA_119_FILE"
);
if
(
str
&&
strncmp
(
str
,
"data-119-"
,
9
)
==
0
)
{
process
(
str
);
return
0
;
}
dir
=
opendir
(
"../data-119"
);
assert
(
dir
);
/*
* Process each file in that directory.
*/
while
((
dent
=
readdir
(
dir
)))
{
if
(
strncmp
(
dent
->
d_name
,
"data-119-"
,
9
)
==
0
)
if
(
process
(
dent
->
d_name
))
processed_files
++
;
}
assert
(
processed_files
);
closedir
(
dir
);
return
0
;
}
asn1c/tests/check-119.-gen-PER.c
0 → 100644
View file @
725883b2
/*
* Mode of operation:
* Each of the *.in files is XER-decoded, then converted into DER,
* then decoded from DER and encoded into XER again. The resulting
* stream is compared with the corresponding .out file.
*/
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
/* for chdir(2) */
#include <string.h>
#include <dirent.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <PDU.h>
enum
expectation
{
EXP_OK
,
/* Encoding/decoding must succeed */
EXP_CXER_EXACT
,
/* Encoding/decoding using CXER must be exact */
EXP_CXER_DIFF
,
/* Encoding/decoding using CXER must be different */
EXP_BROKEN
,
/* Decoding must fail */
EXP_DIFFERENT
,
/* Reconstruction will yield different encoding */
EXP_PER_NOCOMP
,
/* Not PER compatible */
};
static
unsigned
char
buf
[
4096
];
static
int
buf_offset
;
static
int
_buf_writer
(
const
void
*
buffer
,
size_t
size
,
void
*
app_key
)
{
unsigned
char
*
b
,
*
bend
;
(
void
)
app_key
;
assert
(
buf_offset
+
size
<
sizeof
(
buf
));
memcpy
(
buf
+
buf_offset
,
buffer
,
size
);
b
=
buf
+
buf_offset
;
bend
=
b
+
size
;
fprintf
(
stderr
,
"=> ["
);
for
(;
b
<
bend
;
b
++
)
{
if
(
*
b
>=
32
&&
*
b
<
127
&&
*
b
!=
'%'
)
fprintf
(
stderr
,
"%c"
,
*
b
);
else
fprintf
(
stderr
,
"%%%02x"
,
*
b
);
}
fprintf
(
stderr
,
"]:%ld
\n
"
,
(
long
)
size
);
buf_offset
+=
size
;
return
0
;
}
enum
enctype
{
AS_PER
,
AS_DER
,
AS_XER
,
AS_CXER
,
};
static
void
save_object_as
(
PDU_t
*
st
,
enum
expectation
exp
,
enum
enctype
how
)
{
asn_enc_rval_t
rval
;
/* Return value */
buf_offset
=
0
;
/*
* Save object using specified method.
*/
switch
(
how
)
{
case
AS_PER
:
rval
=
uper_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
if
(
exp
==
EXP_PER_NOCOMP
)
assert
(
rval
.
encoded
==
-
1
);
else
assert
(
rval
.
encoded
>
0
);
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
return
;
case
AS_DER
:
rval
=
der_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
break
;
case
AS_XER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_BASIC
,
_buf_writer
,
0
);
break
;
case
AS_CXER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_CANONICAL
,
_buf_writer
,
0
);
break
;
}
if
(
rval
.
encoded
==
-
1
)
{
fprintf
(
stderr
,
"Cannot encode %s: %s
\n
"
,
rval
.
failed_type
->
name
,
strerror
(
errno
));
assert
(
rval
.
encoded
!=
-
1
);
return
;
}
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
}
static
PDU_t
*
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
int
size
,
enum
enctype
how
)
{
asn_dec_rval_t
rval
;
PDU_t
*
st
=
0
;
int
csize
=
1
;
if
(
getenv
(
"INITIAL_CHUNK_SIZE"
))
csize
=
atoi
(
getenv
(
"INITIAL_CHUNK_SIZE"
));
/* Perform multiple iterations with multiple chunks sizes */
for
(;
csize
<
20
;
csize
+=
1
)
{
int
fbuf_offset
=
0
;
int
fbuf_left
=
size
;
int
fbuf_chunk
=
csize
;
fprintf
(
stderr
,
"LOADING OBJECT OF SIZE %d FROM [%s] as %s,"
" chunks %d
\n
"
,
size
,
fname
,
how
==
AS_PER
?
"PER"
:
"XER"
,
csize
);
if
(
st
)
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
st
=
0
;
do
{
fprintf
(
stderr
,
"Decoding bytes %d..%d (left %d)
\n
"
,
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
,
fbuf_left
);
if
(
st
)
{
fprintf
(
stderr
,
"=== currently ===
\n
"
);
asn_fprint
(
stderr
,
&
asn_DEF_PDU
,
st
);
fprintf
(
stderr
,
"=== end ===
\n
"
);
}
switch
(
how
)
{
case
AS_XER
:
rval
=
xer_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
);
break
;
case
AS_PER
:
rval
=
uper_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
,
0
,
0
);
if
(
rval
.
code
==
RC_WMORE
)
{
rval
.
consumed
=
0
;
/* Not restartable */
ASN_STRUCT_FREE
(
asn_DEF_PDU
,
st
);
st
=
0
;
fprintf
(
stderr
,
"-> PER wants more
\n
"
);
}
else
{
fprintf
(
stderr
,
"-> PER ret %d/%d
\n
"
,
rval
.
code
,
rval
.
consumed
);
/* uper_decode() returns _bits_ */
rval
.
consumed
+=
7
;
rval
.
consumed
/=
8
;
}
break
;
}
fbuf_offset
+=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
if
(
rval
.
code
==
RC_WMORE
)
fbuf_chunk
+=
1
;
/* Give little more */
else
fbuf_chunk
=
csize
;
/* Back off */
}
while
(
fbuf_left
&&
rval
.
code
==
RC_WMORE
);
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_PER
)
{
fprintf
(
stderr
,
"[left %d, off %d, size %d]
\n
"
,
fbuf_left
,
fbuf_offset
,
size
);
assert
(
fbuf_offset
==
size
);
}
else
{
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
}
}
else
{
assert
(
rval
.
code
!=
RC_OK
);
fprintf
(
stderr
,
"Failed, but this was expected
\n
"
);
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
st
=
0
;
/* ignore leak for now */
}
}
if
(
st
)
asn_fprint
(
stderr
,
&
asn_DEF_PDU
,
st
);
return
st
;
}
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
if
((
osize
&&
!
nsize
)
||
(
!
osize
&&
nsize
))
return
0
;
/* not equal apriori */
while
(
1
)
{
while
(
obuf
<
oend
&&
isspace
(
*
obuf
))
obuf
++
;
while
(
nbuf
<
nend
&&
isspace
(
*
nbuf
))
nbuf
++
;
if
(
obuf
==
oend
||
nbuf
==
nend
)
{
if
(
obuf
==
oend
&&
nbuf
==
nend
)
break
;
fprintf
(
stderr
,
"%s data in reconstructed encoding
\n
"
,
(
obuf
==
oend
)
?
"More"
:
"Less"
);
return
0
;
}
if
(
*
obuf
!=
*
nbuf
)
{
printf
(
"%c%c != %c%c
\n
"
,
obuf
[
0
],
obuf
[
1
],
nbuf
[
0
],
nbuf
[
1
]);
return
0
;
}
obuf
++
,
nbuf
++
;
}
return
1
;
}
static
void
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
int
size
)
{
PDU_t
*
st
;
int
ret
;
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
if
(
!
st
)
return
;
/* Save and re-load as DER */
save_object_as
(
st
,
expectation
,
AS_PER
);
if
(
expectation
==
EXP_PER_NOCOMP
)
return
;
/* Already checked */
st
=
load_object_from
(
"buffer"
,
expectation
,
buf
,
buf_offset
,
AS_PER
);
assert
(
st
);
save_object_as
(
st
,
expectation
,
(
expectation
==
EXP_CXER_EXACT
||
expectation
==
EXP_CXER_DIFF
)
?
AS_CXER
:
AS_XER
);
fprintf
(
stderr
,
"=== original ===
\n
"
);
fwrite
(
fbuf
,
1
,
size
,
stderr
);
fprintf
(
stderr
,
"=== re-encoded ===
\n
"
);
fwrite
(
buf
,
1
,
buf_offset
,
stderr
);
fprintf
(
stderr
,
"=== end ===
\n
"
);
switch
(
expectation
)
{
case
EXP_DIFFERENT
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
case
EXP_BROKEN
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
case
EXP_CXER_EXACT
:
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
==
buf_offset
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
break
;
case
EXP_CXER_DIFF
:
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
!=
buf_offset
||
memcmp
(
fbuf
,
buf
,
size
));
break
;
case
EXP_OK
:
case
EXP_PER_NOCOMP
:
assert
(
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
break
;
}
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
}
/*
* Decode the .der files and try to regenerate them.
*/
static
int
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
int
ret
;
int
rd
;
FILE
*
fp
;
if
(
ext
==
0
||
strcmp
(
ext
,
".in"
))
return
0
;
switch
(
ext
[
-
1
])
{
case
'B'
:
/* The file is intentionally broken */
expectation
=
EXP_BROKEN
;
break
;
case
'D'
:
/* Reconstructing should yield different data */
expectation
=
EXP_DIFFERENT
;
break
;
case
'E'
:
/* Byte to byte exact reconstruction */
expectation
=
EXP_CXER_EXACT
;
break
;
case
'X'
:
/* Should fail byte-to-byte comparison */
expectation
=
EXP_CXER_DIFF
;
break
;
case
'P'
:
/* Incompatible with PER */
expectation
=
EXP_PER_NOCOMP
;
break
;
default:
expectation
=
EXP_OK
;
break
;
}
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
ret
=
chdir
(
"../data-119"
);
assert
(
ret
==
0
);
fp
=
fopen
(
fname
,
"r"
);
ret
=
chdir
(
"../test-check-119.-gen-PER"
);
assert
(
ret
==
0
);
assert
(
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
fprintf
(
stderr
,
"Finished [%s]
\n
"
,
fname
);
return
1
;
}
int
main
()
{
DIR
*
dir
;
struct
dirent
*
dent
;
int
processed_files
=
0
;
char
*
str
;
/* Process a specific test file */
str
=
getenv
(
"DATA_119_FILE"
);
if
(
str
&&
strncmp
(
str
,
"data-119-"
,
9
)
==
0
)
{
process
(
str
);
return
0
;
}
dir
=
opendir
(
"../data-119"
);
assert
(
dir
);
/*
* Process each file in that directory.
*/
while
((
dent
=
readdir
(
dir
)))
{
if
(
strncmp
(
dent
->
d_name
,
"data-119-"
,
9
)
==
0
)
if
(
process
(
dent
->
d_name
))
processed_files
++
;
}
assert
(
processed_files
);
closedir
(
dir
);
return
0
;
}
asn1c/tests/check-70.c
View file @
725883b2
...
...
@@ -40,7 +40,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
if
(
*
b
>=
32
&&
*
b
<
127
&&
*
b
!=
'%'
)
fprintf
(
stderr
,
"%c"
,
*
b
);
else
fprintf
(
stderr
,
"%%02x"
,
*
b
);
fprintf
(
stderr
,
"%%
%
02x"
,
*
b
);
}
fprintf
(
stderr
,
"]:%ld
\n
"
,
(
long
)
size
);
buf_offset
+=
size
;
...
...
asn1c/tests/data-119/README
0 → 100644
View file @
725883b2
Mode of operation:
Each of the *.in files is XER-decoded, then converted into PER,
then decoded back from PER, then encoded into XER again,
and finally compared to the original encoding.
Naming conventions:
*-B.in - The file is intentionally broken
*-P.in - Is not PER compatible, PER encoding must fail.
*-E.in - CXER reconstruction should yield byte-wise identical data.
Otherwise, a reconstructed buffer should loosely match the original.
asn1c/tests/data-119/data-119-01.in
0 → 100644
View file @
725883b2
<PDU>
<ns></ns>
</PDU>
asn1c/tests/data-119/data-119-02.in
0 → 100644
View file @
725883b2
<PDU>
<ns>0123456789</ns>
</PDU>
asn1c/tests/data-119/data-119-03.in
0 → 100644
View file @
725883b2
<PDU>
<ns> </ns>
</PDU>
asn1c/tests/data-119/data-119-04-P.in
0 → 100644
View file @
725883b2
<PDU>
<ns>z</ns>
</PDU>
asn1c/tests/data-119/data-119-05.in
0 → 100644
View file @
725883b2
<PDU>
<ia5>yabloko</ia5>
<vs>yabloko</vs>
</PDU>
asn1c/tests/data-119/data-119-06-P.in
0 → 100644
View file @
725883b2
<PDU>
<ia5></ia5>
</PDU>
asn1c/tests/data-119/data-119-07-P.in
0 → 100644
View file @
725883b2
<PDU>
<ia5-c>non-capitals</ia5-c>
</PDU>
asn1c/tests/data-119/data-119-08.in
0 → 100644
View file @
725883b2
<PDU>
<ia5-c>CAPITALS</ia5-c>
<vs-c>CAPITALS</vs-c>
</PDU>
asn1c/tests/data-119/data-119-09.in
0 → 100644
View file @
725883b2
<PDU>
<ia5></ia5>
<ia5-c></ia5-c>
<ia5-ce></ia5-ce>
<vs></vs>
<vs-c></vs-c>
<vs-ce></vs-ce>
</PDU>
asn1c/tests/data-119/data-119-10.in
0 → 100644
View file @
725883b2
<PDU>
<ia5-ir>BAZ</ia5-ir>
<vs-ir>BAZ</vs-ir>
<pr-ir>BAZ</pr-ir>
<ns-ir>19</ns-ir>
<ut-c>Do not respect SIZE constraint</ut-c>
<ut-ce>Do not respect SIZE constraint</ut-ce>
<ut-ir>ABCabc</ut-ir>
</PDU>
asn1c/tests/data-119/data-119-11-P.in
0 → 100644
View file @
725883b2
<PDU>
<ia5-ir>FAIL</ia5-ir>
</PDU>
asn1c/tests/data-119/data-119-12-P.in
0 → 100644
View file @
725883b2
<PDU>
<vs-ir>FAIL</vs-ir>
</PDU>
asn1c/tests/data-119/data-119-13-P.in
0 → 100644
View file @
725883b2
<PDU>
<pr-ir>FAIL</pr-ir>
</PDU>
asn1c/tests/data-119/data-119-14-P.in
0 → 100644
View file @
725883b2
<PDU>
<ns-ir>13</ns-ir>
</PDU>
asn1c/tests/data-119/data-119-15.in
0 → 100644
View file @
725883b2
<PDU>
<ut-ir>ABCabc,12234</ut-ir>
</PDU>
asn1c/tests/data-119/data-119-16.in
0 → 100644
View file @
725883b2
<PDU>
<real>3.14159265</real>
</PDU>
asn1c/tests/data-119/data-119-17.in
0 → 100644
View file @
725883b2
<PDU>
<oid>1.3.6.1.4.1.9363.1.5.1</oid>
</PDU>
asn1c/tests/data-70/README
View file @
725883b2
Mode of operation:
Each of the *.in files is XER-decoded, then converted into DER
or PER
,
then decoded back from DER
(PER)
, then encoded into XER again,
Each of the *.in files is XER-decoded, then converted into DER,
then decoded back from DER, then encoded into XER again,
and finally compared to the original encoding.
Naming conventions:
...
...
asn1c/unber.c
View file @
725883b2
...
...
@@ -768,4 +768,8 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *td, size_t slen, int tag_mode, int
asn_dec_rval_t
xer_decode_general
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_struct_ctx_t
*
ctx
,
void
*
struct_key
,
const
char
*
xml_tag
,
const
void
*
buf_ptr
,
size_t
size
,
int
(
*
otd
)(
void
*
struct_key
,
const
void
*
chunk_buf
,
size_t
chunk_size
),
ssize_t
(
*
br
)(
void
*
struct_key
,
const
void
*
chunk_buf
,
size_t
chunk_size
,
int
have_more
))
{
asn_dec_rval_t
rv
=
{
0
,
0
};
(
void
)
opt_codec_ctx
;
(
void
)
ctx
;
(
void
)
struct_key
;
(
void
)
xml_tag
;
(
void
)
buf_ptr
;
(
void
)
size
;
(
void
)
otd
;
(
void
)
br
;
return
rv
;
}
asn_dec_rval_t
OCTET_STRING_decode_uper
(
asn_codec_ctx_t
*
ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
**
sptr
,
asn_per_data_t
*
pd
)
{
asn_dec_rval_t
rv
=
{
0
,
0
};
(
void
)
ctx
;
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
pd
;
return
rv
;
}
asn_enc_rval_t
OCTET_STRING_encode_uper
(
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
*
sptr
,
asn_per_outp_t
*
po
)
{
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
po
;
return
er
;
}
int
xer_is_whitespace
(
const
void
*
b
,
size_t
s
)
{
(
void
)
b
;
(
void
)
s
;
return
0
;
}
libasn1compiler/asn1c_C.c
View file @
725883b2
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_constraint.c
View file @
725883b2
...
...
@@ -316,7 +316,8 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
}
OUT
(
"};
\n
"
);
if
((
arg
->
flags
&
A1C_GEN_PER
))
{
if
((
arg
->
flags
&
A1C_GEN_PER
)
&&
(
etype
&
ASN_STRING_KM_MASK
))
{
int
c
;
OUT
(
"static int permitted_alphabet_code2value_%d[%d] = {
\n
"
,
arg
->
expr
->
_type_unique_index
,
cardinal
);
...
...
@@ -328,6 +329,8 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
}
OUT
(
"};
\n
"
);
OUT
(
"
\n
"
);
DEBUG
(
"code2value map gen for %s"
,
arg
->
expr
->
Identifier
);
arg
->
expr
->
_mark
|=
TM_PERFROMCT
;
}
OUT
(
"
\n
"
);
...
...
libasn1compiler/asn1c_misc.c
View file @
725883b2
...
...
@@ -158,7 +158,8 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
while
(
top_parent
->
parent_expr
)
top_parent
=
top_parent
->
parent_expr
;
DEBUG
(
"asn1c_type_name(%s: 0x%x)"
,
expr
->
Identifier
,
expr
->
expr_type
);
if
(
0
)
DEBUG
(
"asn1c_type_name(%s: 0x%x)"
,
expr
->
Identifier
,
expr
->
expr_type
);
switch
(
expr
->
expr_type
)
{
case
A1TC_REFERENCE
:
...
...
libasn1compiler/asn1c_out.h
View file @
725883b2
...
...
@@ -22,6 +22,7 @@ typedef struct compiler_streams {
OT_POST_INCLUDE
,
/* #include after type definition */
OT_CTABLES
,
/* Constraint tables */
OT_CODE
,
/* Some code */
OT_CTDEFS
,
/* Constraint definitions */
OT_STAT_DEFS
,
/* Static definitions */
OT_MAX
}
target
;
...
...
@@ -34,7 +35,7 @@ typedef struct compiler_streams {
}
compiler_streams_t
;
static
char
*
_compiler_stream2str
[]
__attribute__
((
unused
))
=
{
"IGNORE"
,
"INCLUDES"
,
"DEPS"
,
"FWD-DECLS"
,
"TYPE-DECLS"
,
"FUNC-DECLS"
,
"POST-INCLUDE"
,
"CTABLES"
,
"CODE"
,
"STAT-DEFS"
};
=
{
"IGNORE"
,
"INCLUDES"
,
"DEPS"
,
"FWD-DECLS"
,
"TYPE-DECLS"
,
"FUNC-DECLS"
,
"POST-INCLUDE"
,
"CTABLES"
,
"CODE"
,
"
CTDEFS"
,
"
STAT-DEFS"
};
int
asn1c_compiled_output
(
arg_t
*
arg
,
const
char
*
fmt
,
...);
...
...
libasn1compiler/asn1c_save.c
View file @
725883b2
...
...
@@ -273,10 +273,12 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_CODE
].
chunks
),
next
)
fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_CTDEFS
].
chunks
),
next
)
fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_STAT_DEFS
].
chunks
),
next
)
fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
assert
(
OT_MAX
==
1
0
);
/* Protection from reckless changes */
assert
(
OT_MAX
==
1
1
);
/* Protection from reckless changes */
fclose
(
fp_c
);
fclose
(
fp_h
);
...
...
libasn1fix/asn1fix_constr.c
View file @
725883b2
...
...
@@ -436,6 +436,10 @@ _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) {
b
->
Identifier
,
b
->
_lineno
);
FATAL
(
"Consider adding AUTOMATIC TAGS "
"after module %s DEFINITIONS, "
"or manually tag components"
,
arg
->
expr
->
module
->
ModuleName
);
DEBUG
(
"Tags: %s %s vs. %s %s"
,
asn1p_tag2string
(
&
ta
,
tagbuf
[
0
]),
a
->
Identifier
,
...
...
libasn1parser/asn1p_expr.h
View file @
725883b2
...
...
@@ -247,9 +247,10 @@ typedef struct asn1p_expr_s {
* Here are some predefined ones.
*/
enum
{
TM_NOMARK
,
TM_RECURSION
,
/* Used to break recursion */
TM_BROKEN
,
/* A warning was already issued */
TM_NOMARK
=
0
,
TM_RECURSION
=
(
1
<<
0
),
/* Used to break recursion */
TM_BROKEN
=
(
1
<<
1
),
/* A warning was already issued */
TM_PERFROMCT
=
(
1
<<
2
),
/* PER FROM() constraint tables emitted */
}
_mark
;
/*
...
...
skeletons/GeneralString.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_GeneralString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_hex
,
OCTET_STRING_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_GeneralString_tags
,
sizeof
(
asn_DEF_GeneralString_tags
)
...
...
skeletons/GeneralizedTime.c
View file @
725883b2
...
...
@@ -147,6 +147,11 @@ static ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
26
<<
2
)),
/* [UNIVERSAL 26] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_per_constraints_t
asn_DEF_GeneralizedTime_constraints
=
{
{
APC_CONSTRAINED
,
7
,
7
,
0x20
,
0x7e
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_GeneralizedTime
=
{
"GeneralizedTime"
,
"GeneralizedTime"
,
...
...
@@ -157,7 +162,8 @@ asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = {
GeneralizedTime_encode_der
,
OCTET_STRING_decode_xer_utf8
,
GeneralizedTime_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_GeneralizedTime_tags
,
sizeof
(
asn_DEF_GeneralizedTime_tags
)
...
...
@@ -165,7 +171,7 @@ asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = {
asn_DEF_GeneralizedTime_tags
,
sizeof
(
asn_DEF_GeneralizedTime_tags
)
/
sizeof
(
asn_DEF_GeneralizedTime_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_GeneralizedTime_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
...
...
skeletons/GraphicString.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_GraphicString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_hex
,
OCTET_STRING_encode_xer
,
/* Can't expect it to be ASCII/UTF8 */
0
,
0
,
OCTET_STRING_decode_uper
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_GraphicString_tags
,
sizeof
(
asn_DEF_GraphicString_tags
)
...
...
skeletons/IA5String.c
View file @
725883b2
...
...
@@ -12,6 +12,11 @@ static ber_tlv_tag_t asn_DEF_IA5String_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
22
<<
2
)),
/* [UNIVERSAL 22] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_per_constraints_t
asn_DEF_IA5String_constraints
=
{
{
APC_CONSTRAINED
,
7
,
7
,
0
,
0x7f
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_IA5String
=
{
"IA5String"
,
"IA5String"
,
...
...
@@ -22,7 +27,8 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_IA5String_tags
,
sizeof
(
asn_DEF_IA5String_tags
)
...
...
@@ -30,7 +36,7 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = {
asn_DEF_IA5String_tags
,
sizeof
(
asn_DEF_IA5String_tags
)
/
sizeof
(
asn_DEF_IA5String_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_IA5String_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
...
...
skeletons/ISO646String.c
View file @
725883b2
...
...
@@ -12,6 +12,11 @@ static ber_tlv_tag_t asn_DEF_ISO646String_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
26
<<
2
)),
/* [UNIVERSAL 26] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_per_constraints_t
asn_DEF_ISO646String_constraints
=
{
{
APC_CONSTRAINED
,
7
,
7
,
0x20
,
0x7e
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_ISO646String
=
{
"ISO646String"
,
"ISO646String"
,
...
...
@@ -22,7 +27,8 @@ asn_TYPE_descriptor_t asn_DEF_ISO646String = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_ISO646String_tags
,
sizeof
(
asn_DEF_ISO646String_tags
)
...
...
@@ -30,8 +36,7 @@ asn_TYPE_descriptor_t asn_DEF_ISO646String = {
asn_DEF_ISO646String_tags
,
sizeof
(
asn_DEF_ISO646String_tags
)
/
sizeof
(
asn_DEF_ISO646String_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_ISO646String_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
skeletons/NativeReal.c
View file @
725883b2
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2004
, 2006
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
/*
...
...
@@ -12,6 +12,7 @@
#include <asn_internal.h>
#include <NativeReal.h>
#include <REAL.h>
#include <OCTET_STRING.h>
/*
* NativeReal basic type description.
...
...
@@ -29,7 +30,8 @@ asn_TYPE_descriptor_t asn_DEF_NativeReal = {
NativeReal_encode_der
,
NativeReal_decode_xer
,
NativeReal_encode_xer
,
0
,
0
,
NativeReal_decode_uper
,
NativeReal_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_NativeReal_tags
,
sizeof
(
asn_DEF_NativeReal_tags
)
/
sizeof
(
asn_DEF_NativeReal_tags
[
0
]),
...
...
@@ -157,7 +159,74 @@ NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
return
erval
;
}
/*
* Decode REAL type using PER.
*/
asn_dec_rval_t
NativeReal_decode_uper
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
constraints
,
void
**
dbl_ptr
,
asn_per_data_t
*
pd
)
{
double
*
Dbl
=
(
double
*
)
*
dbl_ptr
;
asn_dec_rval_t
rval
;
REAL_t
tmp
;
void
*
ptmp
=
&
tmp
;
int
ret
;
(
void
)
constraints
;
/*
* If the structure is not there, allocate it.
*/
if
(
Dbl
==
NULL
)
{
*
dbl_ptr
=
CALLOC
(
1
,
sizeof
(
*
Dbl
));
Dbl
=
(
double
*
)
*
dbl_ptr
;
if
(
Dbl
==
NULL
)
_ASN_DECODE_FAILED
;
}
memset
(
&
tmp
,
0
,
sizeof
(
tmp
));
rval
=
OCTET_STRING_decode_uper
(
opt_codec_ctx
,
td
,
NULL
,
&
ptmp
,
pd
);
if
(
rval
.
code
!=
RC_OK
)
{
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_REAL
,
&
tmp
);
return
rval
;
}
ret
=
asn_REAL2double
(
&
tmp
,
Dbl
);
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_REAL
,
&
tmp
);
if
(
ret
)
_ASN_DECODE_FAILED
;
return
rval
;
}
/*
* Encode the NativeReal using the OCTET STRING PER encoder.
*/
asn_enc_rval_t
NativeReal_encode_uper
(
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
constraints
,
void
*
sptr
,
asn_per_outp_t
*
po
)
{
double
Dbl
=
*
(
const
double
*
)
sptr
;
asn_enc_rval_t
erval
;
REAL_t
tmp
;
(
void
)
constraints
;
/* Prepare a temporary clean structure */
memset
(
&
tmp
,
0
,
sizeof
(
tmp
));
if
(
asn_double2REAL
(
&
tmp
,
Dbl
))
_ASN_ENCODE_FAILED
;
/* Encode a DER REAL */
erval
=
OCTET_STRING_encode_uper
(
td
,
NULL
,
&
tmp
,
po
);
if
(
erval
.
encoded
==
-
1
)
erval
.
structure_ptr
=
sptr
;
/* Free possibly allocated members of the temporary structure */
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_REAL
,
&
tmp
);
return
erval
;
}
/*
* Decode the chunk of XML text encoding REAL.
...
...
skeletons/NativeReal.h
View file @
725883b2
...
...
@@ -6,7 +6,7 @@
* This type differs from the standard REAL in that it is modelled using
* the fixed machine type (double), so it can hold only values of
* limited precision. There is no explicit type (i.e., NativeReal_t).
* Use of this type is normally enabled by -fnative-
integer
s.
* Use of this type is normally enabled by -fnative-
type
s.
*/
#ifndef ASN_TYPE_NativeReal_H
#define ASN_TYPE_NativeReal_H
...
...
@@ -25,6 +25,8 @@ ber_type_decoder_f NativeReal_decode_ber;
der_type_encoder_f
NativeReal_encode_der
;
xer_type_decoder_f
NativeReal_decode_xer
;
xer_type_encoder_f
NativeReal_encode_xer
;
per_type_decoder_f
NativeReal_decode_uper
;
per_type_encoder_f
NativeReal_encode_uper
;
#ifdef __cplusplus
}
...
...
skeletons/NumericString.c
View file @
725883b2
/*-
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2003
, 2006
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
...
...
@@ -12,6 +12,31 @@ static ber_tlv_tag_t asn_DEF_NumericString_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
18
<<
2
)),
/* [UNIVERSAL 18] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
int
asn_DEF_NumericString_v2c
(
unsigned
int
value
)
{
switch
(
value
)
{
case
0x20
:
return
0
;
case
0x30
:
case
0x31
:
case
0x32
:
case
0x33
:
case
0x34
:
case
0x35
:
case
0x36
:
case
0x37
:
case
0x38
:
case
0x39
:
return
value
-
(
0x30
-
1
);
}
return
-
1
;
}
static
int
asn_DEF_NumericString_c2v
(
unsigned
int
code
)
{
if
(
code
>
0
)
{
if
(
code
<=
10
)
return
code
+
(
0x30
-
1
);
else
return
-
1
;
}
else
{
return
0x20
;
}
}
static
asn_per_constraints_t
asn_DEF_NumericString_constraints
=
{
{
APC_CONSTRAINED
,
4
,
4
,
0x20
,
0x39
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
asn_DEF_NumericString_v2c
,
asn_DEF_NumericString_c2v
};
asn_TYPE_descriptor_t
asn_DEF_NumericString
=
{
"NumericString"
,
"NumericString"
,
...
...
@@ -22,7 +47,8 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_NumericString_tags
,
sizeof
(
asn_DEF_NumericString_tags
)
...
...
@@ -30,7 +56,7 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = {
asn_DEF_NumericString_tags
,
sizeof
(
asn_DEF_NumericString_tags
)
/
sizeof
(
asn_DEF_NumericString_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_NumericString_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
...
...
skeletons/OBJECT_IDENTIFIER.c
View file @
725883b2
...
...
@@ -4,6 +4,7 @@
*/
#include <asn_internal.h>
#include <OBJECT_IDENTIFIER.h>
#include <OCTET_STRING.h>
#include <limits.h>
/* for CHAR_BIT */
#include <errno.h>
...
...
@@ -23,7 +24,8 @@ asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = {
der_encode_primitive
,
OBJECT_IDENTIFIER_decode_xer
,
OBJECT_IDENTIFIER_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_OBJECT_IDENTIFIER_tags
,
sizeof
(
asn_DEF_OBJECT_IDENTIFIER_tags
)
...
...
skeletons/OCTET_STRING.c
View file @
725883b2
...
...
@@ -1197,6 +1197,93 @@ OCTET_STRING_decode_xer_utf8(asn_codec_ctx_t *opt_codec_ctx,
OCTET_STRING__convert_entrefs
);
}
static
int
OCTET_STRING_per_get_expanded
(
asn_per_data_t
*
po
,
uint8_t
*
buf
,
size_t
size
,
long
lb
,
long
ub
,
int
(
*
code2value
)(
unsigned
int
),
int
unit_bits
)
{
uint8_t
*
end
=
buf
+
size
;
ASN_DEBUG
(
"Expanding %d characters into (%ld..%ld):%d"
,
(
int
)
size
,
lb
,
ub
,
unit_bits
);
/* X.691: 27.5.4 */
if
(
ub
<=
(
2
<<
(
unit_bits
-
1
)))
{
/* Decode without translation */
lb
=
0
;
}
else
if
(
code2value
)
{
for
(;
buf
<
end
;
buf
++
)
{
int
code
=
per_get_few_bits
(
po
,
unit_bits
);
int
value
;
if
(
code
<
0
)
return
-
1
;
/* WMORE */
value
=
code2value
(
code
);
if
(
value
<
0
)
{
ASN_DEBUG
(
"Code %d (0x%02x) is"
" not in map (%ld..%ld)"
,
code
,
code
,
lb
,
ub
);
return
1
;
/* FATAL */
}
*
buf
=
value
;
}
return
0
;
}
for
(;
buf
<
end
;
buf
++
)
{
int
code
=
per_get_few_bits
(
po
,
unit_bits
);
int
ch
=
code
+
lb
;
if
(
code
<
0
)
return
-
1
;
/* WMORE */
if
(
ch
>
ub
)
{
ASN_DEBUG
(
"Code %d is out of range (%ld..%ld)"
,
ch
,
lb
,
ub
);
return
1
;
/* FATAL */
}
*
buf
=
ch
;
}
return
0
;
}
static
int
OCTET_STRING_per_put_squeezed
(
asn_per_outp_t
*
po
,
const
uint8_t
*
buf
,
size_t
size
,
long
lb
,
long
ub
,
int
(
*
value2code
)(
unsigned
int
),
int
unit_bits
)
{
const
uint8_t
*
end
=
buf
+
size
;
ASN_DEBUG
(
"Squeezing %d bytes into (%ld..%ld):%d"
,
(
int
)
size
,
lb
,
ub
,
unit_bits
);
/* X.691: 27.5.4 */
if
(
ub
<=
(
2
<<
(
unit_bits
-
1
)))
{
/* Encode as is */
lb
=
0
;
}
else
if
(
value2code
)
{
for
(;
buf
<
end
;
buf
++
)
{
int
code
=
value2code
(
*
buf
);
if
(
code
<
0
)
{
ASN_DEBUG
(
"Character %d (0x%02x) is"
" not in map (%ld..%ld)"
,
*
buf
,
*
buf
,
lb
,
ub
);
return
-
1
;
}
if
(
per_put_few_bits
(
po
,
code
,
unit_bits
))
return
-
1
;
}
}
for
(
ub
-=
lb
;
buf
<
end
;
buf
++
)
{
int
ch
=
*
buf
-
lb
;
if
(
ch
<
0
||
ch
>
ub
)
{
ASN_DEBUG
(
"Character %d (0x%02x)"
" is out of range (%ld..%ld)"
,
*
buf
,
*
buf
,
lb
,
ub
+
lb
);
return
-
1
;
}
if
(
per_put_few_bits
(
po
,
ch
,
unit_bits
))
return
-
1
;
}
return
0
;
}
asn_dec_rval_t
OCTET_STRING_decode_uper
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
constraints
,
...
...
@@ -1205,15 +1292,17 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
?
(
asn_OCTET_STRING_specifics_t
*
)
td
->
specifics
:
&
asn_DEF_OCTET_STRING_specs
;
asn_per_constraint_t
*
ct
=
constraints
?
&
constraints
->
size
:
(
td
->
per_constraints
?
&
td
->
per_constraints
->
size
:
&
asn_DEF_OCTET_STRING_constraint
);
asn_per_constraints_t
*
pc
=
constraints
?
constraints
:
td
->
per_constraints
;
asn_per_constraint_t
*
cv
=
pc
?
&
pc
->
value
:
0
;
asn_per_constraint_t
*
ct
=
pc
?
&
pc
->
size
:
&
asn_DEF_OCTET_STRING_constraint
;
asn_dec_rval_t
rval
=
{
RC_OK
,
0
};
BIT_STRING_t
*
st
=
(
BIT_STRING_t
*
)
*
sptr
;
ssize_t
consumed_myself
=
0
;
int
repeat
;
int
unit_bits
=
(
specs
->
subvariant
!=
1
)
*
7
+
1
;
int
expand
=
0
;
(
void
)
opt_codec_ctx
;
...
...
@@ -1225,8 +1314,13 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
if
(
!
st
)
RETURN
(
RC_FAIL
);
}
ASN_DEBUG
(
"PER Decoding %s %ld .. %ld bits %d"
,
ct
->
flags
&
APC_EXTENSIBLE
?
"extensible"
:
"fixed"
,
if
(
cv
&&
(
cv
->
flags
&
APC_CONSTRAINED
))
{
unit_bits
=
cv
->
range_bits
;
if
(
unit_bits
!=
8
)
expand
=
1
;
}
ASN_DEBUG
(
"PER Decoding %s size %ld .. %ld bits %d"
,
ct
->
flags
&
APC_EXTENSIBLE
?
"extensible"
:
"non-extensible"
,
ct
->
lower_bound
,
ct
->
upper_bound
,
ct
->
effective_bits
);
if
(
ct
->
flags
&
APC_EXTENSIBLE
)
{
...
...
@@ -1252,8 +1346,17 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
/* X.691, #16.6: short fixed length encoding (up to 2 octets) */
/* X.691, #16.7: long fixed length encoding (up to 64K octets) */
if
(
ct
->
effective_bits
==
0
)
{
int
ret
=
per_get_many_bits
(
pd
,
st
->
buf
,
0
,
int
ret
;
if
(
expand
)
{
ret
=
OCTET_STRING_per_get_expanded
(
pd
,
st
->
buf
,
cv
->
upper_bound
,
cv
->
lower_bound
,
cv
->
upper_bound
,
pc
->
code2value
,
unit_bits
);
if
(
ret
>
0
)
RETURN
(
RC_FAIL
);
}
else
{
ret
=
per_get_many_bits
(
pd
,
st
->
buf
,
0
,
unit_bits
*
ct
->
upper_bound
);
}
if
(
ret
<
0
)
RETURN
(
RC_WMORE
);
consumed_myself
+=
unit_bits
*
ct
->
upper_bound
;
st
->
buf
[
st
->
size
]
=
0
;
...
...
@@ -1277,7 +1380,7 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
ASN_DEBUG
(
"Got PER length eb %ld, len %ld, %s (%s)"
,
(
long
)
ct
->
effective_bits
,
(
long
)
len_bits
,
repeat
?
"repeat"
:
"once"
,
td
->
name
);
if
(
unit_bits
==
1
)
{
if
(
unit_bits
==
1
&&
!
expand
)
{
len_bytes
=
(
len_bits
+
7
)
>>
3
;
if
(
len_bits
&
0x7
)
st
->
bits_unused
=
8
-
(
len_bits
&
0x7
);
...
...
@@ -1290,7 +1393,16 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
if
(
!
p
)
RETURN
(
RC_FAIL
);
st
->
buf
=
(
uint8_t
*
)
p
;
ret
=
per_get_many_bits
(
pd
,
&
st
->
buf
[
st
->
size
],
0
,
len_bits
);
if
(
expand
)
{
ret
=
OCTET_STRING_per_get_expanded
(
pd
,
&
st
->
buf
[
st
->
size
],
len_bytes
,
cv
->
lower_bound
,
cv
->
upper_bound
,
pc
->
code2value
,
unit_bits
);
if
(
ret
>
0
)
RETURN
(
RC_FAIL
);
}
else
{
ret
=
per_get_many_bits
(
pd
,
&
st
->
buf
[
st
->
size
],
0
,
len_bits
);
}
if
(
ret
<
0
)
RETURN
(
RC_WMORE
);
st
->
size
+=
len_bytes
;
}
while
(
repeat
);
...
...
@@ -1306,17 +1418,19 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
?
(
asn_OCTET_STRING_specifics_t
*
)
td
->
specifics
:
&
asn_DEF_OCTET_STRING_specs
;
asn_per_constraint_t
*
ct
=
constraints
?
&
constraints
->
size
:
(
td
->
per_constraints
?
&
td
->
per_constraints
->
size
:
&
asn_DEF_OCTET_STRING_constraint
);
asn_per_constraints_t
*
pc
=
constraints
?
constraints
:
td
->
per_constraints
;
asn_per_constraint_t
*
cv
=
pc
?
&
pc
->
value
:
0
;
asn_per_constraint_t
*
ct
=
pc
?
&
pc
->
size
:
&
asn_DEF_OCTET_STRING_constraint
;
const
BIT_STRING_t
*
st
=
(
const
BIT_STRING_t
*
)
sptr
;
int
unit_bits
=
(
specs
->
subvariant
!=
1
)
*
7
+
1
;
asn_enc_rval_t
er
;
int
ct_extensible
=
ct
->
flags
&
APC_EXTENSIBLE
;
int
inext
=
0
;
/* Lies not within extension root */
int
unit_bits
=
(
specs
->
subvariant
!=
1
)
*
7
+
1
;
int
sizeinunits
=
st
->
size
;
const
uint8_t
*
buf
;
int
squeeze
=
0
;
int
ret
;
if
(
!
st
||
!
st
->
buf
)
...
...
@@ -1328,13 +1442,18 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
sizeinunits
=
sizeinunits
*
8
-
(
st
->
bits_unused
&
0x07
);
}
if
(
cv
&&
(
cv
->
flags
&
APC_CONSTRAINED
))
{
unit_bits
=
cv
->
range_bits
;
if
(
unit_bits
!=
8
)
squeeze
=
1
;
}
ASN_DEBUG
(
"Encoding %s into %d units of %d bits"
" (%
d..%
d, effective %d)%s"
,
" (%
ld..%l
d, effective %d)%s"
,
td
->
name
,
sizeinunits
,
unit_bits
,
ct
->
lower_bound
,
ct
->
upper_bound
,
ct
->
effective_bits
,
ct_extensible
?
" EXT"
:
""
);
/* Figure out wheter size lies within PER visible cons
rt
aint */
/* Figure out wheter size lies within PER visible cons
tr
aint */
if
(
ct
->
effective_bits
>=
0
)
{
if
(
sizeinunits
<
ct
->
lower_bound
...
...
@@ -1365,7 +1484,14 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
ret
=
per_put_few_bits
(
po
,
sizeinunits
-
ct
->
lower_bound
,
ct
->
effective_bits
);
if
(
ret
)
_ASN_ENCODE_FAILED
;
ret
=
per_put_many_bits
(
po
,
st
->
buf
,
sizeinunits
*
unit_bits
);
if
(
squeeze
)
{
ret
=
OCTET_STRING_per_put_squeezed
(
po
,
st
->
buf
,
sizeinunits
,
cv
->
lower_bound
,
cv
->
upper_bound
,
pc
->
value2code
,
unit_bits
);
}
else
{
ret
=
per_put_many_bits
(
po
,
st
->
buf
,
sizeinunits
*
unit_bits
);
}
if
(
ret
)
_ASN_ENCODE_FAILED
;
_ASN_ENCODED_OK
(
er
);
}
...
...
@@ -1385,10 +1511,16 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
ASN_DEBUG
(
"Encoding %d of %d"
,
maySave
,
sizeinunits
);
ret
=
per_put_many_bits
(
po
,
buf
,
maySave
*
unit_bits
);
if
(
squeeze
)
{
ret
=
OCTET_STRING_per_put_squeezed
(
po
,
buf
,
maySave
,
cv
->
lower_bound
,
cv
->
upper_bound
,
pc
->
value2code
,
unit_bits
);
}
else
{
ret
=
per_put_many_bits
(
po
,
buf
,
maySave
*
unit_bits
);
}
if
(
ret
)
_ASN_ENCODE_FAILED
;
if
(
unit_bits
==
1
)
if
(
unit_bits
==
1
&&
!
squeeze
)
buf
+=
maySave
>>
3
;
else
buf
+=
maySave
;
...
...
skeletons/ObjectDescriptor.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_ObjectDescriptor = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_ObjectDescriptor_tags
,
sizeof
(
asn_DEF_ObjectDescriptor_tags
)
...
...
skeletons/PrintableString.c
View file @
725883b2
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2003, 2004, 2006 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
#include <PrintableString.h>
/*
* ASN.1:1984 (X.409)
*/
static
int
_PrintableString_alphabet
[
256
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
/* */
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
/* */
1
,
0
,
0
,
0
,
0
,
0
,
0
,
2
,
3
,
4
,
0
,
5
,
6
,
7
,
8
,
9
,
/* . '() +,-./ */
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
0
,
0
,
21
,
0
,
22
,
/* 0123456789: = ? */
0
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
/* ABCDEFGHIJKLMNO */
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
0
,
0
,
0
,
0
,
0
,
/* PQRSTUVWXYZ */
0
,
49
,
50
,
51
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
62
,
63
,
/* abcdefghijklmno */
64
,
65
,
66
,
67
,
68
,
69
,
70
,
71
,
72
,
73
,
74
,
0
,
0
,
0
,
0
,
0
,
/* pqrstuvwxyz */
};
static
int
_PrintableString_code2value
[
74
]
=
{
32
,
39
,
40
,
41
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
61
,
63
,
65
,
66
,
67
,
68
,
69
,
70
,
71
,
72
,
73
,
74
,
75
,
76
,
77
,
78
,
79
,
80
,
81
,
82
,
83
,
84
,
85
,
86
,
87
,
88
,
89
,
90
,
97
,
98
,
99
,
100
,
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
,
110
,
111
,
112
,
113
,
114
,
115
,
116
,
117
,
118
,
119
,
120
,
121
,
122
};
/*
* PrintableString basic type description.
*/
...
...
@@ -12,6 +33,20 @@ static ber_tlv_tag_t asn_DEF_PrintableString_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
19
<<
2
)),
/* [UNIVERSAL 19] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
int
asn_DEF_PrintableString_v2c
(
unsigned
int
value
)
{
return
_PrintableString_alphabet
[
value
>
255
?
0
:
value
]
-
1
;
}
static
int
asn_DEF_PrintableString_c2v
(
unsigned
int
code
)
{
if
(
code
<
74
)
return
_PrintableString_code2value
[
code
];
return
-
1
;
}
static
asn_per_constraints_t
asn_DEF_PrintableString_constraints
=
{
{
APC_CONSTRAINED
,
4
,
4
,
0x20
,
0x39
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
asn_DEF_PrintableString_v2c
,
asn_DEF_PrintableString_c2v
};
asn_TYPE_descriptor_t
asn_DEF_PrintableString
=
{
"PrintableString"
,
"PrintableString"
,
...
...
@@ -22,7 +57,8 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_PrintableString_tags
,
sizeof
(
asn_DEF_PrintableString_tags
)
...
...
@@ -30,34 +66,12 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = {
asn_DEF_PrintableString_tags
,
sizeof
(
asn_DEF_PrintableString_tags
)
/
sizeof
(
asn_DEF_PrintableString_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_PrintableString_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
/*
* ASN.1:1984 (X.409)
*/
static
int
_PrintableString_alphabet
[
256
]
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x3f
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x40
,
/* ' */
0x41
,
0x42
,
0x00
,
0x43
,
0x44
,
0x45
,
0x46
,
0x47
,
/* ( ) + , - . / */
0x35
,
0x36
,
0x37
,
0x38
,
0x39
,
0x3a
,
0x3b
,
0x3c
,
/* 0 1 2 3 4 5 6 7 */
0x3d
,
0x3e
,
0x48
,
0x00
,
0x00
,
0x49
,
0x00
,
0x4a
,
/* 8 9 : = ? */
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
/* A B C D E F G */
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
/* H I J K L M N O */
0x10
,
0x11
,
0x12
,
0x13
,
0x14
,
0x15
,
0x16
,
0x17
,
/* P Q R S T U V W */
0x18
,
0x19
,
0x1a
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* X Y Z */
0x00
,
0x1b
,
0x1c
,
0x1d
,
0x1e
,
0x1f
,
0x20
,
0x21
,
/* a b c d e f g */
0x22
,
0x23
,
0x24
,
0x25
,
0x26
,
0x27
,
0x28
,
0x29
,
/* h i j k l m n o */
0x2a
,
0x2b
,
0x2c
,
0x2d
,
0x2e
,
0x2f
,
0x30
,
0x31
,
/* p q r s t u v w */
0x32
,
0x33
,
0x34
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* x y z */
};
int
PrintableString_constraint
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
asn_app_constraint_failed_f
*
ctfailcb
,
void
*
app_key
)
{
...
...
skeletons/REAL.c
View file @
725883b2
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2004
, 2006
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#if defined(__alpha)
...
...
@@ -12,6 +12,7 @@
#include <math.h>
#include <errno.h>
#include <REAL.h>
#include <OCTET_STRING.h>
#undef INT_MAX
#define INT_MAX ((int)(((unsigned int)-1) >> 1))
...
...
@@ -42,7 +43,8 @@ asn_TYPE_descriptor_t asn_DEF_REAL = {
der_encode_primitive
,
REAL_decode_xer
,
REAL_encode_xer
,
0
,
0
,
REAL_decode_uper
,
REAL_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_REAL_tags
,
sizeof
(
asn_DEF_REAL_tags
)
/
sizeof
(
asn_DEF_REAL_tags
[
0
]),
...
...
@@ -341,6 +343,20 @@ REAL_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
buf_ptr
,
size
,
REAL__xer_body_decode
);
}
asn_dec_rval_t
REAL_decode_uper
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
constraints
,
void
**
sptr
,
asn_per_data_t
*
pd
)
{
(
void
)
constraints
;
/* No PER visible constraints */
return
OCTET_STRING_decode_uper
(
opt_codec_ctx
,
td
,
0
,
sptr
,
pd
);
}
asn_enc_rval_t
REAL_encode_uper
(
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
constraints
,
void
*
sptr
,
asn_per_outp_t
*
po
)
{
(
void
)
constraints
;
/* No PER visible constraints */
return
OCTET_STRING_encode_uper
(
td
,
0
,
sptr
,
po
);
}
int
asn_REAL2double
(
const
REAL_t
*
st
,
double
*
dbl_value
)
{
...
...
skeletons/REAL.h
View file @
725883b2
...
...
@@ -19,6 +19,8 @@ extern asn_TYPE_descriptor_t asn_DEF_REAL;
asn_struct_print_f
REAL_print
;
xer_type_decoder_f
REAL_decode_xer
;
xer_type_encoder_f
REAL_encode_xer
;
per_type_decoder_f
REAL_decode_uper
;
per_type_encoder_f
REAL_encode_uper
;
/***********************************
* Some handy conversion routines. *
...
...
skeletons/RELATIVE-OID.c
View file @
725883b2
...
...
@@ -5,6 +5,7 @@
*/
#include <asn_internal.h>
#include <RELATIVE-OID.h>
#include <OCTET_STRING.h>
#include <asn_codecs_prim.h>
/* Encoder and decoder of a primitive type */
#include <limits.h>
/* for CHAR_BIT */
#include <errno.h>
...
...
@@ -25,7 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID = {
der_encode_primitive
,
RELATIVE_OID_decode_xer
,
RELATIVE_OID_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_RELATIVE_OID_tags
,
sizeof
(
asn_DEF_RELATIVE_OID_tags
)
...
...
skeletons/T61String.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_T61String = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_hex
,
OCTET_STRING_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_T61String_tags
,
sizeof
(
asn_DEF_T61String_tags
)
...
...
skeletons/TeletexString.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_TeletexString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_hex
,
OCTET_STRING_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_TeletexString_tags
,
sizeof
(
asn_DEF_TeletexString_tags
)
...
...
skeletons/UTCTime.c
View file @
725883b2
...
...
@@ -23,6 +23,11 @@ static ber_tlv_tag_t asn_DEF_UTCTime_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
26
<<
2
)),
/* [UNIVERSAL 26] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_per_constraints_t
asn_DEF_UTCTime_constraints
=
{
{
APC_CONSTRAINED
,
7
,
7
,
0x20
,
0x7e
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_UTCTime
=
{
"UTCTime"
,
"UTCTime"
,
...
...
@@ -33,7 +38,8 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = {
OCTET_STRING_encode_der
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_decode_xer_utf8
,
UTCTime_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_UTCTime_tags
,
sizeof
(
asn_DEF_UTCTime_tags
)
...
...
@@ -41,7 +47,7 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = {
asn_DEF_UTCTime_tags
,
sizeof
(
asn_DEF_UTCTime_tags
)
/
sizeof
(
asn_DEF_UTCTime_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_UTCTime_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
...
...
skeletons/UTF8String.c
View file @
725883b2
...
...
@@ -23,7 +23,8 @@ asn_TYPE_descriptor_t asn_DEF_UTF8String = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_UTF8String_tags
,
sizeof
(
asn_DEF_UTF8String_tags
)
...
...
skeletons/VideotexString.c
View file @
725883b2
...
...
@@ -22,7 +22,8 @@ asn_TYPE_descriptor_t asn_DEF_VideotexString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_hex
,
OCTET_STRING_encode_xer
,
0
,
0
,
OCTET_STRING_decode_uper
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_VideotexString_tags
,
sizeof
(
asn_DEF_VideotexString_tags
)
...
...
skeletons/VisibleString.c
View file @
725883b2
/*-
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2003
, 2006
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
...
...
@@ -12,6 +12,11 @@ static ber_tlv_tag_t asn_DEF_VisibleString_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
26
<<
2
)),
/* [UNIVERSAL 26] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_per_constraints_t
asn_DEF_VisibleString_constraints
=
{
{
APC_CONSTRAINED
,
7
,
7
,
0x20
,
0x7e
},
/* Value */
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
/* Size */
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_VisibleString
=
{
"VisibleString"
,
"VisibleString"
,
...
...
@@ -22,7 +27,8 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = {
OCTET_STRING_encode_der
,
OCTET_STRING_decode_xer_utf8
,
OCTET_STRING_encode_xer_utf8
,
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_VisibleString_tags
,
sizeof
(
asn_DEF_VisibleString_tags
)
...
...
@@ -30,7 +36,7 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = {
asn_DEF_VisibleString_tags
,
sizeof
(
asn_DEF_VisibleString_tags
)
/
sizeof
(
asn_DEF_VisibleString_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_VisibleString_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
};
...
...
skeletons/constr_SET_OF.c
View file @
725883b2
...
...
@@ -921,7 +921,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ASN_DEBUG
(
"Failed to add element into %s"
,
td
->
name
);
/* Fall through */
rv
.
code
=
=
RC_FAIL
;
rv
.
code
=
RC_FAIL
;
}
else
{
ASN_DEBUG
(
"Failed decoding %s of %s (SET OF)"
,
elm
->
type
->
name
,
td
->
name
);
...
...
skeletons/per_support.h
View file @
725883b2
...
...
@@ -29,6 +29,8 @@ typedef struct asn_per_constraint_s {
typedef
struct
asn_per_constraints_s
{
asn_per_constraint_t
value
;
asn_per_constraint_t
size
;
int
(
*
value2code
)(
unsigned
int
value
);
int
(
*
code2value
)(
unsigned
int
code
);
}
asn_per_constraints_t
;
/*
...
...
skeletons/tests/check-OIDs.c
View file @
725883b2
...
...
@@ -442,3 +442,7 @@ main() {
return
0
;
}
asn_dec_rval_t
OCTET_STRING_decode_uper
(
asn_codec_ctx_t
*
ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
**
sptr
,
asn_per_data_t
*
pd
)
{
asn_dec_rval_t
rv
=
{
0
,
0
};
(
void
)
ctx
;
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
pd
;
return
rv
;
}
asn_enc_rval_t
OCTET_STRING_encode_uper
(
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
*
sptr
,
asn_per_outp_t
*
po
)
{
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
po
;
return
er
;
}
skeletons/tests/check-REAL.c
View file @
725883b2
...
...
@@ -286,3 +286,7 @@ main() {
return
0
;
}
asn_dec_rval_t
OCTET_STRING_decode_uper
(
asn_codec_ctx_t
*
ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
**
sptr
,
asn_per_data_t
*
pd
)
{
asn_dec_rval_t
rv
=
{
0
,
0
};
(
void
)
ctx
;
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
pd
;
return
rv
;
}
asn_enc_rval_t
OCTET_STRING_encode_uper
(
asn_TYPE_descriptor_t
*
td
,
asn_per_constraints_t
*
cts
,
void
*
sptr
,
asn_per_outp_t
*
po
)
{
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
(
void
)
td
;
(
void
)
cts
;
(
void
)
sptr
;
(
void
)
po
;
return
er
;
}
tests/119-per-strings-OK.asn1
0 → 100644
View file @
725883b2
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .119
ModulePERStrings
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 119 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
PDU ::= SEQUENCE {
many SEQUENCE OF PDU OPTIONAL,
ia5 IA5String OPTIONAL,
ia5-c IA5String (FROM("A".."Z")) OPTIONAL,
ia5-ce IA5String (FROM("A".."Z",...)) OPTIONAL,
ia5-ir IA5String (FROM("A".."B"|"X".."Z")) OPTIONAL,
vs VisibleString OPTIONAL,
vs-c VisibleString (FROM("A".."Z")) OPTIONAL,
vs-ce VisibleString (FROM("A".."Z",...)) OPTIONAL,
vs-ir VisibleString (FROM("A".."B"|"X".."Z")) OPTIONAL,
pr PrintableString OPTIONAL,
pr-c PrintableString (FROM("A".."Z")) OPTIONAL,
pr-ir PrintableString (FROM("A".."B"|"X".."Z")) OPTIONAL,
ns NumericString OPTIONAL,
ns-c NumericString (FROM("5".."9")) OPTIONAL,
ns-ce NumericString (FROM("5".."9",...)) OPTIONAL,
ns-ir NumericString (FROM("1"|"9")) OPTIONAL,
ut-c UTF8String (SIZE(6)) OPTIONAL,
ut-ce UTF8String (SIZE(6,...)) OPTIONAL,
ut-ir UTF8String (FROM("A"|"Z")) OPTIONAL,
real REAL OPTIONAL,
oid OBJECT IDENTIFIER OPTIONAL
}
END
tests/50-constraint-OK.asn1.-Pgen-PER
View file @
725883b2
This diff is collapsed.
Click to expand it.
tests/90-cond-int-type-OK.asn1.-Pgen-PER
View file @
725883b2
This diff is collapsed.
Click to expand it.
tests/95-choice-per-order-OK.asn1.-Pgen-PER
View file @
725883b2
...
...
@@ -56,6 +56,19 @@ typedef struct Choice {
extern asn_TYPE_descriptor_t asn_DEF_Choice;
/*** <<< CTDEFS [Choice] >>> ***/
static asn_per_constraints_t asn_PER_ch_constr_4 = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
static asn_per_constraints_t asn_PER_Choice_constr_1 = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
/*** <<< STAT-DEFS [Choice] >>> ***/
static asn_TYPE_member_t asn_MBR_ch_4[] = {
...
...
@@ -93,10 +106,6 @@ static asn_CHOICE_specifics_t asn_SPC_ch_specs_4 = {
.canonical_order = asn_MAP_ch_cmap_4, /* Canonically sorted */
.ext_start = -1 /* Extensions start */
};
static asn_per_constraints_t asn_PER_ch_constr_4 = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_ch_4 = {
"ch",
...
...
@@ -121,10 +130,6 @@ asn_TYPE_descriptor_t asn_DEF_ch_4 = {
&asn_SPC_ch_specs_4 /* Additional specs */
};
static asn_per_constraints_t asn_PER_memb_ch_constr_4 = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }
};
static asn_TYPE_member_t asn_MBR_Choice_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Choice, choice.roid),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (13 << 2)),
...
...
@@ -149,7 +154,7 @@ static asn_TYPE_member_t asn_MBR_Choice_1[] = {
.tag_mode = 0,
.type = &asn_DEF_ch_4,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = &asn_PER_
memb_
ch_constr_4,
.per_constraints = &asn_PER_ch_constr_4,
.default_value = 0,
.name = "ch"
},
...
...
@@ -181,10 +186,6 @@ static asn_CHOICE_specifics_t asn_SPC_Choice_specs_1 = {
.canonical_order = asn_MAP_Choice_cmap_1, /* Canonically sorted */
.ext_start = 3 /* Extensions start */
};
static asn_per_constraints_t asn_PER_Choice_constr_1 = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 2, 2, 0, 2 } /* (0..2,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }
};
asn_TYPE_descriptor_t asn_DEF_Choice = {
"Choice",
"Choice",
...
...
@@ -240,6 +241,14 @@ typedef struct Choice2 {
extern asn_TYPE_descriptor_t asn_DEF_Choice2;
/*** <<< CTDEFS [Choice2] >>> ***/
static asn_per_constraints_t asn_PER_Choice2_constr_1 = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
/*** <<< STAT-DEFS [Choice2] >>> ***/
static asn_TYPE_member_t asn_MBR_Choice2_1[] = {
...
...
@@ -276,10 +285,6 @@ static asn_CHOICE_specifics_t asn_SPC_Choice2_specs_1 = {
.canonical_order = 0,
.ext_start = -1 /* Extensions start */
};
static asn_per_constraints_t asn_PER_Choice2_constr_1 = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }
};
asn_TYPE_descriptor_t asn_DEF_Choice2 = {
"Choice2",
"Choice2",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment