pub fn encode_labeled_prefix(
prefix: &LabeledNetworkPrefix,
mode: LabeledNlriMode,
add_path: bool,
peer_max_labels: Option<u8>,
) -> Result<Vec<u8>, LabeledNlriEncodeError>Expand description
Encode a labeled prefix for MP_REACH_NLRI per RFC 8277.
This function respects the encoding mode:
- SingleLabel mode: Exactly one label, BoS=1
- MultiLabel mode: All labels with proper BoS bits
§Arguments
prefix- The labeled prefix to encodemode- The RFC 8277 encoding mode (SingleLabel or MultiLabel)add_path- Whether ADD-PATH capability was negotiated (required for path_id encoding)peer_max_labels- Optional peer-negotiated maximum labels
§Errors
Returns error if:
- Label stack is empty
- Total NLRI length exceeds 255 bits
- SingleLabel mode with multiple labels
- ADD-PATH not negotiated but path_id is present
- Label count exceeds peer_max_labels