Internet-Draft | Abbreviated Title | March 2025 |
Royer | Expires 25 September 2025 | [Page] |
This is an extension to the ABNF specification to allow for bits definitions to be defined.¶
When interacting with hardware or bit oriented over the wire protocols ABNF is not currently the choice. This specification describes a method to add boolean and narrow bit values in order to fix that limitation.¶
And this note while in in draft status: A new Open Source XDR [RFC4506] and ABNF generation tool is being developed [xdrgen] which generates code from ABNF and XDR. It can also generate ABNF from XDR. And it can generate XDR from ABNF. Both also can produce C++ source and header files.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 25 September 2025.¶
Copyright (c) 2025 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
This specification adds to [RFC5234], Section 2.3 Terminal values by adding an optional bit width to the binary, decimal, and hexadecimal terminals:¶
A caution to the implementors of code generated from ABNF that specifies bit widths for signed integer values. Many computer languages will convert a narrower bit value into a wider bit value and move the sign bit to the most significant position. So when preparing a signed bit value, be sure to clamp the value and adjust the sign to the correct bit position before packing the bits. This would apply to signed integer values and not unsigned integer values.¶
The right most elements are placed into the least signification part of the value. The left most bits being more significant than the bits to the right of them as shown in examples Figure 2 and Figure 3.¶
The result are these existing definitions with the added optional width indicators.¶
ABNF ---- b = binary b:%d = binary with a bit width of %d d = decimal d:%d = decimal with a bit width of %d x = hexadecimal x:%d = hexadecimal with a bit width of %d. p:%d = pad with %d zero bits. one-or-more = %x31-39 *(0x30-39) rulename = ALPHA *(ALPHA / DIGIT / "_") *(":" one-or-more)
In Figure 2 example, "device-status" is 8-bits wide, and the three values to the right of the equal sign have a total width of 8-bits.¶
ABNF ---- device-status:8 = light-on:1 status:3 switch-position:4
in Figure 3 "email-status" is defined to be 8-bits wide, and only three bits are used, so five zero bits have been defined to be at the most significant positions. The total to the right of the equal sign is 8-bits:¶
ABNF ---- email-status:8 = %p:5 seen:1 flagged:1 deleted:1
Figure Figure 4 shows an example where "c-string" on the left sides has no predefined width and the right side has a variable number of 8-bit wide values.¶
And "collection" has no predefined with and the right side is set of values with various and variable widths.¶
ABNF ---- c-string = (ALPHA:8 / DIGIT:8 ) *(ALPHA:8 / DIGIT:8) %x00:8 collection = %p:4 header:12 c-string width:32 *(ALPHA:8)
The padding does not need to be at the left. it can be in the middle and could have many zero bits as shown in Figure 5.¶
ABNF ---- trajectory:64 = %p:18 rotation:10 %p:2 vector-x:10 %p:2 vector-y:10 %p:2 vector-z:10
The following sets of rules are identical and valid:¶
ABNF ---- ; Original CRLF CRLF = %d13.10 ; Declaring CRLF is 16-bits wide. CRLF:16 = %d13.10 ; Declaring CRLF is 16-bits wide. CRLF:16 = %d13:8.10:8 ; CRLF still is 16-bits wide, but declaring it is optional. CRLF = %d13:8.10:8 ; Original rulename rulename = %d97 %d98 %d99 ; Declaring rulename is 24-bits wide rulename:24 = %d97:8 %d98:8 %d99:8 ; rulename still is 24-bits wide, but declaring it is optional. rulename = %d97:8 %d98:8 %d99:8 ; Orignal DIGIT DIGIT = %x30-39 ; Declaring DIGIT is 8-bits wide. DIGIT:8 = %x30-39 ; Declaring DIGIT is 8-bits wide. DIGIT:8 = %x30:8-39:8 ; DIGIT is still 8-bits wide, but declaring it is optional. DIGIT = %x30:8-39:8
This memo includes no request to IANA.¶
This document should not affect the security of the Internet.¶