feat: BGP (Border Gateway Protocol) Header Support#59
Open
jecsand838 wants to merge 11 commits into
Open
Conversation
Contributor
Author
|
CC: @svencowart |
svencowart
suggested changes
Jun 9, 2025
Co-authored-by: Sven Cowart <svencowart@gmail.com>
Co-authored-by: Sven Cowart <svencowart@gmail.com>
…y and to align with RFC standards.
…and extensibility in handling BGP UPDATE message components.
… efficient parsing, manipulation, and iteration of BGP message components.
…ations with explicit `new` methods for clarity and added zero-initialized constructors across key layouts.
Contributor
|
@jecsand838 based on the changes, I suggest this text to be the new PR description. This PR introduces initial support for BGP (Border Gateway Protocol version 4) by adding the Key Features Added:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces initial support for BGP (Border Gateway Protocol version 4) by adding the
src/bgp.rsfile. This lays the groundwork for structuring BGP messages within thenetwork-typeslibrary.Key Features Added:
BgpHdrStruct:specific_payload_bytes) to hold the initial fixed portion of message-specific payloads (i.e., for OPEN, UPDATE, NOTIFICATION, ROUTE-REFRESH messages). This design avoids heap allocations andunsafeunions while allowing access to these fields.marker,length,msg_type).Message-Specific Layout Structs:
OpenMsgLayout: Defines offsets and total length for fixed fields in BGP OPEN messages (RFC 4271, Section 4.2).UpdateInitialMsgLayout: Defines offsets and total length for the initial fixed field (Withdrawn Routes Length) in BGP UPDATE messages (RFC 4271, Section 4.3).NotificationMsgLayout: Defines offsets and total length for fixed fields in BGP NOTIFICATION messages (RFC 4271, Section 4.5).RouteRefreshMsgLayout: Defines offsets and total length for fixed fields in BGP ROUTE-REFRESH messages (RFC 2918, Section 3).Accessor Methods for Message-Specific Fields:
BgpHdrnow includes methods to safely get and set fields for OPEN, UPDATE (initial part), NOTIFICATION, and ROUTE-REFRESH messages.msg_typeto correctly interpret thespecific_payload_bytesarray based on the correspondingMsgLayoutstruct.Option<T>to handle cases where themsg_typedoesn't match or if the payload is unexpectedly short.boolindicating success or failure ((i.e., ifmsg_typeis incorrect or payload is too short).update_total_path_attr_lenandset_update_total_path_attr_lenmethods are provided to access the "Total Path Attribute Length" field in UPDATE messages, which requires the full message byte slice due to the preceding variable-length "Withdrawn Routes" field.Constants:
BGP_OPEN_MSG_TYPE).Unit Tests
This change is