Skip to main content

decode_message

Function decode_message 

Source
pub fn decode_message(
    buf: &mut Bytes,
    max_message_len: u16,
) -> Result<Message, DecodeError>
Expand description

Decode a complete BGP message from a buffer.

The buffer must contain exactly one complete message (header + body). The caller (transport framing layer) is responsible for length-delimited framing — use peek_message_length to determine when a complete message is available.

max_message_len is the negotiated maximum: 4096 normally, or 65535 when Extended Messages (RFC 8654) has been negotiated.

Advances the buffer past the consumed bytes on success.

§Errors

Returns a DecodeError if the header is malformed or the message body fails validation for its type.