Skip to content

Commit

Permalink
Add As4Aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
DRiKE committed Aug 29, 2023
1 parent c122b78 commit 48f56e2
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/bgp/message/update_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub mod new_pas {
15 => MpUnreachNlri(MpUnreachNlriBuilder), Flags::OPT_NON_TRANS,
16 => ExtendedCommunities(ExtendedCommunitiesList), Flags::OPT_TRANS,
17 => As4Path(HopPath), Flags::OPT_TRANS,
//18=> As4Aggregator TODO
18 => As4Aggregator(Asn), Flags::OPT_TRANS,
20 => Connector(Ipv4Addr), Flags::OPT_TRANS,
21 => AsPathLimit(AsPathLimitInfo), Flags::OPT_TRANS,
//22 => PmsiTunnel(todo), Flags::OPT_TRANS,
Expand Down Expand Up @@ -829,6 +829,25 @@ pub mod new_pas {

}

//--- As4Aggregator

impl Attribute for As4Aggregator {
fn value_len(&self) -> usize { 4 }

fn compose_value<Target: OctetsBuilder>(&self, target: &mut Target)
-> Result<(), Target::AppendError>
{
target.append_slice(&self.0.to_raw())
}

fn parse<Octs: Octets>(parser: &mut Parser<Octs>, _sc: SessionConfig)
-> Result<As4Aggregator, ParseError>
{
Ok(As4Aggregator(Asn::from_u32(parser.parse_u32_be()?)))
}
}


//--- Connector (deprecated)

impl Attribute for Connector {
Expand Down Expand Up @@ -932,6 +951,8 @@ pub mod new_pas {
}
}

//--- Otc

impl Attribute for Otc {
fn value_len(&self) -> usize { 4 }

Expand All @@ -948,6 +969,9 @@ pub mod new_pas {
}
}


//------------ Tests ---------------------------------------------------------

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1119,7 +1143,10 @@ pub mod new_pas {
)))
);

//TODO 18 As4Aggregator
check(
vec![0xc0, 0x12, 0x04, 0x00, 0x00, 0x04, 0xd2],
As4Aggregator(Asn::from_u32(1234)).into()
);

check(
vec![0xc0, 0x14, 0x04, 1, 2, 3, 4],
Expand Down

0 comments on commit 48f56e2

Please sign in to comment.