bgp.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:deb-ryu 作者: openstack 项目源码 文件源码
def __init__(self, afi, safi, next_hop, nlri,
                 flags=0, type_=None, length=None):
        super(BGPPathAttributeMpReachNLRI, self).__init__(
            flags=flags, type_=type_, length=length)
        self.afi = afi
        self.safi = safi
        if not isinstance(next_hop, (list, tuple)):
            next_hop = [next_hop]
        for n in next_hop:
            if not netaddr.valid_ipv4(n) and not netaddr.valid_ipv6(n):
                raise ValueError('Invalid address for next_hop: %s' % n)
        # Note: For the backward compatibility, stores the first next_hop
        # address and all next_hop addresses separately.
        if next_hop:
            self._next_hop = next_hop[0]
        else:
            self._next_hop = None
        self._next_hop_list = next_hop
        self.nlri = nlri
        addr_cls = _get_addr_class(afi, safi)
        for i in nlri:
            if not isinstance(i, addr_cls):
                raise ValueError('Invalid NRLI class for afi=%d and safi=%d'
                                 % (self.afi, self.safi))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号