def __init__ (self,aggregator): asn = 0 for value in (ord(_) for _ in aggregator[:-4]): asn = (asn << 8) + value self.asn=ASN(asn) self.speaker=Inet(AFI.ipv4,SAFI.unicast,aggregator[-4:]) self._str = '%s:%s' % (self.asn,self.speaker)
class Aggregator (Attribute): ID = AttributeID.AGGREGATOR FLAG = Flag.TRANSITIVE|Flag.OPTIONAL MULTIPLE = False def __init__ (self,aggregator): asn = 0 for value in (ord(_) for _ in aggregator[:-4]): asn = (asn << 8) + value self.asn=ASN(asn) self.speaker=Inet(AFI.ipv4,SAFI.unicast,aggregator[-4:]) self._str = '%s:%s' % (self.asn,self.speaker) def pack (self,asn4,as4agg=False): if as4agg: backup = self.ID self.ID = AttributeID.AS4_AGGREGATOR packed = self._attribute(self.asn.pack(True)+self.speaker.pack()) self.ID = backup return packed elif asn4: return self._attribute(self.asn.pack(True)+self.speaker.pack()) elif not self.asn.asn4(): return self._attribute(self.asn.pack(False)+self.speaker.pack()) else: return self._attribute(self.asn.trans()+self.speaker.pack()) + self.pack(True,True) def __len__ (self): raise RuntimeError('size can be 6 or 8 - we can not say') def __str__ (self): return self._str
def __init__(self,afi,safi,packed,mask): self.mask = mask Inet.__init__(self,afi,safi,packed)
def __str__ (self): return Inet.__str__(self)
def pack (self,asn4=None): return Inet.pack(self)
def __init__ (self,afi,safi,packed): Inet.__init__(self,afi,safi,packed) # This override Inet.pack too. self.packed = self._attribute(Inet.pack(self))
def __str__(self): return Inet.__str__(self)
def pack(self, asn4=None): return Inet.pack(self)
def __init__(self, afi, safi, packed): Inet.__init__(self, afi, safi, packed) # This override Inet.pack too. self.packed = self._attribute(Inet.pack(self))
def __init__(self, cluster_id): Inet.__init__(self, AFI.ipv4, SAFI.unicast_multicast, cluster_id)
def __init__ (self,packed): Inet.__init__(self,*rawinet(packed))
def __init__ (self,ipv4): Inet.__init__(self,*inet(ipv4)) if self.afi != AFI.ipv4: raise ValueError('RouterID must be an IPv4 address')
def __init__ (self,ipv4): Inet.__init__(self,*inet(ipv4))
def __init__(self, afi, safi, packed, mask): self.mask = mask Inet.__init__(self, afi, safi, packed)
def __init__ (self,cluster_id): Inet.__init__(self,AFI.ipv4,SAFI.unicast_multicast,cluster_id)