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
3a4689a7
Commit
3a4689a7
authored
Nov 24, 2006
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BMPString and UniversalString support
parent
fbaeb852
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
956 additions
and
182 deletions
+956
-182
asn1c/tests/data-119/data-119-18.in
asn1c/tests/data-119/data-119-18.in
+10
-0
asn1c/tests/data-119/data-119-19.in
asn1c/tests/data-119/data-119-19.in
+10
-0
asn1c/tests/data-119/data-119-20-P.in
asn1c/tests/data-119/data-119-20-P.in
+3
-0
asn1c/tests/data-119/data-119-21-P.in
asn1c/tests/data-119/data-119-21-P.in
+3
-0
asn1c/tests/data-119/data-119-22-P.in
asn1c/tests/data-119/data-119-22-P.in
+3
-0
asn1c/tests/data-119/data-119-23-P.in
asn1c/tests/data-119/data-119-23-P.in
+3
-0
asn1c/tests/data-119/data-119-24-P.in
asn1c/tests/data-119/data-119-24-P.in
+3
-0
asn1c/tests/data-119/data-119-25-P.in
asn1c/tests/data-119/data-119-25-P.in
+3
-0
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+42
-2
libasn1compiler/asn1c_constraint.c
libasn1compiler/asn1c_constraint.c
+1
-2
libasn1fix/asn1fix_constraint_compat.c
libasn1fix/asn1fix_constraint_compat.c
+2
-2
skeletons/ANY.c
skeletons/ANY.c
+1
-1
skeletons/BIT_STRING.c
skeletons/BIT_STRING.c
+1
-1
skeletons/BMPString.c
skeletons/BMPString.c
+15
-4
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+257
-137
skeletons/OCTET_STRING.h
skeletons/OCTET_STRING.h
+7
-1
skeletons/UniversalString.c
skeletons/UniversalString.c
+14
-3
tests/119-per-strings-OK.asn1
tests/119-per-strings-OK.asn1
+10
-0
tests/119-per-strings-OK.asn1.-EF
tests/119-per-strings-OK.asn1.-EF
+12
-2
tests/119-per-strings-OK.asn1.-Pgen-PER
tests/119-per-strings-OK.asn1.-Pgen-PER
+556
-27
No files found.
asn1c/tests/data-119/data-119-18.in
0 → 100644
View file @
3a4689a7
<PDU>
<many>
<PDU><bm>abra kadabra</bm></PDU>
<PDU><bm-c>AAAAZZZZ</bm-c></PDU>
<PDU><bm-cs>шесть!</bm-cs></PDU>
<PDU><bm-ce>ABC</bm-ce></PDU>
<PDU><bm-ce>ABCabc (extensibility in play)</bm-ce></PDU>
<PDU><bm-ir>ABXZ</bm-ir></PDU>
</many>
</PDU>
asn1c/tests/data-119/data-119-19.in
0 → 100644
View file @
3a4689a7
<PDU>
<many>
<PDU><us>kadabra</us></PDU>
<PDU><us-c>AAAAZZZZ</us-c></PDU>
<PDU><us-cs>шесть!</us-cs></PDU>
<PDU><us-ce>ABC</us-ce></PDU>
<PDU><us-ce>ABCabc (extensibility in play)</us-ce></PDU>
<PDU><us-ir>ABXZ</us-ir></PDU>
</many>
</PDU>
asn1c/tests/data-119/data-119-20-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<bm-c>abcd</bm-c>
</PDU>
asn1c/tests/data-119/data-119-21-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<us-c>abcd</us-c>
</PDU>
asn1c/tests/data-119/data-119-22-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<bm-cs></bm-cs>
</PDU>
asn1c/tests/data-119/data-119-23-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<us-cs></us-cs>
</PDU>
asn1c/tests/data-119/data-119-24-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<bm-ir>ABC</bm-ir>
</PDU>
asn1c/tests/data-119/data-119-25-P.in
0 → 100644
View file @
3a4689a7
<PDU>
<us-ir>ABC</us-ir>
</PDU>
libasn1compiler/asn1c_C.c
View file @
3a4689a7
...
...
@@ -1825,14 +1825,16 @@ emit_single_member_PER_constraint(arg_t *arg, asn1cnst_range_t *range, int alpha
}
}
if
(
1
)
{
if
(
alphabetsize
)
{
ebits
=
rbits
;
}
else
{
/* X.691, #10.9.4.1 */
for
(
ebits
=
0
;
ebits
<=
16
;
ebits
++
)
if
(
r
<=
1
<<
ebits
)
break
;
if
(
ebits
==
17
||
range
->
right
.
value
>=
65536
)
ebits
=
-
1
;
}
else
{
if
(
0
)
{
/* X.691, #10.5.7.1 */
for
(
ebits
=
0
;
ebits
<=
8
;
ebits
++
)
if
(
r
<=
1
<<
ebits
)
break
;
...
...
@@ -1843,11 +1845,25 @@ emit_single_member_PER_constraint(arg_t *arg, asn1cnst_range_t *range, int alpha
ebits
=
-
1
;
}
}
}
OUT
(
"{ APC_CONSTRAINED%s,%s% d, % d, "
,
range
->
extensible
?
" | APC_EXTENSIBLE"
:
""
,
range
->
extensible
?
" "
:
"
\t
"
,
rbits
,
ebits
);
if
(
alphabetsize
)
{
asn1c_integer_t
lv
=
range
->
left
.
value
;
asn1c_integer_t
rv
=
range
->
right
.
value
;
int
gcmt
=
0
;
if
(
lv
>
0x7fffffff
)
{
lv
=
0x7fffffff
;
gcmt
++
;
}
if
(
rv
>
0x7fffffff
)
{
rv
=
0x7fffffff
;
gcmt
++
;
}
if
(
gcmt
)
{
OUT
(
"% "
PRIdASN
", % "
PRIdASN
" }"
,
lv
,
rv
);
goto
pcmt
;
}
}
}
else
{
if
(
range
->
extensible
)
{
OUT
(
"{ APC_SEMI_CONSTRAINED | APC_EXTENSIBLE, "
...
...
@@ -1862,6 +1878,8 @@ emit_single_member_PER_constraint(arg_t *arg, asn1cnst_range_t *range, int alpha
OUT
(
"{ APC_UNCONSTRAINED,
\t
-1, -1, 0, 0 }"
);
}
pcmt:
/*
* Print some courtesy debug information.
*/
...
...
@@ -1948,8 +1966,30 @@ emit_member_PER_constraints(arg_t *arg, asn1p_expr_t *expr, const char *pfx) {
expr
->
combined_constraints
,
ACT_CT_FROM
,
0
,
0
,
0
);
DEBUG
(
"Emitting FROM constraint for %s"
,
expr
->
Identifier
);
if
((
range
->
left
.
type
==
ARE_MIN
&&
range
->
right
.
type
==
ARE_MAX
)
||
range
->
not_PER_visible
)
{
switch
(
etype
)
{
case
ASN_STRING_BMPString
:
range
->
left
.
type
=
ARE_VALUE
;
range
->
left
.
value
=
0
;
range
->
right
.
type
=
ARE_VALUE
;
range
->
right
.
value
=
65535
;
range
->
not_PER_visible
=
0
;
range
->
extensible
=
0
;
break
;
case
ASN_STRING_UniversalString
:
OUT
(
"{ APC_CONSTRAINED,
\t
32, 32,"
" 0, 2147483647 }"
" /* special case 1 */
\n
"
);
goto
avoid
;
default:
break
;
}
}
if
(
emit_single_member_PER_constraint
(
arg
,
range
,
1
,
0
))
return
-
1
;
avoid:
asn1constraint_range_free
(
range
);
}
else
{
range
=
asn1constraint_compute_PER_range
(
etype
,
...
...
libasn1compiler/asn1c_constraint.c
View file @
3a4689a7
...
...
@@ -72,7 +72,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
case
ASN_BASIC_BIT_STRING
:
case
ASN_BASIC_OCTET_STRING
:
produce_st
=
1
;
break
;
break
;
default:
if
(
etype
&
ASN_STRING_MASK
)
produce_st
=
1
;
...
...
@@ -222,7 +222,6 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
return
0
;
}
if
(
range
->
left
.
type
==
ARE_MIN
&&
range
->
right
.
type
==
ARE_MAX
)
{
/*
...
...
libasn1fix/asn1fix_constraint_compat.c
View file @
3a4689a7
...
...
@@ -128,7 +128,7 @@ asn1constraint_default_alphabet(asn1p_expr_type_e expr_type) {
DECL_notPV
(
utf8
,
0x00
,
0x7fffffff
);
/* Not PER-visible */
DECL
(
bmp
,
0x00
,
65533
);
/* 64K-2 cells */
DECL
(
uint7
,
0x00
,
0x7f
);
DECL
(
uint3
1
,
0x00
,
0x7
fffffff
);
DECL
(
uint3
2
,
0x00
,
0xf
fffffff
);
DECL
(
Space
,
0x20
,
0x20
);
DECL
(
ApostropheAndParens
,
0x27
,
0x29
);
DECL
(
PlusTillColon
,
0x2b
,
0x3a
);
...
...
@@ -213,7 +213,7 @@ asn1constraint_default_alphabet(asn1p_expr_type_e expr_type) {
assert
(
range_utf8
.
not_PER_visible
);
return
&
range_utf8
;
case
ASN_STRING_UniversalString
:
return
&
range_uint3
1
;
return
&
range_uint3
2
;
case
ASN_BASIC_UTCTime
:
/* Permitted alphabet constraint is not applicable */
assert
(
range_UTCTime
.
not_PER_visible
);
...
...
skeletons/ANY.c
View file @
3a4689a7
...
...
@@ -9,7 +9,7 @@
static
asn_OCTET_STRING_specifics_t
asn_DEF_ANY_specs
=
{
sizeof
(
ANY_t
),
offsetof
(
ANY_t
,
_asn_ctx
),
2
/* Special indicator that this is an ANY type */
ASN_OSUBV_ANY
};
asn_TYPE_descriptor_t
asn_DEF_ANY
=
{
"ANY"
,
...
...
skeletons/BIT_STRING.c
View file @
3a4689a7
...
...
@@ -15,7 +15,7 @@ static ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
static
asn_OCTET_STRING_specifics_t
asn_DEF_BIT_STRING_specs
=
{
sizeof
(
BIT_STRING_t
),
offsetof
(
BIT_STRING_t
,
_asn_ctx
),
1
,
/* Special indicator that this is a BIT STRING type */
ASN_OSUBV_BIT
};
asn_TYPE_descriptor_t
asn_DEF_BIT_STRING
=
{
"BIT STRING"
,
...
...
skeletons/BMPString.c
View file @
3a4689a7
...
...
@@ -13,6 +13,16 @@ static ber_tlv_tag_t asn_DEF_BMPString_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
30
<<
2
)),
/* [UNIVERSAL 30] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_OCTET_STRING_specifics_t
asn_DEF_BMPString_specs
=
{
sizeof
(
BMPString_t
),
offsetof
(
BMPString_t
,
_asn_ctx
),
ASN_OSUBV_U16
/* 16-bits character */
};
static
asn_per_constraints_t
asn_DEF_BMPString_constraints
=
{
{
APC_CONSTRAINED
,
16
,
16
,
0
,
65535
},
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_BMPString
=
{
"BMPString"
,
"BMPString"
,
...
...
@@ -23,7 +33,8 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
OCTET_STRING_encode_der
,
BMPString_decode_xer
,
/* Convert from UTF-8 */
BMPString_encode_xer
,
/* Convert to UTF-8 */
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_BMPString_tags
,
sizeof
(
asn_DEF_BMPString_tags
)
...
...
@@ -31,9 +42,9 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
asn_DEF_BMPString_tags
,
sizeof
(
asn_DEF_BMPString_tags
)
/
sizeof
(
asn_DEF_BMPString_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_BMPString_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
&
asn_DEF_BMPString_specs
};
/*
...
...
@@ -131,7 +142,7 @@ BMPString_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
rc
.
consumed
=
0
;
return
rc
;
}
else
{
dstwc
[
2
*
wcs_len
]
=
0
;
dstwc
[
wcs_len
]
=
0
;
/* nul-terminate */
wcs
=
(
uint32_t
*
)
dstwc
;
}
}
...
...
skeletons/OCTET_STRING.c
View file @
3a4689a7
This diff is collapsed.
Click to expand it.
skeletons/OCTET_STRING.h
View file @
3a4689a7
...
...
@@ -70,7 +70,13 @@ typedef struct asn_OCTET_STRING_specifics_s {
int
struct_size
;
/* Size of the structure */
int
ctx_offset
;
/* Offset of the asn_struct_ctx_t member */
int
subvariant
;
/* {0,1,2} for O-S, BIT STRING or ANY */
enum
asn_OS_Subvariant
{
ASN_OSUBV_ANY
,
/* The open type (ANY) */
ASN_OSUBV_BIT
,
/* BIT STRING */
ASN_OSUBV_STR
,
/* String types, not {BMP,Universal}String */
ASN_OSUBV_U16
,
/* 16-bit character (BMPString) */
ASN_OSUBV_U32
/* 32-bit character (UniversalString) */
}
subvariant
;
}
asn_OCTET_STRING_specifics_t
;
#ifdef __cplusplus
...
...
skeletons/UniversalString.c
View file @
3a4689a7
...
...
@@ -13,6 +13,16 @@ static ber_tlv_tag_t asn_DEF_UniversalString_tags[] = {
(
ASN_TAG_CLASS_UNIVERSAL
|
(
28
<<
2
)),
/* [UNIVERSAL 28] IMPLICIT ...*/
(
ASN_TAG_CLASS_UNIVERSAL
|
(
4
<<
2
))
/* ... OCTET STRING */
};
static
asn_OCTET_STRING_specifics_t
asn_DEF_UniversalString_specs
=
{
sizeof
(
UniversalString_t
),
offsetof
(
UniversalString_t
,
_asn_ctx
),
ASN_OSUBV_U32
/* 32-bits character */
};
static
asn_per_constraints_t
asn_DEF_UniversalString_constraints
=
{
{
APC_CONSTRAINED
,
32
,
32
,
0
,
2147483647
},
{
APC_SEMI_CONSTRAINED
,
-
1
,
-
1
,
0
,
0
},
0
,
0
};
asn_TYPE_descriptor_t
asn_DEF_UniversalString
=
{
"UniversalString"
,
"UniversalString"
,
...
...
@@ -23,7 +33,8 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
OCTET_STRING_encode_der
,
UniversalString_decode_xer
,
/* Convert from UTF-8 */
UniversalString_encode_xer
,
/* Convert into UTF-8 */
0
,
0
,
OCTET_STRING_decode_uper
,
OCTET_STRING_encode_uper
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_UniversalString_tags
,
sizeof
(
asn_DEF_UniversalString_tags
)
...
...
@@ -31,9 +42,9 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
asn_DEF_UniversalString_tags
,
sizeof
(
asn_DEF_UniversalString_tags
)
/
sizeof
(
asn_DEF_UniversalString_tags
[
0
]),
0
,
/* No PER visible constraints */
&
asn_DEF_UniversalString_constraints
,
0
,
0
,
/* No members */
0
/* No specifics */
&
asn_DEF_UniversalString_specs
};
...
...
tests/119-per-strings-OK.asn1
View file @
3a4689a7
...
...
@@ -31,6 +31,16 @@ BEGIN
ut-c UTF8String (SIZE(6)) OPTIONAL,
ut-ce UTF8String (SIZE(6,...)) OPTIONAL,
ut-ir UTF8String (FROM("A"|"Z")) OPTIONAL,
bm BMPString OPTIONAL,
bm-c BMPString (FROM("A".."Z")) OPTIONAL,
bm-cs BMPString (SIZE(6)) OPTIONAL,
bm-ce BMPString (FROM("A".."Z",...)) OPTIONAL,
bm-ir BMPString (FROM("A".."B"|"X".."Z")) OPTIONAL,
us UniversalString OPTIONAL,
us-c UniversalString (FROM("A".."Z")) OPTIONAL,
us-cs UniversalString (SIZE(6)) OPTIONAL,
us-ce UniversalString (FROM("A".."Z",...)) OPTIONAL,
us-ir UniversalString (FROM("A".."B"|"X".."Z")) OPTIONAL,
real REAL OPTIONAL,
oid OBJECT IDENTIFIER OPTIONAL
}
...
...
tests/119-per-strings-OK.asn1.-EF
View file @
3a4689a7
...
...
@@ -23,8 +23,18 @@ PDU ::= SEQUENCE {
ut-c [16] IMPLICIT UTF8String (SIZE(6)) OPTIONAL,
ut-ce [17] IMPLICIT UTF8String (SIZE(6,...)) OPTIONAL,
ut-ir [18] IMPLICIT UTF8String (FROM("A" | "Z")) OPTIONAL,
real [19] IMPLICIT REAL OPTIONAL,
oid [20] IMPLICIT OBJECT IDENTIFIER OPTIONAL
bm [19] IMPLICIT BMPString OPTIONAL,
bm-c [20] IMPLICIT BMPString (FROM("A".."Z")) OPTIONAL,
bm-cs [21] IMPLICIT BMPString (SIZE(6)) OPTIONAL,
bm-ce [22] IMPLICIT BMPString (FROM("A".."Z",...)) OPTIONAL,
bm-ir [23] IMPLICIT BMPString (FROM("A".."B" | "X".."Z")) OPTIONAL,
us [24] IMPLICIT UniversalString OPTIONAL,
us-c [25] IMPLICIT UniversalString (FROM("A".."Z")) OPTIONAL,
us-cs [26] IMPLICIT UniversalString (SIZE(6)) OPTIONAL,
us-ce [27] IMPLICIT UniversalString (FROM("A".."Z",...)) OPTIONAL,
us-ir [28] IMPLICIT UniversalString (FROM("A".."B" | "X".."Z")) OPTIONAL,
real [29] IMPLICIT REAL OPTIONAL,
oid [30] IMPLICIT OBJECT IDENTIFIER OPTIONAL
}
END
tests/119-per-strings-OK.asn1.-Pgen-PER
View file @
3a4689a7
This diff is collapsed.
Click to expand it.
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