def test_peer_down_notification(self): reason = bmp.BMP_PEER_DOWN_REASON_LOCAL_BGP_NOTIFICATION data = b'hoge' data = bgp.BGPNotification(error_code=1, error_subcode=2, data=data) msg = bmp.BMPPeerDownNotification(reason=reason, data=data, peer_type=bmp.BMP_PEER_TYPE_GLOBAL, is_post_policy=True, peer_distinguisher=0, peer_address='192.0.2.1', peer_as=30000, peer_bgp_id='192.0.2.1', timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) eq_(msg.to_jsondict(), msg2.to_jsondict()) eq_(rest, b'')
def _construct_peer_down_notification(self, peer): if peer.is_mpbgp_cap_valid(bgp.RF_IPv4_VPN) or \ peer.is_mpbgp_cap_valid(bgp.RF_IPv6_VPN): peer_type = bmp.BMP_PEER_TYPE_L3VPN else: peer_type = bmp.BMP_PEER_TYPE_GLOBAL peer_as = peer._neigh_conf.remote_as peer_bgp_id = peer.protocol.recv_open_msg.bgp_identifier peer_address, _ = peer.protocol._remotename return bmp.BMPPeerDownNotification(bmp.BMP_PEER_DOWN_REASON_UNKNOWN, data=None, peer_type=peer_type, is_post_policy=False, peer_distinguisher=0, peer_address=peer_address, peer_as=peer_as, peer_bgp_id=peer_bgp_id, timestamp=0)