diff --git a/crates/route_client/proto/route_service.proto b/crates/route_client/proto/route_service.proto index e6f113a..40c3d84 100644 --- a/crates/route_client/proto/route_service.proto +++ b/crates/route_client/proto/route_service.proto @@ -77,8 +77,20 @@ message PeerStatus { message PeerStatusResponse { repeated PeerStatus peer_status = 1; } +message AnnouncementRequest { + string peer_name = 1; + Prefix prefix = 2; + repeated string large_communities = 3; +} + +message AnnouncementResponse {} + // BGPServerAdminService implements an administrative interface to // view the status and control the operation of this BGP server. service BGPServerAdminService { + // Get the status of a specific peer. rpc PeerStatus(PeerStatusRequest) returns (PeerStatusResponse); + + // Make a BGP announcement to a specific peer. + rpc AnnounceToPeer(AnnouncementRequest) returns (AnnouncementResponse); } \ No newline at end of file diff --git a/crates/server/proto/route_service.proto b/crates/server/proto/route_service.proto index e6f113a..40c3d84 100644 --- a/crates/server/proto/route_service.proto +++ b/crates/server/proto/route_service.proto @@ -77,8 +77,20 @@ message PeerStatus { message PeerStatusResponse { repeated PeerStatus peer_status = 1; } +message AnnouncementRequest { + string peer_name = 1; + Prefix prefix = 2; + repeated string large_communities = 3; +} + +message AnnouncementResponse {} + // BGPServerAdminService implements an administrative interface to // view the status and control the operation of this BGP server. service BGPServerAdminService { + // Get the status of a specific peer. rpc PeerStatus(PeerStatusRequest) returns (PeerStatusResponse); + + // Make a BGP announcement to a specific peer. + rpc AnnounceToPeer(AnnouncementRequest) returns (AnnouncementResponse); } \ No newline at end of file diff --git a/crates/server/src/route_server.rs b/crates/server/src/route_server.rs index b972498..fd9cac4 100644 --- a/crates/server/src/route_server.rs +++ b/crates/server/src/route_server.rs @@ -20,6 +20,8 @@ use crate::rib_manager::RouteManagerCommands; use crate::route_server::route_server::bgp_server_admin_service_server::BgpServerAdminService; use crate::route_server::route_server::route_service_server::RouteService; use crate::route_server::route_server::AddressFamily; +use crate::route_server::route_server::AnnouncementRequest; +use crate::route_server::route_server::AnnouncementResponse; use crate::route_server::route_server::DumpPathsRequest; use crate::route_server::route_server::DumpPathsResponse; use crate::route_server::route_server::Path; @@ -40,7 +42,7 @@ use tokio::sync::oneshot; use tokio_stream::wrappers::ReceiverStream; use tonic::Response; use tonic::Status; -use tracing::warn; +use tracing::{info, warn}; pub mod route_server { tonic::include_proto!("bgpd.grpc"); @@ -139,6 +141,26 @@ impl BgpServerAdminService for RouteServer { Ok(Response::new(result)) } + + async fn announce_to_peer( + &self, + request: tonic::Request, + ) -> Result, Status> { + info!("Processing announce_to_peer: {:?}", request); + + let request = request.get_ref(); + + if let Some(peer) = self.peer_state_machines.get(&request.peer_name) { + info!("Would make announcement to peer: {}", &request.peer_name); + } else { + return Err(Status::invalid_argument(format!( + "No such peer: {}", + &request.peer_name, + ))); + } + + Ok(Response::new(AnnouncementResponse::default())) + } } #[tonic::async_trait]