Example #1
0
	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)
Example #2
0
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
Example #3
0
	def __init__(self,afi,safi,packed,mask):
		self.mask = mask
		Inet.__init__(self,afi,safi,packed)
Example #4
0
	def __str__ (self):
		return Inet.__str__(self)
Example #5
0
	def pack (self,asn4=None):
		return Inet.pack(self)
Example #6
0
	def __init__ (self,afi,safi,packed):
		Inet.__init__(self,afi,safi,packed)
		# This override Inet.pack too.
		self.packed = self._attribute(Inet.pack(self))
Example #7
0
 def __str__(self):
     return Inet.__str__(self)
Example #8
0
 def pack(self, asn4=None):
     return Inet.pack(self)
Example #9
0
 def __init__(self, afi, safi, packed):
     Inet.__init__(self, afi, safi, packed)
     # This override Inet.pack too.
     self.packed = self._attribute(Inet.pack(self))
Example #10
0
 def __init__(self, cluster_id):
     Inet.__init__(self, AFI.ipv4, SAFI.unicast_multicast, cluster_id)
Example #11
0
	def __init__ (self,packed):
		Inet.__init__(self,*rawinet(packed))
Example #12
0
	def __init__ (self,ipv4):
		Inet.__init__(self,*inet(ipv4))
		if self.afi != AFI.ipv4:
			raise ValueError('RouterID must be an IPv4 address')
Example #13
0
	def __init__ (self,ipv4):
		Inet.__init__(self,*inet(ipv4))
Example #14
0
 def __init__(self, afi, safi, packed, mask):
     self.mask = mask
     Inet.__init__(self, afi, safi, packed)
Example #15
0
	def __init__ (self,cluster_id):
		Inet.__init__(self,AFI.ipv4,SAFI.unicast_multicast,cluster_id)