def new(self, neighbor, restarted): graceful = neighbor.graceful_restart families = neighbor.families() mp = MultiProtocol() mp.extend(families) self[Capability.CODE.MULTIPROTOCOL] = mp if neighbor.asn4: self[Capability.CODE.FOUR_BYTES_ASN] = ASN4(neighbor.local_as) if neighbor.add_path: ap_families = [] if (AFI(AFI.ipv4), SAFI(SAFI.unicast)) in families: ap_families.append((AFI(AFI.ipv4), SAFI(SAFI.unicast))) if (AFI(AFI.ipv6), SAFI(SAFI.unicast)) in families: ap_families.append((AFI(AFI.ipv6), SAFI(SAFI.unicast))) if (AFI(AFI.ipv4), SAFI(SAFI.nlri_mpls)) in families: ap_families.append((AFI(AFI.ipv4), SAFI(SAFI.nlri_mpls))) if (AFI(AFI.ipv6), SAFI(SAFI.unicast)) in families: ap_families.append((AFI(AFI.ipv6), SAFI(SAFI.unicast))) self[Capability.CODE.ADD_PATH] = AddPath(ap_families, neighbor.add_path) if graceful: if restarted: self[Capability.CODE.GRACEFUL_RESTART] = Graceful().set( Graceful.RESTART_STATE, graceful, [(afi, safi, Graceful.FORWARDING_STATE) for (afi, safi) in families]) else: self[Capability.CODE.GRACEFUL_RESTART] = Graceful().set( 0x0, graceful, [(afi, safi, Graceful.FORWARDING_STATE) for (afi, safi) in families]) if neighbor.route_refresh: self[Capability.CODE.ROUTE_REFRESH] = RouteRefresh() self[Capability.CODE. ENHANCED_ROUTE_REFRESH] = EnhancedRouteRefresh() # MUST be the last key added if neighbor.multisession: # XXX: FIXME: should it not be the RFC version ? self[Capability.CODE.MULTISESSION] = MultiSession().set( [Capability.CODE.MULTIPROTOCOL]) return self
def unpack(data): asn, target = unpack('!LH', data[2:8]) return TrafficRedirectASN4(ASN4(asn), target, data[:8])
def _asn4(self, neighbor): if not neighbor.asn4: return self[Capability.CODE.FOUR_BYTES_ASN] = ASN4(neighbor.local_as)
def _asn4(self, neighbor): if not neighbor['capability']['asn4']: return self[Capability.CODE.FOUR_BYTES_ASN] = ASN4(neighbor['local-as'])