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))
评论列表
文章目录