From 8d0eb0a06bbdfaa47b4979dffed28a7f38b16680 Mon Sep 17 00:00:00 2001 From: Naoto Hanaue Date: Mon, 11 May 2015 20:34:56 +0900 Subject: 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 --- server/grpc_server.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server/grpc_server.go') 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 -- cgit v1.2.3