summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/bmp.go14
-rw-r--r--server/grpc_server.go1
-rw-r--r--server/server.go20
3 files changed, 27 insertions, 8 deletions
diff --git a/server/bmp.go b/server/bmp.go
index 86029983..3d8b50f6 100644
--- a/server/bmp.go
+++ b/server/bmp.go
@@ -35,7 +35,7 @@ func (m *broadcastBMPMsg) send() {
m.ch <- m
}
-type bmpConn struct {
+type bmpServer struct {
conn *net.TCPConn
host string
}
@@ -160,18 +160,18 @@ func (c *bmpClient) send() chan *broadcastBMPMsg {
return c.ch
}
-func bmpPeerUp(laddr string, lport, rport uint16, sent, recv *bgp.BGPMessage, t int, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bgp.BMPMessage {
- ph := bgp.NewBMPPeerHeader(uint8(t), policy, pd, peeri.Address.String(), peeri.AS, peeri.LocalID.String(), float64(timestamp))
+func bmpPeerUp(laddr string, lport, rport uint16, sent, recv *bgp.BGPMessage, t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bgp.BMPMessage {
+ ph := bgp.NewBMPPeerHeader(t, policy, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp))
return bgp.NewBMPPeerUpNotification(*ph, laddr, lport, rport, sent, recv)
}
-func bmpPeerDown(reason uint8, t int, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bgp.BMPMessage {
- ph := bgp.NewBMPPeerHeader(uint8(t), policy, pd, peeri.Address.String(), peeri.AS, peeri.LocalID.String(), float64(timestamp))
+func bmpPeerDown(reason uint8, t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bgp.BMPMessage {
+ ph := bgp.NewBMPPeerHeader(t, policy, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp))
return bgp.NewBMPPeerDownNotification(*ph, reason, nil, []byte{})
}
-func bmpPeerRoute(t int, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64, payload []byte) *bgp.BMPMessage {
- ph := bgp.NewBMPPeerHeader(uint8(t), policy, pd, peeri.Address.String(), peeri.AS, peeri.LocalID.String(), float64(timestamp))
+func bmpPeerRoute(t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64, payload []byte) *bgp.BMPMessage {
+ ph := bgp.NewBMPPeerHeader(t, policy, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp))
m := bgp.NewBMPRouteMonitoring(*ph, nil)
body := m.Body.(*bgp.BMPRouteMonitoring)
body.BGPUpdatePayload = payload
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 212e9842..63d6e1ad 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -66,6 +66,7 @@ const (
REQ_MOD_POLICY
REQ_POLICY_ASSIGNMENT
REQ_MOD_POLICY_ASSIGNMENT
+ REQ_BMP_NEIGHBORS
)
type Server struct {
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 {