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
9ae018ee
Commit
9ae018ee
authored
Jul 24, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Native Integer OER support
parent
40fa826a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
2 deletions
+108
-2
skeletons/NativeInteger.c
skeletons/NativeInteger.c
+2
-2
skeletons/NativeInteger.h
skeletons/NativeInteger.h
+2
-0
skeletons/NativeInteger_oer.c
skeletons/NativeInteger_oer.c
+104
-0
No files found.
skeletons/NativeInteger.c
View file @
9ae018ee
...
@@ -33,8 +33,8 @@ asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
...
@@ -33,8 +33,8 @@ asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
0
,
0
,
0
,
0
,
#else
#else
0
,
NativeInteger_decode_oer
,
/* OER decoder */
0
,
NativeInteger_encode_oer
,
/* Canonical OER encoder */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#endif
/* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
0
,
0
,
...
...
skeletons/NativeInteger.h
View file @
9ae018ee
...
@@ -27,6 +27,8 @@ ber_type_decoder_f NativeInteger_decode_ber;
...
@@ -27,6 +27,8 @@ ber_type_decoder_f NativeInteger_decode_ber;
der_type_encoder_f
NativeInteger_encode_der
;
der_type_encoder_f
NativeInteger_encode_der
;
xer_type_decoder_f
NativeInteger_decode_xer
;
xer_type_decoder_f
NativeInteger_decode_xer
;
xer_type_encoder_f
NativeInteger_encode_xer
;
xer_type_encoder_f
NativeInteger_encode_xer
;
oer_type_decoder_f
NativeInteger_decode_oer
;
oer_type_encoder_f
NativeInteger_encode_oer
;
per_type_decoder_f
NativeInteger_decode_uper
;
per_type_decoder_f
NativeInteger_decode_uper
;
per_type_encoder_f
NativeInteger_encode_uper
;
per_type_encoder_f
NativeInteger_encode_uper
;
...
...
skeletons/NativeInteger_oer.c
0 → 100644
View file @
9ae018ee
/*
* 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 <NativeInteger.h>
#include <errno.h>
asn_dec_rval_t
NativeInteger_decode_oer
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
asn_oer_constraints_t
*
constraints
,
void
**
nint_ptr
,
const
void
*
ptr
,
size_t
size
)
{
asn_INTEGER_specifics_t
*
specs
=
(
asn_INTEGER_specifics_t
*
)
td
->
specifics
;
asn_dec_rval_t
rval
=
{
RC_OK
,
0
};
long
*
native
=
(
long
*
)
*
nint_ptr
;
asn_oer_constraint_t
*
ct
;
(
void
)
opt_codec_ctx
;
(
void
)
specs
;
if
(
!
native
)
{
native
=
(
long
*
)(
*
nint_ptr
=
CALLOC
(
1
,
sizeof
(
*
native
)));
if
(
!
native
)
ASN__DECODE_FAILED
;
}
if
(
!
constraints
)
constraints
=
td
->
oer_constraints
;
ct
=
constraints
?
&
constraints
->
value
:
0
;
INTEGER_t
tmpint
;
INTEGER_t
*
tmpintptr
=
&
tmpint
;
memset
(
&
tmpint
,
0
,
sizeof
(
tmpint
));
/*
* OPTIMIZATION: Encode directly rather than passing through INTEGER.
* Saves a memory allocation.
*/
rval
=
INTEGER_decode_oer
(
opt_codec_ctx
,
&
asn_DEF_INTEGER
,
constraints
,
(
void
**
)
&
tmpintptr
,
ptr
,
size
);
if
(
rval
.
code
!=
RC_OK
)
{
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_INTEGER
,
&
tmpint
);
return
rval
;
}
if
(
specs
&&
specs
->
field_unsigned
)
{
unsigned
long
ul
;
if
(
asn_INTEGER2ulong
(
&
tmpint
,
&
ul
)
!=
0
)
{
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_INTEGER
,
&
tmpint
);
rval
.
code
=
RC_FAIL
;
rval
.
consumed
=
0
;
return
rval
;
}
else
{
*
native
=
ul
;
}
}
else
{
long
l
;
if
(
asn_INTEGER2long
(
&
tmpint
,
&
l
)
!=
0
)
{
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_INTEGER
,
&
tmpint
);
rval
.
code
=
RC_FAIL
;
rval
.
consumed
=
0
;
return
rval
;
}
else
{
*
native
=
l
;
}
}
return
rval
;
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
NativeInteger_encode_oer
(
asn_TYPE_descriptor_t
*
td
,
asn_oer_constraints_t
*
constraints
,
void
*
sptr
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_INTEGER_specifics_t
*
specs
=
(
asn_INTEGER_specifics_t
*
)
td
->
specifics
;
long
native
;
if
(
!
sptr
)
ASN__ENCODE_FAILED
;
native
=
*
(
const
long
*
)
sptr
;
ASN_DEBUG
(
"Encoding %s %ld as NativeInteger"
,
td
?
td
->
name
:
""
,
native
);
INTEGER_t
tmpint
;
memset
(
&
tmpint
,
0
,
sizeof
(
tmpint
));
if
((
specs
&&
specs
->
field_unsigned
)
?
asn_ulong2INTEGER
(
&
tmpint
,
native
)
:
asn_long2INTEGER
(
&
tmpint
,
native
))
{
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_INTEGER
,
&
tmpint
);
ASN__ENCODE_FAILED
;
}
else
{
asn_enc_rval_t
er
=
INTEGER_encode_oer
(
td
,
constraints
,
&
tmpint
,
cb
,
app_key
);
ASN_STRUCT_FREE_CONTENTS_ONLY
(
asn_DEF_INTEGER
,
&
tmpint
);
return
er
;
}
}
#endif
/* ASN_DISABLE_OER_SUPPORT */
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