示例#1
0
    def negotiated_afs(self):
        local_caps = self.sent_open_msg.opt_param
        remote_caps = self.recv_open_msg.opt_param

        local_mbgp_cap = [
            cap for cap in local_caps if cap.cap_code == BGP_CAP_MULTIPROTOCOL
        ]
        remote_mbgp_cap = [
            cap for cap in remote_caps if cap.cap_code == BGP_CAP_MULTIPROTOCOL
        ]

        # Check MP_BGP capabilities were advertised.
        if local_mbgp_cap and remote_mbgp_cap:
            local_families = set([(peer_cap.afi, peer_cap.safi)
                                  for peer_cap in local_mbgp_cap])
            remote_families = set([(peer_cap.afi, peer_cap.safi)
                                   for peer_cap in remote_mbgp_cap])
            afi_safi = local_families.intersection(remote_families)
        else:
            afi_safi = set()

        afs = []
        for afi, safi in afi_safi:
            afs.append(get_rf(afi, safi))
        return afs
示例#2
0
文件: speaker.py 项目: John-Lin/ryu
    def negotiated_afs(self):
        local_caps = self.sent_open_msg.opt_param
        remote_caps = self.recv_open_msg.opt_param

        local_mbgp_cap = [cap for cap in local_caps
                          if cap.cap_code == BGP_CAP_MULTIPROTOCOL]
        remote_mbgp_cap = [cap for cap in remote_caps
                           if cap.cap_code == BGP_CAP_MULTIPROTOCOL]

        # Check MP_BGP capabilities were advertised.
        if local_mbgp_cap and remote_mbgp_cap:
            local_families = set([
                (peer_cap.afi, peer_cap.safi)
                for peer_cap in local_mbgp_cap
            ])
            remote_families = set([
                (peer_cap.afi, peer_cap.safi)
                for peer_cap in remote_mbgp_cap
            ])
            afi_safi = local_families.intersection(remote_families)
        else:
            afi_safi = set()

        afs = []
        for afi, safi in afi_safi:
            afs.append(get_rf(afi, safi))
        return afs