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
9de6cd89
Commit
9de6cd89
authored
Aug 10, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using ioc constraints in run time
parent
9ec239e7
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
285 additions
and
37 deletions
+285
-37
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+227
-12
libasn1compiler/asn1c_internal.h
libasn1compiler/asn1c_internal.h
+3
-1
libasn1compiler/asn1c_ioc.c
libasn1compiler/asn1c_ioc.c
+1
-1
libasn1compiler/asn1c_out.h
libasn1compiler/asn1c_out.h
+23
-13
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+3
-1
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+5
-4
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+14
-4
skeletons/constr_TYPE.h
skeletons/constr_TYPE.h
+9
-1
No files found.
libasn1compiler/asn1c_C.c
View file @
9de6cd89
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_internal.h
View file @
9de6cd89
...
...
@@ -41,13 +41,15 @@
#include "asn1compiler.h"
struct
asn1c_ioc_table_and_objset_s
;
typedef
struct
arg_s
{
enum
asn1c_flags
flags
;
void
(
*
logger_cb
)(
int
_severity
,
const
char
*
fmt
,
...);
int
(
*
default_cb
)(
struct
arg_s
*
);
int
(
*
default_cb
)(
struct
arg_s
*
,
const
struct
asn1c_ioc_table_and_objset_s
*
opt
);
struct
compiler_streams
*
target
;
...
...
libasn1compiler/asn1c_ioc.c
View file @
9de6cd89
...
...
@@ -223,7 +223,7 @@ emit_ioc_table(arg_t *arg, asn1p_expr_t *context, asn1c_ioc_table_and_objset_t i
(
void
)
context
;
GEN_INCLUDE_STD
(
"asn_ioc"
);
REDIR
(
OT_
STAT_DEF
S
);
REDIR
(
OT_
IOC_TABLE
S
);
/* Emit values that are used in the Information Object Set table first */
for
(
size_t
rn
=
0
;
rn
<
ioc_tao
.
ioct
->
rows
;
rn
++
)
{
...
...
libasn1compiler/asn1c_out.h
View file @
9de6cd89
...
...
@@ -21,6 +21,7 @@ typedef struct compiler_streams {
OT_TYPE_DECLS
,
/* Type declarations */
OT_FUNC_DECLS
,
/* Function declarations */
OT_POST_INCLUDE
,
/* #include after type definition */
OT_IOC_TABLES
,
/* Information Object Class tables */
OT_CTABLES
,
/* Constraint tables */
OT_CODE
,
/* Some code */
OT_CTDEFS
,
/* Constraint definitions */
...
...
@@ -36,7 +37,7 @@ typedef struct compiler_streams {
}
compiler_streams_t
;
static
char
*
_compiler_stream2str
[]
__attribute__
((
unused
))
=
{
"IGNORE"
,
"INCLUDES"
,
"DEPS"
,
"FWD-DECLS"
,
"FWD-DEFS"
,
"TYPE-DECLS"
,
"FUNC-DECLS"
,
"POST-INCLUDE"
,
"CTABLES"
,
"CODE"
,
"CTDEFS"
,
"STAT-DEFS"
};
=
{
"IGNORE"
,
"INCLUDES"
,
"DEPS"
,
"FWD-DECLS"
,
"FWD-DEFS"
,
"TYPE-DECLS"
,
"FUNC-DECLS"
,
"POST-INCLUDE"
,
"
IOC-TABLES"
,
"
CTABLES"
,
"CODE"
,
"CTDEFS"
,
"STAT-DEFS"
};
int
asn1c_compiled_output
(
arg_t
*
arg
,
const
char
*
fmt
,
...);
...
...
@@ -56,18 +57,27 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
INDENT(-1); \
} while(0)
#define EMBED(ev) do { \
arg->embed++; \
INDENTED(arg_t _tmp = *arg; \
_tmp.expr = ev; \
_tmp.default_cb(&_tmp); \
); \
arg->embed--; \
if(ev->expr_type != A1TC_EXTENSIBLE) \
OUT(";\n"); \
assert(arg->target->target == OT_TYPE_DECLS || \
arg->target->target == OT_FWD_DEFS); \
} while(0)
#define EMBED(ev) \
do { \
arg->embed++; \
INDENTED(arg_t _tmp = *arg; _tmp.expr = ev; \
_tmp.default_cb(&_tmp, NULL);); \
arg->embed--; \
if(ev->expr_type != A1TC_EXTENSIBLE) OUT(";\n"); \
assert(arg->target->target == OT_TYPE_DECLS \
|| arg->target->target == OT_FWD_DEFS); \
} while(0)
#define EMBED_WITH_IOCT(ev, ioc) \
do { \
arg->embed++; \
INDENTED(arg_t _tmp = *arg; _tmp.expr = ev; \
_tmp.default_cb(&_tmp, ((ioc).ioct ? &ioc : 0));); \
arg->embed--; \
if(ev->expr_type != A1TC_EXTENSIBLE) OUT(";\n"); \
assert(arg->target->target == OT_TYPE_DECLS \
|| arg->target->target == OT_FWD_DEFS); \
} while(0)
/* Output a piece of text into a default stream */
#define OUT(fmt, args...) asn1c_compiled_output(arg, fmt, ##args)
...
...
libasn1compiler/asn1c_save.c
View file @
9de6cd89
...
...
@@ -303,6 +303,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
safe_fprintf
(
fp_c
,
"#include
\"
%s.h
\"\n\n
"
,
filename
);
if
(
arg
->
flags
&
A1C_NO_INCLUDE_DEPS
)
SAVE_STREAM
(
fp_c
,
OT_POST_INCLUDE
,
""
,
1
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_IOC_TABLES
].
chunks
),
next
)
safe_fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_CTABLES
].
chunks
),
next
)
safe_fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_CODE
].
chunks
),
next
)
...
...
@@ -312,7 +314,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
TQ_FOR
(
ot
,
&
(
cs
->
destination
[
OT_STAT_DEFS
].
chunks
),
next
)
safe_fwrite
(
ot
->
buf
,
ot
->
len
,
1
,
fp_c
);
assert
(
OT_MAX
==
1
2
);
/* Protection from reckless changes */
assert
(
OT_MAX
==
1
3
);
/* Protection from reckless changes */
fclose
(
fp_c
);
fclose
(
fp_h
);
...
...
libasn1compiler/asn1compiler.c
View file @
9de6cd89
...
...
@@ -2,9 +2,10 @@
#include "asn1c_lang.h"
#include "asn1c_out.h"
#include "asn1c_save.h"
#include "asn1c_ioc.h"
static
void
default_logger_cb
(
int
,
const
char
*
fmt
,
...);
static
int
asn1c_compile_expr
(
arg_t
*
arg
);
static
int
asn1c_compile_expr
(
arg_t
*
arg
,
const
asn1c_ioc_table_and_objset_t
*
);
static
int
asn1c_attach_streams
(
asn1p_expr_t
*
expr
);
static
int
asn1c_detach_streams
(
asn1p_expr_t
*
expr
);
...
...
@@ -42,7 +43,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
cs
->
target
=
OT_TYPE_DECLS
;
arg
->
target
=
cs
;
ret
=
asn1c_compile_expr
(
arg
);
ret
=
asn1c_compile_expr
(
arg
,
NULL
);
if
(
ret
)
{
FATAL
(
"Cannot compile
\"
%s
\"
(%x:%x) at line %d"
,
arg
->
expr
->
Identifier
,
...
...
@@ -72,7 +73,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
}
static
int
asn1c_compile_expr
(
arg_t
*
arg
)
{
asn1c_compile_expr
(
arg_t
*
arg
,
const
asn1c_ioc_table_and_objset_t
*
opt_ioc
)
{
asn1p_expr_t
*
expr
=
arg
->
expr
;
int
(
*
type_cb
)(
arg_t
*
);
int
ret
;
...
...
@@ -99,7 +100,7 @@ asn1c_compile_expr(arg_t *arg) {
for
(
i
=
0
;
i
<
expr
->
specializations
.
pspecs_count
;
i
++
)
{
arg
->
expr
=
expr
->
specializations
.
pspec
[
i
].
my_clone
;
ret
=
asn1c_compile_expr
(
arg
);
ret
=
asn1c_compile_expr
(
arg
,
opt_ioc
);
if
(
ret
)
break
;
}
arg
->
expr
=
expr
;
/* Restore */
...
...
skeletons/constr_SEQUENCE.c
View file @
9de6cd89
...
...
@@ -1081,7 +1081,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
*/
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn_TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
void
*
memb_ptr
;
/* Pointer to the member */
void
*
memb_ptr
;
/* Pointer to the member */
void
**
memb_ptr2
;
/* Pointer to that pointer */
if
(
IN_EXTENSION_GROUP
(
specs
,
edx
))
...
...
@@ -1119,9 +1119,19 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Fetch the member from the stream */
ASN_DEBUG
(
"Decoding member %s in %s"
,
elm
->
name
,
td
->
name
);
rv
=
elm
->
type
->
uper_decoder
(
opt_codec_ctx
,
elm
->
type
,
elm
->
per_constraints
,
memb_ptr2
,
pd
);
if
(
rv
.
code
!=
RC_OK
)
{
if
((
elm
->
flags
&
ATF_OPEN_TYPE
)
&&
elm
->
type_selector
)
{
asn_TYPE_descriptor_t
*
et
=
elm
->
type_selector
(
td
,
st
);
if
(
!
et
)
{
FREEMEM
(
opres
);
ASN__DECODE_FAILED
;
}
rv
=
uper_open_type_get
(
opt_codec_ctx
,
et
,
NULL
,
memb_ptr2
,
pd
);
}
else
{
rv
=
elm
->
type
->
uper_decoder
(
opt_codec_ctx
,
elm
->
type
,
elm
->
per_constraints
,
memb_ptr2
,
pd
);
}
if
(
rv
.
code
!=
RC_OK
)
{
ASN_DEBUG
(
"Failed decode %s in %s"
,
elm
->
name
,
td
->
name
);
FREEMEM
(
opres
);
...
...
skeletons/constr_TYPE.h
View file @
9de6cd89
...
...
@@ -91,7 +91,14 @@ typedef ber_tlv_tag_t (asn_outmost_tag_f)(
/* The instance of the above function type; used internally. */
asn_outmost_tag_f
asn_TYPE_outmost_tag
;
/*
* Fetch the desired type of the Open Type based on the
* Information Object Set driven constraints.
*/
typedef
struct
asn_TYPE_descriptor_s
*
(
asn_type_selector_f
)(
const
struct
asn_TYPE_descriptor_s
*
parent_type_descriptor
,
const
void
*
parent_structure_ptr
);
/*
* The definitive description of the destination language's structure.
*/
...
...
@@ -161,6 +168,7 @@ typedef struct asn_TYPE_member_s {
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
int
tag_mode
;
/* IMPLICIT/no/EXPLICIT tag at current level */
asn_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
asn_type_selector_f
*
type_selector
;
/* IoS selector */
asn_constr_check_f
*
memb_constraints
;
/* Constraints validator */
asn_oer_constraints_t
*
oer_constraints
;
/* OER compiled constraints */
asn_per_constraints_t
*
per_constraints
;
/* PER compiled constraints */
...
...
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