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
4cfcd4f1
Unverified
Commit
4cfcd4f1
authored
Feb 04, 2024
by
Mouse
Committed by
GitHub
Feb 04, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #174 from v0-e/copy-op
Copy operation
parents
a6bdcd22
edfc7e7f
Changes
76
Show whitespace changes
Inline
Side-by-side
Showing
76 changed files
with
769 additions
and
2 deletions
+769
-2
asn1-tools/unber/libasn1_unber_tool.c
asn1-tools/unber/libasn1_unber_tool.c
+9
-0
skeletons/ANY.c
skeletons/ANY.c
+1
-0
skeletons/ANY.h
skeletons/ANY.h
+1
-0
skeletons/BIT_STRING.c
skeletons/BIT_STRING.c
+35
-0
skeletons/BIT_STRING.h
skeletons/BIT_STRING.h
+1
-0
skeletons/BMPString.c
skeletons/BMPString.c
+1
-0
skeletons/BMPString.h
skeletons/BMPString.h
+1
-0
skeletons/BOOLEAN.c
skeletons/BOOLEAN.c
+27
-0
skeletons/BOOLEAN.h
skeletons/BOOLEAN.h
+1
-0
skeletons/ENUMERATED.c
skeletons/ENUMERATED.c
+1
-0
skeletons/ENUMERATED.h
skeletons/ENUMERATED.h
+1
-0
skeletons/GeneralString.c
skeletons/GeneralString.c
+1
-0
skeletons/GeneralString.h
skeletons/GeneralString.h
+1
-0
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+1
-0
skeletons/GeneralizedTime.h
skeletons/GeneralizedTime.h
+1
-0
skeletons/GraphicString.c
skeletons/GraphicString.c
+1
-0
skeletons/GraphicString.h
skeletons/GraphicString.h
+1
-0
skeletons/IA5String.c
skeletons/IA5String.c
+1
-0
skeletons/IA5String.h
skeletons/IA5String.h
+1
-0
skeletons/INTEGER.c
skeletons/INTEGER.c
+38
-0
skeletons/INTEGER.h
skeletons/INTEGER.h
+1
-0
skeletons/ISO646String.c
skeletons/ISO646String.c
+1
-0
skeletons/ISO646String.h
skeletons/ISO646String.h
+1
-0
skeletons/NULL.c
skeletons/NULL.c
+13
-0
skeletons/NULL.h
skeletons/NULL.h
+1
-0
skeletons/NativeEnumerated.c
skeletons/NativeEnumerated.c
+1
-0
skeletons/NativeEnumerated.h
skeletons/NativeEnumerated.h
+1
-0
skeletons/NativeInteger.c
skeletons/NativeInteger.c
+28
-0
skeletons/NativeInteger.h
skeletons/NativeInteger.h
+1
-0
skeletons/NativeReal.c
skeletons/NativeReal.c
+30
-0
skeletons/NativeReal.h
skeletons/NativeReal.h
+1
-0
skeletons/NumericString.c
skeletons/NumericString.c
+1
-0
skeletons/NumericString.h
skeletons/NumericString.h
+1
-0
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+1
-0
skeletons/OBJECT_IDENTIFIER.h
skeletons/OBJECT_IDENTIFIER.h
+1
-0
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+38
-0
skeletons/OCTET_STRING.h
skeletons/OCTET_STRING.h
+1
-0
skeletons/OPEN_TYPE.c
skeletons/OPEN_TYPE.c
+1
-0
skeletons/OPEN_TYPE.h
skeletons/OPEN_TYPE.h
+1
-0
skeletons/ObjectDescriptor.c
skeletons/ObjectDescriptor.c
+1
-0
skeletons/PrintableString.c
skeletons/PrintableString.c
+1
-0
skeletons/PrintableString.h
skeletons/PrintableString.h
+1
-0
skeletons/REAL.c
skeletons/REAL.c
+36
-0
skeletons/REAL.h
skeletons/REAL.h
+1
-0
skeletons/RELATIVE-OID.c
skeletons/RELATIVE-OID.c
+1
-0
skeletons/RELATIVE-OID.h
skeletons/RELATIVE-OID.h
+1
-0
skeletons/T61String.c
skeletons/T61String.c
+1
-0
skeletons/T61String.h
skeletons/T61String.h
+1
-0
skeletons/TeletexString.c
skeletons/TeletexString.c
+1
-0
skeletons/TeletexString.h
skeletons/TeletexString.h
+1
-0
skeletons/UTCTime.c
skeletons/UTCTime.c
+1
-0
skeletons/UTCTime.h
skeletons/UTCTime.h
+1
-0
skeletons/UTF8String.c
skeletons/UTF8String.c
+1
-0
skeletons/UTF8String.h
skeletons/UTF8String.h
+1
-0
skeletons/UniversalString.c
skeletons/UniversalString.c
+1
-0
skeletons/UniversalString.h
skeletons/UniversalString.h
+1
-0
skeletons/VideotexString.c
skeletons/VideotexString.c
+1
-0
skeletons/VideotexString.h
skeletons/VideotexString.h
+1
-0
skeletons/VisibleString.c
skeletons/VisibleString.c
+1
-0
skeletons/VisibleString.h
skeletons/VisibleString.h
+1
-0
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+54
-0
skeletons/constr_CHOICE.h
skeletons/constr_CHOICE.h
+1
-0
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+51
-0
skeletons/constr_SEQUENCE.h
skeletons/constr_SEQUENCE.h
+1
-0
skeletons/constr_SEQUENCE_OF.c
skeletons/constr_SEQUENCE_OF.c
+1
-0
skeletons/constr_SEQUENCE_OF.h
skeletons/constr_SEQUENCE_OF.h
+1
-0
skeletons/constr_SET.c
skeletons/constr_SET.c
+51
-0
skeletons/constr_SET.h
skeletons/constr_SET.h
+1
-0
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+56
-0
skeletons/constr_SET_OF.h
skeletons/constr_SET_OF.h
+1
-0
skeletons/constr_TYPE.c
skeletons/constr_TYPE.c
+20
-0
skeletons/constr_TYPE.h
skeletons/constr_TYPE.h
+22
-0
tests/tests-randomized/check-bundles.sh
tests/tests-randomized/check-bundles.sh
+10
-0
tests/tests-randomized/random-test-driver.c
tests/tests-randomized/random-test-driver.c
+82
-2
tests/tests-skeletons/Makefile.am
tests/tests-skeletons/Makefile.am
+5
-0
tests/tests-skeletons/check-copy.c
tests/tests-skeletons/check-copy.c
+107
-0
No files found.
asn1-tools/unber/libasn1_unber_tool.c
View file @
4cfcd4f1
...
...
@@ -866,6 +866,15 @@ OCTET_STRING_compare(const asn_TYPE_descriptor_t *td, const void *a,
return
0
;
}
int
OCTET_STRING_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
a
,
const
void
*
b
)
{
(
void
)
td
;
(
void
)
a
;
(
void
)
b
;
return
0
;
}
intmax_t
asn_random_between
(
intmax_t
a
,
intmax_t
b
)
{
(
void
)
b
;
...
...
skeletons/ANY.c
View file @
4cfcd4f1
...
...
@@ -18,6 +18,7 @@ asn_TYPE_operation_t asn_OP_ANY = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
...
...
skeletons/ANY.h
View file @
4cfcd4f1
...
...
@@ -29,6 +29,7 @@ extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define ANY_compare OCTET_STRING_compare
#define ANY_copy OCTET_STRING_copy
#define ANY_constraint asn_generic_no_constraint
...
...
skeletons/BIT_STRING.c
View file @
4cfcd4f1
...
...
@@ -24,6 +24,7 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
BIT_STRING_compare
,
BIT_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
/* Implemented in terms of OCTET STRING */
...
...
@@ -213,3 +214,37 @@ BIT_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return
1
;
}
}
int
BIT_STRING_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
const
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
;
BIT_STRING_t
*
a
=
(
BIT_STRING_t
*
)
*
aptr
;
const
BIT_STRING_t
*
b
=
(
const
BIT_STRING_t
*
)
bptr
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
->
buf
);
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
!
a
)
return
-
1
;
}
uint8_t
*
buf
=
MALLOC
(
b
->
size
+
1
);
if
(
!
buf
)
return
-
1
;
memcpy
(
buf
,
b
->
buf
,
b
->
size
);
buf
[
b
->
size
]
=
0
;
FREEMEM
(
a
->
buf
);
a
->
buf
=
buf
;
a
->
size
=
b
->
size
;
a
->
bits_unused
=
b
->
bits_unused
;
return
0
;
}
skeletons/BIT_STRING.h
View file @
4cfcd4f1
...
...
@@ -31,6 +31,7 @@ asn_struct_print_f BIT_STRING_print; /* Human-readable output */
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
BIT_STRING_compare
;
asn_struct_copy_f
BIT_STRING_copy
;
asn_constr_check_f
BIT_STRING_constraint
;
...
...
skeletons/BMPString.c
View file @
4cfcd4f1
...
...
@@ -32,6 +32,7 @@ asn_TYPE_operation_t asn_OP_BMPString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
...
...
skeletons/BMPString.h
View file @
4cfcd4f1
...
...
@@ -28,6 +28,7 @@ asn_struct_print_f BMPString_print; /* Human-readable output */
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define BMPString_compare OCTET_STRING_compare
#define BMPString_copy OCTET_STRING_copy
asn_constr_check_f
BMPString_constraint
;
...
...
skeletons/BOOLEAN.c
View file @
4cfcd4f1
...
...
@@ -19,6 +19,7 @@ asn_TYPE_operation_t asn_OP_BOOLEAN = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
BOOLEAN_compare
,
BOOLEAN_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
BOOLEAN_decode_ber
,
BOOLEAN_encode_der
,
...
...
@@ -128,3 +129,29 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return
1
;
}
}
int
BOOLEAN_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
BOOLEAN_t
*
a
=
*
aptr
;
const
BOOLEAN_t
*
b
=
bptr
;
(
void
)
td
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
MALLOC
(
sizeof
(
BOOLEAN_t
));
if
(
!
a
)
return
-
1
;
}
*
a
=
*
b
;
return
0
;
}
skeletons/BOOLEAN.h
View file @
4cfcd4f1
...
...
@@ -28,6 +28,7 @@ asn_struct_print_f BOOLEAN_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
BOOLEAN_compare
;
asn_struct_copy_f
BOOLEAN_copy
;
#define BOOLEAN_constraint asn_generic_no_constraint
...
...
skeletons/ENUMERATED.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_ENUMERATED = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
INTEGER_compare
,
/* Implemented in terms of INTEGER */
INTEGER_copy
,
/* Implemented in terms of INTEGER */
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive
,
INTEGER_encode_der
,
/* Implemented in terms of INTEGER */
...
...
skeletons/ENUMERATED.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_ENUMERATED;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define ENUMERATED_compare INTEGER_compare
#define ENUMERATED_copy INTEGER_copy
#define ENUMERATED_constraint asn_generic_no_constraint
...
...
skeletons/GeneralString.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_GeneralString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/GeneralString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_GeneralString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define GeneralString_compare OCTET_STRING_compare
#define GeneralString_copy OCTET_STRING_copy
#define GeneralString_constraint asn_generic_unknown_constraint
...
...
skeletons/GeneralizedTime.c
View file @
4cfcd4f1
...
...
@@ -182,6 +182,7 @@ asn_TYPE_operation_t asn_OP_GeneralizedTime = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
GeneralizedTime_compare
,
GeneralizedTime_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
GeneralizedTime_encode_der
,
...
...
skeletons/GeneralizedTime.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ asn_struct_print_f GeneralizedTime_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
GeneralizedTime_compare
;
#define GeneralizedTime_copy OCTET_STRING_copy
asn_constr_check_f
GeneralizedTime_constraint
;
...
...
skeletons/GraphicString.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_GraphicString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/GraphicString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_GraphicString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define GraphicString_compare OCTET_STRING_compare
#define GraphicString_copy OCTET_STRING_copy
#define GraphicString_constraint asn_generic_unknown_constraint
...
...
skeletons/IA5String.c
View file @
4cfcd4f1
...
...
@@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_IA5String = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/IA5String.h
View file @
4cfcd4f1
...
...
@@ -26,6 +26,7 @@ extern asn_TYPE_operation_t asn_OP_IA5String;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define IA5String_compare OCTET_STRING_compare
#define IA5String_copy OCTET_STRING_copy
asn_constr_check_f
IA5String_constraint
;
...
...
skeletons/INTEGER.c
View file @
4cfcd4f1
...
...
@@ -22,6 +22,7 @@ asn_TYPE_operation_t asn_OP_INTEGER = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
INTEGER_compare
,
INTEGER_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive
,
INTEGER_encode_der
,
...
...
@@ -738,3 +739,40 @@ INTEGER_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
}
int
INTEGER_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
(
void
)
td
;
INTEGER_t
*
a
=
*
aptr
;
const
INTEGER_t
*
b
=
bptr
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
->
buf
);
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
CALLOC
(
1
,
sizeof
(
*
a
));
if
(
!
a
)
return
-
1
;
}
if
(
b
->
size
)
{
uint8_t
*
buf
=
MALLOC
(
b
->
size
);
if
(
!
buf
)
return
-
1
;
memcpy
(
buf
,
b
->
buf
,
b
->
size
);
FREEMEM
(
a
->
buf
);
a
->
buf
=
buf
;
a
->
size
=
b
->
size
;
}
else
{
FREEMEM
(
a
->
buf
);
a
->
buf
=
0
;
a
->
size
=
0
;
}
return
0
;
}
skeletons/INTEGER.h
View file @
4cfcd4f1
...
...
@@ -47,6 +47,7 @@ asn_struct_print_f INTEGER_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
INTEGER_compare
;
asn_struct_copy_f
INTEGER_copy
;
#define INTEGER_constraint asn_generic_no_constraint
...
...
skeletons/ISO646String.c
View file @
4cfcd4f1
...
...
@@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_ISO646String = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/ISO646String.h
View file @
4cfcd4f1
...
...
@@ -24,6 +24,7 @@ extern asn_TYPE_operation_t asn_OP_ISO646String;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define ISO646String_compare OCTET_STRING_compare
#define ISO646String_copy OCTET_STRING_copy
#define ISO646String_constraint VisibleString_constraint
...
...
skeletons/NULL.c
View file @
4cfcd4f1
...
...
@@ -19,6 +19,7 @@ asn_TYPE_operation_t asn_OP_NULL = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NULL_compare
,
NULL_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NULL_decode_ber
,
NULL_encode_der
,
/* Special handling of DER encoding */
...
...
@@ -113,3 +114,15 @@ NULL_compare(const asn_TYPE_descriptor_t *td, const void *a, const void *b) {
(
void
)
b
;
return
0
;
}
int
NULL_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
a
,
const
void
*
b
)
{
(
void
)
td
;
if
(
b
&&
!*
a
)
{
*
a
=
CALLOC
(
1
,
sizeof
(
NULL_t
));
if
(
!*
a
)
return
-
1
;
}
return
0
;
}
skeletons/NULL.h
View file @
4cfcd4f1
...
...
@@ -27,6 +27,7 @@ asn_struct_print_f NULL_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
NULL_compare
;
asn_struct_copy_f
NULL_copy
;
#define NULL_constraint asn_generic_no_constraint
...
...
skeletons/NativeEnumerated.c
View file @
4cfcd4f1
...
...
@@ -26,6 +26,7 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NativeInteger_compare
,
NativeInteger_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NativeInteger_decode_ber
,
NativeInteger_encode_der
,
...
...
skeletons/NativeEnumerated.h
View file @
4cfcd4f1
...
...
@@ -29,6 +29,7 @@ extern asn_TYPE_operation_t asn_OP_NativeEnumerated;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define NativeEnumerated_compare NativeInteger_compare
#define NativeEnumerated_copy NativeInteger_copy
#define NativeEnumerated_constraint asn_generic_no_constraint
...
...
skeletons/NativeInteger.c
View file @
4cfcd4f1
...
...
@@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_NativeInteger = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NativeInteger_compare
,
NativeInteger_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NativeInteger_decode_ber
,
NativeInteger_encode_der
,
...
...
@@ -152,3 +153,30 @@ NativeInteger_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const v
return
1
;
}
}
int
NativeInteger_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
unsigned
long
*
a
=
*
aptr
;
const
unsigned
long
*
b
=
bptr
;
(
void
)
td
;
/* Check if source has data */
if
(
!
b
)
{
/* Clear destination */
if
(
a
)
{
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
MALLOC
(
sizeof
(
*
a
));
if
(
!
a
)
return
-
1
;
}
*
a
=
*
b
;
return
0
;
}
skeletons/NativeInteger.h
View file @
4cfcd4f1
...
...
@@ -29,6 +29,7 @@ asn_struct_print_f NativeInteger_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
NativeInteger_compare
;
asn_struct_copy_f
NativeInteger_copy
;
#define NativeInteger_constraint asn_generic_no_constraint
...
...
skeletons/NativeReal.c
View file @
4cfcd4f1
...
...
@@ -46,6 +46,7 @@ asn_TYPE_operation_t asn_OP_NativeReal = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
NativeReal_compare
,
NativeReal_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
NativeReal_decode_ber
,
NativeReal_encode_der
,
...
...
@@ -149,6 +150,35 @@ NativeReal_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
}
int
NativeReal_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
size_t
float_size
=
NativeReal__float_size
(
td
);
void
*
a
=
*
aptr
;
const
void
*
b
=
bptr
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
MALLOC
(
float_size
);
if
(
!
a
)
return
-
1
;
}
if
(
float_size
==
sizeof
(
float
))
{
*
(
float
*
)
a
=
*
(
const
float
*
)
b
;
}
else
{
*
(
double
*
)
a
=
*
(
const
double
*
)
b
;
}
return
0
;
}
void
NativeReal_free
(
const
asn_TYPE_descriptor_t
*
td
,
void
*
ptr
,
enum
asn_struct_free_method
method
)
{
...
...
skeletons/NativeReal.h
View file @
4cfcd4f1
...
...
@@ -37,6 +37,7 @@ asn_struct_print_f NativeReal_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
NativeReal_compare
;
asn_struct_copy_f
NativeReal_copy
;
#define NativeReal_constraint asn_generic_no_constraint
...
...
skeletons/NumericString.c
View file @
4cfcd4f1
...
...
@@ -47,6 +47,7 @@ asn_TYPE_operation_t asn_OP_NumericString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/NumericString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_NumericString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define NumericString_compare OCTET_STRING_compare
#define NumericString_copy OCTET_STRING_copy
asn_constr_check_f
NumericString_constraint
;
...
...
skeletons/OBJECT_IDENTIFIER.c
View file @
4cfcd4f1
...
...
@@ -24,6 +24,7 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
/* Implemented in terms of a string comparison */
OCTET_STRING_copy
,
/* Implemented in terms of a string copy */
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive
,
der_encode_primitive
,
...
...
skeletons/OBJECT_IDENTIFIER.h
View file @
4cfcd4f1
...
...
@@ -32,6 +32,7 @@ asn_struct_print_f OBJECT_IDENTIFIER_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define OBJECT_IDENTIFIER_compare OCTET_STRING_compare
#define OBJECT_IDENTIFIER_copy OCTET_STRING_copy
asn_constr_check_f
OBJECT_IDENTIFIER_constraint
;
...
...
skeletons/OCTET_STRING.c
View file @
4cfcd4f1
...
...
@@ -26,6 +26,7 @@ asn_TYPE_operation_t asn_OP_OCTET_STRING = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
...
...
@@ -249,6 +250,43 @@ OCTET_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
int
OCTET_STRING_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
const
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
?
(
const
asn_OCTET_STRING_specifics_t
*
)
td
->
specifics
:
&
asn_SPC_OCTET_STRING_specs
;
OCTET_STRING_t
*
a
=
*
aptr
;
const
OCTET_STRING_t
*
b
=
bptr
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
->
buf
);
a
->
buf
=
0
;
a
->
size
=
0
;
FREEMEM
(
a
);
}
*
aptr
=
0
;
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
(
OCTET_STRING_t
*
)
CALLOC
(
1
,
specs
->
struct_size
);
if
(
!
a
)
return
-
1
;
}
void
*
buf
=
MALLOC
(
b
->
size
+
1
);
if
(
!
buf
)
return
-
1
;
memcpy
(
buf
,
b
->
buf
,
b
->
size
);
((
uint8_t
*
)
buf
)[
b
->
size
]
=
'\0'
;
FREEMEM
(
a
->
buf
);
a
->
buf
=
(
uint8_t
*
)
buf
;
a
->
size
=
b
->
size
;
return
0
;
}
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
int
OCTET_STRING_per_get_characters
(
asn_per_data_t
*
po
,
uint8_t
*
buf
,
...
...
skeletons/OCTET_STRING.h
View file @
4cfcd4f1
...
...
@@ -29,6 +29,7 @@ asn_struct_print_f OCTET_STRING_print_utf8;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
OCTET_STRING_compare
;
asn_struct_copy_f
OCTET_STRING_copy
;
#define OCTET_STRING_constraint asn_generic_no_constraint
...
...
skeletons/OPEN_TYPE.c
View file @
4cfcd4f1
...
...
@@ -14,6 +14,7 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OPEN_TYPE_compare
,
OPEN_TYPE_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OPEN_TYPE_decode_ber
,
OPEN_TYPE_encode_der
,
...
...
skeletons/OPEN_TYPE.h
View file @
4cfcd4f1
...
...
@@ -33,6 +33,7 @@ extern "C" {
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define OPEN_TYPE_compare CHOICE_compare
#define OPEN_TYPE_copy CHOICE_copy
#define OPEN_TYPE_constraint CHOICE_constraint
...
...
skeletons/ObjectDescriptor.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_ObjectDescriptor = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/PrintableString.c
View file @
4cfcd4f1
...
...
@@ -57,6 +57,7 @@ asn_TYPE_operation_t asn_OP_PrintableString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/PrintableString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_PrintableString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define PrintableString_compare OCTET_STRING_compare
#define PrintableString_copy OCTET_STRING_copy
asn_constr_check_f
PrintableString_constraint
;
...
...
skeletons/REAL.c
View file @
4cfcd4f1
...
...
@@ -62,6 +62,7 @@ asn_TYPE_operation_t asn_OP_REAL = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
REAL_compare
,
REAL_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive
,
der_encode_primitive
,
...
...
@@ -361,6 +362,41 @@ REAL_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
}
}
int
REAL_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
REAL_t
*
a
=
*
aptr
;
const
REAL_t
*
b
=
bptr
;
(
void
)
td
;
if
(
!
b
)
{
if
(
a
)
{
FREEMEM
(
a
->
buf
);
FREEMEM
(
a
);
*
aptr
=
0
;
}
return
0
;
}
if
(
!
a
)
{
a
=
*
aptr
=
CALLOC
(
1
,
sizeof
(
*
a
));
if
(
!
a
)
return
-
1
;
}
if
(
b
->
size
)
{
uint8_t
*
buf
=
(
uint8_t
*
)
MALLOC
(
b
->
size
);
if
(
!
buf
)
return
-
1
;
memcpy
(
buf
,
b
->
buf
,
b
->
size
);
FREEMEM
(
a
->
buf
);
a
->
buf
=
buf
;
a
->
size
=
b
->
size
;
}
return
0
;
}
int
asn_REAL2double
(
const
REAL_t
*
st
,
double
*
dbl_value
)
{
unsigned
int
octv
;
...
...
skeletons/REAL.h
View file @
4cfcd4f1
...
...
@@ -54,6 +54,7 @@ asn_struct_print_f REAL_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
REAL_compare
;
asn_struct_copy_f
REAL_copy
;
#define REAL_constraint asn_generic_no_constraint
...
...
skeletons/RELATIVE-OID.c
View file @
4cfcd4f1
...
...
@@ -22,6 +22,7 @@ asn_TYPE_operation_t asn_OP_RELATIVE_OID = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
/* Implemented in terms of opaque comparison */
OCTET_STRING_copy
,
/* Implemented in terms of opaque copy */
#if !defined(ASN_DISABLE_BER_SUPPORT)
ber_decode_primitive
,
der_encode_primitive
,
...
...
skeletons/RELATIVE-OID.h
View file @
4cfcd4f1
...
...
@@ -28,6 +28,7 @@ asn_struct_print_f RELATIVE_OID_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define RELATIVE_OID_compare OCTET_STRING_compare
#define RELATIVE_OID_copy OCTET_STRING_copy
#define RELATIVE_OID_constraint asn_generic_no_constraint
...
...
skeletons/T61String.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_T61String = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/T61String.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_T61String;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define T61String_compare OCTET_STRING_compare
#define T61String_copy OCTET_STRING_copy
#define T61String_constraint asn_generic_unknown_constraint
...
...
skeletons/TeletexString.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_TeletexString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/TeletexString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_TeletexString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define TeletexString_compare OCTET_STRING_compare
#define TeletexString_copy OCTET_STRING_copy
#define TeletexString_constraint asn_generic_unknown_constraint
...
...
skeletons/UTCTime.c
View file @
4cfcd4f1
...
...
@@ -38,6 +38,7 @@ asn_TYPE_operation_t asn_OP_UTCTime = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
UTCTime_compare
,
UTCTime_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
/* Implemented in terms of OCTET STRING */
...
...
skeletons/UTCTime.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ asn_struct_print_f UTCTime_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
UTCTime_compare
;
#define UTCTime_copy OCTET_STRING_copy
asn_constr_check_f
UTCTime_constraint
;
...
...
skeletons/UTF8String.c
View file @
4cfcd4f1
...
...
@@ -21,6 +21,7 @@ asn_TYPE_operation_t asn_OP_UTF8String = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/UTF8String.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ asn_struct_print_f UTF8String_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define UTF8String_compare OCTET_STRING_compare
#define UTF8String_copy OCTET_STRING_copy
asn_constr_check_f
UTF8String_constraint
;
...
...
skeletons/UniversalString.c
View file @
4cfcd4f1
...
...
@@ -32,6 +32,7 @@ asn_TYPE_operation_t asn_OP_UniversalString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
...
...
skeletons/UniversalString.h
View file @
4cfcd4f1
...
...
@@ -24,6 +24,7 @@ asn_struct_print_f UniversalString_print; /* Human-readable output */
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define UniversalString_compare OCTET_STRING_compare
#define UniversalString_copy OCTET_STRING_copy
asn_constr_check_f
UniversalString_constraint
;
...
...
skeletons/VideotexString.c
View file @
4cfcd4f1
...
...
@@ -20,6 +20,7 @@ asn_TYPE_operation_t asn_OP_VideotexString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/VideotexString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_VideotexString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define VideotexString_compare OCTET_STRING_compare
#define VideotexString_copy OCTET_STRING_copy
#define VideotexString_constraint asn_generic_unknown_constraint
...
...
skeletons/VisibleString.c
View file @
4cfcd4f1
...
...
@@ -27,6 +27,7 @@ asn_TYPE_operation_t asn_OP_VisibleString = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
OCTET_STRING_compare
,
OCTET_STRING_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
OCTET_STRING_decode_ber
,
/* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der
,
...
...
skeletons/VisibleString.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern asn_TYPE_operation_t asn_OP_VisibleString;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
#define VisibleString_compare OCTET_STRING_compare
#define VisibleString_copy OCTET_STRING_copy
asn_constr_check_f
VisibleString_constraint
;
...
...
skeletons/constr_CHOICE.c
View file @
4cfcd4f1
...
...
@@ -13,6 +13,7 @@ asn_TYPE_operation_t asn_OP_CHOICE = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
CHOICE_compare
,
CHOICE_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
CHOICE_decode_ber
,
CHOICE_encode_der
,
...
...
@@ -314,6 +315,59 @@ CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bp
}
}
int
CHOICE_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
if
(
!
td
)
return
-
1
;
void
*
st
=
*
aptr
;
const
asn_CHOICE_specifics_t
*
specs
=
(
const
asn_CHOICE_specifics_t
*
)
td
->
specifics
;
const
asn_TYPE_member_t
*
elm
;
/* CHOICE's element */
int
present
;
int
ret
;
void
*
amemb
;
void
**
amembp
;
const
void
*
bmemb
;
if
(
!
bptr
)
{
if
(
st
)
{
ASN_STRUCT_FREE
(
*
td
,
st
);
*
aptr
=
NULL
;
}
return
0
;
}
if
(
!
st
)
{
st
=
*
aptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
!
st
)
return
-
1
;
}
present
=
_fetch_present_idx
(
bptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
if
(
present
<=
0
&&
(
unsigned
)
present
>
td
->
elements_count
)
return
-
1
;
--
present
;
elm
=
&
td
->
elements
[
present
];
if
(
elm
->
flags
&
ATF_POINTER
)
{
/* Member is a pointer to another structure */
amembp
=
(
void
**
)((
char
*
)
st
+
elm
->
memb_offset
);
bmemb
=
*
(
const
void
*
const
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
else
{
amemb
=
(
char
*
)
st
+
elm
->
memb_offset
;
amembp
=
&
amemb
;
bmemb
=
(
const
void
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
ret
=
elm
->
type
->
op
->
copy_struct
(
elm
->
type
,
amembp
,
bmemb
);
if
(
ret
!=
0
)
return
ret
;
_set_present_idx
(
st
,
specs
->
pres_offset
,
specs
->
pres_size
,
present
+
1
);
return
0
;
}
/*
* Return the 1-based choice variant presence index.
* Returns 0 in case of error.
...
...
skeletons/constr_CHOICE.h
View file @
4cfcd4f1
...
...
@@ -46,6 +46,7 @@ asn_struct_print_f CHOICE_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
CHOICE_compare
;
asn_struct_copy_f
CHOICE_copy
;
asn_constr_check_f
CHOICE_constraint
;
...
...
skeletons/constr_SEQUENCE.c
View file @
4cfcd4f1
...
...
@@ -14,6 +14,7 @@ asn_TYPE_operation_t asn_OP_SEQUENCE = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
SEQUENCE_compare
,
SEQUENCE_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
SEQUENCE_decode_ber
,
SEQUENCE_encode_der
,
...
...
@@ -198,3 +199,53 @@ SEQUENCE_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return
0
;
}
int
SEQUENCE_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
if
(
!
td
)
return
-
1
;
const
asn_SEQUENCE_specifics_t
*
specs
=
(
const
asn_SEQUENCE_specifics_t
*
)
td
->
specifics
;
size_t
edx
;
void
*
st
=
*
aptr
;
/* Target structure */
if
(
!
bptr
)
{
if
(
st
)
{
SEQUENCE_free
(
td
,
st
,
0
);
*
aptr
=
0
;
}
return
0
;
}
/*
* Create the target structure if it is not present already.
*/
if
(
st
==
0
)
{
st
=
*
aptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
st
==
0
)
return
-
1
;
}
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn_TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
void
*
amemb
;
void
**
amembp
;
const
void
*
bmemb
;
int
ret
;
if
(
elm
->
flags
&
ATF_POINTER
)
{
/* Member is a pointer to another structure */
amembp
=
(
void
**
)((
char
*
)
st
+
elm
->
memb_offset
);
bmemb
=
*
(
const
void
*
const
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
else
{
amemb
=
(
char
*
)
st
+
elm
->
memb_offset
;
amembp
=
&
amemb
;
bmemb
=
(
const
void
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
ret
=
elm
->
type
->
op
->
copy_struct
(
elm
->
type
,
amembp
,
bmemb
);
if
(
ret
!=
0
)
return
ret
;
}
return
0
;
}
skeletons/constr_SEQUENCE.h
View file @
4cfcd4f1
...
...
@@ -51,6 +51,7 @@ asn_struct_print_f SEQUENCE_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
SEQUENCE_compare
;
asn_struct_copy_f
SEQUENCE_copy
;
asn_constr_check_f
SEQUENCE_constraint
;
...
...
skeletons/constr_SEQUENCE_OF.c
View file @
4cfcd4f1
...
...
@@ -15,6 +15,7 @@ asn_TYPE_operation_t asn_OP_SEQUENCE_OF = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
SEQUENCE_OF_compare
,
SEQUENCE_OF_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
SEQUENCE_OF_decode_ber
,
SEQUENCE_OF_encode_der
,
...
...
skeletons/constr_SEQUENCE_OF.h
View file @
4cfcd4f1
...
...
@@ -23,6 +23,7 @@ extern "C" {
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
SEQUENCE_OF_compare
;
#define SEQUENCE_OF_copy SET_OF_copy
#define SEQUENCE_OF_constraint SET_OF_constraint
...
...
skeletons/constr_SET.c
View file @
4cfcd4f1
...
...
@@ -14,6 +14,7 @@ asn_TYPE_operation_t asn_OP_SET = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
SET_compare
,
SET_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
SET_decode_ber
,
SET_encode_der
,
...
...
@@ -216,3 +217,53 @@ SET_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return
0
;
}
int
SET_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
if
(
!
td
)
return
-
1
;
const
asn_SET_specifics_t
*
specs
=
(
const
asn_SET_specifics_t
*
)
td
->
specifics
;
size_t
edx
;
void
*
st
=
*
aptr
;
/* Target structure */
if
(
!
bptr
)
{
if
(
st
)
{
SET_free
(
td
,
st
,
ASFM_FREE_EVERYTHING
);
*
aptr
=
0
;
}
return
0
;
}
/*
* Create the target structure if it is not present already.
*/
if
(
st
==
0
)
{
st
=
*
aptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
st
==
0
)
return
-
1
;
}
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn_TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
void
*
amemb
;
void
**
amembp
;
const
void
*
bmemb
;
int
ret
;
if
(
elm
->
flags
&
ATF_POINTER
)
{
/* Member is a pointer to another structure */
amembp
=
(
void
**
)((
char
*
)
st
+
elm
->
memb_offset
);
bmemb
=
*
(
const
void
*
const
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
else
{
amemb
=
(
char
*
)
st
+
elm
->
memb_offset
;
amembp
=
&
amemb
;
bmemb
=
(
const
void
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
}
ret
=
elm
->
type
->
op
->
copy_struct
(
elm
->
type
,
amembp
,
bmemb
);
if
(
ret
!=
0
)
return
ret
;
}
return
0
;
}
skeletons/constr_SET.h
View file @
4cfcd4f1
...
...
@@ -52,6 +52,7 @@ asn_struct_print_f SET_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
SET_compare
;
asn_struct_copy_f
SET_copy
;
asn_constr_check_f
SET_constraint
;
...
...
skeletons/constr_SET_OF.c
View file @
4cfcd4f1
...
...
@@ -14,6 +14,7 @@ asn_TYPE_operation_t asn_OP_SET_OF = {
0
,
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
SET_OF_compare
,
SET_OF_copy
,
#if !defined(ASN_DISABLE_BER_SUPPORT)
SET_OF_decode_ber
,
SET_OF_encode_der
,
...
...
@@ -371,3 +372,58 @@ SET_OF_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
return
0
;
}
int
SET_OF_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
aptr
,
const
void
*
bptr
)
{
if
(
!
td
)
return
-
1
;
const
asn_SET_OF_specifics_t
*
specs
=
(
const
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
void
*
st
=
*
aptr
;
if
(
!
bptr
)
{
if
(
*
aptr
)
{
asn_set_empty
(
_A_SET_FROM_VOID
(
*
aptr
));
*
aptr
=
0
;
}
return
0
;
}
if
(
st
==
0
)
{
st
=
*
aptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
st
==
0
)
return
-
1
;
}
asn_anonymous_set_
*
a
=
_A_SET_FROM_VOID
(
*
aptr
);
const
asn_anonymous_set_
*
b
=
_A_CSET_FROM_VOID
(
bptr
);
if
(
b
->
size
)
{
void
*
_new_arr
;
_new_arr
=
REALLOC
(
a
->
array
,
b
->
size
*
sizeof
(
b
->
array
[
0
]));
if
(
_new_arr
)
{
a
->
array
=
(
void
**
)
_new_arr
;
a
->
size
=
b
->
size
;
}
else
{
return
-
1
;
}
a
->
count
=
b
->
count
;
for
(
int
i
=
0
;
i
<
b
->
count
;
i
++
)
{
void
*
bmemb
=
b
->
array
[
i
];
if
(
bmemb
)
{
void
*
amemb
=
0
;
int
ret
;
ret
=
td
->
elements
->
type
->
op
->
copy_struct
(
td
->
elements
->
type
,
&
amemb
,
bmemb
);
if
(
ret
!=
0
)
return
ret
;
a
->
array
[
i
]
=
amemb
;
}
else
{
a
->
array
[
i
]
=
0
;
}
}
}
return
0
;
}
skeletons/constr_SET_OF.h
View file @
4cfcd4f1
...
...
@@ -33,6 +33,7 @@ asn_struct_print_f SET_OF_print;
#endif
/* !defined(ASN_DISABLE_PRINT_SUPPORT) */
asn_struct_compare_f
SET_OF_compare
;
asn_struct_copy_f
SET_OF_copy
;
asn_constr_check_f
SET_OF_constraint
;
...
...
skeletons/constr_TYPE.c
View file @
4cfcd4f1
...
...
@@ -54,6 +54,26 @@ asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
return
fflush
(
stream
);
}
/*
* Copy a structuture.
*/
int
asn_copy
(
const
asn_TYPE_descriptor_t
*
td
,
void
**
struct_dst
,
const
void
*
struct_src
)
{
if
(
!
td
||
!
struct_dst
||
!
struct_src
)
{
errno
=
EINVAL
;
return
-
1
;
}
if
(
!
td
->
op
)
{
errno
=
ENOSYS
;
return
-
1
;
}
return
td
->
op
->
copy_struct
(
td
,
struct_dst
,
struct_src
);
}
/* Dump the data into the specified stdio stream */
static
int
_print2fp
(
const
void
*
buffer
,
size_t
size
,
void
*
app_key
)
{
...
...
skeletons/constr_TYPE.h
View file @
4cfcd4f1
...
...
@@ -143,6 +143,16 @@ typedef int (asn_struct_compare_f)(
const
void
*
struct_A
,
const
void
*
struct_B
);
/*
* Copies struct B into struct A.
* Allocates memory for struct A, if necessary.
*/
typedef
int
(
asn_struct_copy_f
)(
const
struct
asn_TYPE_descriptor_s
*
type_descriptor
,
void
**
struct_A
,
const
void
*
struct_B
);
/*
* Return the outmost tag of the type.
* If the type is untagged CHOICE, the dynamic operation is performed.
...
...
@@ -175,6 +185,7 @@ typedef struct asn_TYPE_operation_s {
asn_struct_free_f
*
free_struct
;
/* Free the structure */
asn_struct_print_f
*
print_struct
;
/* Human readable output */
asn_struct_compare_f
*
compare_struct
;
/* Compare two structures */
asn_struct_copy_f
*
copy_struct
;
/* Copy method */
ber_type_decoder_f
*
ber_decoder
;
/* Generic BER decoder */
der_type_encoder_f
*
der_encoder
;
/* Canonical DER encoder */
xer_type_decoder_f
*
xer_decoder
;
/* Generic XER decoder */
...
...
@@ -291,6 +302,17 @@ int asn_fprint(FILE *stream, /* Destination stream descriptor */
const
asn_TYPE_descriptor_t
*
td
,
/* ASN.1 type descriptor */
const
void
*
struct_ptr
);
/* Structure to be printed */
/*
* Copies a source structure (struct_src) into destination structure
* (struct_dst). Allocates memory for the destination structure, if necessary.
* RETURN VALUES:
* 0: Copy OK.
* -1: Problem copying the structure.
*/
int
asn_copy
(
const
asn_TYPE_descriptor_t
*
td
,
/* ASN.1 type descriptor */
void
**
struct_dst
,
/* Structure to be populated */
const
void
*
struct_src
);
/* Structure to be copied */
#ifdef __cplusplus
}
#endif
...
...
tests/tests-randomized/check-bundles.sh
View file @
4cfcd4f1
...
...
@@ -187,6 +187,16 @@ compile_and_test() {
return
3
fi
echo
"Checking random data copy"
copy_check_cmd
=
"
${
ASAN_ENV_FLAGS
}
./random-test-driver -s
${
rmax
}
${
encodings
}
-y"
echo
"(
${
reproduce_make
}
&&
${
copy_check_cmd
}
)"
>
.test-reproduce
if
eval
"
$copy_check_cmd
"
;
then
echo
"Copy test OK"
else
{
echo
"RETRY:"
;
cat
.test-reproduce
;
}
return
3
fi
echo
"Generating new random data"
rm
-rf
random-data
cmd
=
"
${
ASAN_ENV_FLAGS
}
UBSAN_OPTIONS=print_stacktrace=1"
...
...
tests/tests-randomized/random-test-driver.c
View file @
4cfcd4f1
...
...
@@ -327,12 +327,85 @@ check_random_roundtrip(enum asn_transfer_syntax syntax, size_t max_random_value_
enc
.
name
);
}
static
void
check_copy_op
(
enum
asn_transfer_syntax
syntax
,
size_t
max_random_value_size
,
int
iterations
,
int
debug
)
{
struct
encoding_map
enc
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
encodings
)
/
sizeof
(
encodings
[
0
]);
i
++
)
{
enc
=
encodings
[
i
];
if
(
enc
.
syntax
==
syntax
)
{
fprintf
(
stderr
,
"Testing %d iterations of round-trip for %s
\n
"
,
iterations
,
enc
.
name
);
break
;
}
}
for
(
int
i
=
0
;
i
<
iterations
;
i
++
)
{
T_t
*
structure
=
0
;
T_t
*
new_structure
=
0
;
if
(
asn_random_fill
(
&
asn_DEF_T
,
(
void
**
)
&
structure
,
max_random_value_size
)
==
-
1
)
{
assert
(
structure
==
0
);
fprintf
(
stderr
,
"Can't generate %d'th value, skipping
\n
"
,
i
);
continue
;
}
assert
(
structure
!=
0
);
if
(
debug
)
{
fprintf
(
stderr
,
"Random structure %s:
\n
"
,
sizeof
(
ASN1_STR
)
>
60
?
"T"
:
ASN1_STR
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
structure
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
structure
);
}
int
cr
=
asn_DEF_T
.
op
->
copy_struct
(
&
asn_DEF_T
,
(
void
**
)
&
new_structure
,
structure
);
if
(
cr
!=
0
)
{
fprintf
(
stderr
,
"Copying structure %s:
\n
"
,
sizeof
(
ASN1_STR
)
>
60
?
"T"
:
ASN1_STR
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
structure
);
assert
(
cr
==
0
);
exit
(
EX_SOFTWARE
);
}
assert
(
new_structure
!=
0
);
/*
* Confirm that we decoded the same data.
*/
int
cmp
=
asn_DEF_T
.
op
->
compare_struct
(
&
asn_DEF_T
,
structure
,
new_structure
);
if
(
cmp
!=
0
||
debug
)
{
fprintf
(
stderr
,
"Random %s value:
\n
"
,
ASN1_STR
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
structure
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
structure
);
fprintf
(
stderr
,
"Copied %s value:
\n
"
,
ASN1_STR
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
new_structure
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
new_structure
);
assert
(
cmp
==
0
);
}
ASN_STRUCT_FREE
(
asn_DEF_T
,
structure
);
ASN_STRUCT_FREE
(
asn_DEF_T
,
new_structure
);
if
(
i
<
5
)
{
fprintf
(
stderr
,
"[%03d] copy OK
\n
"
,
i
);
}
else
if
(
i
==
5
)
{
fprintf
(
stderr
,
"... and so on
\n
"
);
}
}
fprintf
(
stderr
,
"OK %d iterations of copy-op for %s
\n
"
,
iterations
,
enc
.
name
);
}
int
main
(
int
argc
,
char
**
argv
)
{
uint32_t
enabled_encodings
=
0
;
enum
{
MODE_UNKNOWN
,
MODE_GENERATE_RANDOM_DATA
,
MODE_CHECK_RANDOM_ROUNDTRIP
MODE_CHECK_RANDOM_ROUNDTRIP
,
MODE_CHECK_COPY_OP
}
mode
=
MODE_UNKNOWN
;
const
char
*
generate_into_dir
=
NULL
;
int
iterations
=
100
;
...
...
@@ -340,7 +413,7 @@ int main(int argc, char **argv) {
int
debug
=
0
;
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"cde:g:hn:s:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"cde:g:hn:s:
y
"
))
!=
-
1
)
{
switch
(
c
)
{
case
'c'
:
mode
=
MODE_CHECK_RANDOM_ROUNDTRIP
;
...
...
@@ -377,6 +450,9 @@ int main(int argc, char **argv) {
}
max_random_value_size
=
atoi
(
optarg
);
break
;
case
'y'
:
mode
=
MODE_CHECK_COPY_OP
;
break
;
default:
usage
(
argv
[
0
]);
exit
(
2
);
...
...
@@ -408,6 +484,10 @@ int main(int argc, char **argv) {
check_random_roundtrip
(
syntax
,
max_random_value_size
,
iterations
,
debug
);
break
;
case
MODE_CHECK_COPY_OP
:
check_copy_op
(
syntax
,
max_random_value_size
,
iterations
,
debug
);
break
;
}
}
}
...
...
tests/tests-skeletons/Makefile.am
View file @
4cfcd4f1
...
...
@@ -4,6 +4,7 @@ check_PROGRAMS = \
check-ber_tlv_tag
\
check-length
\
check-bits
\
check-copy
\
check-OIDs
\
check-GeneralizedTime
\
check-OCTET_STRING
\
...
...
@@ -27,6 +28,7 @@ check_PROGRAMS += \
check-32-ber_tlv_tag
\
check-32-length
\
check-32-bits
\
check-32-copy
\
check-32-OIDs
\
check-32-GeneralizedTime
\
check-32-OCTET_STRING
\
...
...
@@ -54,6 +56,9 @@ check_32_length_SOURCES=check-length.c
check_32_bits_CFLAGS
=
$(CFLAGS_M32)
check_32_bits_LDADD
=
$(LDADD_32)
check_32_bits_SOURCES
=
check-bits.c
check_32_copy_CFLAGS
=
$(CFLAGS_M32)
check_32_copy_LDADD
=
$(LDADD_32)
check_32_copy_SOURCES
=
check-copy.c
check_32_OIDs_CFLAGS
=
$(CFLAGS_M32)
check_32_OIDs_LDADD
=
$(LDADD_32)
check_32_OIDs_SOURCES
=
check-OIDs.c
...
...
tests/tests-skeletons/check-copy.c
0 → 100644
View file @
4cfcd4f1
#include <stdio.h>
#include <assert.h>
#include <OCTET_STRING.c>
#include <BIT_STRING.c>
#include <INTEGER.c>
#include <BOOLEAN.c>
#include <NULL.c>
#include <REAL.c>
#define check(td, a, b) test(__LINE__, td, a, b)
static
int
copy
(
asn_TYPE_descriptor_t
*
td
,
void
**
a
,
const
void
*
b
)
{
return
asn_copy
(
td
,
a
,
b
)
!=
0
;
}
static
int
compare
(
asn_TYPE_descriptor_t
*
td
,
void
*
a
,
void
*
b
)
{
return
td
->
op
->
compare_struct
(
td
,
a
,
b
)
!=
0
;
}
static
int
test
(
int
lineno
,
asn_TYPE_descriptor_t
*
td
,
void
**
a
,
void
*
b
)
{
int
rv
;
rv
=
copy
(
td
,
a
,
b
);
if
(
rv
)
{
fprintf
(
stderr
,
"%03d: copy() failed
\n
"
,
lineno
);
assert
(
rv
==
0
);
}
rv
=
compare
(
td
,
*
a
,
b
);
if
(
rv
)
{
fprintf
(
stderr
,
"%03d: compare() failed
\n
"
,
lineno
);
assert
(
rv
==
0
);
}
ASN_STRUCT_FREE
(
*
td
,
*
a
);
ASN_STRUCT_FREE_CONTENTS_ONLY
(
*
td
,
b
);
return
0
;
}
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
(
void
)
av
;
/* OCTET STRING */
{
OCTET_STRING_t
b
=
{
0
};
OCTET_STRING_fromBuf
(
&
b
,
"Hello"
,
5
);
OCTET_STRING_t
*
a
=
NULL
;
check
(
&
asn_DEF_OCTET_STRING
,
(
void
**
)
&
a
,
&
b
);
}
/* INTEGER */
{
INTEGER_t
b
=
{
0
};
asn_ulong2INTEGER
(
&
b
,
123
);
INTEGER_t
*
a
=
NULL
;
check
(
&
asn_DEF_INTEGER
,
(
void
**
)
&
a
,
&
b
);
}
{
INTEGER_t
b
=
{
0
};
INTEGER_t
*
a
=
NULL
;
check
(
&
asn_DEF_INTEGER
,
(
void
**
)
&
a
,
&
b
);
}
/* BIT STRING */
{
BIT_STRING_t
b
=
{
0
};
b
.
buf
=
MALLOC
(
2
);
b
.
size
=
2
;
b
.
buf
[
0
]
=
0x80
;
b
.
buf
[
1
]
=
0x02
;
b
.
bits_unused
=
1
;
BIT_STRING_t
*
a
=
NULL
;
check
(
&
asn_DEF_BIT_STRING
,
(
void
**
)
&
a
,
&
b
);
}
/* BOOLEAN */
{
BOOLEAN_t
b
=
{
0
};
b
=
1
;
BIT_STRING_t
*
a
=
NULL
;
check
(
&
asn_DEF_BOOLEAN
,
(
void
**
)
&
a
,
&
b
);
}
/* NULL */
{
NULL_t
b
=
{
0
};
NULL_t
*
a
=
NULL
;
check
(
&
asn_DEF_NULL
,
(
void
**
)
&
a
,
&
b
);
}
/* REAL */
{
REAL_t
b
=
{
0
};
asn_double2REAL
(
&
b
,
123
.
456
);
REAL_t
*
a
=
NULL
;
check
(
&
asn_DEF_REAL
,
(
void
**
)
&
a
,
&
b
);
}
return
0
;
}
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