-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add native uint24 support #1932
Comments
What about arbitrary bit-width integers? I've been using a lot of Zig and I've loved that feature, specifically for cases like this (for example I used it's not absolutely necessary, but I could see that being really nice for Spicy too. I have no idea how I'd implement that, though :) |
:-) For arbitrary width integer parsing, bitfields might be a reasonable and existing mechanism, actually. As a clarification, this isn't about supporting 24bit or arbitrary-width integer arithmetic (seems esoteric), but having a short-cut to parse 3 bytes into an integer. |
For reference, we've also had a request for uint128 (but no ticket yet I believe). That said, I don't think I want to do arbitrary bit-width integers. That'd be lot of work (in particular making sure they interact nicely with current std sizes, and performance doesn't suffer), with not that much actual demand afaics.
I would indeed be reluctant to introduce a full uint24 as well, but could see a short-cut for unpacking it. Do you have an idea for syntax? It doesn't fit nicely with the current |
Grml, I guess my hope was to allow just Maybe some lifted bitfield'ish notation instead?
|
The "bitfield'ish notation" looks like a new thing to me, would maybe an optional : uint8 &width=8;
# equivalent to
: uint8; or for the original issue transaction_id: uint32 &width=24; I think this should also integrate nicely with EDIT: Actually we already have : uint32 &size=3; # ParseError: expecting 4 bytes for unpacking value (3 bytes available) |
I like that, that looks most natural to me. The size couldn't be more than |
I really like,
Wouldn't filling the int from left to right and right-shift by |
Working on DHCPv6, there's a 24bit transaction ID:
https://datatracker.ietf.org/doc/html/rfc8415#section-8
My current "hack" for parsing is as follows:
MySQL also has a 24bit packet length field:
https://dev.mysql.com/doc/dev/mysql-server/8.4.3/page_protocol_basic_packets.html#sect_protocol_basic_packets_packet
Zeek's Spicy SSL parser apparently also has a need for uint24:
https://github.com/zeek/zeek/blob/master/src/analyzer/protocol/ssl/spicy/SSL.spicy#L968
This version likey has quite some overhead due to "bytes" and the
to_uint()
call.The SMB protocol's message length is also using 24bits:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/1dfacde4-b5c7-4494-8a14-a09d3ab4cc83
This seems sufficient examples in popular protocols to motivate native uint24 support in Spicy. Thoughts?
The text was updated successfully, but these errors were encountered: