Skip to content

feat: Extend protobuf messages #21

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

Merged
merged 2 commits into from
May 27, 2025
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gateway_config"
version = "0.2.1"
version = "0.2.2"
edition = "2024"
license = "Apache-2.0"

Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

fn main() {
#[cfg(feature = "regenerate")] {
#[cfg(feature = "regenerate")]
{
// We will use self-contained protoc binary, have to hack env param to force it to use
unsafe {
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path().unwrap());
Expand Down Expand Up @@ -30,5 +31,4 @@ fn main() {
{
// Do nothing
}

}
27 changes: 18 additions & 9 deletions pkg/dataplane/dataplane.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion proto/dataplane.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ message OspfConfig {
/* Defines a logical interface. May correlate with physical representation */
message Interface {
string name = 1;
string ipaddr = 2;
repeated string ipaddrs = 2;
IfType type = 3;
IfRole role = 4;
optional uint32 vlan = 5; /* only if VLAN role is defined */
Expand Down Expand Up @@ -189,6 +189,7 @@ message BgpNeighbor {
string remote_asn = 2;
repeated BgpAF af_activate = 3;
BgpNeighborUpdateSource update_source = 4;
repeated string networks = 5;
}

/* IP Prefix filtering route map description */
Expand Down
6 changes: 4 additions & 2 deletions src/generated/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub struct OspfConfig {
pub struct Interface {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub ipaddr: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "2")]
pub ipaddrs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(enumeration = "IfType", tag = "3")]
pub r#type: i32,
#[prost(enumeration = "IfRole", tag = "4")]
Expand Down Expand Up @@ -219,6 +219,8 @@ pub struct BgpNeighbor {
pub af_activate: ::prost::alloc::vec::Vec<i32>,
#[prost(message, optional, tag = "4")]
pub update_source: ::core::option::Option<BgpNeighborUpdateSource>,
#[prost(string, repeated, tag = "5")]
pub networks: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// IP Prefix filtering route map description
#[derive(::serde::Deserialize, ::serde::Serialize)]
Expand Down
66 changes: 43 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,54 @@ pub mod config {
}

pub use config::{
// Service definitions
config_service_server::{ConfigService, ConfigServiceServer},
config_service_client::ConfigServiceClient,

// Request/Response types
GetConfigRequest,
BgpAddressFamilyIPv4,
BgpAddressFamilyIPv6,
BgpAddressFamilyL2vpnEvpn,
BgpAf,
BgpNeighbor,
// Device related types
Device,
Eal,
// Common types
Error,

Expose,
GatewayConfig,
GetConfigGenerationRequest,
GetConfigGenerationResponse,
UpdateConfigRequest,
UpdateConfigResponse,

// Common types
Error,

// Device related types
Device, Ports, Eal, LogLevel, PacketDriver,

// Request/Response types
GetConfigRequest,
IfRole,
IfType,
// Interface related types
Interface, IfType, IfRole, OspfConfig, OspfInterface,

// Underlay related types
Underlay, Vrf, RouterConfig, BgpNeighbor, BgpAf,
BgpAddressFamilyIPv4, BgpAddressFamilyIPv6, BgpAddressFamilyL2vpnEvpn,
RouteMap,

Interface,
LogLevel,
OspfConfig,
OspfInterface,

// Overlay related types
Overlay, Vpc, VpcPeering, PeeringEntryFor, Expose, PeeringIPs, PeeringAs,
Overlay,
PacketDriver,

PeeringAs,
PeeringEntryFor,
PeeringIPs,
Ports,
RouteMap,

RouterConfig,
// Underlay related types
Underlay,
UpdateConfigRequest,
UpdateConfigResponse,

Vpc,
VpcPeering,
Vrf,
config_service_client::ConfigServiceClient,

// Service definitions
config_service_server::{ConfigService, ConfigServiceServer},
};

pub fn get_proto_path() -> std::path::PathBuf {
Expand Down
12 changes: 8 additions & 4 deletions tests/simple_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::net::SocketAddr;
use tonic::{Request, Response, Status};

use gateway_config::{
ConfigService, ConfigServiceServer, ConfigServiceClient,
GetConfigGenerationRequest, GetConfigGenerationResponse,
ConfigService, ConfigServiceClient, ConfigServiceServer, GetConfigGenerationRequest,
GetConfigGenerationResponse,
};

struct SimpleConfigService {
Expand Down Expand Up @@ -35,14 +35,18 @@ impl ConfigService for SimpleConfigService {
&self,
_request: Request<gateway_config::GetConfigRequest>,
) -> Result<Response<gateway_config::GatewayConfig>, Status> {
Err(Status::unimplemented("get_config not implemented in this test"))
Err(Status::unimplemented(
"get_config not implemented in this test",
))
}

async fn update_config(
&self,
_request: Request<gateway_config::UpdateConfigRequest>,
) -> Result<Response<gateway_config::UpdateConfigResponse>, Status> {
Err(Status::unimplemented("update_config not implemented in this test"))
Err(Status::unimplemented(
"update_config not implemented in this test",
))
}
}

Expand Down