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
ce10a57a
Unverified
Commit
ce10a57a
authored
Feb 06, 2024
by
Mouse
Committed by
GitHub
Feb 06, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #176 from v0-e/integer-aper-imax
aper: INTEGER longs to intmaxs
parents
4cfcd4f1
d9ce1d51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
skeletons/INTEGER_aper.c
skeletons/INTEGER_aper.c
+23
-23
No files found.
skeletons/INTEGER_aper.c
View file @
ce10a57a
...
@@ -57,7 +57,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -57,7 +57,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int
max_range_bytes
=
(
ct
->
range_bits
>>
3
)
+
int
max_range_bytes
=
(
ct
->
range_bits
>>
3
)
+
(((
ct
->
range_bits
%
8
)
>
0
)
?
1
:
0
);
(((
ct
->
range_bits
%
8
)
>
0
)
?
1
:
0
);
int
length
=
0
,
i
;
int
length
=
0
,
i
;
long
value
=
0
;
intmax_t
value
=
0
;
for
(
i
=
1
;
;
i
++
)
{
for
(
i
=
1
;
;
i
++
)
{
int
upper
=
1
<<
i
;
int
upper
=
1
<<
i
;
...
@@ -79,18 +79,18 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -79,18 +79,18 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int
buf
=
per_get_few_bits
(
pd
,
8
);
int
buf
=
per_get_few_bits
(
pd
,
8
);
if
(
buf
<
0
)
if
(
buf
<
0
)
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
value
+=
(((
long
)
buf
)
<<
(
8
*
length
));
value
+=
(((
intmax_t
)
buf
)
<<
(
8
*
length
));
}
}
value
+=
ct
->
lower_bound
;
value
+=
ct
->
lower_bound
;
if
((
specs
&&
specs
->
field_unsigned
)
if
((
specs
&&
specs
->
field_unsigned
)
?
asn_u
int642INTEGER
(
st
,
(
unsigned
long
)
value
)
?
asn_u
max2INTEGER
(
st
,
(
uintmax_t
)
value
)
:
asn_i
nt64
2INTEGER
(
st
,
value
))
:
asn_i
max
2INTEGER
(
st
,
value
))
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
ASN_DEBUG
(
"Got value %ld + low %lld"
,
ASN_DEBUG
(
"Got value %ld + low %lld"
,
value
,
(
long
long
in
t
)
ct
->
lower_bound
);
value
,
(
intmax_
t
)
ct
->
lower_bound
);
}
else
{
}
else
{
long
value
=
0
;
intmax_t
value
=
0
;
if
(
ct
->
range_bits
<
8
)
{
if
(
ct
->
range_bits
<
8
)
{
value
=
per_get_few_bits
(
pd
,
ct
->
range_bits
);
value
=
per_get_few_bits
(
pd
,
ct
->
range_bits
);
if
(
value
<
0
)
ASN__DECODE_STARVED
;
if
(
value
<
0
)
ASN__DECODE_STARVED
;
...
@@ -108,11 +108,11 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -108,11 +108,11 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}
}
value
+=
ct
->
lower_bound
;
value
+=
ct
->
lower_bound
;
if
((
specs
&&
specs
->
field_unsigned
)
if
((
specs
&&
specs
->
field_unsigned
)
?
asn_u
long2INTEGER
(
st
,
value
)
?
asn_u
max2INTEGER
(
st
,
(
uintmax_t
)
value
)
:
asn_
long
2INTEGER
(
st
,
value
))
:
asn_
imax
2INTEGER
(
st
,
value
))
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
ASN_DEBUG
(
"Got value %ld + low %lld"
,
ASN_DEBUG
(
"Got value %ld + low %lld"
,
value
,
(
long
long
in
t
)
ct
->
lower_bound
);
value
,
(
intmax_
t
)
ct
->
lower_bound
);
}
}
return
rval
;
return
rval
;
}
else
{
}
else
{
...
@@ -167,7 +167,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
...
@@ -167,7 +167,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
const
uint8_t
*
buf
;
const
uint8_t
*
buf
;
const
uint8_t
*
end
;
const
uint8_t
*
end
;
const
asn_per_constraint_t
*
ct
;
const
asn_per_constraint_t
*
ct
;
long
value
=
0
;
intmax_t
value
=
0
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
...
@@ -179,26 +179,26 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
...
@@ -179,26 +179,26 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
if
(
ct
)
{
if
(
ct
)
{
int
inext
=
0
;
int
inext
=
0
;
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
u
nsigned
long
uval
;
u
intmax_t
uval
;
if
(
asn_INTEGER2u
long
(
st
,
&
uval
))
if
(
asn_INTEGER2u
max
(
st
,
&
uval
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
)
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
)
inext
=
1
;
inext
=
1
;
}
else
if
(
ct
->
range_bits
>=
0
)
{
}
else
if
(
ct
->
range_bits
>=
0
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
||
uval
>
(
u
nsigned
long
)
ct
->
upper_bound
)
||
uval
>
(
u
intmax_t
)
ct
->
upper_bound
)
inext
=
1
;
inext
=
1
;
}
}
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
uval
,
st
->
buf
[
0
],
st
->
size
,
uval
,
st
->
buf
[
0
],
st
->
size
,
(
long
long
in
t
)
ct
->
lower_bound
,
(
intmax_
t
)
ct
->
lower_bound
,
(
long
long
in
t
)
ct
->
upper_bound
,
(
intmax_
t
)
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
inext
?
"ext"
:
"fix"
);
value
=
uval
;
value
=
uval
;
}
else
{
}
else
{
if
(
asn_INTEGER2
long
(
st
,
&
value
))
ASN__ENCODE_FAILED
;
if
(
asn_INTEGER2
imax
(
st
,
&
value
))
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
value
<
ct
->
lower_bound
)
if
(
value
<
ct
->
lower_bound
)
...
@@ -210,8 +210,8 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
...
@@ -210,8 +210,8 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
}
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
value
,
st
->
buf
[
0
],
st
->
size
,
value
,
st
->
buf
[
0
],
st
->
size
,
(
long
long
in
t
)
ct
->
lower_bound
,
(
intmax_
t
)
ct
->
lower_bound
,
(
long
long
in
t
)
ct
->
upper_bound
,
(
intmax_
t
)
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
inext
?
"ext"
:
"fix"
);
}
}
if
(
ct
->
flags
&
APC_EXTENSIBLE
)
{
if
(
ct
->
flags
&
APC_EXTENSIBLE
)
{
...
@@ -225,11 +225,11 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
...
@@ -225,11 +225,11 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
/* X.691, #12.2.2 */
/* X.691, #12.2.2 */
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
u
nsigned
long
v
;
u
intmax_t
v
;
/* #10.5.6 */
/* #10.5.6 */
ASN_DEBUG
(
"Encoding integer %ld (%lld) with range %d bits"
,
ASN_DEBUG
(
"Encoding integer %ld (%lld) with range %d bits"
,
value
,
(
long
long
in
t
)(
value
-
ct
->
lower_bound
),
value
,
(
intmax_
t
)(
value
-
ct
->
lower_bound
),
ct
->
range_bits
);
ct
->
range_bits
);
v
=
value
-
ct
->
lower_bound
;
v
=
value
-
ct
->
lower_bound
;
...
@@ -287,7 +287,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
...
@@ -287,7 +287,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
}
if
(
ct
&&
ct
->
lower_bound
)
{
if
(
ct
&&
ct
->
lower_bound
)
{
ASN_DEBUG
(
"Adjust lower bound to %lld"
,
(
long
long
in
t
)
ct
->
lower_bound
);
ASN_DEBUG
(
"Adjust lower bound to %lld"
,
(
intmax_
t
)
ct
->
lower_bound
);
/* TODO: adjust lower bound */
/* TODO: adjust lower bound */
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
}
}
...
...
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