summaryrefslogtreecommitdiffhomepage
path: root/server/grpc_server.go
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-05-12 01:06:59 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-05-19 16:33:16 +0900
commit77eaf6a051f7272a3217ab199f53aa3fc9d546a6 (patch)
treea6ff0b0d39ceb3989f82b783bbe6601401e7a962 /server/grpc_server.go
parent8d0eb0a06bbdfaa47b4979dffed28a7f38b16680 (diff)
cli: add the show command for the routing policy
% gobgp -u 10.0.255.1 policy routepolicy PolicyName policy0: StatementName st0: Conditions: PrefixSet: ps0 192.168.0.0/16 16..24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT PolicyName policy1: StatementName st1: Conditions: PrefixSet: ps1 192.168.20.0/24 192.168.200.0/24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT % gobgp -u 10.0.255.1 policy routepolicy policy0 PolicyName policy0: StatementName st0: Conditions: PrefixSet: ps0 192.168.0.0/16 16..24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r--server/grpc_server.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 2965d647..3fd45b83 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -50,6 +50,8 @@ const (
REQ_POLICY_PREFIXES_DELETE
REQ_POLICY_NEIGHBOR
REQ_POLICY_NEIGHBORS
+ REQ_POLICY_ROUTEPOLICIES
+ REQ_POLICY_ROUTEPOLICY
)
const GRPC_PORT = 8080
@@ -281,6 +283,8 @@ func (s *Server) getPolicies(reqType int, arg *api.PolicyArguments, stream inter
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))
+ case api.Resource_POLICY_ROUTEPOLICY:
+ err = stream.(api.Grpc_GetPolicyRoutePoliciesServer).Send(res.Data.(*api.PolicyDefinition))
default:
return fmt.Errorf("unsupported resource type: %v", arg.Resource)
}
@@ -299,6 +303,8 @@ func (s *Server) getPolicy(arg *api.PolicyArguments) (interface{}, error) {
reqType = REQ_POLICY_PREFIX
case api.Resource_POLICY_NEIGHBOR:
reqType = REQ_POLICY_NEIGHBOR
+ case api.Resource_POLICY_ROUTEPOLICY:
+ reqType = REQ_POLICY_ROUTEPOLICY
default:
return nil, fmt.Errorf("unsupported resource type: %v", arg.Resource)
}
@@ -396,6 +402,21 @@ func (s *Server) GetPolicyNeighbor(ctx context.Context, arg *api.PolicyArguments
return data.(*api.NeighborSet), nil
}
+func (s *Server) GetPolicyRoutePolicies(arg *api.PolicyArguments, stream api.Grpc_GetPolicyRoutePoliciesServer) error {
+ if err := s.getPolicies(REQ_POLICY_ROUTEPOLICIES, arg, stream); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (s *Server) GetPolicyRoutePolicy(ctx context.Context, arg *api.PolicyArguments) (*api.PolicyDefinition, error) {
+ data, err := s.getPolicy(arg)
+ if err != nil {
+ return nil, err
+ }
+ return data.(*api.PolicyDefinition), nil
+}
+
type GrpcRequest struct {
RequestType int
RemoteAddr string