pub struct UpdateMessage {
pub withdrawn_routes: Bytes,
pub path_attributes: Bytes,
pub nlri: Bytes,
}Expand description
A decoded BGP UPDATE message (RFC 4271 §4.3).
Stores the three variable-length sections as raw Bytes.
Call parse() to decode NLRI and path attributes.
Fields§
§withdrawn_routes: BytesRaw withdrawn routes (NLRI encoding).
path_attributes: BytesRaw path attributes.
nlri: BytesRaw Network Layer Reachability Information.
Implementations§
Source§impl UpdateMessage
impl UpdateMessage
Sourcepub fn decode(buf: &mut impl Buf, body_len: usize) -> Result<Self, DecodeError>
pub fn decode(buf: &mut impl Buf, body_len: usize) -> Result<Self, DecodeError>
Decode an UPDATE message body from a buffer.
The header must already be consumed; body_len is
header.length - HEADER_LEN.
§Errors
Returns DecodeError::UpdateLengthMismatch if the body is too short
or length fields are inconsistent, or DecodeError::Incomplete if
the buffer has fewer bytes than body_len.
Sourcepub fn parse(
&self,
four_octet_as: bool,
add_path_ipv4: bool,
add_path_families: &[(Afi, Safi)],
) -> Result<ParsedUpdate, DecodeError>
pub fn parse( &self, four_octet_as: bool, add_path_ipv4: bool, add_path_families: &[(Afi, Safi)], ) -> Result<ParsedUpdate, DecodeError>
Parse the raw UPDATE into decoded prefixes and path attributes.
four_octet_as controls whether AS numbers in AS_PATH are 2 or 4 bytes
wide (determined by capability negotiation).
add_path_ipv4 indicates whether the peer is sending Add-Path path IDs
for IPv4 body NLRI (RFC 7911). When false, decoded entries have path_id = 0.
§Errors
Returns DecodeError if NLRI or attribute data is malformed.
Sourcepub fn encode_with_limit(
&self,
buf: &mut impl BufMut,
max_message_len: u16,
) -> Result<(), EncodeError>
pub fn encode_with_limit( &self, buf: &mut impl BufMut, max_message_len: u16, ) -> Result<(), EncodeError>
Encode a complete UPDATE message (header + body) into a buffer.
max_message_len is the negotiated maximum: 4096 normally, or 65535
when Extended Messages (RFC 8654) has been negotiated.
§Errors
Returns EncodeError::MessageTooLong if the encoded message exceeds
the negotiated maximum message size.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
Encode using the standard 4096-byte limit.
§Errors
Returns EncodeError::MessageTooLong if the encoded message exceeds
the standard 4096-byte maximum.
Sourcepub fn build(
announced: &[Ipv4NlriEntry],
withdrawn: &[Ipv4NlriEntry],
attributes: &[PathAttribute],
four_octet_as: bool,
add_path: bool,
ipv4_unicast_mode: Ipv4UnicastMode,
) -> Self
pub fn build( announced: &[Ipv4NlriEntry], withdrawn: &[Ipv4NlriEntry], attributes: &[PathAttribute], four_octet_as: bool, add_path: bool, ipv4_unicast_mode: Ipv4UnicastMode, ) -> Self
Build an UpdateMessage from structured data.
Encodes NLRI, withdrawn routes, and path attributes into the raw
Bytes fields that encode() expects.
When add_path is true, path IDs are included in the wire encoding.
When false, only the prefix is encoded (path IDs are ignored).
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Total encoded size in bytes.
Trait Implementations§
Source§impl Clone for UpdateMessage
impl Clone for UpdateMessage
Source§fn clone(&self) -> UpdateMessage
fn clone(&self) -> UpdateMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more