diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-05-11 20:34:56 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-05-19 16:33:16 +0900 |
commit | 8d0eb0a06bbdfaa47b4979dffed28a7f38b16680 (patch) | |
tree | 02075c54997b45ec543e09e2310b6201afd070ec /server/grpc_server.go | |
parent | 772dbed046cc75891cc37d7a34a85d94d6e40e8b (diff) |
cli: add the show command for the neighbor conditions
% gobgp -u 10.0.255.1 policy neighbor
Name Address
ns0 10.0.0.2
ns1 2001::192:168:0:2
% gobgp -u 10.0.255.1 policy neighbor ns0
Name Address
ns0 10.0.0.2
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index cc0a0e16..2965d647 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -48,6 +48,8 @@ const ( REQ_POLICY_PREFIX_ADD REQ_POLICY_PREFIX_DELETE REQ_POLICY_PREFIXES_DELETE + REQ_POLICY_NEIGHBOR + REQ_POLICY_NEIGHBORS ) const GRPC_PORT = 8080 @@ -277,6 +279,8 @@ func (s *Server) getPolicies(reqType int, arg *api.PolicyArguments, stream inter switch arg.Resource { case api.Resource_POLICY_PREFIX: err = stream.(api.Grpc_GetPolicyPrefixesServer).Send(res.Data.(*api.PrefixSet)) + case api.Resource_POLICY_NEIGHBOR: + err = stream.(api.Grpc_GetPolicyNeighborsServer).Send(res.Data.(*api.NeighborSet)) default: return fmt.Errorf("unsupported resource type: %v", arg.Resource) } @@ -293,6 +297,8 @@ func (s *Server) getPolicy(arg *api.PolicyArguments) (interface{}, error) { switch arg.Resource { case api.Resource_POLICY_PREFIX: reqType = REQ_POLICY_PREFIX + case api.Resource_POLICY_NEIGHBOR: + reqType = REQ_POLICY_NEIGHBOR default: return nil, fmt.Errorf("unsupported resource type: %v", arg.Resource) } @@ -375,6 +381,21 @@ func (s *Server) ModPolicyPrefix(stream api.Grpc_ModPolicyPrefixServer) error { } } +func (s *Server) GetPolicyNeighbors(arg *api.PolicyArguments, stream api.Grpc_GetPolicyNeighborsServer) error { + if err := s.getPolicies(REQ_POLICY_NEIGHBORS, arg, stream); err != nil { + return err + } + return nil +} + +func (s *Server) GetPolicyNeighbor(ctx context.Context, arg *api.PolicyArguments) (*api.NeighborSet, error) { + data, err := s.getPolicy(arg) + if err != nil { + return nil, err + } + return data.(*api.NeighborSet), nil +} + type GrpcRequest struct { RequestType int RemoteAddr string |