Skip to content

Commit

Permalink
Fix Display for Unrecognized Wellknown communities
Browse files Browse the repository at this point in the history
  • Loading branch information
DRiKE committed Jul 17, 2023
1 parent cfc4c3a commit 7951069
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bgp/communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ macro_rules! wellknown {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
match self {
$($name::$var => write!(f, $pprim),)+
$name::Unrecognized(n) => write!(f, "0x{:08X}", n)
$name::Unrecognized(n) => write!(f, "0xFFFF{:04X}", n)
}
}
}
Expand Down Expand Up @@ -1410,4 +1410,12 @@ mod tests {
assert!(<Wellknown as TryFrom<u32>>::try_from(0xffff0001).is_ok());
assert!(<Wellknown as TryFrom<u32>>::try_from(0x0fff0001).is_err());
}

#[test]
fn to_string_and_back() {
let c: Community = [0xFF, 0xFF, 0xFF, 0x05].into();
let s = c.to_string();
let c2 = Community::from_str(&s).unwrap();
assert_eq!(c, c2);
}
}

0 comments on commit 7951069

Please sign in to comment.