summaryrefslogtreecommitdiffhomepage
path: root/api/grpc_server.go
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-10-16 07:35:02 +0000
committerWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-10-16 14:07:06 +0000
commit1f4a3192af12c240e08941490ad8d9dfd7f1bb10 (patch)
tree8f61edea2e019d45b02d3356202f7839245ee234 /api/grpc_server.go
parent11969f468543e881d7a4c758bb8f7af5797793b5 (diff)
cli/api: support getting table summary information
$ gobgp global rib summary -a ipv4 $ gobgp neighbor 10.0.0.1 local summary $ gobgp neighbor 10.0.0.1 adj-in summary $ gobgp neighbor 10.0.0.1 adj-out summary Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'api/grpc_server.go')
-rw-r--r--api/grpc_server.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index f9a2d1ba..5e4d49af 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -1746,3 +1746,37 @@ func (s *Server) StartServer(ctx context.Context, arg *StartServerRequest) (*Sta
func (s *Server) StopServer(ctx context.Context, arg *StopServerRequest) (*StopServerResponse, error) {
return &StopServerResponse{}, s.bgpServer.Stop()
}
+
+func (s *Server) GetRibInfo(ctx context.Context, arg *GetRibInfoRequest) (*GetRibInfoResponse, error) {
+ family := bgp.RouteFamily(arg.Info.Family)
+ var in bool
+ var err error
+ var info *table.TableInfo
+ switch arg.Info.Type {
+ case Resource_GLOBAL, Resource_LOCAL:
+ info, err = s.bgpServer.GetRibInfo(arg.Info.Name, family)
+ case Resource_ADJ_IN:
+ in = true
+ fallthrough
+ case Resource_ADJ_OUT:
+ info, err = s.bgpServer.GetAdjRibInfo(arg.Info.Name, family, in)
+ default:
+ return nil, fmt.Errorf("unsupported resource type: %s", arg.Info.Type)
+ }
+
+ if err != nil {
+ return nil, err
+ }
+
+ return &GetRibInfoResponse{
+ Info: &TableInfo{
+ Type: arg.Info.Type,
+ Family: arg.Info.Family,
+ Name: arg.Info.Name,
+ NumDestination: uint64(info.NumDestination),
+ NumPath: uint64(info.NumPath),
+ NumAccepted: uint64(info.NumAccepted),
+ },
+ }, nil
+
+}