summaryrefslogtreecommitdiffhomepage
path: root/server/grpc_server.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-16 15:04:32 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-20 10:33:10 +0900
commit722975bfafdd723160dced623936c361475c9bff (patch)
treeade5ddb978c797de4864fff814adf2781dac2108 /server/grpc_server.go
parent434aa169f457d6bbc4d923641fc57e2c84fe6ef9 (diff)
policy: another cleanup
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r--server/grpc_server.go50
1 files changed, 20 insertions, 30 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 16b501ec..c3f004df 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -43,18 +43,12 @@ const (
REQ_NEIGHBOR_POLICY
REQ_MOD_NEIGHBOR_POLICY
REQ_GLOBAL_RIB
- REQ_POLICY_PREFIX
- REQ_POLICY_PREFIXES
REQ_POLICY_PREFIX_ADD
REQ_POLICY_PREFIX_DELETE
REQ_POLICY_PREFIXES_DELETE
- REQ_POLICY_NEIGHBOR
- REQ_POLICY_NEIGHBORS
REQ_POLICY_NEIGHBOR_ADD
REQ_POLICY_NEIGHBOR_DELETE
REQ_POLICY_NEIGHBORS_DELETE
- REQ_POLICY_ASPATH
- REQ_POLICY_ASPATHS
REQ_POLICY_ASPATH_ADD
REQ_POLICY_ASPATH_DELETE
REQ_POLICY_ASPATHS_DELETE
@@ -63,13 +57,9 @@ const (
REQ_POLICY_ROUTEPOLICY_ADD
REQ_POLICY_ROUTEPOLICY_DELETE
REQ_POLICY_ROUTEPOLICIES_DELETE
- REQ_POLICY_COMMUNITY
- REQ_POLICY_COMMUNITIES
REQ_POLICY_COMMUNITY_ADD
REQ_POLICY_COMMUNITY_DELETE
REQ_POLICY_COMMUNITIES_DELETE
- REQ_POLICY_EXTCOMMUNITY
- REQ_POLICY_EXTCOMMUNITIES
REQ_POLICY_EXTCOMMUNITY_ADD
REQ_POLICY_EXTCOMMUNITY_DELETE
REQ_POLICY_EXTCOMMUNITIES_DELETE
@@ -84,6 +74,7 @@ const (
REQ_VRF_MOD
REQ_MOD_PATH
REQ_GLOBAL_POLICY
+ REQ_DEFINED_SET
)
const GRPC_PORT = 8080
@@ -406,16 +397,6 @@ func (s *Server) GetPolicyRoutePolicies(arg *api.PolicyArguments, stream api.Gob
var rf bgp.RouteFamily
var reqType int
switch arg.Resource {
- case api.Resource_POLICY_PREFIX:
- reqType = REQ_POLICY_PREFIXES
- case api.Resource_POLICY_NEIGHBOR:
- reqType = REQ_POLICY_NEIGHBORS
- case api.Resource_POLICY_ASPATH:
- reqType = REQ_POLICY_ASPATHS
- case api.Resource_POLICY_COMMUNITY:
- reqType = REQ_POLICY_COMMUNITIES
- case api.Resource_POLICY_EXTCOMMUNITY:
- reqType = REQ_POLICY_EXTCOMMUNITIES
case api.Resource_POLICY_ROUTEPOLICY:
reqType = REQ_POLICY_ROUTEPOLICIES
default:
@@ -432,16 +413,6 @@ func (s *Server) GetPolicyRoutePolicy(ctx context.Context, arg *api.PolicyArgume
var rf bgp.RouteFamily
var reqType int
switch arg.Resource {
- case api.Resource_POLICY_PREFIX:
- reqType = REQ_POLICY_PREFIX
- case api.Resource_POLICY_NEIGHBOR:
- reqType = REQ_POLICY_NEIGHBOR
- case api.Resource_POLICY_ASPATH:
- reqType = REQ_POLICY_ASPATH
- case api.Resource_POLICY_COMMUNITY:
- reqType = REQ_POLICY_COMMUNITY
- case api.Resource_POLICY_EXTCOMMUNITY:
- reqType = REQ_POLICY_EXTCOMMUNITY
case api.Resource_POLICY_ROUTEPOLICY:
reqType = REQ_POLICY_ROUTEPOLICY
default:
@@ -529,6 +500,25 @@ func (s *Server) ModVrf(ctx context.Context, arg *api.ModVrfArguments) (*api.Err
return none, nil
}
+func (s *Server) GetDefinedSet(ctx context.Context, arg *api.DefinedSet) (*api.DefinedSet, error) {
+ req := NewGrpcRequest(REQ_DEFINED_SET, "", bgp.RouteFamily(0), arg)
+ s.bgpServerCh <- req
+ res := <-req.ResponseCh
+ if err := res.Err(); err != nil {
+ return nil, err
+ }
+ return res.Data.(*api.DefinedSet), nil
+}
+
+func (s *Server) GetDefinedSets(arg *api.DefinedSet, stream api.GobgpApi_GetDefinedSetsServer) error {
+ req := NewGrpcRequest(REQ_DEFINED_SET, "", bgp.RouteFamily(0), arg)
+ s.bgpServerCh <- req
+
+ return handleMultipleResponses(req, func(res *GrpcResponse) error {
+ return stream.Send(res.Data.(*api.DefinedSet))
+ })
+}
+
type GrpcRequest struct {
RequestType int
Name string