summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index 69c27f14..91466753 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1656,6 +1656,13 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
ResponseErr: err,
}
close(grpcReq.ResponseCh)
+ case REQ_POLICY:
+ if err := server.handleGrpcGetPolicy(grpcReq); err != nil {
+ grpcReq.ResponseCh <- &GrpcResponse{
+ ResponseErr: err,
+ }
+ }
+ close(grpcReq.ResponseCh)
case REQ_POLICY_ROUTEPOLICY, REQ_POLICY_ROUTEPOLICIES:
info := server.policy.PolicyMap
typ := grpcReq.RequestType
@@ -1819,6 +1826,28 @@ func (server *BgpServer) handleGrpcModStatement(grpcReq *GrpcRequest) error {
}
+func (server *BgpServer) handleGrpcGetPolicy(grpcReq *GrpcRequest) error {
+ arg := grpcReq.Data.(*api.Policy)
+ name := arg.Name
+ found := false
+ for _, s := range server.policy.PolicyMap {
+ if name != "" && name != s.Name() {
+ continue
+ }
+ grpcReq.ResponseCh <- &GrpcResponse{
+ Data: s.ToApiStruct(),
+ }
+ found = true
+ if name != "" {
+ break
+ }
+ }
+ if !found {
+ return fmt.Errorf("not found %s", name)
+ }
+ return nil
+}
+
func (server *BgpServer) handleMrt(grpcReq *GrpcRequest) {
now := uint32(time.Now().Unix())
view := ""