Skip to content
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

Named bit string positions with UPER #240

Closed
aosterhage opened this issue Aug 5, 2022 · 3 comments
Closed

Named bit string positions with UPER #240

aosterhage opened this issue Aug 5, 2022 · 3 comments

Comments

@aosterhage
Copy link

aosterhage commented Aug 5, 2022

I'm utilizing asn1scc with UPER encodings in C. I can't find the appropriate information in the ITU-T X.691 document about encoding bit strings but examining several different ASN.1 compilers it seems that bit strings are flipped in UPER from how they are defined. E.g. given this definition of a bit string:

BitString BIT STRING ::= {
  first(0),
  second(1),
  third(2)
} (SIZE(3))

this data:

someBitString BitString ::= { first, second, third }

will be encoded to:
0x e0 or 0b 1110 0000

My confusion comes from the included bit string names provided by asn1scc (per #196). It will provide something similar to:

#define BitString_first 0x1  /*(1 << 0)*/
#define BitString_second 0x2  /*(1 << 1)*/
#define BitString_third 0x4  /*(1 << 2)*/

which seemingly are unusable for constructing or examining any BitString types because the C library doesn't seem to do any conversions. Is this expected or do I have a misunderstanding somewhere?

@maxime-esa
Copy link
Collaborator

maxime-esa commented Aug 5, 2022

@usr3-1415 will correct me if I am wrong but I think you are right and this is what I reported in this comment : #196 (comment)

@aosterhage
Copy link
Author

Thanks for the link, I missed that comment when going through the thread

usr3-1415 added a commit that referenced this issue Sep 4, 2022
New helper functions are now generated that set the appropriate bit in the bit string.
@usr3-1415
Copy link
Collaborator

A new set of functions is now generated that help programmer to set the bit string.
In this case, these functions will be called BitString_set_first(), BitString_set_second() etc.
There functions are not called during the encoding or decoding process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants