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
1d76f3c4
Commit
1d76f3c4
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add OER codec for string types
parent
ca84c46d
vlm_master
velichkov_s1ap_plus_option_group
No related merge requests found
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
214 additions
and
26 deletions
+214
-26
skeletons/BMPString.c
skeletons/BMPString.c
+2
-2
skeletons/GeneralString.c
skeletons/GeneralString.c
+2
-2
skeletons/GraphicString.c
skeletons/GraphicString.c
+2
-2
skeletons/IA5String.c
skeletons/IA5String.c
+2
-2
skeletons/ISO646String.c
skeletons/ISO646String.c
+2
-2
skeletons/NumericString.c
skeletons/NumericString.c
+2
-2
skeletons/OCTET_STRING.h
skeletons/OCTET_STRING.h
+2
-0
skeletons/OCTET_STRING_oer.c
skeletons/OCTET_STRING_oer.c
+185
-0
skeletons/PrintableString.c
skeletons/PrintableString.c
+2
-2
skeletons/T61String.c
skeletons/T61String.c
+2
-2
skeletons/TeletexString.c
skeletons/TeletexString.c
+2
-2
skeletons/UTF8String.c
skeletons/UTF8String.c
+2
-2
skeletons/UniversalString.c
skeletons/UniversalString.c
+2
-2
skeletons/VideotexString.c
skeletons/VideotexString.c
+2
-2
skeletons/VisibleString.c
skeletons/VisibleString.c
+2
-2
skeletons/file-dependencies
skeletons/file-dependencies
+1
-0
No files found.
skeletons/BMPString.c
View file @
1d76f3c4
...
@@ -37,8 +37,8 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
...
@@ -37,8 +37,8 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/GeneralString.c
View file @
1d76f3c4
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_GeneralString = {
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_GeneralString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/GraphicString.c
View file @
1d76f3c4
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_GraphicString = {
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_GraphicString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/IA5String.c
View file @
1d76f3c4
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = {
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/ISO646String.c
View file @
1d76f3c4
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_ISO646String = {
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_ISO646String = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/NumericString.c
View file @
1d76f3c4
...
@@ -51,8 +51,8 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = {
...
@@ -51,8 +51,8 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/OCTET_STRING.h
View file @
1d76f3c4
...
@@ -30,6 +30,8 @@ xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
...
@@ -30,6 +30,8 @@ xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
xer_type_decoder_f
OCTET_STRING_decode_xer_utf8
;
/* ASCII/UTF-8 */
xer_type_decoder_f
OCTET_STRING_decode_xer_utf8
;
/* ASCII/UTF-8 */
xer_type_encoder_f
OCTET_STRING_encode_xer
;
xer_type_encoder_f
OCTET_STRING_encode_xer
;
xer_type_encoder_f
OCTET_STRING_encode_xer_utf8
;
xer_type_encoder_f
OCTET_STRING_encode_xer_utf8
;
oer_type_decoder_f
OCTET_STRING_decode_oer
;
oer_type_encoder_f
OCTET_STRING_encode_oer
;
per_type_decoder_f
OCTET_STRING_decode_uper
;
per_type_decoder_f
OCTET_STRING_decode_uper
;
per_type_encoder_f
OCTET_STRING_encode_uper
;
per_type_encoder_f
OCTET_STRING_encode_uper
;
...
...
This diff is collapsed.
Click to expand it.
skeletons/OCTET_STRING_oer.c
0 → 100644
View file @
1d76f3c4
/*
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef ASN_DISABLE_OER_SUPPORT
#include <asn_internal.h>
#include <OCTET_STRING.h>
#include <errno.h>
static
asn_oer_constraints_t
asn_DEF_OCTET_STRING_oer_constraints
=
{
{
0
,
0
,
0
},
{
AOC_HAS_LOWER_BOUND
,
0
,
0
}
};
asn_dec_rval_t
OCTET_STRING_decode_oer
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_oer_constraints_t
*
constraints
,
void
**
sptr
,
const
void
*
ptr
,
size_t
size
)
{
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
?
(
asn_OCTET_STRING_specifics_t
*
)
td
->
specifics
:
(
asn_OCTET_STRING_specifics_t
*
)
&
asn_DEF_OCTET_STRING
.
specifics
;
OCTET_STRING_t
*
st
=
(
OCTET_STRING_t
*
)
*
sptr
;
asn_oer_constraints_t
*
cts
=
constraints
?
constraints
:
td
->
oer_constraints
;
asn_oer_constraint_t
*
csiz
=
cts
?
&
cts
->
size
:
&
asn_DEF_OCTET_STRING_oer_constraints
.
size
;
asn_dec_rval_t
rval
=
{
RC_OK
,
0
};
size_t
expected_length
=
0
;
size_t
unit_bytes
;
switch
(
specs
->
subvariant
)
{
default:
case
ASN_OSUBV_BIT
:
ASN_DEBUG
(
"Invalid use of OCTET STRING to decode BIT STRING"
);
ASN__DECODE_FAILED
;
case
ASN_OSUBV_ANY
:
/* Fall through */
case
ASN_OSUBV_STR
:
unit_bytes
=
1
;
break
;
case
ASN_OSUBV_U16
:
unit_bytes
=
2
;
break
;
case
ASN_OSUBV_U32
:
unit_bytes
=
4
;
break
;
}
(
void
)
opt_codec_ctx
;
if
(
!
st
)
{
st
=
(
OCTET_STRING_t
*
)(
*
sptr
=
CALLOC
(
1
,
specs
->
struct_size
));
if
(
!
st
)
ASN__DECODE_FAILED
;
}
if
((
csiz
->
flags
&
(
AOC_HAS_LOWER_BOUND
|
AOC_HAS_UPPER_BOUND
))
==
(
AOC_HAS_LOWER_BOUND
|
AOC_HAS_UPPER_BOUND
)
&&
csiz
->
lower_bound
==
csiz
->
upper_bound
)
{
expected_length
=
unit_bytes
*
csiz
->
lower_bound
;
}
else
{
/*
* X.696 (08/2015) #27.2
* Encode length determinant as _number of octets_, but only
* if upper bound is not equal to lower bound.
*/
ssize_t
len_len
=
oer_fetch_length
(
ptr
,
size
,
&
expected_length
);
if
(
len_len
>
0
)
{
rval
.
consumed
=
len_len
;
ptr
=
(
const
char
*
)
ptr
+
len_len
;
size
-=
len_len
;
}
else
if
(
len_len
==
0
)
{
ASN__DECODE_STARVED
;
}
else
if
(
len_len
<
0
)
{
ASN__DECODE_FAILED
;
}
if
(
expected_length
%
unit_bytes
!=
0
)
{
ASN_DEBUG
(
"Data size %zu bytes is not consistent with multiplier %zu"
,
expected_length
,
unit_bytes
);
ASN__DECODE_FAILED
;
}
}
if
(
size
<
expected_length
)
{
ASN__DECODE_STARVED
;
}
else
{
uint8_t
*
buf
=
MALLOC
(
expected_length
+
1
);
if
(
buf
==
NULL
)
{
ASN__DECODE_FAILED
;
}
else
{
memcpy
(
buf
,
ptr
,
expected_length
);
buf
[
expected_length
]
=
'\0'
;
}
FREEMEM
(
st
->
buf
);
st
->
buf
=
buf
;
st
->
size
=
expected_length
;
rval
.
consumed
+=
expected_length
;
return
rval
;
}
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
OCTET_STRING_encode_oer
(
asn_TYPE_descriptor_t
*
td
,
asn_oer_constraints_t
*
constraints
,
void
*
sptr
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_OCTET_STRING_specifics_t
*
specs
=
td
->
specifics
?
(
asn_OCTET_STRING_specifics_t
*
)
td
->
specifics
:
(
asn_OCTET_STRING_specifics_t
*
)
&
asn_DEF_OCTET_STRING
.
specifics
;
OCTET_STRING_t
*
st
=
(
OCTET_STRING_t
*
)
sptr
;
asn_oer_constraints_t
*
cts
=
constraints
?
constraints
:
td
->
oer_constraints
;
asn_oer_constraint_t
*
csiz
=
cts
?
&
cts
->
size
:
&
asn_DEF_OCTET_STRING_oer_constraints
.
size
;
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
if
(
!
st
)
ASN__ENCODE_FAILED
;
ASN_DEBUG
(
"Encoding %s %d as OCTET STRING"
,
td
?
td
->
name
:
""
,
st
->
size
);
if
((
csiz
->
flags
&
(
AOC_HAS_LOWER_BOUND
|
AOC_HAS_UPPER_BOUND
))
==
(
AOC_HAS_LOWER_BOUND
|
AOC_HAS_UPPER_BOUND
)
&&
csiz
->
lower_bound
==
csiz
->
upper_bound
)
{
/*
* Check that available data matches the constraint
*/
size_t
unit_bytes
;
switch
(
specs
->
subvariant
)
{
default:
case
ASN_OSUBV_BIT
:
ASN_DEBUG
(
"Invalid use of OCTET STRING to encode BIT STRING"
);
ASN__ENCODE_FAILED
;
case
ASN_OSUBV_ANY
:
/* Fall through */
case
ASN_OSUBV_STR
:
unit_bytes
=
1
;
break
;
case
ASN_OSUBV_U16
:
unit_bytes
=
2
;
break
;
case
ASN_OSUBV_U32
:
unit_bytes
=
4
;
break
;
}
if
(
st
->
size
!=
unit_bytes
*
csiz
->
lower_bound
)
{
ASN_DEBUG
(
"Trying to encode %s (%zu bytes) which doesn't fit SIZE "
"constraint (%d)"
,
td
->
name
,
st
->
size
,
csiz
->
lower_bound
);
ASN__ENCODE_FAILED
;
}
}
else
{
/*
* X.696 (08/2015) #27.2
* Encode length determinant as _number of octets_, but only
* if upper bound is not equal to lower bound.
*/
ssize_t
ret
=
oer_serialize_length
(
st
->
size
,
cb
,
app_key
);
if
(
ret
<
0
)
{
ASN__ENCODE_FAILED
;
}
er
.
encoded
+=
ret
;
}
er
.
encoded
+=
st
->
size
;
if
(
cb
(
st
->
buf
,
st
->
size
,
app_key
)
<
0
)
{
ASN__ENCODE_FAILED
;
}
else
{
ASN__ENCODED_OK
(
er
);
}
}
#endif
/* ASN_DISABLE_OER_SUPPORT */
This diff is collapsed.
Click to expand it.
skeletons/PrintableString.c
View file @
1d76f3c4
...
@@ -61,8 +61,8 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = {
...
@@ -61,8 +61,8 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/T61String.c
View file @
1d76f3c4
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_T61String = {
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_T61String = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/TeletexString.c
View file @
1d76f3c4
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_TeletexString = {
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_TeletexString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/UTF8String.c
View file @
1d76f3c4
...
@@ -27,8 +27,8 @@ asn_TYPE_descriptor_t asn_DEF_UTF8String = {
...
@@ -27,8 +27,8 @@ asn_TYPE_descriptor_t asn_DEF_UTF8String = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/UniversalString.c
View file @
1d76f3c4
...
@@ -37,8 +37,8 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
...
@@ -37,8 +37,8 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/VideotexString.c
View file @
1d76f3c4
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_VideotexString = {
...
@@ -26,8 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_VideotexString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/VisibleString.c
View file @
1d76f3c4
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = {
...
@@ -31,8 +31,8 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = {
0
,
0
,
0
,
0
,
#else
#else
0
,
OCTET_STRING_decode_oer
,
0
,
OCTET_STRING_encode_oer
,
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
This diff is collapsed.
Click to expand it.
skeletons/file-dependencies
View file @
1d76f3c4
...
@@ -69,6 +69,7 @@ converter-sample.c # A default name for sample transcoder
...
@@ -69,6 +69,7 @@ converter-sample.c # A default name for sample transcoder
CODEC-OER: # THIS IS A SPECIAL SECTION
CODEC-OER: # THIS IS A SPECIAL SECTION
INTEGER_oer.c
INTEGER_oer.c
OCTET_STRING_oer.c
NativeInteger_oer.c
NativeInteger_oer.c
constr_SEQUENCE_oer.c
constr_SEQUENCE_oer.c
...
...
This diff is collapsed.
Click to expand it.
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