Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Havar
asn1c
Commits
ff7dd147
Commit
ff7dd147
authored
Mar 20, 2005
by
Lev Walkin
Browse files
ContainedSubtype support
parent
7ec9b4c7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
ff7dd147
...
...
@@ -4,6 +4,7 @@
* Added extra const qualifiers into the support code.
* More RFC variations supported in crfc2asn1.pl.
* Refined string values compatibility. (Test cases 77, 78).
* Support for ContainedSubtype constraints. (Test case 16).
0.9.12: 2005-Mar-10
...
...
TODO
View file @
ff7dd147
...
...
@@ -16,6 +16,3 @@ which is already completed. Also see #3.2.
3. MINOR:
3.1 Parsing of CONSTRAINED BY clauses
3.2 Support for ContainedSubtype constraint.
libasn1parser/asn1p_constr.c
View file @
ff7dd147
...
...
@@ -22,6 +22,8 @@ void
asn1p_constraint_free
(
asn1p_constraint_t
*
ct
)
{
if
(
ct
)
{
if
(
ct
->
containedSubtype
)
asn1p_value_free
(
ct
->
containedSubtype
);
if
(
ct
->
value
)
asn1p_value_free
(
ct
->
value
);
if
(
ct
->
range_start
)
...
...
@@ -59,9 +61,10 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
clone
->
type
=
src
->
type
;
clone
->
presence
=
src
->
presence
;
CLONE
(
value
,
asn1p_value_clone
);
CLONE
(
range_start
,
asn1p_value_clone
);
CLONE
(
range_stop
,
asn1p_value_clone
);
CLONE
(
containedSubtype
,
asn1p_value_clone
);
CLONE
(
value
,
asn1p_value_clone
);
CLONE
(
range_start
,
asn1p_value_clone
);
CLONE
(
range_stop
,
asn1p_value_clone
);
for
(
i
=
0
;
i
<
src
->
el_count
;
i
++
)
{
asn1p_constraint_t
*
t
;
...
...
@@ -115,6 +118,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
switch
(
type
)
{
case
ACT_INVALID
:
return
"INVALID"
;
case
ACT_EL_TYPE
:
return
"ContainedSubtype"
;
case
ACT_EL_VALUE
:
return
"SingleValue"
;
case
ACT_EL_RANGE
:
...
...
libasn1parser/asn1p_constr.h
View file @
ff7dd147
...
...
@@ -11,7 +11,8 @@ typedef struct asn1p_constraint_s {
/*
* Constraint elements.
*/
ACT_EL_VALUE
,
/* 123, "A", T (elementary value) */
ACT_EL_TYPE
,
/* T (contained subtype) */
ACT_EL_VALUE
,
/* 123, "A", (elementary value) */
ACT_EL_RANGE
,
/* 1..2 (elementary range) */
ACT_EL_LLRANGE
,
/* 1<..2 (elementary range) */
ACT_EL_RLRANGE
,
/* 1..<2 (elementary range) */
...
...
@@ -43,8 +44,9 @@ typedef struct asn1p_constraint_s {
}
presence
;
/*
*
A single
values.
*
Separate types and
values.
*/
asn1p_value_t
*
containedSubtype
;
asn1p_value_t
*
value
;
asn1p_value_t
*
range_start
;
asn1p_value_t
*
range_stop
;
...
...
libasn1parser/asn1p_y.c
View file @
ff7dd147
This diff is collapsed.
Click to expand it.
libasn1parser/asn1p_y.y
View file @
ff7dd147
...
...
@@ -282,7 +282,8 @@ static asn1p_value_t *
%type <a_constr> ComponentRelationConstraint
%type <a_constr> AtNotationList
%type <a_ref> AtNotationElement
%type <a_value> ConstraintValue
%type <a_value> SingleValue
%type <a_value> ContainedSubtype
%type <a_ctype> ConstraintSpec
%type <a_ctype> ConstraintRangeSpec
%type <a_wsynt> optWithSyntax
...
...
@@ -1572,20 +1573,26 @@ ConstraintSubtypeElement:
ret = asn1p_constraint_insert($$, $2);
checkmem(ret == 0);
}
|
Constraint
Value {
|
Single
Value {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = ACT_EL_VALUE;
$$->value = $1;
}
| ConstraintValue ConstraintRangeSpec ConstraintValue {
| ContainedSubtype {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = ACT_EL_TYPE;
$$->containedSubtype = $1;
}
| SingleValue ConstraintRangeSpec SingleValue {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = $2;
$$->range_start = $1;
$$->range_stop = $3;
}
| TOK_MIN ConstraintRangeSpec
Constraint
Value {
| TOK_MIN ConstraintRangeSpec
Single
Value {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = $2;
...
...
@@ -1593,7 +1600,7 @@ ConstraintSubtypeElement:
$$->range_stop = $3;
$$->range_start->type = ATV_MIN;
}
|
Constraint
Value ConstraintRangeSpec TOK_MAX {
|
Single
Value ConstraintRangeSpec TOK_MAX {
$$ = asn1p_constraint_new(yylineno);
checkmem($$);
$$->type = $2;
...
...
@@ -1634,7 +1641,7 @@ ConstraintSpec:
}
;
Constraint
Value:
Single
Value:
TOK_FALSE {
$$ = asn1p_value_fromint(0);
checkmem($$);
...
...
@@ -1663,7 +1670,10 @@ ConstraintValue:
checkmem($$);
free($1);
}
| TypeRefName {
;
ContainedSubtype:
TypeRefName {
asn1p_ref_t *ref;
int ret;
ref = asn1p_ref_new(yylineno);
...
...
libasn1print/asn1print.c
View file @
ff7dd147
...
...
@@ -284,6 +284,9 @@ asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
printf
(
"("
);
switch
(
ct
->
type
)
{
case
ACT_EL_TYPE
:
asn1print_value
(
ct
->
value
,
flags
);
break
;
case
ACT_EL_VALUE
:
asn1print_value
(
ct
->
value
,
flags
);
break
;
...
...
tests/16-constraint-OK.asn1
View file @
ff7dd147
...
...
@@ -12,11 +12,15 @@ ModuleTestConstraint
BEGIN
-- external reference
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z"|"#"))
Type0 ::= IA5String (Type6)
Type1 ::= IA5String (SIZE(1..ten,...))(FROM("a".."z"|"#",...))
Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc"))
Type3 ::= BMPString (SIZE(1))
Type4 ::= INTEGER (1..MAX)
Type5 ::= BOOLEAN (TRUE|FALSE)
Type6 ::= IA5String (Type1)
ten INTEGER ::= 10
v1 Type1 ::= "#value wi
th ""double quotes"""
...
...
tests/16-constraint-OK.asn1.-EF
View file @
ff7dd147
...
...
@@ -3,7 +3,9 @@ ModuleTestConstraint { iso org(3) dod(6) internet(1) private(4) enterprise(1)
DEFINITIONS ::=
BEGIN
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z" | "#"))
Type0 ::= IA5String (((SIZE(1..10))(FROM("a".."z" | "#"))))
Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z" | "#",...))
Type2 ::= IA5String (SIZE(MIN..4) | FROM("abc"))
...
...
@@ -13,6 +15,10 @@ Type4 ::= INTEGER (1..MAX)
Type5 ::= BOOLEAN (TRUE | FALSE)
Type6 ::= IA5String ((SIZE(1..10))(FROM("a".."z" | "#")))
ten INTEGER ::= 10
v1 Type1 ::= "#value with ""double quotes"""
END
tests/16-constraint-OK.asn1.-EFprint-constraints
0 → 100644
View file @
ff7dd147
File added
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