Example #1
0
	def unpack (cls,data,length):
		if length != 4:
			raise Notify(3,5, "Unable to decode attribute. Incorrect Size")
		else:
			b = BitArray(bytes=data)
			colormask = b.unpack('uintbe:32')
			return cls(colormask=colormask)
Example #2
0
	def unpack (cls,data,length):
		if len(data) == 2:
    		# OSPF
			igpmetric = unpack('!H',data)[0]
			return cls(igpmetric=igpmetric)
		elif len(data) == 1:
    		# ISIS small metrics
			igpmetric = unpack('!B',data)[0]
			return cls(igpmetric=igpmetric)
		elif len(data) == 3:
    		# ISIS wide metrics
			b = BitArray(bytes=data)
			igpmetric = b.unpack('uintbe:24')
			return cls(igpmetric=igpmetric)
		else:
			raise Notify(3,5, "Incorrect IGP Metric Size")