Line data Source code
1 : /* 2 : * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #include "bgp/peer_stats.h" 7 : 8 508 : void PeerStats::FillProtoStats(const IPeerDebugStats::ProtoStats &stats, 9 : PeerProtoStats *proto_stats) { 10 508 : proto_stats->set_open(stats.open); 11 508 : proto_stats->set_keepalive(stats.keepalive); 12 508 : proto_stats->set_close(stats.close); 13 508 : proto_stats->set_update(stats.update); 14 508 : proto_stats->set_notification(stats.notification); 15 508 : proto_stats->set_total(stats.open + stats.keepalive + stats.close + 16 508 : stats.update + stats.notification); 17 508 : } 18 : 19 1016 : void PeerStats::FillRouteUpdateStats(const IPeerDebugStats::UpdateStats &stats, 20 : PeerUpdateStats *rt_stats) { 21 1016 : rt_stats->set_total(stats.total); 22 1016 : rt_stats->set_reach(stats.reach); 23 1016 : rt_stats->set_unreach(stats.unreach); 24 1016 : } 25 : 26 254 : void PeerStats::FillRxErrorStats(const IPeerDebugStats::RxErrorStats &src, 27 : PeerRxErrorStats *dest) { 28 254 : PeerRxInet6ErrorStats error_stats; 29 254 : error_stats.set_bad_inet6_xml_token_count(src.inet6_bad_xml_token_count); 30 254 : error_stats.set_bad_inet6_prefix_count(src.inet6_bad_prefix_count); 31 254 : error_stats.set_bad_inet6_nexthop_count(src.inet6_bad_nexthop_count); 32 254 : error_stats.set_bad_inet6_afi_safi_count(src.inet6_bad_afi_safi_count); 33 254 : dest->set_inet6_error_stats(error_stats); 34 254 : } 35 : 36 254 : void PeerStats::FillRxRouteStats(const IPeerDebugStats::RxRouteStats &src, 37 : PeerRxRouteStats *dest) { 38 254 : dest->set_total_path_count(src.total_path_count); 39 254 : dest->set_primary_path_count(src.primary_path_count); 40 254 : } 41 : 42 508 : void PeerStats::FillPeerUpdateStats(const IPeerDebugStats *peer_stats, 43 : PeerUpdateStats *rt_stats_rx, 44 : PeerUpdateStats *rt_stats_tx) { 45 : 46 508 : IPeerDebugStats::UpdateStats update_stats_rx; 47 508 : peer_stats->GetRxRouteUpdateStats(&update_stats_rx); 48 508 : FillRouteUpdateStats(update_stats_rx, rt_stats_rx); 49 : 50 508 : IPeerDebugStats::UpdateStats update_stats_tx; 51 508 : peer_stats->GetTxRouteUpdateStats(&update_stats_tx); 52 508 : FillRouteUpdateStats(update_stats_tx, rt_stats_tx); 53 508 : } 54 : 55 254 : void PeerStats::FillPeerUpdateStats(const IPeerDebugStats *peer_stats, 56 : PeerStatsData *peer_stats_data) { 57 254 : PeerUpdateStats stats_rx; 58 254 : PeerUpdateStats stats_tx; 59 : 60 254 : FillPeerUpdateStats(peer_stats, &stats_rx, &stats_tx); 61 254 : peer_stats_data->set_raw_rx_update_stats(stats_rx); 62 254 : peer_stats_data->set_raw_tx_update_stats(stats_tx); 63 254 : } 64 : 65 254 : void PeerStats::FillPeerDebugStats(const IPeerDebugStats *peer_stats, 66 : PeerStatsInfo *stats) { 67 254 : PeerProtoStats proto_stats_tx; 68 254 : PeerProtoStats proto_stats_rx; 69 254 : PeerUpdateStats rt_stats_rx; 70 254 : PeerUpdateStats rt_stats_tx; 71 254 : PeerRxErrorStats dest_error_stats_rx; 72 254 : PeerRxRouteStats dest_route_stats_rx; 73 : 74 254 : IPeerDebugStats::ProtoStats stats_rx; 75 254 : peer_stats->GetRxProtoStats(&stats_rx); 76 254 : FillProtoStats(stats_rx, &proto_stats_rx); 77 : 78 254 : IPeerDebugStats::ProtoStats stats_tx; 79 254 : peer_stats->GetTxProtoStats(&stats_tx); 80 254 : FillProtoStats(stats_tx, &proto_stats_tx); 81 : 82 254 : FillPeerUpdateStats(peer_stats, &rt_stats_rx, &rt_stats_tx); 83 : 84 254 : IPeerDebugStats::RxErrorStats src_error_stats_rx; 85 254 : peer_stats->GetRxErrorStats(&src_error_stats_rx); 86 254 : FillRxErrorStats(src_error_stats_rx, &dest_error_stats_rx); 87 : 88 254 : IPeerDebugStats::RxRouteStats src_route_stats_rx; 89 254 : peer_stats->GetRxRouteStats(&src_route_stats_rx); 90 254 : FillRxRouteStats(src_route_stats_rx, &dest_route_stats_rx); 91 : 92 254 : stats->set_rx_proto_stats(proto_stats_rx); 93 254 : stats->set_tx_proto_stats(proto_stats_tx); 94 254 : stats->set_rx_update_stats(rt_stats_rx); 95 254 : stats->set_tx_update_stats(rt_stats_tx); 96 254 : stats->set_rx_error_stats(dest_error_stats_rx); 97 254 : stats->set_rx_route_stats(dest_route_stats_rx); 98 254 : }