diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 02:52:18 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 02:52:18 -0800 |
commit | 93dcc43b1dd184a6e917862e4ee9a31d79411b26 (patch) | |
tree | 77d46962d5c9a5e8ac9ff944c3d3a1b49368aeb8 /server/server.go | |
parent | 1f80266d6ef342a2ed89c76936afd1e16cf3001d (diff) |
rest: support local-rib URL
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/server.go b/server/server.go index 126bd6a9..2852598b 100644 --- a/server/server.go +++ b/server/server.go @@ -32,6 +32,7 @@ const ( PEER_MSG_NEW PEER_MSG_PATH PEER_MSG_DOWN + PEER_MSG_REST //hacky, fix later ) type message struct { @@ -150,7 +151,6 @@ func (server *BgpServer) broadcast(msg *message) { } func (server *BgpServer) handleRest(restReq *api.RestRequest) { - defer close(restReq.ResponseCh) switch restReq.RequestType { case api.REQ_NEIGHBOR: // get neighbor state @@ -166,5 +166,21 @@ func (server *BgpServer) handleRest(restReq *api.RestRequest) { result.ResponseErr = fmt.Errorf("Neighbor that has %v does not exist.", remoteAddr) } restReq.ResponseCh <- result + close(restReq.ResponseCh) + case api.REQ_LOCAL_RIB: + remoteAddr := restReq.RemoteAddr + result := &api.RestResponseNeighbor{} + peer, found := server.peerMap[remoteAddr] + if found { + msg := message{ + event: PEER_MSG_REST, + data: restReq, + } + peer.SendMessage(&msg) + } else { + result.ResponseErr = fmt.Errorf("Neighbor that has %v does not exist.", remoteAddr) + restReq.ResponseCh <- result + close(restReq.ResponseCh) + } } } |