tcpdump mailing list archives
Re: endianness of portable BPF bytecode
From: Denis Ovsienko via tcpdump-workers <tcpdump-workers () lists tcpdump org>
Date: Fri, 10 Jun 2022 21:59:25 +0100
--- Begin Message --- From: Denis Ovsienko <denis () ovsienko info>
Date: Fri, 10 Jun 2022 21:59:25 +0100
On Thu, 2 Jun 2022 20:58:38 +0100 Denis Ovsienko via tcpdump-workers <tcpdump-workers () lists tcpdump org> wrote:If there is no convention in place yet, I would like to propose declaring big-endian as the implicit/default byte order, then particular file format(s) with headers can override that as needed.Below is a draft of such a file format. It addresses the following needs: * There is a header with a signature string to avoid false positive detection as some other file type that begins exactly with particular bytecode (ran into this during disassembly experiments). * There are version fields to address possible future changes to the encoding (either backward-compatible or not). * The explicit instruction count enables detection of truncated or malformed files on one hand, on the other it divides the bytecode from the optional meta-data. * The optional meta-data allows to captures some of the bytecode compilation context to aid in debugging. All multiple-byte fields are big-endian. File format: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'c' | 'B' | 'P' | 'F' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 's' | 'a' | 'v' | 'e' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'f' | 'i' | 'l' | 'e' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MajorVer=0 | MinorVer | InstructionCount=n | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | instruction 1 | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | instruction 2 | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | ~ ~ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | instruction n | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | optional trailing TLV space | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Instruction: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | opcode | jt | jf | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | k | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ TLV format: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ~ | | ~ Value (0 or more bytes) ~ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Length value does not include Type and Length. Type=0x00 (FILTER) Length is variable Value=<ASCII string, the filter expression> Type=0x01 (OPTIMIZED) Length=1 Value=<integer, bytecode optimizer enabled> (0 for off, 1 for on) Type=0x02 (LINKTYPE_ID) Length=4 Value=<integer, link-layer header type> Type=0x03 (LINKTYPE_NAME) Length is variable Value=<ASCII string, the link-layer header type name> Type=0x04 (COMMENT) Length is variabe Value=<UTF-8 string, comment or the generating software description> Type=0x05 (TIMESTAMP) Length=8 Value=<integer, Unix timestamp> -- Denis Ovsienko
--- End Message ---
_______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Current thread:
- endianness of portable BPF bytecode Denis Ovsienko via tcpdump-workers (Jun 02)
- Re: endianness of portable BPF bytecode Denis Ovsienko via tcpdump-workers (Jun 10)
- Re: endianness of portable BPF bytecode Guy Harris via tcpdump-workers (Jun 10)
- Message not available
- Re: endianness of portable BPF bytecode Denis Ovsienko via tcpdump-workers (Jun 10)
- Message not available
- Re: endianness of portable BPF bytecode Denis Ovsienko via tcpdump-workers (Jun 11)
- Re: endianness of portable BPF bytecode Denis Ovsienko via tcpdump-workers (Jun 10)
- Re: endianness of portable BPF bytecode (DRAFT revision 3) Denis Ovsienko via tcpdump-workers (Jun 25)
- Re: endianness of portable BPF bytecode (DRAFT revision 4) Denis Ovsienko via tcpdump-workers (Jun 30)
