diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-22 13:24:31 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-22 14:49:46 +0900 |
commit | a4501ccc3f680de0a9f9cc8621256d71d3679478 (patch) | |
tree | 1ab8e04fb4c6c39f512be1e9f76c26c78a127ac7 /server/grpc_server.go | |
parent | 3409f6a5443cf0d6cf0d318feba845f237cd14ba (diff) |
mrt: support mrt dump
$ gobgp mrt dump 10 -o ./dump
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index 160e9cfc..4a652c4f 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -82,6 +82,7 @@ const ( REQ_POLICY_EXTCOMMUNITIES_DELETE REQ_MONITOR_GLOBAL_BEST_CHANGED REQ_MONITOR_NEIGHBOR_PEER_STATE + REQ_MRT_GLOBAL_RIB ) const GRPC_PORT = 8080 @@ -591,6 +592,35 @@ func (s *Server) ModPolicyRoutePolicy(stream api.Grpc_ModPolicyRoutePolicyServer } } +func (s *Server) GetMrt(arg *api.MrtArguments, stream api.Grpc_GetMrtServer) error { + var reqType int + switch arg.Resource { + case api.Resource_GLOBAL: + reqType = REQ_MRT_GLOBAL_RIB + default: + return fmt.Errorf("unsupported resource type: %v", arg.Resource) + } + rf, err := convertAf2Rf(arg.Af) + if err != nil { + return err + } + + req := NewGrpcRequest(reqType, "", rf, arg.Interval) + s.bgpServerCh <- req + for res := range req.ResponseCh { + if err = res.Err(); err != nil { + log.Debug(err.Error()) + goto END + } + if err = stream.Send(res.Data.(*api.MrtMessage)); err != nil { + goto END + } + } +END: + req.EndCh <- struct{}{} + return err +} + type GrpcRequest struct { RequestType int RemoteAddr string |