Skip to content

Commit

Permalink
Merge pull request #138 from bgpkit/feature/rfc4724
Browse files Browse the repository at this point in the history
add support for end-of-RIB message test
  • Loading branch information
digizeph authored Nov 10, 2023
2 parents 0876066 + 312327b commit fba9fa7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ If you would like to see any specific RFC's support, please submit an issue on G
- [X] [RFC 2042](https://datatracker.ietf.org/doc/html/rfc2042): Registering New BGP Attribute Types
- [X] [RFC 3392](https://datatracker.ietf.org/doc/html/rfc3392): Capabilities Advertisement with BGP-4
- [X] [RFC 4271](https://datatracker.ietf.org/doc/html/rfc4271): A Border Gateway Protocol 4 (BGP-4)
- [X] [RFC 4724](https://datatracker.ietf.org/doc/html/rfc4724): Graceful Restart Mechanism for BGP
- [X] [RFC 4456](https://datatracker.ietf.org/doc/html/rfc4456): BGP Route Reflection: An Alternative to Full Mesh Internal BGP (IBGP)
- [X] [RFC 5065](https://datatracker.ietf.org/doc/html/rfc5065): Autonomous System Confederations for BGP
- [X] [RFC 6793](https://datatracker.ietf.org/doc/html/rfc6793): BGP Support for Four-Octet Autonomous System (AS) Number Space
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ If you would like to see any specific RFC's support, please submit an issue on G
- [X] [RFC 2042](https://datatracker.ietf.org/doc/html/rfc2042): Registering New BGP Attribute Types
- [X] [RFC 3392](https://datatracker.ietf.org/doc/html/rfc3392): Capabilities Advertisement with BGP-4
- [X] [RFC 4271](https://datatracker.ietf.org/doc/html/rfc4271): A Border Gateway Protocol 4 (BGP-4)
- [X] [RFC 4724](https://datatracker.ietf.org/doc/html/rfc4724): Graceful Restart Mechanism for BGP
- [X] [RFC 4456](https://datatracker.ietf.org/doc/html/rfc4456): BGP Route Reflection: An Alternative to Full Mesh Internal BGP (IBGP)
- [X] [RFC 5065](https://datatracker.ietf.org/doc/html/rfc5065): Autonomous System Confederations for BGP
- [X] [RFC 6793](https://datatracker.ietf.org/doc/html/rfc6793): BGP Support for Four-Octet Autonomous System (AS) Number Space
Expand Down
2 changes: 1 addition & 1 deletion src/models/bgp/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn get_deprecated_attr_type(attr_type: u8) -> Option<&'static str> {
}

/// Convenience wrapper for a list of attributes
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct Attributes {
// Black box type to allow for later changes/optimizations. The most common attributes could be
// added as fields to allow for easier lookup.
Expand Down
26 changes: 26 additions & 0 deletions src/parser/bgp/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,17 @@ impl BgpUpdateMessage {
bytes.extend(encode_nlri_prefixes(&self.announced_prefixes, add_path));
bytes.freeze()
}

/// Check if this is an end-of-rib message.
///
/// <https://datatracker.ietf.org/doc/html/rfc4724#section-2>
/// End-of-rib message is a special update message that contains no NLRI or withdrawal NLRI.
pub fn is_end_of_rib(&self) -> bool {
self.announced_prefixes.is_empty()
&& self.withdrawn_prefixes.is_empty()
&& self.attributes.get_reachable().is_none()
&& self.attributes.get_unreachable().is_none()
}
}

impl BgpMessage {
Expand All @@ -350,3 +361,18 @@ impl BgpMessage {
bytes.freeze()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_end_of_rib() {
let msg = BgpUpdateMessage {
withdrawn_prefixes: vec![],
attributes: Attributes::default(),
announced_prefixes: vec![],
};
assert!(msg.is_end_of_rib());
}
}

0 comments on commit fba9fa7

Please sign in to comment.