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
5b78e1cb
Commit
5b78e1cb
authored
Jun 24, 2007
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uper extensions decoding
parent
f55a6dde
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
302 additions
and
56 deletions
+302
-56
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+249
-53
skeletons/per_decoder.c
skeletons/per_decoder.c
+1
-0
skeletons/per_support.c
skeletons/per_support.c
+45
-3
skeletons/per_support.h
skeletons/per_support.h
+7
-0
No files found.
skeletons/constr_SEQUENCE.c
View file @
5b78e1cb
This diff is collapsed.
Click to expand it.
skeletons/per_decoder.c
View file @
5b78e1cb
...
...
@@ -30,6 +30,7 @@ uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sp
}
/* Fill in the position indicator */
memset
(
&
pd
,
0
,
sizeof
(
pd
));
pd
.
buffer
=
(
const
uint8_t
*
)
buffer
;
pd
.
nboff
=
skip_bits
;
pd
.
nbits
=
8
*
size
-
unused_bits
;
/* 8 is CHAR_BIT from <limits.h> */
...
...
skeletons/per_support.c
View file @
5b78e1cb
...
...
@@ -12,14 +12,33 @@
int32_t
per_get_few_bits
(
asn_per_data_t
*
pd
,
int
nbits
)
{
size_t
off
;
/* Next after last bit offset */
ssize_t
nleft
;
uint32_t
accum
;
const
uint8_t
*
buf
;
if
(
nbits
<
0
||
pd
->
nboff
+
nbits
>
pd
->
nbits
)
if
(
nbits
<
0
)
return
-
1
;
ASN_DEBUG
(
"[PER get %d bits from %p+%d bits]"
,
nbits
,
pd
->
buffer
,
pd
->
nboff
);
nleft
=
pd
->
nbits
-
pd
->
nboff
;
if
(
nbits
>
nleft
)
{
int32_t
tailv
,
vhead
;
if
(
!
pd
->
refill
||
nbits
>
31
)
return
-
1
;
/* Accumulate unused bytes before refill */
ASN_DEBUG
(
"Obtain the rest %d bits"
,
nleft
);
tailv
=
per_get_few_bits
(
pd
,
nleft
);
if
(
tailv
<
0
)
return
-
1
;
/* Refill (replace pd contents with new data) */
if
(
pd
->
refill
(
pd
))
return
-
1
;
nbits
-=
nleft
;
vhead
=
per_get_few_bits
(
pd
,
nbits
);
/* Combine the rest of previous pd with the head of new one */
tailv
=
(
tailv
<<
nbits
)
|
vhead
;
/* Could == -1 */
return
tailv
;
}
ASN_DEBUG
(
"[PER get %d bits from %p+%d bits, %d available]"
,
nbits
,
pd
->
buffer
,
pd
->
nboff
,
nleft
);
/*
* Normalize position indicator.
...
...
@@ -129,6 +148,29 @@ uper_get_length(asn_per_data_t *pd, int ebits, int *repeat) {
return
(
16384
*
value
);
}
/*
* Get the normally small length "n".
* This procedure used to decode length of extensions bit-maps
* for SET and SEQUENCE types.
*/
ssize_t
uper_get_nslength
(
asn_per_data_t
*
pd
)
{
ssize_t
length
;
if
(
per_get_few_bits
(
pd
,
1
)
==
0
)
{
ASN_DEBUG
(
"l=?"
);
length
=
per_get_few_bits
(
pd
,
6
);
ASN_DEBUG
(
"l=%d"
,
length
);
if
(
length
<
0
)
return
-
1
;
return
length
+
1
;
}
else
{
int
repeat
;
length
=
uper_get_length
(
pd
,
-
1
,
&
repeat
);
if
(
length
>=
0
&&
!
repeat
)
return
length
;
return
-
1
;
/* Error, or do not support >16K extensions */
}
}
/*
* Get the normally small non-negative whole number.
* X.691, #10.6
...
...
skeletons/per_support.h
View file @
5b78e1cb
...
...
@@ -40,6 +40,8 @@ typedef struct asn_per_data_s {
const
uint8_t
*
buffer
;
/* Pointer to the octet stream */
size_t
nboff
;
/* Bit offset to the meaningful bit */
size_t
nbits
;
/* Number of bits in the stream */
int
(
*
refill
)(
struct
asn_per_data_s
*
);
void
*
refill_key
;
}
asn_per_data_t
;
/*
...
...
@@ -64,6 +66,11 @@ ssize_t uper_get_length(asn_per_data_t *pd,
int
effective_bound_bits
,
int
*
repeat
);
/*
* Get the normally small length "n".
*/
ssize_t
uper_get_nslength
(
asn_per_data_t
*
pd
);
/*
* Get the normally small non-negative whole number.
*/
...
...
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