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
fe8c6b7e
Commit
fe8c6b7e
authored
Oct 03, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add OER for BOOLEAN
parent
8cec5235
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
10 deletions
+82
-10
skeletons/BOOLEAN.c
skeletons/BOOLEAN.c
+70
-8
skeletons/BOOLEAN.h
skeletons/BOOLEAN.h
+4
-2
tests/tests-randomized/bundles/01-BOOLEAN-bundle.txt
tests/tests-randomized/bundles/01-BOOLEAN-bundle.txt
+8
-0
No files found.
skeletons/BOOLEAN.c
View file @
fe8c6b7e
...
@@ -24,8 +24,8 @@ asn_TYPE_operation_t asn_OP_BOOLEAN = {
...
@@ -24,8 +24,8 @@ asn_TYPE_operation_t asn_OP_BOOLEAN = {
0
,
0
,
0
,
0
,
#else
#else
0
,
BOOLEAN_decode_oer
,
0
,
BOOLEAN_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
@@ -258,6 +258,8 @@ BOOLEAN_free(const asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -258,6 +258,8 @@ BOOLEAN_free(const asn_TYPE_descriptor_t *td, void *ptr,
}
}
}
}
#ifndef ASN_DISABLE_PER_SUPPORT
asn_dec_rval_t
asn_dec_rval_t
BOOLEAN_decode_uper
(
const
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
BOOLEAN_decode_uper
(
const
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
const
asn_per_constraints_t
*
constraints
,
void
**
sptr
,
const
asn_per_constraints_t
*
constraints
,
void
**
sptr
,
...
@@ -308,6 +310,60 @@ BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
...
@@ -308,6 +310,60 @@ BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK
(
er
);
ASN__ENCODED_OK
(
er
);
}
}
#endif
/* ASN_DISABLE_PER_SUPPORT */
#ifndef ASN_DISABLE_OER_SUPPORT
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
BOOLEAN_encode_oer
(
asn_TYPE_descriptor_t
*
td
,
const
asn_oer_constraints_t
*
constraints
,
void
*
sptr
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_enc_rval_t
er
=
{
1
,
0
,
0
};
const
BOOLEAN_t
*
st
=
sptr
;
uint8_t
bool_value
=
*
st
?
0xff
:
0
;
/* 0xff mandated by OER */
(
void
)
td
;
(
void
)
constraints
;
/* Constraints are unused in OER */
if
(
cb
(
&
bool_value
,
1
,
app_key
)
<
0
)
{
ASN__ENCODE_FAILED
;
}
else
{
ASN__ENCODED_OK
(
er
);
}
}
asn_dec_rval_t
BOOLEAN_decode_oer
(
const
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
const
asn_oer_constraints_t
*
constraints
,
void
**
sptr
,
const
void
*
ptr
,
size_t
size
)
{
asn_dec_rval_t
ok
=
{
RC_OK
,
1
};
BOOLEAN_t
*
st
;
(
void
)
opt_codec_ctx
;
(
void
)
td
;
(
void
)
constraints
;
/* Constraints are unused in OER */
if
(
size
<
1
)
{
ASN__DECODE_STARVED
;
}
if
(
!
(
st
=
*
sptr
))
{
st
=
(
BOOLEAN_t
*
)(
*
sptr
=
CALLOC
(
1
,
sizeof
(
*
st
)));
if
(
!
st
)
ASN__DECODE_FAILED
;
}
*
st
=
*
(
const
uint8_t
*
)
ptr
;
return
ok
;
}
#endif
int
int
BOOLEAN_compare
(
const
asn_TYPE_descriptor_t
*
td
,
const
void
*
aptr
,
BOOLEAN_compare
(
const
asn_TYPE_descriptor_t
*
td
,
const
void
*
aptr
,
...
@@ -318,7 +374,7 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
...
@@ -318,7 +374,7 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
(
void
)
td
;
(
void
)
td
;
if
(
a
&&
b
)
{
if
(
a
&&
b
)
{
if
(
*
a
==
*
b
)
{
if
(
!*
a
==
!*
b
)
{
/* TRUE can be encoded by any non-zero byte. */
return
0
;
return
0
;
}
else
if
(
!*
a
)
{
}
else
if
(
!*
a
)
{
return
-
1
;
return
-
1
;
...
@@ -334,16 +390,13 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
...
@@ -334,16 +390,13 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
asn_random_fill_result_t
asn_random_fill_result_t
BOOLEAN_random_fill
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
sptr
,
BOOLEAN_random_fill
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
sptr
,
const
asn_encoding_constraints_t
*
constr
,
const
asn_encoding_constraints_t
*
constr
aints
,
size_t
max_length
)
{
size_t
max_length
)
{
asn_random_fill_result_t
result_ok
=
{
ARFILL_OK
,
1
};
asn_random_fill_result_t
result_ok
=
{
ARFILL_OK
,
1
};
asn_random_fill_result_t
result_failed
=
{
ARFILL_FAILED
,
0
};
asn_random_fill_result_t
result_failed
=
{
ARFILL_FAILED
,
0
};
asn_random_fill_result_t
result_skipped
=
{
ARFILL_SKIPPED
,
0
};
asn_random_fill_result_t
result_skipped
=
{
ARFILL_SKIPPED
,
0
};
BOOLEAN_t
*
st
=
*
sptr
;
BOOLEAN_t
*
st
=
*
sptr
;
(
void
)
td
;
(
void
)
constr
;
if
(
max_length
==
0
)
return
result_skipped
;
if
(
max_length
==
0
)
return
result_skipped
;
if
(
st
==
NULL
)
{
if
(
st
==
NULL
)
{
...
@@ -353,7 +406,16 @@ BOOLEAN_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
...
@@ -353,7 +406,16 @@ BOOLEAN_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
}
}
}
}
*
st
=
asn_random_between
(
0
,
1
);
if
(
!
constraints
)
constraints
=
&
td
->
encoding_constraints
;
if
(
constraints
->
per_constraints
)
{
const
asn_per_constraint_t
*
pc
=
&
constraints
->
per_constraints
->
value
;
if
(
pc
->
flags
&
APC_CONSTRAINED
)
{
*
st
=
asn_random_between
(
pc
->
lower_bound
,
pc
->
upper_bound
);
return
result_ok
;
}
}
/* Simulate booleans that are sloppily set */
*
st
=
asn_random_between
(
0
,
1
)
?
asn_random_between
(
1
,
0x7fffffff
)
:
0
;
return
result_ok
;
return
result_ok
;
}
}
skeletons/BOOLEAN.h
View file @
fe8c6b7e
...
@@ -26,10 +26,12 @@ asn_struct_print_f BOOLEAN_print;
...
@@ -26,10 +26,12 @@ asn_struct_print_f BOOLEAN_print;
asn_struct_compare_f
BOOLEAN_compare
;
asn_struct_compare_f
BOOLEAN_compare
;
ber_type_decoder_f
BOOLEAN_decode_ber
;
ber_type_decoder_f
BOOLEAN_decode_ber
;
der_type_encoder_f
BOOLEAN_encode_der
;
der_type_encoder_f
BOOLEAN_encode_der
;
xer_type_decoder_f
BOOLEAN_decode_x
er
;
oer_type_decoder_f
BOOLEAN_decode_o
er
;
xer_type_encoder_f
BOOLEAN_encode_x
er
;
oer_type_encoder_f
BOOLEAN_encode_o
er
;
per_type_decoder_f
BOOLEAN_decode_uper
;
per_type_decoder_f
BOOLEAN_decode_uper
;
per_type_encoder_f
BOOLEAN_encode_uper
;
per_type_encoder_f
BOOLEAN_encode_uper
;
xer_type_decoder_f
BOOLEAN_decode_xer
;
xer_type_encoder_f
BOOLEAN_encode_xer
;
asn_random_fill_f
BOOLEAN_random_fill
;
asn_random_fill_f
BOOLEAN_random_fill
;
#define BOOLEAN_constraint asn_generic_no_constraint
#define BOOLEAN_constraint asn_generic_no_constraint
...
...
tests/tests-randomized/bundles/01-BOOLEAN-bundle.txt
0 → 100644
View file @
fe8c6b7e
-- Test boolean. Should be easy
T ::= BOOLEAN
T ::= BOOLEAN (FALSE)
T ::= BOOLEAN (TRUE)
T ::= BOOLEAN (FALSE,...)
T ::= BOOLEAN (TRUE,...)
T ::= BOOLEAN (FALSE..TRUE)
T ::= BOOLEAN (FALSE..TRUE,...)
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