Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for end-of-RIB message test #138

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading