diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-16 09:27:07 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-16 09:27:07 +0900 |
commit | 03bf3795ef880537d37349ea7a772daafcddd0de (patch) | |
tree | 2600a7e91b5f65b62d56cea0c53a2b23bd3d25be /server/peer.go | |
parent | 7743748a1559c722f4a1c7870978fa7d07cfe6cb (diff) |
api: add reset and shutdown support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/server/peer.go b/server/peer.go index 4e6f2ff3..6f0d2f6b 100644 --- a/server/peer.go +++ b/server/peer.go @@ -168,8 +168,24 @@ func (peer *Peer) sendMessages(msgs []*bgp.BGPMessage) { func (peer *Peer) handleREST(restReq *api.RestRequest) { result := &api.RestResponse{} - j, _ := json.Marshal(peer.rib.Tables[peer.rf]) - result.Data = j + switch restReq.RequestType { + case api.REQ_LOCAL_RIB: + j, _ := json.Marshal(peer.rib.Tables[peer.rf]) + result.Data = j + case api.REQ_NEIGHBOR_SHUTDOWN: + peer.fsm.outgoing <- bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN, nil) + case api.REQ_NEIGHBOR_RESET: + peer.fsm.outgoing <- bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_RESET, nil) + case api.REQ_NEIGHBOR_SOFT_RESET: + case api.REQ_NEIGHBOR_SOFT_RESET_IN: + // check capability + // drop allIn and other peers? + // peer.adjRib.DropAllIn(peer.rf) + peer.fsm.outgoing <- bgp.NewBGPRouteRefreshMessage(uint16(int(peer.rf)>>16), 0, uint8(int(peer.rf)&0xff)) + case api.REQ_NEIGHBOR_SOFT_RESET_OUT: + pathList := peer.adjRib.GetOutPathList(peer.rf) + peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) + } restReq.ResponseCh <- result close(restReq.ResponseCh) } |