-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BNER support stubs #247
base: master
Are you sure you want to change the base?
BNER support stubs #247
Conversation
bc863e3
to
410649e
Compare
410649e
to
7378fa5
Compare
493e9fc
to
25110a0
Compare
25110a0
to
dae3e5c
Compare
abc770b
to
72ed265
Compare
72ed265
to
e271d55
Compare
e271d55
to
e7474f7
Compare
@vlm I create a branch on my fork Once you've reviewed and merged this PR, I'll start creating other PR based on the work on the Here is a link to compare your |
(the contributors are properly listed in the
|
e7474f7
to
cce5152
Compare
skeletons/bner_support.c
Outdated
|
||
ber_tlv_tag_t bner_tag; | ||
|
||
if(ber_tag == -1) return -1; /* ANY */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vlm
I have this check here because an asn1 rule like this:
BACnetTimeValue ::= SEQUENCE {
time Time,
value ABSTRACT-SYNTAX.&Type -- any primitive datatype; complex types cannot be decoded
}
will produce code like this:
asn_TYPE_member_t asn_MBR_BACnetTimeValue_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct BACnetTimeValue, time),
(ASN_TAG_CLASS_APPLICATION | (11 << 2)),
0,
&asn_DEF_Time,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"time"
},
{ ATF_ANY_TYPE | ATF_NOFLAGS, 0, offsetof(struct BACnetTimeValue, value),
-1 /* Ambiguous tag (ANY?) */,
0,
&asn_DEF_ANY,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"value"
},
The line in the code above:
-1 /* Ambiguous tag (ANY?) */,
is of type ber_tlv_tag_t
, which is typedef unsigned ber_tlv_tag_t
However, this line of code causes this compilation error:
bner_support.c: In function ‘convert_ber_to_bner_tag’:
bner_support.c:320:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if(ber_tag == -1) return -1; /* ANY */
^
I tried changing it to typedef signed ber_tlv_tag_t
, but this causes tests/tests-skeletons/check-ber_tlv_tag
to fail:
$ cat tests/tests-skeletons/test-suite.log
========================================================
asn1c 0.9.29: tests/tests-skeletons/test-suite.log
========================================================
# TOTAL: 17
# PASS: 16
# SKIP: 0
# XFAIL: 0
# FAIL: 1
# XPASS: 0
# ERROR: 0
.. contents:: :depth: 2
FAIL: check-ber_tlv_tag
=======================
../../../tests/tests-skeletons/check-ber_tlv_tag.c:103:21: runtime error: left shift of negative value -294967296
#0 0x401003 in main (/home/jringle-admin/git/asn1c/.tmp.build/tests/tests-skeletons/check-ber_tlv_tag+0x401003)
#1 0x2aef36a22f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
#2 0x40115f (/home/jringle-admin/git/asn1c/.tmp.build/tests/tests-skeletons/check-ber_tlv_tag+0x40115f)
Do you have any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that X.690 section 8.1.2 doesn't seem to specify a maximum tag value allowed, but rather that the tag value can be arbitrarily large just by adding more subsequent identifier octets with the high order bit set. As such, it seems to me that the limit on the largest tag value would be limited by the implementation that is implementing the Basic Encoding Rules. Are there users of BER out there where you could reasonably expect that they would experience hardship if the largest BER tag value was cut in half from this implementation's max value due to changing it to typedef signed ber_tlv_tag_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not anticipate end-user problems, but it changing signedness of ber_tlv_tag_t will surely cause me going over the code base for quite some time in search of inadvertent security issues. So do it as a separate PR to make it a bit easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1c63322
to
c672a2c
Compare
bb4f4fa
to
84c009b
Compare
@brchiu I usually do it using |
I created a separate PR #249 for the ASN_TAG_AMBIGUOUS part of this PR |
84c009b
to
2832076
Compare
2832076
to
8ff07d2
Compare
The BNER support in the asn1c compiler will only support the BNER variable encoding rules. The bner_{en,de}code() functions will to see if the PDU being {en,de}coded is one that requires BNER fixed encoding rules (these are "BACnet.*PDU". If it is, then it will call bner_fixed_{en,de}coder() These two functions are declared as weak functions that will return an error. The intent here is that an external project will provide replacement functions for these two functions.
698f856
to
194762f
Compare
194762f
to
7c6c02f
Compare
06e4c85
to
2788662
Compare
This will allow a bacnet library to override this function and be able to pretty print the BNER primitives: Double CharacterString Date Time BACnetObjectIdentifier
2788662
to
aa62608
Compare
This PR will add stubs in for BACnet Encoding Rules to reduce merge conflicts while developing the BNER encoding