pub struct OpenMessage {
pub version: u8,
pub my_as: u16,
pub hold_time: u16,
pub bgp_identifier: Ipv4Addr,
pub capabilities: Vec<Capability>,
}Expand description
A decoded BGP OPEN message (RFC 4271 §4.2).
Fields§
§version: u8BGP version (must be 4).
my_as: u162-byte AS from the OPEN wire format. May be AS_TRANS (23456)
if the speaker’s ASN > 65535 — the true ASN is in the
FourOctetAs capability.
hold_time: u16Proposed hold time in seconds (0 = no keepalives, or >= 3).
bgp_identifier: Ipv4AddrBGP Identifier (router ID).
capabilities: Vec<Capability>Capabilities from optional parameters.
Implementations§
Source§impl OpenMessage
impl OpenMessage
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 OPEN message body from a buffer.
The header must already be consumed; body_len is
header.length - HEADER_LEN.
§Errors
Returns a DecodeError if the body is too short, the version is
unsupported, or optional parameters are malformed.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
Encode a complete OPEN message (header + body) into a buffer.
§Errors
Returns an EncodeError if the optional parameters exceed 255 bytes
or the total message exceeds the maximum BGP message size.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Total encoded size in bytes.
Sourcepub fn four_byte_as(&self) -> u32
pub fn four_byte_as(&self) -> u32
Extract the 4-byte ASN from capabilities, if advertised.
Falls back to my_as (2-byte) if no FourOctetAs capability.
Trait Implementations§
Source§impl Clone for OpenMessage
impl Clone for OpenMessage
Source§fn clone(&self) -> OpenMessage
fn clone(&self) -> OpenMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more