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
a2987ea6
Commit
a2987ea6
authored
Jun 26, 2007
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instrumentation
parent
c60d08ff
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
25 deletions
+45
-25
asn1c/tests/check-126.-gen-PER.c
asn1c/tests/check-126.-gen-PER.c
+1
-1
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+25
-10
skeletons/per_encoder.c
skeletons/per_encoder.c
+1
-0
skeletons/per_encoder.h
skeletons/per_encoder.h
+2
-2
skeletons/per_support.c
skeletons/per_support.c
+12
-9
tests/126-per-extensions-OK.asn1
tests/126-per-extensions-OK.asn1
+4
-3
No files found.
asn1c/tests/check-126.-gen-PER.c
View file @
a2987ea6
...
@@ -104,7 +104,7 @@ load_object_from(const char *fname, char *fbuf, int size, enum enctype how, int
...
@@ -104,7 +104,7 @@ load_object_from(const char *fname, char *fbuf, int size, enum enctype how, int
st
=
0
;
st
=
0
;
do
{
do
{
fprintf
(
stderr
,
"Decoding bytes %d..%d (left %d) [%s]
\n
"
,
fprintf
(
stderr
,
"
\n
Decoding bytes %d..%d (left %d) [%s]
\n
"
,
fbuf_offset
,
fbuf_offset
,
fbuf_chunk
<
fbuf_left
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
,
?
fbuf_chunk
:
fbuf_left
,
...
...
skeletons/constr_SEQUENCE.c
View file @
a2987ea6
...
@@ -1092,7 +1092,7 @@ uper_ugot_refill(asn_per_data_t *pd) {
...
@@ -1092,7 +1092,7 @@ uper_ugot_refill(asn_per_data_t *pd) {
pd
->
buffer
=
oldpd
->
buffer
;
pd
->
buffer
=
oldpd
->
buffer
;
pd
->
nboff
=
oldpd
->
nboff
-
1
;
pd
->
nboff
=
oldpd
->
nboff
-
1
;
pd
->
nbits
=
oldpd
->
nbits
;
pd
->
nbits
=
oldpd
->
nbits
;
ASN_DEBUG
(
"Return from
unclaimed
"
);
ASN_DEBUG
(
"Return from
UNCLAIMED
"
);
return
0
;
return
0
;
}
}
...
@@ -1133,7 +1133,7 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -1133,7 +1133,7 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
_ASN_STACK_OVERFLOW_CHECK
(
opt_codec_ctx
);
_ASN_STACK_OVERFLOW_CHECK
(
opt_codec_ctx
);
ASN_DEBUG
(
"Getting open type
from %d bits (%d+%d), %p"
,
pd
->
nbits
-
pd
->
nboff
,
pd
->
nboff
,
pd
->
nbits
,
pd
->
buffer
);
ASN_DEBUG
(
"Getting open type
off %d (%d+%d), %p"
,
pd
->
moved
,
pd
->
nboff
,
pd
->
nbits
,
pd
->
buffer
);
arg
.
oldpd
=
*
pd
;
arg
.
oldpd
=
*
pd
;
arg
.
unclaimed
=
0
;
arg
.
unclaimed
=
0
;
arg
.
ot_moved
=
0
;
arg
.
ot_moved
=
0
;
...
@@ -1149,22 +1149,32 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -1149,22 +1149,32 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
td
->
name
,
pd
->
moved
,
arg
.
oldpd
.
moved
,
td
->
name
,
pd
->
moved
,
arg
.
oldpd
.
moved
,
arg
.
unclaimed
,
arg
.
repeat
);
arg
.
unclaimed
,
arg
.
repeat
);
ASN_DEBUG
(
"OT1 moved %d, estimated %d uncl=%d"
,
arg
.
oldpd
.
moved
,
arg
.
oldpd
.
nboff
+
((((
int
)
arg
.
oldpd
.
buffer
)
&
0x7
)
<<
3
),
arg
.
unclaimed
);
padding
=
pd
->
moved
%
8
;
padding
=
pd
->
moved
%
8
;
if
(
padding
)
{
if
(
padding
)
{
int32_t
pvalue
;
if
(
padding
>
7
)
{
if
(
padding
>
7
)
{
ASN_DEBUG
(
"Too large padding %d in open type"
,
ASN_DEBUG
(
"Too large padding %d in open type"
,
padding
);
padding
);
rv
.
code
=
RC_FAIL
;
rv
.
code
=
RC_FAIL
;
return
rv
;
return
rv
;
}
}
padding
=
8
-
padding
;
ASN_DEBUG
(
"Getting padding of %d bits"
,
padding
);
ASN_DEBUG
(
"Getting padding of %d bits"
,
padding
);
switch
(
per_get_few_bits
(
pd
,
padding
))
{
pvalue
=
per_get_few_bits
(
pd
,
padding
);
switch
(
pvalue
)
{
case
-
1
:
case
-
1
:
ASN_DEBUG
(
"Padding skip failed"
);
ASN_DEBUG
(
"Padding skip failed"
);
_ASN_DECODE_
FAIL
ED
;
_ASN_DECODE_
STARV
ED
;
case
0
:
break
;
case
0
:
break
;
default:
default:
ASN_DEBUG
(
"Non-blank padding"
);
ASN_DEBUG
(
"Non-blank padding (%d bits 0x%02x)"
,
padding
,
pvalue
);
_ASN_DECODE_FAILED
;
_ASN_DECODE_FAILED
;
}
}
}
}
...
@@ -1173,15 +1183,15 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -1173,15 +1183,15 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if
(
1
)
_ASN_DECODE_FAILED
;
if
(
1
)
_ASN_DECODE_FAILED
;
arg
.
unclaimed
+=
pd
->
nbits
-
pd
->
nboff
;
arg
.
unclaimed
+=
pd
->
nbits
-
pd
->
nboff
;
}
}
arg
.
oldpd
.
nbits
-=
pd
->
moved
-
arg
.
ot_moved
;
arg
.
oldpd
.
moved
+=
pd
->
moved
-
arg
.
ot_moved
;
/* Adjust pd back so it points to original data */
pd
->
nboff
=
arg
.
oldpd
.
nboff
;
pd
->
nbits
=
arg
.
oldpd
.
nbits
-
(
pd
->
moved
-
arg
.
ot_moved
);
pd
->
nbits
=
arg
.
oldpd
.
nbits
;
pd
->
moved
=
arg
.
oldpd
.
moved
+
(
pd
->
moved
-
arg
.
ot_moved
);
pd
->
moved
=
arg
.
oldpd
.
moved
;
pd
->
refill
=
arg
.
oldpd
.
refill
;
pd
->
refill
=
arg
.
oldpd
.
refill
;
pd
->
refill_key
=
arg
.
oldpd
.
refill_key
;
pd
->
refill_key
=
arg
.
oldpd
.
refill_key
;
/* Skip data not consumed by the decoder */
/* Skip data not consumed by the decoder */
if
(
arg
.
unclaimed
)
ASN_DEBUG
(
"Getting unclaimed %d"
,
arg
.
unclaimed
);
while
(
arg
.
unclaimed
)
{
while
(
arg
.
unclaimed
)
{
size_t
toget
=
24
;
size_t
toget
=
24
;
if
(
arg
.
unclaimed
<
toget
)
if
(
arg
.
unclaimed
<
toget
)
...
@@ -1201,6 +1211,8 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -1201,6 +1211,8 @@ uper_get_open_type(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
}
}
}
}
assert
(
pd
->
moved
==
pd
->
nboff
+
((((
int
)
pd
->
buffer
)
&
0x7
)
<<
3
));
if
(
arg
.
repeat
)
{
if
(
arg
.
repeat
)
{
ASN_DEBUG
(
"Not consumed the whole thing"
);
ASN_DEBUG
(
"Not consumed the whole thing"
);
rv
.
code
=
RC_FAIL
;
rv
.
code
=
RC_FAIL
;
...
@@ -1411,6 +1423,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -1411,6 +1423,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Skip over overflow extensions which aren't present
/* Skip over overflow extensions which aren't present
* in this system's version of the protocol */
* in this system's version of the protocol */
for
(;;)
{
for
(;;)
{
ASN_DEBUG
(
"Getting overflow extensions"
);
switch
(
per_get_few_bits
(
&
epmd
,
1
))
{
switch
(
per_get_few_bits
(
&
epmd
,
1
))
{
case
-
1
:
break
;
case
-
1
:
break
;
case
0
:
continue
;
case
0
:
continue
;
...
@@ -1580,6 +1593,8 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
...
@@ -1580,6 +1593,8 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
void
*
memb_ptr
;
/* Pointer to the member */
void
*
memb_ptr
;
/* Pointer to the member */
void
**
memb_ptr2
;
/* Pointer to that pointer */
void
**
memb_ptr2
;
/* Pointer to that pointer */
ASN_DEBUG
(
"About to encode %s"
,
elm
->
type
->
name
);
/* Fetch the pointer to this member */
/* Fetch the pointer to this member */
if
(
elm
->
flags
&
ATF_POINTER
)
{
if
(
elm
->
flags
&
ATF_POINTER
)
{
memb_ptr2
=
(
void
**
)((
char
*
)
sptr
+
elm
->
memb_offset
);
memb_ptr2
=
(
void
**
)((
char
*
)
sptr
+
elm
->
memb_offset
);
...
...
skeletons/per_encoder.c
View file @
a2987ea6
...
@@ -88,6 +88,7 @@ uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cons
...
@@ -88,6 +88,7 @@ uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cons
}
}
default:
default:
*
buffer_r
=
key
.
buffer
;
*
buffer_r
=
key
.
buffer
;
ASN_DEBUG
(
"Complete encoded in %d bits"
,
er
.
encoded
);
return
((
er
.
encoded
+
7
)
>>
3
);
return
((
er
.
encoded
+
7
)
>>
3
);
}
}
}
}
...
...
skeletons/per_encoder.h
View file @
a2987ea6
/*-
/*-
* Copyright (c) 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2006
, 2007
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
* Redistribution and modifications are permitted subject to BSD license.
*/
*/
#ifndef _PER_ENCODER_H_
#ifndef _PER_ENCODER_H_
...
@@ -42,7 +42,7 @@ asn_enc_rval_t uper_encode_to_buffer(
...
@@ -42,7 +42,7 @@ asn_enc_rval_t uper_encode_to_buffer(
* A variant of uper_encode_to_buffer() which allocates buffer itself.
* A variant of uper_encode_to_buffer() which allocates buffer itself.
* Returns the number of bytes in the buffer or -1 in case of failure.
* Returns the number of bytes in the buffer or -1 in case of failure.
* WARNING: This function produces a "Production of the complete encoding",
* WARNING: This function produces a "Production of the complete encoding",
* with length of at least one octet. Contrast this to precise bit-p
reserv
ing
* with length of at least one octet. Contrast this to precise bit-p
ack
ing
* encoding of uper_encode() and uper_encode_to_buffer().
* encoding of uper_encode() and uper_encode_to_buffer().
*/
*/
ssize_t
uper_encode_to_new_buffer
(
ssize_t
uper_encode_to_new_buffer
(
...
...
skeletons/per_support.c
View file @
a2987ea6
...
@@ -34,7 +34,7 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
...
@@ -34,7 +34,7 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
int32_t
tailv
,
vhead
;
int32_t
tailv
,
vhead
;
if
(
!
pd
->
refill
||
nbits
>
31
)
return
-
1
;
if
(
!
pd
->
refill
||
nbits
>
31
)
return
-
1
;
/* Accumulate unused bytes before refill */
/* Accumulate unused bytes before refill */
ASN_DEBUG
(
"Obtain the rest %d bits
"
,
nleft
);
ASN_DEBUG
(
"Obtain the rest %d bits
(want %d)"
,
nleft
,
nbits
);
tailv
=
per_get_few_bits
(
pd
,
nleft
);
tailv
=
per_get_few_bits
(
pd
,
nleft
);
if
(
tailv
<
0
)
return
-
1
;
if
(
tailv
<
0
)
return
-
1
;
/* Refill (replace pd contents with new data) */
/* Refill (replace pd contents with new data) */
...
@@ -47,9 +47,6 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
...
@@ -47,9 +47,6 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
return
tailv
;
return
tailv
;
}
}
ASN_DEBUG
(
"[PER get %d bits from (%d@%d+%d)]"
,
nbits
,
pd
->
moved
,
pd
->
nboff
,
nleft
);
/*
/*
* Normalize position indicator.
* Normalize position indicator.
*/
*/
...
@@ -89,7 +86,12 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
...
@@ -89,7 +86,12 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
return
-
1
;
return
-
1
;
}
}
return
(
accum
&
(((
uint32_t
)
1
<<
nbits
)
-
1
));
accum
&=
(((
uint32_t
)
1
<<
nbits
)
-
1
);
ASN_DEBUG
(
"[PER got %d bits from (%d@%d+%d) => 0x%x]"
,
nbits
,
pd
->
moved
,
pd
->
nboff
,
nleft
,
accum
);
return
accum
;
}
}
/*
/*
...
@@ -172,12 +174,13 @@ ssize_t
...
@@ -172,12 +174,13 @@ ssize_t
uper_get_nslength
(
asn_per_data_t
*
pd
)
{
uper_get_nslength
(
asn_per_data_t
*
pd
)
{
ssize_t
length
;
ssize_t
length
;
ASN_DEBUG
(
"Getting normally small length"
);
if
(
per_get_few_bits
(
pd
,
1
)
==
0
)
{
if
(
per_get_few_bits
(
pd
,
1
)
==
0
)
{
ASN_DEBUG
(
"l=?"
)
;
length
=
per_get_few_bits
(
pd
,
6
)
+
1
;
length
=
per_get_few_bits
(
pd
,
6
)
;
if
(
length
<=
0
)
return
-
1
;
ASN_DEBUG
(
"l=%d"
,
length
);
ASN_DEBUG
(
"l=%d"
,
length
);
if
(
length
<
0
)
return
-
1
;
return
length
;
return
length
+
1
;
}
else
{
}
else
{
int
repeat
;
int
repeat
;
length
=
uper_get_length
(
pd
,
-
1
,
&
repeat
);
length
=
uper_get_length
(
pd
,
-
1
,
&
repeat
);
...
...
tests/126-per-extensions-OK.asn1
View file @
a2987ea6
...
@@ -16,15 +16,16 @@ BEGIN
...
@@ -16,15 +16,16 @@ BEGIN
str-o IA5String OPTIONAL,
str-o IA5String OPTIONAL,
str-m IA5String,
str-m IA5String,
singl Singleton,
singl Singleton,
pdu-2 PDU-2
pdu-2 PDU-2
OPTIONAL
}
}
Singleton ::= SEQUENCE {
Singleton ::= SEQUENCE {
mandatory
IA5String DEFAULT "z"
opt-z
IA5String DEFAULT "z"
}
}
PDU-2 ::= CHOICE {
PDU-2 ::= CHOICE {
str-p2 IA5String
str-p2 IA5String,
...
}
}
END
END
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