mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-11-23 09:12:14 +01:00
Merge pull request #504 from Anito23/master
Added compatibility with the new GoBGP API
This commit is contained in:
commit
cc79eeaea3
@ -33,24 +33,34 @@ decode_path_dynamic_t decode_path_dynamic = NULL;
|
||||
class GrpcClient {
|
||||
public:
|
||||
GrpcClient(std::shared_ptr<Channel> channel) : stub_(GobgpApi::NewStub(channel)) {}
|
||||
|
||||
void GetAllActiveAnnounces(unsigned int route_family) {
|
||||
ClientContext context;
|
||||
gobgpapi::Arguments arguments;
|
||||
gobgpapi::Table table;
|
||||
|
||||
arguments.set_rf(route_family);
|
||||
table.set_family(route_family);
|
||||
// We could specify certain neighbor here
|
||||
arguments.set_name("");
|
||||
arguments.set_resource(gobgpapi::Resource::GLOBAL);
|
||||
table.set_name("");
|
||||
table.set_type(gobgpapi::Resource::GLOBAL);
|
||||
|
||||
auto destinations_list = stub_->GetRib(&context, arguments);
|
||||
gobgpapi::Table response_table;
|
||||
|
||||
gobgpapi::Destination current_destination;
|
||||
auto status = stub_->GetRib(&context, table, &response_table);
|
||||
|
||||
if (!status.ok()) {
|
||||
// error_message
|
||||
logger << log4cpp::Priority::INFO << "Problem with RPC: " << status.error_code() << " message " << status.error_message();
|
||||
//std::cout << "Problem with RPC: " << status.error_code() << " message " << status.error_message() << std::endl;
|
||||
return;
|
||||
} else {
|
||||
// std::cout << "RPC working well" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "List of announced prefixes for route family: " << route_family << std::endl << std::endl;
|
||||
|
||||
for (auto current_destination : response_table.destinations()) {
|
||||
logger << log4cpp::Priority::INFO << "Prefix: " << current_destination.prefix();
|
||||
//std::cout << "Prefix: " << current_destination.prefix() << std::endl;
|
||||
|
||||
logger << log4cpp::Priority::INFO << "List of announced prefixes for route family: " << route_family;
|
||||
while (destinations_list->Read(¤t_destination)) {
|
||||
logger << log4cpp::Priority::INFO << "Prefix: " << current_destination.prefix();
|
||||
|
||||
//std::cout << "Paths size: " << current_destination.paths_size() << std::endl;
|
||||
|
||||
gobgpapi::Path my_path = current_destination.paths(0);
|
||||
@ -76,19 +86,12 @@ class GrpcClient {
|
||||
|
||||
gobgp_lib_path.path_attributes = my_path_attributes;
|
||||
|
||||
logger << log4cpp::Priority::INFO << "NLRI: " << decode_path_dynamic(&gobgp_lib_path);
|
||||
}
|
||||
|
||||
Status status = destinations_list->Finish();
|
||||
if (!status.ok()) {
|
||||
// error_message
|
||||
logger << log4cpp::Priority::INFO << "Problem with RPC: " << status.error_code() << " message " << status.error_message();
|
||||
} else {
|
||||
// std::cout << "RPC working well" << std::endl;
|
||||
logger << log4cpp::Priority::INFO << "NLRI: " << decode_path_dynamic(&gobgp_lib_path);
|
||||
//std::cout << "NLRI: " << decode_path(&gobgp_lib_path) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void AnnounceFlowSpecPrefix() {
|
||||
|
||||
void AnnounceFlowSpecPrefix(bool withdraw) {
|
||||
const gobgpapi::ModPathArguments current_mod_path_arguments;
|
||||
|
||||
unsigned int AFI_IP = 1;
|
||||
@ -96,13 +99,13 @@ class GrpcClient {
|
||||
unsigned int ipv4_flow_spec_route_family = AFI_IP<<16 | SAFI_FLOW_SPEC_UNICAST;
|
||||
|
||||
gobgpapi::Path* current_path = new gobgpapi::Path;
|
||||
// If you want withdraw, please use it
|
||||
// current_path->set_is_withdraw(true);
|
||||
current_path->set_is_withdraw(withdraw);
|
||||
|
||||
/*
|
||||
buf:
|
||||
char *value;
|
||||
int len;
|
||||
|
||||
path:
|
||||
buf nlri;
|
||||
buf** path_attributes;
|
||||
@ -110,9 +113,9 @@ class GrpcClient {
|
||||
int path_attributes_cap;
|
||||
*/
|
||||
|
||||
path* path_c_struct = serialize_path_dynamic(ipv4_flow_spec_route_family, (char*)"match destination 10.0.0.0/24 protocol tcp source 20.0.0.0/24 then redirect 10:10");
|
||||
path* path_c_struct = serialize_path(ipv4_flow_spec_route_family, (char*)"match destination 10.0.0.0/24 protocol tcp source 20.0.0.0/24 then redirect 10:10");
|
||||
|
||||
// printf("Decoded NLRI output: %s, length %d raw string length: %d\n", decode_path_dynamic(path_c_struct), path_c_struct->nlri.len, strlen(path_c_struct->nlri.value));
|
||||
// printf("Decoded NLRI output: %s, length %d raw string length: %d\n", decode_path(path_c_struct), path_c_struct->nlri.len, strlen(path_c_struct->nlri.value));
|
||||
|
||||
for (int path_attribute_number = 0; path_attribute_number < path_c_struct->path_attributes_len; path_attribute_number++) {
|
||||
current_path->add_pattrs(path_c_struct->path_attributes[path_attribute_number]->value,
|
||||
@ -121,10 +124,10 @@ class GrpcClient {
|
||||
|
||||
current_path->set_nlri(path_c_struct->nlri.value, path_c_struct->nlri.len);
|
||||
|
||||
gobgpapi::ModPathArguments request;
|
||||
gobgpapi::ModPathsArguments request;
|
||||
request.set_resource(gobgpapi::Resource::GLOBAL);
|
||||
|
||||
google::protobuf::RepeatedPtrField< ::gobgpapi::Path >* current_path_list = request.mutable_paths();
|
||||
google::protobuf::RepeatedPtrField< ::gobgpapi::Path >* current_path_list = request.mutable_paths();
|
||||
current_path_list->AddAllocated(current_path);
|
||||
request.set_name("");
|
||||
|
||||
@ -133,12 +136,13 @@ class GrpcClient {
|
||||
gobgpapi::Error return_error;
|
||||
|
||||
// result is a std::unique_ptr<grpc::ClientWriter<gobgpapi::ModPathArguments> >
|
||||
auto send_stream = stub_->ModPath(&context, &return_error);
|
||||
auto send_stream = stub_->ModPaths(&context, &return_error);
|
||||
|
||||
bool write_result = send_stream->Write(request);
|
||||
|
||||
if (!write_result) {
|
||||
logger << log4cpp::Priority::INFO << "Write to API failed\n";
|
||||
logger << log4cpp::Priority::INFO << "Write to API failed\n";
|
||||
//std::cout << "Write to API failed\n";
|
||||
}
|
||||
|
||||
// Finish all writes
|
||||
@ -149,8 +153,10 @@ class GrpcClient {
|
||||
if (status.ok()) {
|
||||
//std::cout << "modpath executed correctly" << std::cout;
|
||||
} else {
|
||||
logger << log4cpp::Priority::INFO << "modpath failed with code: " << status.error_code()
|
||||
logger << log4cpp::Priority::INFO << "modpath failed with code: " << status.error_code()
|
||||
<< " message " << status.error_message();
|
||||
//std::cout << "modpath failed with code: " << status.error_code()
|
||||
// << " message " << status.error_message() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +168,7 @@ class GrpcClient {
|
||||
unsigned int ipv4_unicast_route_family = AFI_IP<<16 | SAFI_UNICAST;
|
||||
|
||||
gobgpapi::Path* current_path = new gobgpapi::Path;
|
||||
|
||||
// current_path->set_is_withdraw(withdraw);
|
||||
if (is_withdrawal) {
|
||||
current_path->set_is_withdraw(true);
|
||||
}
|
||||
@ -171,15 +177,17 @@ class GrpcClient {
|
||||
buf:
|
||||
char *value;
|
||||
int len;
|
||||
|
||||
path:
|
||||
buf nlri;
|
||||
buf** path_attributes;
|
||||
int path_attributes_len;
|
||||
int path_attributes_cap;
|
||||
*/
|
||||
|
||||
|
||||
std::string announce_line = announced_prefix + " nexthop " + announced_prefix_nexthop;
|
||||
|
||||
// 10.10.20.33/22 nexthop 10.10.1.99/32
|
||||
path* path_c_struct = serialize_path_dynamic(ipv4_unicast_route_family, (char*)announce_line.c_str());
|
||||
|
||||
if (path_c_struct == NULL) {
|
||||
@ -187,7 +195,7 @@ class GrpcClient {
|
||||
return;
|
||||
}
|
||||
|
||||
// printf("Decoded NLRI output: %s, length %d raw string length: %d\n", decode_path_dynamic(path_c_struct), path_c_struct->nlri.len, strlen(path_c_struct->nlri.value));
|
||||
// printf("Decoded NLRI output: %s, length %d raw string length: %d\n", decode_path(path_c_struct), path_c_struct->nlri.len, strlen(path_c_struct->nlri.value));
|
||||
|
||||
for (int path_attribute_number = 0; path_attribute_number < path_c_struct->path_attributes_len; path_attribute_number++) {
|
||||
current_path->add_pattrs(path_c_struct->path_attributes[path_attribute_number]->value,
|
||||
@ -196,7 +204,7 @@ class GrpcClient {
|
||||
|
||||
current_path->set_nlri(path_c_struct->nlri.value, path_c_struct->nlri.len);
|
||||
|
||||
gobgpapi::ModPathArguments request;
|
||||
gobgpapi::ModPathsArguments request;
|
||||
request.set_resource(gobgpapi::Resource::GLOBAL);
|
||||
google::protobuf::RepeatedPtrField< ::gobgpapi::Path >* current_path_list = request.mutable_paths();
|
||||
current_path_list->AddAllocated(current_path);
|
||||
@ -207,11 +215,12 @@ class GrpcClient {
|
||||
gobgpapi::Error return_error;
|
||||
|
||||
// result is a std::unique_ptr<grpc::ClientWriter<api::ModPathArguments> >
|
||||
auto send_stream = stub_->ModPath(&context, &return_error);
|
||||
auto send_stream = stub_->ModPaths(&context, &return_error);
|
||||
|
||||
bool write_result = send_stream->Write(request);
|
||||
|
||||
if (!write_result) {
|
||||
//std::cout << "Write to API failed\n";
|
||||
logger << log4cpp::Priority::ERROR << "Write to API failed\n";
|
||||
return;
|
||||
}
|
||||
@ -224,6 +233,8 @@ class GrpcClient {
|
||||
if (status.ok()) {
|
||||
//std::cout << "modpath executed correctly" << std::cout;
|
||||
} else {
|
||||
//std::cout << "modpath failed with code: " << status.error_code()
|
||||
// << " message " << status.error_message() << std::endl;
|
||||
logger << log4cpp::Priority::ERROR << "modpath failed with code: " << status.error_code()
|
||||
<< " message " << status.error_message();
|
||||
|
||||
@ -231,9 +242,9 @@ class GrpcClient {
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetAllNeighbor(std::string neighbor_ip) {
|
||||
std::string GetNeighbor(std::string neighbor_ip) {
|
||||
gobgpapi::Arguments request;
|
||||
request.set_rf(4);
|
||||
request.set_family(4);
|
||||
request.set_name(neighbor_ip);
|
||||
|
||||
ClientContext context;
|
||||
@ -243,12 +254,12 @@ class GrpcClient {
|
||||
|
||||
if (status.ok()) {
|
||||
gobgpapi::PeerConf peer_conf = peer.conf();
|
||||
gobgpapi::PeerInfo peer_info = peer.info();
|
||||
gobgpapi::PeerState peer_info = peer.info();
|
||||
|
||||
std::stringstream buffer;
|
||||
|
||||
buffer
|
||||
<< "Peer AS: " << peer_conf.remote_as() << "\n"
|
||||
<< "Peer AS: " << peer_conf.peer_as() << "\n"
|
||||
<< "Peer router id: " << peer_conf.id() << "\n"
|
||||
<< "Peer flops: " << peer_info.flops() << "\n"
|
||||
<< "BGP state: " << peer_info.bgp_state();
|
||||
@ -270,7 +281,8 @@ bool gobgp_announce_host = false;
|
||||
|
||||
void gobgp_action_init() {
|
||||
logger << log4cpp::Priority::INFO << "GoBGP action module loaded";
|
||||
gobgp_client = new GrpcClient(grpc::CreateChannel("localhost:8080", grpc::InsecureCredentials()));
|
||||
gobgp_client = new GrpcClient(grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
|
||||
// GrpcClient gobgp_client(grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
|
||||
|
||||
if (configuration_map.count("gobgp_next_hop")) {
|
||||
gobgp_nexthop = configuration_map["gobgp_next_hop"];
|
||||
|
@ -20,9 +20,12 @@ package gobgpapi;
|
||||
// Interface exported by the server.
|
||||
|
||||
service GobgpApi {
|
||||
rpc GetGlobalConfig(Arguments) returns (Global) {}
|
||||
rpc ModGlobalConfig(ModGlobalConfigArguments) returns (Error) {}
|
||||
rpc GetNeighbors(Arguments) returns (stream Peer) {}
|
||||
rpc GetNeighbor(Arguments) returns (Peer) {}
|
||||
rpc GetRib(Arguments) returns (stream Destination) {}
|
||||
rpc ModNeighbor(ModNeighborArguments) returns(Error) {}
|
||||
rpc GetRib(Table) returns (Table) {}
|
||||
rpc Reset(Arguments) returns (Error) {}
|
||||
rpc SoftReset(Arguments) returns (Error) {}
|
||||
rpc SoftResetIn(Arguments) returns (Error) {}
|
||||
@ -30,19 +33,31 @@ service GobgpApi {
|
||||
rpc Shutdown(Arguments) returns (Error) {}
|
||||
rpc Enable(Arguments) returns (Error) {}
|
||||
rpc Disable(Arguments) returns (Error) {}
|
||||
rpc ModPath(stream ModPathArguments) returns (Error) {}
|
||||
rpc GetNeighborPolicy(Arguments) returns (ApplyPolicy) {}
|
||||
rpc ModNeighborPolicy(stream PolicyArguments) returns (stream Error) {}
|
||||
rpc GetPolicyRoutePolicies(PolicyArguments) returns (stream PolicyDefinition) {}
|
||||
rpc GetPolicyRoutePolicy(PolicyArguments) returns (PolicyDefinition) {}
|
||||
rpc ModPolicyRoutePolicy(stream PolicyArguments) returns (stream Error) {}
|
||||
rpc ModPath(ModPathArguments) returns (ModPathResponse) {}
|
||||
rpc ModPaths(stream ModPathsArguments) returns (Error) {}
|
||||
rpc MonitorRib(Table) returns (stream Destination) {}
|
||||
rpc MonitorBestChanged(Arguments) returns (stream Destination) {}
|
||||
rpc MonitorPeerState(Arguments) returns (stream Peer) {}
|
||||
rpc MonitorROAValidation(Arguments) returns (stream ROAResult) {}
|
||||
rpc GetMrt(MrtArguments) returns (stream MrtMessage) {}
|
||||
rpc ModMrt(ModMrtArguments) returns (Error) {}
|
||||
rpc ModBmp(ModBmpArguments) returns (Error) {}
|
||||
rpc GetRPKI(Arguments) returns (stream RPKI) {}
|
||||
rpc ModRPKI(ModRpkiArguments) returns (Error) {}
|
||||
rpc GetROA(Arguments) returns (stream ROA) {}
|
||||
rpc GetVrfs(Arguments) returns (stream Vrf) {}
|
||||
rpc ModVrf(ModVrfArguments) returns (Error) {}
|
||||
rpc GetDefinedSet(DefinedSet) returns (DefinedSet) {}
|
||||
rpc GetDefinedSets(DefinedSet) returns (stream DefinedSet) {}
|
||||
rpc ModDefinedSet(ModDefinedSetArguments) returns (Error) {}
|
||||
rpc GetStatement(Statement) returns (Statement) {}
|
||||
rpc GetStatements(Statement) returns (stream Statement) {}
|
||||
rpc ModStatement(ModStatementArguments) returns (Error) {}
|
||||
rpc GetPolicy(Policy) returns (Policy) {}
|
||||
rpc GetPolicies(Policy) returns (stream Policy) {}
|
||||
rpc ModPolicy(ModPolicyArguments) returns (Error) {}
|
||||
rpc GetPolicyAssignment(PolicyAssignment) returns (PolicyAssignment) {}
|
||||
rpc ModPolicyAssignment(ModPolicyAssignmentArguments) returns (Error) {}
|
||||
}
|
||||
|
||||
message Error {
|
||||
@ -56,55 +71,123 @@ message Error {
|
||||
|
||||
message Arguments {
|
||||
Resource resource = 1;
|
||||
uint32 rf = 2;
|
||||
uint32 family = 2;
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
message ModPathArguments {
|
||||
Operation operation = 1;
|
||||
Resource resource = 2;
|
||||
string name = 3;
|
||||
Path path = 4;
|
||||
// uuid field can be only used when operation is DEL
|
||||
bytes uuid = 5;
|
||||
// family field is only used when operation is DEL_ALL
|
||||
uint32 family = 6;
|
||||
}
|
||||
|
||||
message ModPathResponse {
|
||||
bytes uuid = 1;
|
||||
}
|
||||
|
||||
message ModPathsArguments {
|
||||
Resource resource = 1;
|
||||
string name = 2;
|
||||
repeated Path paths = 3;
|
||||
}
|
||||
|
||||
message PolicyArguments {
|
||||
Resource resource = 1;
|
||||
Operation operation = 2;
|
||||
string neighbor_address = 3;
|
||||
string name = 4;
|
||||
PolicyDefinition policy_definition = 6;
|
||||
ApplyPolicy apply_policy = 7;
|
||||
message ModNeighborArguments {
|
||||
Operation operation = 1;
|
||||
Peer peer = 2;
|
||||
}
|
||||
|
||||
message MrtArguments {
|
||||
Resource resource = 1;
|
||||
uint32 rf = 2;
|
||||
uint32 family = 2;
|
||||
uint64 interval = 3;
|
||||
string neighbor_address = 4;
|
||||
}
|
||||
|
||||
message ModMrtArguments {
|
||||
Operation operation = 1;
|
||||
int32 dump_type = 2;
|
||||
string filename = 3;
|
||||
uint64 interval = 4;
|
||||
}
|
||||
|
||||
message ModBmpArguments {
|
||||
Operation operation = 1;
|
||||
string address = 2;
|
||||
uint32 port = 3;
|
||||
enum MonitoringPolicy {
|
||||
PRE = 0;
|
||||
POST = 1;
|
||||
BOTH = 2;
|
||||
}
|
||||
MonitoringPolicy type = 4;
|
||||
}
|
||||
|
||||
message ModRpkiArguments {
|
||||
Operation operation = 1;
|
||||
string address = 2;
|
||||
uint32 port = 3;
|
||||
}
|
||||
|
||||
message ModVrfArguments {
|
||||
Operation operation = 1;
|
||||
Vrf vrf = 2;
|
||||
}
|
||||
|
||||
message ModDefinedSetArguments {
|
||||
Operation operation = 1;
|
||||
DefinedSet set = 2;
|
||||
}
|
||||
|
||||
message ModStatementArguments {
|
||||
Operation operation = 1;
|
||||
Statement statement = 2;
|
||||
}
|
||||
|
||||
message ModPolicyArguments {
|
||||
Operation operation = 1;
|
||||
Policy policy = 2;
|
||||
// if this flag is set, gobgpd won't define new statements
|
||||
// but refer existing statements using statement's names in this arguments.
|
||||
// this flag only works with Operation_ADD
|
||||
bool refer_existing_statements = 3;
|
||||
// if this flag is set, gobgpd won't delete any statements
|
||||
// even if some statements get not used by any policy by this operation.
|
||||
// this flag means nothing if it is used with Operation_ADD
|
||||
bool preserve_statements = 4;
|
||||
}
|
||||
|
||||
message ModPolicyAssignmentArguments {
|
||||
Operation operation = 1;
|
||||
PolicyAssignment assignment = 2;
|
||||
}
|
||||
|
||||
message ModGlobalConfigArguments {
|
||||
Operation operation = 1;
|
||||
Global global = 2;
|
||||
}
|
||||
|
||||
enum Resource {
|
||||
GLOBAL = 0;
|
||||
LOCAL = 1;
|
||||
ADJ_IN = 2;
|
||||
ADJ_OUT = 3;
|
||||
POLICY_PREFIX = 4;
|
||||
POLICY_NEIGHBOR = 5;
|
||||
POLICY_ASPATH = 6;
|
||||
POLICY_COMMUNITY = 7;
|
||||
POLICY_ROUTEPOLICY = 8;
|
||||
POLICY_EXTCOMMUNITY = 9;
|
||||
VRF = 10;
|
||||
VRF = 4;
|
||||
}
|
||||
|
||||
enum Operation {
|
||||
ADD = 0;
|
||||
DEL = 1;
|
||||
DEL_ALL = 2;
|
||||
REPLACE = 3;
|
||||
ENABLE = 4;
|
||||
DISABLE = 5;
|
||||
RESET = 6;
|
||||
SOFTRESET = 7;
|
||||
}
|
||||
|
||||
message Path {
|
||||
@ -115,150 +198,271 @@ message Path {
|
||||
bool is_withdraw = 5;
|
||||
int32 validation = 6;
|
||||
bool no_implicit_withdraw = 7;
|
||||
uint32 rf = 8;
|
||||
uint32 family = 8;
|
||||
uint32 source_asn = 9;
|
||||
string source_id = 10;
|
||||
bool filtered = 11;
|
||||
bool stale = 12;
|
||||
bool is_from_external = 13;
|
||||
string neighbor_ip = 14;
|
||||
}
|
||||
|
||||
message Destination {
|
||||
string prefix = 1;
|
||||
repeated Path paths = 2;
|
||||
bool longer_prefixes = 3;
|
||||
}
|
||||
|
||||
message PeerConf {
|
||||
string remote_ip = 1;
|
||||
string id = 2;
|
||||
uint32 remote_as = 3;
|
||||
repeated bytes remote_cap = 6;
|
||||
repeated bytes local_cap = 7;
|
||||
uint32 holdtime = 8;
|
||||
uint32 keepalive_interval = 9;
|
||||
}
|
||||
|
||||
message PeerInfo {
|
||||
string bgp_state = 1;
|
||||
string admin_state = 2;
|
||||
uint32 fsm_established_transitions = 3;
|
||||
uint64 total_message_out = 4;
|
||||
uint64 total_message_in = 5;
|
||||
uint64 update_message_out = 6;
|
||||
uint64 update_message_in = 7;
|
||||
uint64 keep_alive_message_out = 8;
|
||||
uint64 keep_alive_message_in = 9;
|
||||
uint64 open_message_out = 10;
|
||||
uint64 open_message_in = 11;
|
||||
uint64 notification_out = 12;
|
||||
uint64 notification_in = 13;
|
||||
uint64 refresh_message_out = 14;
|
||||
uint64 refresh_message_in = 15;
|
||||
uint64 discarded_out = 16;
|
||||
uint64 discarded_in = 17;
|
||||
int64 uptime = 18;
|
||||
int64 downtime = 19;
|
||||
string last_error = 20;
|
||||
uint32 received = 21;
|
||||
uint32 accepted = 22;
|
||||
uint32 advertized = 23;
|
||||
uint32 out_q = 24;
|
||||
uint32 flops = 25;
|
||||
uint32 negotiated_holdtime = 26;
|
||||
uint32 keepalive_interval = 27;
|
||||
message Table {
|
||||
Resource type = 1;
|
||||
string name = 2;
|
||||
uint32 family = 3;
|
||||
repeated Destination destinations = 4;
|
||||
bool post_policy = 5;
|
||||
}
|
||||
|
||||
message Peer {
|
||||
PeerConf conf = 1;
|
||||
PeerInfo info = 2;
|
||||
repeated uint32 families = 2;
|
||||
ApplyPolicy apply_policy = 3;
|
||||
PeerConf conf = 5;
|
||||
EbgpMultihop ebgp_multihop = 6;
|
||||
RouteReflector route_reflector = 10;
|
||||
PeerState info = 11;
|
||||
Timers timers = 12;
|
||||
Transport transport = 13;
|
||||
RouteServer route_server = 15;
|
||||
}
|
||||
|
||||
message ApplyPolicy {
|
||||
PolicyAssignment in_policy = 1;
|
||||
PolicyAssignment export_policy = 2;
|
||||
PolicyAssignment import_policy = 3;
|
||||
}
|
||||
|
||||
message PeerConf {
|
||||
string auth_password = 1;
|
||||
string description = 2;
|
||||
uint32 local_as = 3;
|
||||
string neighbor_address = 4;
|
||||
uint32 peer_as = 5;
|
||||
string peer_group = 6;
|
||||
uint32 peer_type = 7;
|
||||
uint32 remove_private_as = 8;
|
||||
bool route_flap_damping = 9;
|
||||
uint32 send_community = 10;
|
||||
repeated bytes remote_cap = 11;
|
||||
repeated bytes local_cap = 12;
|
||||
string id = 13;
|
||||
}
|
||||
|
||||
message EbgpMultihop {
|
||||
bool enabled = 1;
|
||||
uint32 multihop_ttl = 2;
|
||||
}
|
||||
|
||||
message RouteReflector {
|
||||
bool route_reflector_client = 1;
|
||||
uint32 route_reflector_cluster_id = 2;
|
||||
}
|
||||
|
||||
message PeerState {
|
||||
string auth_password = 1;
|
||||
string description = 2;
|
||||
uint32 local_as = 3;
|
||||
Messages messages = 4;
|
||||
string neighbor_address = 5;
|
||||
uint32 peer_as = 6;
|
||||
string peer_group = 7;
|
||||
uint32 peer_type = 8;
|
||||
Queues queues = 9;
|
||||
uint32 remove_private_as = 10;
|
||||
bool route_flap_damping = 11;
|
||||
uint32 send_community = 12;
|
||||
uint32 session_state = 13;
|
||||
repeated string supported_capabilities = 14;
|
||||
string bgp_state = 15;
|
||||
string admin_state = 16;
|
||||
uint32 received = 17;
|
||||
uint32 accepted = 18;
|
||||
uint32 advertised = 19;
|
||||
uint32 out_q = 20;
|
||||
uint32 flops = 21;
|
||||
}
|
||||
|
||||
message Messages {
|
||||
Message received = 1;
|
||||
Message sent = 2;
|
||||
}
|
||||
|
||||
message Message {
|
||||
uint64 NOTIFICATION = 1;
|
||||
uint64 UPDATE = 2;
|
||||
uint64 OPEN = 3;
|
||||
uint64 KEEPALIVE = 4;
|
||||
uint64 REFRESH = 5;
|
||||
uint64 DISCARDED = 6;
|
||||
uint64 TOTAL = 7;
|
||||
}
|
||||
|
||||
message Queues {
|
||||
uint32 input = 1;
|
||||
uint32 output = 2;
|
||||
}
|
||||
|
||||
message Timers {
|
||||
TimersConfig config =1;
|
||||
TimersState state = 2;
|
||||
}
|
||||
|
||||
message TimersConfig{
|
||||
uint64 connect_retry = 1;
|
||||
uint64 hold_time = 2;
|
||||
uint64 keepalive_interval = 3;
|
||||
uint64 minimum_advertisement_interval = 4;
|
||||
}
|
||||
|
||||
message TimersState{
|
||||
uint64 connect_retry = 1;
|
||||
uint64 hold_time = 2;
|
||||
uint64 keepalive_interval = 3;
|
||||
uint64 minimum_advertisement_interval = 4;
|
||||
uint64 negotiated_hold_time = 5;
|
||||
uint64 uptime = 6;
|
||||
uint64 downtime = 7;
|
||||
}
|
||||
|
||||
message Transport {
|
||||
string local_address = 1;
|
||||
uint32 local_port = 2;
|
||||
bool mtu_discovery = 3;
|
||||
bool passive_mode = 4;
|
||||
string remote_address = 5;
|
||||
uint32 remote_port = 6;
|
||||
uint32 tcp_mss = 7;
|
||||
}
|
||||
|
||||
message RouteServer {
|
||||
bool route_server_client = 1;
|
||||
}
|
||||
|
||||
message Prefix {
|
||||
string ip_prefix = 1;
|
||||
string mask_length_range = 2;
|
||||
uint32 mask_length_min = 2;
|
||||
uint32 mask_length_max = 3;
|
||||
}
|
||||
|
||||
message PrefixSet {
|
||||
string prefix_set_name = 1;
|
||||
repeated Prefix prefix_list = 2;
|
||||
string match_set_options = 3;
|
||||
enum DefinedType {
|
||||
PREFIX = 0;
|
||||
NEIGHBOR = 1;
|
||||
TAG = 2;
|
||||
AS_PATH = 3;
|
||||
COMMUNITY = 4;
|
||||
EXT_COMMUNITY = 5;
|
||||
}
|
||||
|
||||
message Neighbor {
|
||||
string address = 1;
|
||||
message DefinedSet {
|
||||
DefinedType type = 1;
|
||||
string name = 2;
|
||||
repeated string list = 3;
|
||||
repeated Prefix prefixes = 4;
|
||||
}
|
||||
|
||||
message NeighborSet {
|
||||
string neighbor_set_name = 1;
|
||||
repeated Neighbor neighbor_list = 2;
|
||||
string match_set_options = 3;
|
||||
enum MatchType {
|
||||
ANY = 0;
|
||||
ALL = 1;
|
||||
INVERT = 2;
|
||||
}
|
||||
|
||||
message MatchSet {
|
||||
MatchType type = 1;
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
enum AsPathLengthType {
|
||||
EQ = 0;
|
||||
GE = 1;
|
||||
LE = 2;
|
||||
}
|
||||
|
||||
message AsPathLength {
|
||||
string value = 1;
|
||||
string operator = 2;
|
||||
}
|
||||
|
||||
message AsPathSet {
|
||||
string as_path_set_name = 1;
|
||||
repeated string as_path_members = 2;
|
||||
string match_set_options = 3;
|
||||
}
|
||||
|
||||
message CommunitySet {
|
||||
string community_set_name = 1;
|
||||
repeated string community_members = 2;
|
||||
string match_set_options = 3;
|
||||
}
|
||||
|
||||
message ExtCommunitySet {
|
||||
string ext_community_set_name = 1;
|
||||
repeated string ext_community_members = 2;
|
||||
string match_set_options = 3;
|
||||
AsPathLengthType type = 1;
|
||||
uint32 length = 2;
|
||||
}
|
||||
|
||||
message Conditions {
|
||||
PrefixSet match_prefix_set = 1;
|
||||
NeighborSet match_neighbor_set = 2;
|
||||
AsPathLength match_as_path_length = 3;
|
||||
AsPathSet match_as_path_set = 4;
|
||||
CommunitySet match_community_set = 5;
|
||||
ExtCommunitySet match_ext_community_set = 6;
|
||||
MatchSet prefix_set = 1;
|
||||
MatchSet neighbor_set = 2;
|
||||
AsPathLength as_path_length = 3;
|
||||
MatchSet as_path_set = 4;
|
||||
MatchSet community_set = 5;
|
||||
MatchSet ext_community_set = 6;
|
||||
int32 rpki_result = 7;
|
||||
}
|
||||
|
||||
enum RouteAction {
|
||||
NONE = 0;
|
||||
ACCEPT = 1;
|
||||
REJECT = 2;
|
||||
}
|
||||
|
||||
enum CommunityActionType {
|
||||
COMMUNITY_ADD = 0;
|
||||
COMMUNITY_REMOVE = 1;
|
||||
COMMUNITY_REPLACE = 2;
|
||||
}
|
||||
|
||||
message CommunityAction {
|
||||
repeated string communities = 1;
|
||||
string options = 2;
|
||||
CommunityActionType type = 1;
|
||||
repeated string communities = 2;
|
||||
}
|
||||
|
||||
enum MedActionType {
|
||||
MED_MOD = 0;
|
||||
MED_REPLACE = 1;
|
||||
}
|
||||
|
||||
message MedAction {
|
||||
MedActionType type = 1;
|
||||
int64 value = 2;
|
||||
}
|
||||
|
||||
message AsPrependAction {
|
||||
string as = 1;
|
||||
uint32 repeatn = 2;
|
||||
uint32 asn = 1;
|
||||
uint32 repeat = 2;
|
||||
bool use_left_most = 3;
|
||||
}
|
||||
|
||||
message Actions {
|
||||
string route_action = 1;
|
||||
RouteAction route_action = 1;
|
||||
CommunityAction community = 2;
|
||||
string med = 3;
|
||||
MedAction med = 3;
|
||||
AsPrependAction as_prepend = 4;
|
||||
CommunityAction ext_community = 5;
|
||||
}
|
||||
|
||||
message Statement {
|
||||
string statement_neme = 1;
|
||||
string name = 1;
|
||||
Conditions conditions = 2;
|
||||
Actions actions = 3;
|
||||
}
|
||||
|
||||
message PolicyDefinition {
|
||||
string policy_definition_name = 1;
|
||||
repeated Statement statement_list = 2;
|
||||
message Policy {
|
||||
string name = 1;
|
||||
repeated Statement statements = 2;
|
||||
}
|
||||
|
||||
message ApplyPolicy {
|
||||
repeated PolicyDefinition import_policies = 1;
|
||||
string default_import_policy = 2;
|
||||
repeated PolicyDefinition export_policies = 3;
|
||||
string default_export_policy = 4;
|
||||
repeated PolicyDefinition in_policies = 5;
|
||||
string default_in_policy = 6;
|
||||
enum PolicyType {
|
||||
IN = 0;
|
||||
IMPORT = 1;
|
||||
EXPORT = 2;
|
||||
}
|
||||
|
||||
message PolicyAssignment {
|
||||
PolicyType type = 1;
|
||||
Resource resource = 2;
|
||||
string name = 3;
|
||||
repeated Policy policies = 4;
|
||||
RouteAction default = 5;
|
||||
}
|
||||
|
||||
message MrtMessage {
|
||||
@ -267,13 +471,27 @@ message MrtMessage {
|
||||
|
||||
message RPKIConf {
|
||||
string address = 1;
|
||||
string remote_port = 2;
|
||||
}
|
||||
|
||||
message RPKIState {
|
||||
int64 uptime = 1;
|
||||
int64 downtime = 2;
|
||||
int32 received_ipv4 = 3;
|
||||
int32 received_ipv6 = 4;
|
||||
bool up = 3;
|
||||
uint32 record_ipv4 = 4;
|
||||
uint32 record_ipv6 = 5;
|
||||
uint32 prefix_ipv4 = 6;
|
||||
uint32 prefix_ipv6 = 7;
|
||||
uint32 serial = 8;
|
||||
int64 received_ipv4 = 9;
|
||||
int64 received_ipv6 = 10;
|
||||
int64 serial_notify = 11;
|
||||
int64 cache_reset = 12;
|
||||
int64 cache_response = 13;
|
||||
int64 end_of_data = 14;
|
||||
int64 error = 15;
|
||||
int64 serial_query = 16;
|
||||
int64 reset_query = 17;
|
||||
}
|
||||
|
||||
message RPKI {
|
||||
@ -286,6 +504,31 @@ message ROA {
|
||||
uint32 prefixlen = 2;
|
||||
uint32 maxlen = 3;
|
||||
string prefix = 4;
|
||||
RPKIConf conf = 5;
|
||||
}
|
||||
|
||||
message ROAResult {
|
||||
enum ValidationReason {
|
||||
UPDATE = 0;
|
||||
WITHDRAW = 1;
|
||||
PEER_DOWN = 2;
|
||||
REVALIDATE = 3;
|
||||
}
|
||||
ValidationReason reason = 1;
|
||||
string address = 2;
|
||||
int64 timestamp = 3;
|
||||
bytes aspath_attr = 4;
|
||||
uint32 origin_as = 5;
|
||||
string prefix = 6;
|
||||
enum ValidationResult {
|
||||
NONE = 0;
|
||||
NOT_FOUND = 1;
|
||||
VALID = 2;
|
||||
INVALID = 3;
|
||||
}
|
||||
ValidationResult old_result = 7;
|
||||
ValidationResult new_result = 8;
|
||||
repeated ROA roas = 9;
|
||||
}
|
||||
|
||||
message Vrf {
|
||||
@ -294,3 +537,14 @@ message Vrf {
|
||||
repeated bytes import_rt = 3;
|
||||
repeated bytes export_rt = 4;
|
||||
}
|
||||
|
||||
message Global {
|
||||
uint32 as = 1;
|
||||
string router_id = 2;
|
||||
int32 listen_port = 3;
|
||||
repeated string listen_addresses = 4;
|
||||
repeated uint32 families = 5;
|
||||
uint32 mpls_label_min = 6;
|
||||
uint32 mpls_label_max = 7;
|
||||
bool collector = 8;
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ class FastnetmonApiServiceImpl final : public Fastnetmon::Service {
|
||||
FastnetmonApiServiceImpl api_service;
|
||||
|
||||
std::unique_ptr<Server> StartupApiServer() {
|
||||
std::string server_address("0.0.0.0:50051");
|
||||
std::string server_address("127.0.0.1:50052");
|
||||
ServerBuilder builder;
|
||||
// Listen on the given address without any authentication mechanism.
|
||||
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
|
||||
|
@ -105,7 +105,7 @@ int main(int argc, char** argv) {
|
||||
// are created. This channel models a connection to an endpoint (in this case,
|
||||
// localhost at port 50051). We indicate that the channel isn't authenticated
|
||||
// (use of InsecureCredentials()).
|
||||
FastnetmonClient fastnetmon( grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
|
||||
FastnetmonClient fastnetmon( grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials()));
|
||||
|
||||
std::string request_command = argv[1];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user