summaryrefslogtreecommitdiffhomepage
path: root/server/bmp.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2018-05-15 10:42:18 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-24 11:25:11 +0900
commita980a0237ebc4b4338d5d54257d5078e0772240a (patch)
treefa7c9c4444c2c26b6aed776ccfe6ac18f9d7d341 /server/bmp.go
parent76ef1163238a109bda09e019348de6550a5b3e61 (diff)
server/server: Add field to WatchEventPeerState for PeerDownEvent
To include the PeerDownReason and data in BMP messages, this commit adds some field to WatchEventPeerState. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'server/bmp.go')
-rw-r--r--server/bmp.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/server/bmp.go b/server/bmp.go
index 2e9db698..91507cd3 100644
--- a/server/bmp.go
+++ b/server/bmp.go
@@ -205,17 +205,12 @@ func (b *bmpClient) loop() {
}
}
case *WatchEventPeerState:
- info := &table.PeerInfo{
- Address: msg.PeerAddress,
- AS: msg.PeerAS,
- ID: msg.PeerID,
- }
if msg.State == bgp.BGP_FSM_ESTABLISHED {
- if err := write(bmpPeerUp(msg.LocalAddress.String(), msg.LocalPort, msg.PeerPort, msg.SentOpen, msg.RecvOpen, bmp.BMP_PEER_TYPE_GLOBAL, false, 0, info, msg.Timestamp.Unix())); err != nil {
+ if err := write(bmpPeerUp(msg, bmp.BMP_PEER_TYPE_GLOBAL, false, 0)); err != nil {
return false
}
} else {
- if err := write(bmpPeerDown(bmp.BMP_PEER_DOWN_REASON_UNKNOWN, bmp.BMP_PEER_TYPE_GLOBAL, false, 0, info, msg.Timestamp.Unix())); err != nil {
+ if err := write(bmpPeerDown(msg, bmp.BMP_PEER_TYPE_GLOBAL, false, 0)); err != nil {
return false
}
}
@@ -264,22 +259,22 @@ type bmpClient struct {
ribout ribout
}
-func bmpPeerUp(laddr string, lport, rport uint16, sent, recv *bgp.BGPMessage, t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bmp.BMPMessage {
+func bmpPeerUp(ev *WatchEventPeerState, t uint8, policy bool, pd uint64) *bmp.BMPMessage {
var flags uint8 = 0
if policy {
flags |= bmp.BMP_PEER_FLAG_POST_POLICY
}
- ph := bmp.NewBMPPeerHeader(t, flags, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp))
- return bmp.NewBMPPeerUpNotification(*ph, laddr, lport, rport, sent, recv)
+ ph := bmp.NewBMPPeerHeader(t, flags, pd, ev.PeerAddress.String(), ev.PeerAS, ev.PeerID.String(), float64(ev.Timestamp.Unix()))
+ return bmp.NewBMPPeerUpNotification(*ph, ev.LocalAddress.String(), ev.LocalPort, ev.PeerPort, ev.SentOpen, ev.RecvOpen)
}
-func bmpPeerDown(reason uint8, t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64) *bmp.BMPMessage {
+func bmpPeerDown(ev *WatchEventPeerState, t uint8, policy bool, pd uint64) *bmp.BMPMessage {
var flags uint8 = 0
if policy {
flags |= bmp.BMP_PEER_FLAG_POST_POLICY
}
- ph := bmp.NewBMPPeerHeader(t, flags, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp))
- return bmp.NewBMPPeerDownNotification(*ph, reason, nil, []byte{})
+ ph := bmp.NewBMPPeerHeader(t, flags, pd, ev.PeerAddress.String(), ev.PeerAS, ev.PeerID.String(), float64(ev.Timestamp.Unix()))
+ return bmp.NewBMPPeerDownNotification(*ph, uint8(ev.StateReason.PeerDownReason), ev.StateReason.BGPNotification, ev.StateReason.Data)
}
func bmpPeerRoute(t uint8, policy bool, pd uint64, fourBytesAs bool, peeri *table.PeerInfo, timestamp int64, payload []byte) *bmp.BMPMessage {