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
d357f3d5
Commit
d357f3d5
authored
Aug 10, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ioc value encoding
parent
83d8b2f2
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
513 additions
and
50 deletions
+513
-50
libasn1compiler/asn1c_ioc.c
libasn1compiler/asn1c_ioc.c
+4
-4
libasn1fix/asn1fix_cws.c
libasn1fix/asn1fix_cws.c
+41
-31
tests/tests-asn1c-compiler/125-bitstring-constraint-OK.asn1.-X
.../tests-asn1c-compiler/125-bitstring-constraint-OK.asn1.-X
+1
-1
tests/tests-asn1c-compiler/139-component-relation-OK.asn1.-P
tests/tests-asn1c-compiler/139-component-relation-OK.asn1.-P
+4
-4
tests/tests-asn1c-compiler/140-component-relation-OK.asn1
tests/tests-asn1c-compiler/140-component-relation-OK.asn1
+1
-1
tests/tests-asn1c-compiler/140-component-relation-OK.asn1.-EFprint-class-matrix
...iler/140-component-relation-OK.asn1.-EFprint-class-matrix
+1
-1
tests/tests-asn1c-compiler/140-component-relation-OK.asn1.-P
tests/tests-asn1c-compiler/140-component-relation-OK.asn1.-P
+4
-4
tests/tests-asn1c-compiler/141-component-relation-OK.asn1
tests/tests-asn1c-compiler/141-component-relation-OK.asn1
+38
-0
tests/tests-asn1c-compiler/141-component-relation-OK.asn1.-EFprint-class-matrix
...iler/141-component-relation-OK.asn1.-EFprint-class-matrix
+40
-0
tests/tests-asn1c-compiler/141-component-relation-OK.asn1.-P
tests/tests-asn1c-compiler/141-component-relation-OK.asn1.-P
+375
-0
tests/tests-asn1c-compiler/98-attribute-class-OK.asn1.-P
tests/tests-asn1c-compiler/98-attribute-class-OK.asn1.-P
+4
-4
No files found.
libasn1compiler/asn1c_ioc.c
View file @
d357f3d5
...
...
@@ -132,8 +132,8 @@ emit_ioc_value(arg_t *arg, struct asn1p_ioc_cell_s *cell) {
return
-
1
;
}
}
OUT
(
"static const %s asn_VAL_%
s_%d = "
,
prim_type
,
MKID
(
cell
->
value
)
,
cell
->
value
->
_type_unique_index
);
OUT
(
"static const %s asn_VAL_%
d_%s = "
,
prim_type
,
cell
->
value
->
_type_unique_index
,
MKID
(
cell
->
value
)
);
asn1p_expr_t
*
expr_value
=
cell
->
value
;
while
(
expr_value
->
value
->
type
==
ATV_REFERENCED
)
{
...
...
@@ -198,8 +198,8 @@ emit_ioc_cell(arg_t *arg, struct asn1p_ioc_cell_s *cell) {
GEN_INCLUDE
(
asn1c_type_name
(
arg
,
cell
->
value
,
TNF_INCLUDE
));
OUT
(
"aioc__value, "
);
OUT
(
"&asn_DEF_%s, "
,
asn1c_type_name
(
arg
,
cell
->
value
,
TNF_SAFE
));
OUT
(
"&asn_VAL_%
s_%d"
,
MKID
(
cell
->
value
)
,
cell
->
value
->
_type_unique_index
);
OUT
(
"&asn_VAL_%
d_%s"
,
cell
->
value
->
_type_unique_index
,
MKID
(
cell
->
value
)
);
}
else
if
(
cell
->
value
->
meta_type
==
AMT_TYPEREF
)
{
GEN_INCLUDE
(
asn1c_type_name
(
arg
,
cell
->
value
,
TNF_INCLUDE
));
...
...
libasn1fix/asn1fix_cws.c
View file @
d357f3d5
...
...
@@ -4,8 +4,8 @@
static
int
_asn1f_parse_class_object_data
(
arg_t
*
,
asn1p_expr_t
*
eclass
,
struct
asn1p_ioc_row_s
*
row
,
asn1p_wsyntx_t
*
syntax
,
const
uint8_t
*
buf
,
const
uint8_t
*
bend
,
int
optional_mode
,
const
uint8_t
**
newpos
);
static
int
_asn1f_assign_cell_value
(
arg_t
*
arg
,
struct
asn1p_ioc_cell_s
*
cell
,
const
uint8_t
*
buf
,
const
uint8_t
*
bend
);
int
optional_mode
,
const
uint8_t
**
newpos
,
int
counter
);
static
int
_asn1f_assign_cell_value
(
arg_t
*
arg
,
struct
asn1p_ioc_cell_s
*
cell
,
const
uint8_t
*
buf
,
const
uint8_t
*
bend
,
int
counter
);
static
asn1p_wsyntx_chunk_t
*
asn1f_next_literal_chunk
(
asn1p_wsyntx_t
*
syntax
,
asn1p_wsyntx_chunk_t
*
chunk
,
const
uint8_t
*
buf
);
int
...
...
@@ -43,7 +43,7 @@ asn1f_check_class_object(arg_t *arg) {
expr
->
value
->
value
.
string
.
buf
+
1
,
expr
->
value
->
value
.
string
.
buf
+
expr
->
value
->
value
.
string
.
size
-
1
,
0
,
0
);
0
,
0
,
0
);
asn1p_ioc_row_delete
(
row
);
...
...
@@ -74,6 +74,7 @@ struct parse_object_key {
arg_t
*
arg
;
asn1p_expr_t
*
expr
;
/* InformationObjectSet */
asn1p_expr_t
*
eclass
;
/* CLASS */
int
sequence
;
/* Sequence counter */
};
/*
...
...
@@ -120,11 +121,13 @@ _asn1f_parse_object_cb(const uint8_t *buf, size_t size, void *keyp) {
asn1p_ioc_row_t
*
row
;
int
ret
;
key
->
sequence
++
;
row
=
asn1p_ioc_row_new
(
eclass
);
assert
(
row
);
ret
=
_asn1f_parse_class_object_data
(
arg
,
eclass
,
row
,
eclass
->
with_syntax
,
buf
,
buf
+
size
,
0
,
0
);
buf
,
buf
+
size
,
0
,
0
,
key
->
sequence
);
if
(
ret
)
{
LOG
((
int
)(
ret
<
0
),
"Cannot parse %s of CLASS %s found at line %d"
,
...
...
@@ -143,7 +146,7 @@ _asn1f_parse_object_cb(const uint8_t *buf, size_t size, void *keyp) {
row
=
asn1p_ioc_row_new
(
eclass
);
assert
(
row
);
ret
=
_asn1f_parse_class_object_data
(
arg
,
eclass
,
row
,
eclass
->
with_syntax
,
buf
,
buf
+
size
,
0
,
0
);
buf
,
buf
+
size
,
0
,
0
,
key
->
sequence
);
assert
(
ret
==
0
);
if
(
_asn1f_add_unique_row
(
arg
,
expr
,
row
)
!=
0
)
...
...
@@ -261,6 +264,7 @@ asn1f_parse_class_object(arg_t *arg) {
.
arg
=
arg
,
.
expr
=
expr
,
.
eclass
=
eclass
,
.
sequence
=
0
};
switch
(
source
)
{
...
...
@@ -288,7 +292,7 @@ static int
_asn1f_parse_class_object_data
(
arg_t
*
arg
,
asn1p_expr_t
*
eclass
,
struct
asn1p_ioc_row_s
*
row
,
asn1p_wsyntx_t
*
syntax
,
const
uint8_t
*
buf
,
const
uint8_t
*
bend
,
int
optional_mode
,
const
uint8_t
**
newpos
)
{
int
optional_mode
,
const
uint8_t
**
newpos
,
int
counter
)
{
struct
asn1p_wsyntx_chunk_s
*
chunk
;
int
ret
;
...
...
@@ -342,7 +346,7 @@ _asn1f_parse_class_object_data(arg_t *arg, asn1p_expr_t *eclass,
DEBUG
(
"Reference %s satisfied by %s (%d)"
,
chunk
->
content
.
token
,
buf
,
p
-
buf
);
ret
=
_asn1f_assign_cell_value
(
arg
,
cell
,
buf
,
p
);
ret
=
_asn1f_assign_cell_value
(
arg
,
cell
,
buf
,
p
,
counter
);
if
(
ret
)
return
ret
;
buf
=
p
;
if
(
newpos
)
*
newpos
=
buf
;
...
...
@@ -351,7 +355,7 @@ _asn1f_parse_class_object_data(arg_t *arg, asn1p_expr_t *eclass,
const
uint8_t
*
np
=
0
;
SKIPSPACES
;
ret
=
_asn1f_parse_class_object_data
(
arg
,
eclass
,
row
,
chunk
->
content
.
syntax
,
buf
,
bend
,
1
,
&
np
);
chunk
->
content
.
syntax
,
buf
,
bend
,
1
,
&
np
,
counter
);
if
(
newpos
)
*
newpos
=
np
;
if
(
ret
&&
np
!=
buf
)
return
ret
;
...
...
@@ -368,9 +372,9 @@ _asn1f_parse_class_object_data(arg_t *arg, asn1p_expr_t *eclass,
static
int
_asn1f_assign_cell_value
(
arg_t
*
arg
,
struct
asn1p_ioc_cell_s
*
cell
,
const
uint8_t
*
buf
,
const
uint8_t
*
bend
)
{
const
uint8_t
*
buf
,
const
uint8_t
*
bend
,
int
counter
)
{
asn1p_expr_t
*
expr
=
(
asn1p_expr_t
*
)
NULL
;
char
*
p
;
char
*
mivr
;
/* Most Immediate Value Representation */
int
new_ref
=
1
;
asn1p_t
*
asn
;
asn1p_module_t
*
mod
;
...
...
@@ -385,19 +389,19 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
return
-
1
;
}
p
=
malloc
(
bend
-
buf
+
1
);
assert
(
p
);
memcpy
(
p
,
buf
,
bend
-
buf
);
p
[
bend
-
buf
]
=
'\0'
;
mivr
=
malloc
(
bend
-
buf
+
1
);
assert
(
mivr
);
memcpy
(
mivr
,
buf
,
bend
-
buf
);
mivr
[
bend
-
buf
]
=
'\0'
;
/* remove trailing space */
for
(
i
=
bend
-
buf
-
1
;
(
i
>
0
)
&&
isspace
(
p
[
i
]);
i
--
)
p
[
i
]
=
'\0'
;
for
(
i
=
bend
-
buf
-
1
;
(
i
>
0
)
&&
isspace
(
mivr
[
i
]);
i
--
)
mivr
[
i
]
=
'\0'
;
/* This value 100 should be larger than following formatting string */
psize
=
bend
-
buf
+
100
;
pp
=
malloc
(
psize
);
if
(
pp
==
NULL
)
{
free
(
p
);
free
(
mivr
);
return
-
1
;
}
...
...
@@ -406,7 +410,7 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
"M DEFINITIONS ::=
\n
BEGIN
\n
"
"V ::= %s
\n
"
"END
\n
"
,
p
mivr
);
}
else
if
(
cell
->
field
->
expr_type
==
A1TC_CLASSFIELD_FTVFS
)
{
type_expr
=
TQ_FIRST
(
&
(
cell
->
field
->
members
));
...
...
@@ -417,11 +421,11 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
type_expr
->
reference
?
type_expr
->
reference
->
components
[
0
].
name
:
_asn1p_expr_type2string
(
type_expr
->
expr_type
),
p
mivr
);
}
else
{
WARNING
(
"asn1c only be able to parse TypeFieldSpec and FixedTypeValueFieldSpec. Failed when parsing %s at line %d
\n
"
,
p
,
arg
->
expr
->
_lineno
);
free
(
p
);
WARNING
(
"asn1c only be able to parse TypeFieldSpec and FixedTypeValueFieldSpec. Failed when parsing %s at line %d
\n
"
,
mivr
,
arg
->
expr
->
_lineno
);
free
(
mivr
);
free
(
pp
);
return
-
1
;
}
...
...
@@ -435,10 +439,10 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
if
(
asn
==
NULL
)
{
FATAL
(
"Cannot parse Setting token %s "
"at line %d"
,
p
,
mivr
,
arg
->
expr
->
_lineno
);
free
(
p
);
free
(
mivr
);
return
-
1
;
}
else
{
mod
=
TQ_FIRST
(
&
(
asn
->
modules
));
...
...
@@ -446,13 +450,19 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
expr
=
TQ_REMOVE
(
&
(
mod
->
members
),
next
);
assert
(
expr
);
free
(
expr
->
Identifier
);
expr
->
parent_expr
=
NULL
;
asn1p_expr_set_source
(
expr
,
arg
->
expr
->
module
,
arg
->
expr
->
_lineno
);
if
(
expr
->
reference
)
{
expr
->
_type_unique_index
=
counter
;
DEBUG
(
"Parsed identifier %s, mivr [%s], reference [%s] value [%s]"
,
expr
->
Identifier
,
mivr
,
asn1p_ref_string
(
expr
->
reference
),
asn1f_printable_value
(
expr
->
value
));
free
(
expr
->
Identifier
);
if
(
expr
->
value
)
{
expr
->
Identifier
=
strdup
(
asn1f_printable_value
(
expr
->
value
));
}
else
if
(
expr
->
reference
)
{
expr
->
Identifier
=
strdup
(
expr
->
reference
->
components
[
expr
->
reference
->
comp_count
-
1
].
name
);
}
else
{
expr
->
Identifier
=
p
;
expr
->
Identifier
=
mivr
;
}
asn1p_delete
(
asn
);
}
...
...
@@ -467,21 +477,21 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_cell_s *cell,
expr
->
reference
=
0
;
asn1p_expr_free
(
expr
);
FATAL
(
"Cannot find %s referenced by %s at line %d"
,
p
,
arg
->
expr
->
Identifier
,
mivr
,
arg
->
expr
->
Identifier
,
arg
->
expr
->
_lineno
);
free
(
p
);
/* freeing must happen *after* p was used in FATAL() */
free
(
mivr
);
return
-
1
;
}
}
DEBUG
(
"Field %s assignment of %s got %s"
,
cell
->
field
->
Identifier
,
p
,
expr
->
Identifier
);
cell
->
field
->
Identifier
,
mivr
,
expr
->
Identifier
);
cell
->
value
=
expr
;
cell
->
new_ref
=
new_ref
;
if
(
expr
->
Identifier
!=
p
)
{
free
(
p
);
if
(
expr
->
Identifier
!=
mivr
)
{
free
(
mivr
);
}
return
0
;
...
...
tests/tests-asn1c-compiler/125-bitstring-constraint-OK.asn1.-X
View file @
d357f3d5
...
...
@@ -3,6 +3,6 @@
<!-- ASN.1 module
ModuleBitStringConstraint { iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 125 }
found in ../
tests
/125-bitstring-constraint-OK.asn1 -->
found in ../
../tests/tests-asn1c-compiler
/125-bitstring-constraint-OK.asn1 -->
<!ELEMENT T (flag1?, flag2?, flag3?)>
tests/tests-asn1c-compiler/139-component-relation-OK.asn1.-P
View file @
d357f3d5
...
...
@@ -28,12 +28,12 @@ extern asn_TYPE_descriptor_t asn_DEF_Frame;
/*** <<< IOC-TABLES [Frame] >>> ***/
static const long asn_VAL_
basicMessage_0
= 1;
static const long asn_VAL_2_
0
= 2;
static const long asn_VAL_
1_basicMessage
= 1;
static const long asn_VAL_2_
2
= 2;
static const asn_ioc_cell_t asn_IOS_FrameTypes_1_rows[] = {
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_
basicMessage_0
},
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_
1_basicMessage
},
{ "&Type", aioc__type, &asn_DEF_PrimitiveMessage },
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_
0
},
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_
2
},
{ "&Type", aioc__type, &asn_DEF_ComplexMessage }
};
static asn_ioc_set_t asn_IOS_FrameTypes_1[] = {
...
...
tests/tests-asn1c-compiler/140-component-relation-OK.asn1
View file @
d357f3d5
...
...
@@ -13,7 +13,7 @@ BEGIN
Frame ::= SEQUENCE {
ident FRAME-STRUCTURE.&id({FrameTypes}),
value FRAME-STRUCTURE.&Type({FrameTypes}{@
.
ident}),
value FRAME-STRUCTURE.&Type({FrameTypes}{@ident}),
...
}
...
...
tests/tests-asn1c-compiler/140-component-relation-OK.asn1.-EFprint-class-matrix
View file @
d357f3d5
...
...
@@ -5,7 +5,7 @@ BEGIN
Frame ::= SEQUENCE {
ident FRAME-STRUCTURE.&id ({FrameTypes}),
value FRAME-STRUCTURE.&Type ({FrameTypes}{@
.
ident}),
value FRAME-STRUCTURE.&Type ({FrameTypes}{@ident}),
...
}
...
...
tests/tests-asn1c-compiler/140-component-relation-OK.asn1.-P
View file @
d357f3d5
...
...
@@ -28,12 +28,12 @@ extern asn_TYPE_descriptor_t asn_DEF_Frame;
/*** <<< IOC-TABLES [Frame] >>> ***/
static const long asn_VAL_
basicMessage_0
= 1;
static const long asn_VAL_2_
0
= 2;
static const long asn_VAL_
1_basicMessage
= 1;
static const long asn_VAL_2_
2
= 2;
static const asn_ioc_cell_t asn_IOS_FrameTypes_1_rows[] = {
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_
basicMessage_0
},
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_
1_basicMessage
},
{ "&Type", aioc__type, &asn_DEF_PrimitiveMessage },
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_
0
},
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_
2
},
{ "&Type", aioc__type, &asn_DEF_ComplexMessage }
};
static asn_ioc_set_t asn_IOS_FrameTypes_1[] = {
...
...
tests/tests-asn1c-compiler/141-component-relation-OK.asn1
0 → 100755
View file @
d357f3d5
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .141
ModuleComponentRelationConstraint
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 141 }
DEFINITIONS ::=
BEGIN
Frame ::= SEQUENCE {
ident FRAME-STRUCTURE.&id({FrameTypes}),
value FRAME-STRUCTURE.&Type({FrameTypes}{@.ident}),
...
}
FRAME-STRUCTURE ::= CLASS {
&id ConstrainedInteger UNIQUE,
&Type
} WITH SYNTAX {&Type IDENTIFIED BY &id}
ConstrainedInteger ::= INTEGER (0..32767)
FrameTypes FRAME-STRUCTURE ::= {
{ PrimitiveMessage IDENTIFIED BY primMessage } |
{ ComplexMessage IDENTIFIED BY cplxMessage }
, ... }
PrimitiveMessage ::= SEQUENCE {}
ComplexMessage ::= SEQUENCE {}
primMessage INTEGER ::= 1
cplxMessage INTEGER ::= 2
END
tests/tests-asn1c-compiler/141-component-relation-OK.asn1.-EFprint-class-matrix
0 → 100644
View file @
d357f3d5
ModuleComponentRelationConstraint { iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 141 }
DEFINITIONS ::=
BEGIN
Frame ::= SEQUENCE {
ident FRAME-STRUCTURE.&id ({FrameTypes}),
value FRAME-STRUCTURE.&Type ({FrameTypes}{@.ident}),
...
}
FRAME-STRUCTURE ::= CLASS {
&id ConstrainedInteger UNIQUE,
&Type ANY
} WITH SYNTAX {&Type IDENTIFIED BY &id}
-- Information Object Set has 2 entries:
-- [ &id][ &Type]
-- [1] primMessage PrimitiveMessage
-- [2] cplxMessage ComplexMessage
ConstrainedInteger ::= INTEGER (0..32767)
FrameTypes FRAME-STRUCTURE ::= {{ PrimitiveMessage IDENTIFIED BY primMessage } | { ComplexMessage IDENTIFIED BY cplxMessage },...}
-- Information Object Set has 2 entries:
-- [ &id][ &Type]
-- [1] primMessage PrimitiveMessage
-- [2] cplxMessage ComplexMessage
PrimitiveMessage ::= SEQUENCE { }
ComplexMessage ::= SEQUENCE { }
primMessage INTEGER ::= 1
cplxMessage INTEGER ::= 2
END
tests/tests-asn1c-compiler/141-component-relation-OK.asn1.-P
0 → 100644
View file @
d357f3d5
/*** <<< INCLUDES [Frame] >>> ***/
#include "ConstrainedInteger.h"
#include <ANY.h>
#include <asn_ioc.h>
#include "PrimitiveMessage.h"
#include "ComplexMessage.h"
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Frame] >>> ***/
typedef struct Frame {
ConstrainedInteger_t ident;
ANY_t value;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Frame_t;
/*** <<< FUNC-DECLS [Frame] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Frame;
/*** <<< IOC-TABLES [Frame] >>> ***/
static const long asn_VAL_1_primMessage = 1;
static const long asn_VAL_2_cplxMessage = 2;
static const asn_ioc_cell_t asn_IOS_FrameTypes_1_rows[] = {
{ "&id", aioc__value, &asn_DEF_ConstrainedInteger, &asn_VAL_1_primMessage },
{ "&Type", aioc__type, &asn_DEF_PrimitiveMessage },
{ "&id", aioc__value, &asn_DEF_ConstrainedInteger, &asn_VAL_2_cplxMessage },
{ "&Type", aioc__type, &asn_DEF_ComplexMessage }
};
static asn_ioc_set_t asn_IOS_FrameTypes_1[] = {
2, 2, asn_IOS_FrameTypes_1_rows
};
/*** <<< CODE [Frame] >>> ***/
static int
memb_ident_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 32767)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static asn_TYPE_descriptor_t *
select_value_type(const asn_TYPE_descriptor_t *parent_type, const void *parent_sptr) {
asn_ioc_set_t *itable = asn_IOS_FrameTypes_1;
size_t constraining_column = 0; /* &id */
size_t for_column = 1; /* &Type */
size_t row;
const long *constraining_value = (const long *)((const char *)parent_sptr + offsetof(struct Frame, ident));
for(row=0; row < itable->rows_count; row++) {
asn_ioc_cell_s *constraining_cell = itable->rows[row * itable->columns_count + constraining_column];
asn_ioc_cell_s *type_cell = itable->rows[row * itable->columns_count + for_column];
if(constraining_cell->type_descriptor->struct_compare(constraining_cell->type_descriptor, constraining_value, constraining_cell->value_sptr) == 0) {
return type_cell->type_descriptor;
}
}
return NULL;
}
static int
memb_value_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
}
return td->check_constraints(td, sptr, ctfailcb, app_key);
}
/*** <<< STAT-DEFS [Frame] >>> ***/
static asn_TYPE_member_t asn_MBR_Frame_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Frame, ident),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_ConstrainedInteger,
.type_selector = 0,
.memb_constraints = memb_ident_constraint_1,
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "ident"
},
{ ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct Frame, value),
.tag = -1 /* Ambiguous tag (ANY?) */,
.tag_mode = 0,
.type = &asn_DEF_ANY,
.type_selector = select_value_type,
.memb_constraints = memb_value_constraint_1,
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "value"
},
};
static const ber_tlv_tag_t asn_DEF_Frame_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Frame_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* ident */
};
static asn_SEQUENCE_specifics_t asn_SPC_Frame_specs_1 = {
sizeof(struct Frame),
offsetof(struct Frame, _asn_ctx),
asn_MAP_Frame_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
1, /* Start extensions */
3 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_Frame = {
"Frame",
"Frame",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_compare,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Frame_tags_1,
sizeof(asn_DEF_Frame_tags_1)
/sizeof(asn_DEF_Frame_tags_1[0]), /* 1 */
asn_DEF_Frame_tags_1, /* Same as above */
sizeof(asn_DEF_Frame_tags_1)
/sizeof(asn_DEF_Frame_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Frame_1,
2, /* Elements count */
&asn_SPC_Frame_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [ConstrainedInteger] >>> ***/
#include <NativeInteger.h>
/*** <<< TYPE-DECLS [ConstrainedInteger] >>> ***/
typedef long ConstrainedInteger_t;
/*** <<< FUNC-DECLS [ConstrainedInteger] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_ConstrainedInteger;
asn_struct_free_f ConstrainedInteger_free;
asn_struct_print_f ConstrainedInteger_print;
asn_constr_check_f ConstrainedInteger_constraint;
ber_type_decoder_f ConstrainedInteger_decode_ber;
der_type_encoder_f ConstrainedInteger_encode_der;
xer_type_decoder_f ConstrainedInteger_decode_xer;
xer_type_encoder_f ConstrainedInteger_encode_xer;
/*** <<< CODE [ConstrainedInteger] >>> ***/
int
ConstrainedInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 32767)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*
* This type is implemented using NativeInteger,
* so here we adjust the DEF accordingly.
*/
/*** <<< STAT-DEFS [ConstrainedInteger] >>> ***/
static const ber_tlv_tag_t asn_DEF_ConstrainedInteger_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_ConstrainedInteger = {
"ConstrainedInteger",
"ConstrainedInteger",
NativeInteger_free,
NativeInteger_print,
NativeInteger_compare,
ConstrainedInteger_constraint,
NativeInteger_decode_ber,
NativeInteger_encode_der,
NativeInteger_decode_xer,
NativeInteger_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_ConstrainedInteger_tags_1,
sizeof(asn_DEF_ConstrainedInteger_tags_1)
/sizeof(asn_DEF_ConstrainedInteger_tags_1[0]), /* 1 */
asn_DEF_ConstrainedInteger_tags_1, /* Same as above */
sizeof(asn_DEF_ConstrainedInteger_tags_1)
/sizeof(asn_DEF_ConstrainedInteger_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [PrimitiveMessage] >>> ***/
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [PrimitiveMessage] >>> ***/
typedef struct PrimitiveMessage {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} PrimitiveMessage_t;
/*** <<< FUNC-DECLS [PrimitiveMessage] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_PrimitiveMessage;
extern asn_SEQUENCE_specifics_t asn_SPC_PrimitiveMessage_specs_1;
/*** <<< STAT-DEFS [PrimitiveMessage] >>> ***/
static const ber_tlv_tag_t asn_DEF_PrimitiveMessage_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_SEQUENCE_specifics_t asn_SPC_PrimitiveMessage_specs_1 = {
sizeof(struct PrimitiveMessage),
offsetof(struct PrimitiveMessage, _asn_ctx),
0, /* No top level tags */
0, /* No tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_PrimitiveMessage = {
"PrimitiveMessage",
"PrimitiveMessage",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_compare,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_PrimitiveMessage_tags_1,
sizeof(asn_DEF_PrimitiveMessage_tags_1)
/sizeof(asn_DEF_PrimitiveMessage_tags_1[0]), /* 1 */
asn_DEF_PrimitiveMessage_tags_1, /* Same as above */
sizeof(asn_DEF_PrimitiveMessage_tags_1)
/sizeof(asn_DEF_PrimitiveMessage_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
&asn_SPC_PrimitiveMessage_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [ComplexMessage] >>> ***/
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [ComplexMessage] >>> ***/
typedef struct ComplexMessage {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} ComplexMessage_t;
/*** <<< FUNC-DECLS [ComplexMessage] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_ComplexMessage;
extern asn_SEQUENCE_specifics_t asn_SPC_ComplexMessage_specs_1;
/*** <<< STAT-DEFS [ComplexMessage] >>> ***/
static const ber_tlv_tag_t asn_DEF_ComplexMessage_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_SEQUENCE_specifics_t asn_SPC_ComplexMessage_specs_1 = {
sizeof(struct ComplexMessage),
offsetof(struct ComplexMessage, _asn_ctx),
0, /* No top level tags */
0, /* No tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_ComplexMessage = {
"ComplexMessage",
"ComplexMessage",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_compare,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_ComplexMessage_tags_1,
sizeof(asn_DEF_ComplexMessage_tags_1)
/sizeof(asn_DEF_ComplexMessage_tags_1[0]), /* 1 */
asn_DEF_ComplexMessage_tags_1, /* Same as above */
sizeof(asn_DEF_ComplexMessage_tags_1)
/sizeof(asn_DEF_ComplexMessage_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
&asn_SPC_ComplexMessage_specs_1 /* Additional specs */
};
tests/tests-asn1c-compiler/98-attribute-class-OK.asn1.-P
View file @
d357f3d5
...
...
@@ -22,11 +22,11 @@ extern asn_TYPE_descriptor_t asn_DEF_Attribute;
/*** <<< IOC-TABLES [Attribute] >>> ***/
static const RELATIVE_OID_t asn_VAL_
raf_0
= { "not supported", 0 };
static const RELATIVE_OID_t asn_VAL_
rcf_0
= { "not supported", 0 };
static const RELATIVE_OID_t asn_VAL_
1_raf
= { "not supported", 0 };
static const RELATIVE_OID_t asn_VAL_
2_rcf
= { "not supported", 0 };
static const asn_ioc_cell_t asn_IOS_Attributes_1_rows[] = {
{ "&id", aioc__value, &asn_DEF_RELATIVE_OID, &asn_VAL_
raf_0
},
{ "&id", aioc__value, &asn_DEF_RELATIVE_OID, &asn_VAL_
rcf_0
}
{ "&id", aioc__value, &asn_DEF_RELATIVE_OID, &asn_VAL_
1_raf
},
{ "&id", aioc__value, &asn_DEF_RELATIVE_OID, &asn_VAL_
2_rcf
}
};
static asn_ioc_set_t asn_IOS_Attributes_1[] = {
2, 1, asn_IOS_Attributes_1_rows
...
...
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