binpac | High level language for describing protocol parsers | Parser library
kandi X-RAY | binpac Summary
kandi X-RAY | binpac Summary
-- mode: rst-mode -- .. Version number is filled in automatically.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of binpac
binpac Key Features
binpac Examples and Code Snippets
Community Discussions
Trending Discussions on binpac
QUESTION
I'm looking for what I'll call a 'binary serializer/deserializer code generator' for lack of a better term that specifically allows you to specify the on-the-wire format with arbitrary bit lengths and then generates the necessary C/C++ code to pack/unpack packets in that format. I started down the path of using a struct with bit fields but after reading this post I'm wondering if there's already something out there that handles all the messy problems. An example data structure I would need to deal with:
...ANSWER
Answered 2018-Jun-13 at 16:13You might consider ASN.1 for this and use PER (aligned or unaligned). You can use either BIT STRING types constrained to your needed lengths, or INTEGER types with constraints to limit values to the number of bits you would like. Since ASN.1 and its encoding rules are independent of machine architecture and programming language, you don't have to worry about whether your machine is big-endian or little-endian, or whether one end of the communications prefers Java rather than C or C++. A good ASN.1 Tool handles all of that for you. You can find out more about ASN.1 at the ASN.1 Project page which has a link Introduction to ASN.1 as well as a list of ASN.1 Tools (some free some commercial). The reason I mention UNALIGNED PER is that you can literally send exactly the number of bits across that line as you desire with no added padding bits between.
For BIT STRINGS, you can even assign names to individual bits that have some meaning to you for your application.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install binpac
./configure cd build make make install. This will perform an out-of-source build into the build directory using the default build options and then install the binpac binary into /usr/local/bin. Run ./configure --help for more options.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page