Skip to main content

UpdateMessage

Struct UpdateMessage 

Source
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: Bytes

Raw withdrawn routes (NLRI encoding).

§path_attributes: Bytes

Raw path attributes.

§nlri: Bytes

Raw Network Layer Reachability Information.

Implementations§

Source§

impl UpdateMessage

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn encoded_len(&self) -> usize

Total encoded size in bytes.

Trait Implementations§

Source§

impl Clone for UpdateMessage

Source§

fn clone(&self) -> UpdateMessage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UpdateMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for UpdateMessage

Source§

impl PartialEq for UpdateMessage

Source§

fn eq(&self, other: &UpdateMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for UpdateMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.