diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-05-12 19:50:57 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-05-19 16:33:16 +0900 |
commit | 0349e0d69926a6cb16467fcd88edf69cbd0f524e (patch) | |
tree | e9e1ce9e4ee9313e7494d9cfb02b7806f83dd77b /server/grpc_server.go | |
parent | 77eaf6a051f7272a3217ab199f53aa3fc9d546a6 (diff) |
cli: add the show command for routing policy of neighbor
% gobgp -u 10.0.255.1 neighbor 10.0.0.3 policy
DefaultImportPolicy: ACCEPT
DefaultImportPolicy: ACCEPT
ImportPolicies:
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 policy5:
ExportPolicies:
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
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index 3fd45b83..d8188c56 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -40,6 +40,7 @@ const ( REQ_NEIGHBOR_SOFT_RESET_OUT REQ_NEIGHBOR_ENABLE REQ_NEIGHBOR_DISABLE + REQ_NEIGHBOR_POLICY REQ_GLOBAL_RIB REQ_GLOBAL_ADD REQ_GLOBAL_DELETE @@ -268,6 +269,24 @@ func (s *Server) ModPath(stream api.Grpc_ModPathServer) error { } } } + +func (s *Server) GetNeighborPolicy(ctx context.Context, arg *api.Arguments) (*api.ApplyPolicy, error) { + rf, err := convertAf2Rf(arg.Af) + if err != nil { + return nil, err + } + + req := NewGrpcRequest(REQ_NEIGHBOR_POLICY, arg.RouterId, rf, nil) + s.bgpServerCh <- req + + res := <-req.ResponseCh + if err := res.Err(); err != nil { + log.Debug(err.Error()) + return nil, err + } + return res.Data.(*api.ApplyPolicy), nil +} + func (s *Server) getPolicies(reqType int, arg *api.PolicyArguments, stream interface{}) error { var rf bgp.RouteFamily req := NewGrpcRequest(reqType, "", rf, nil) |