コード例 #1
0
    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
コード例 #2
0
ファイル: traffic.py プロジェクト: itbj/exabgp
 def unpack(data):
     asn, target = unpack('!LH', data[2:8])
     return TrafficRedirectASN4(ASN4(asn), target, data[:8])
コード例 #3
0
    def _asn4(self, neighbor):
        if not neighbor.asn4:
            return

        self[Capability.CODE.FOUR_BYTES_ASN] = ASN4(neighbor.local_as)
コード例 #4
0
ファイル: capabilities.py プロジェクト: waders909/exabgp
    def _asn4(self, neighbor):
        if not neighbor['capability']['asn4']:
            return

        self[Capability.CODE.FOUR_BYTES_ASN] = ASN4(neighbor['local-as'])