From f4c07da88154dd4b21012576a4ceb205715f4b3e Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Wed, 30 Dec 2015 17:39:13 +0900 Subject: server: add REQ_BMP_NEIGHBORS api for internal bmp use Signed-off-by: ISHIDA Wataru --- server/server.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index 71eefced..8de474a2 100644 --- a/server/server.go +++ b/server/server.go @@ -1658,7 +1658,25 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { i++ } go sendMultipleResponses(grpcReq, results) - + case REQ_BMP_NEIGHBORS: + //TODO: merge REQ_NEIGHBORS and REQ_BMP_NEIGHBORS + msgs := make([]*bgp.BMPMessage, 0, len(server.neighborMap)) + for _, peer := range server.neighborMap { + if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED { + continue + } + laddr, lport := peer.fsm.LocalHostPort() + _, rport := peer.fsm.RemoteHostPort() + sentOpen := buildopen(peer.fsm.gConf, peer.fsm.pConf) + info := peer.fsm.peerInfo + timestamp := peer.conf.Timers.State.Uptime + msg := bmpPeerUp(laddr, lport, rport, sentOpen, peer.recvOpen, bgp.BMP_PEER_TYPE_GLOBAL, false, 0, info, timestamp) + msgs = append(msgs, msg) + } + grpcReq.ResponseCh <- &GrpcResponse{ + Data: msgs, + } + close(grpcReq.ResponseCh) case REQ_NEIGHBOR: peer, err := server.checkNeighborRequest(grpcReq) if err != nil { -- cgit v1.2.3