How to use the exabgp.util.ordinal function in exabgp

To help you get started, we’ve selected a few exabgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / nlri / rtc.py View on Github external
def resetFlags(char):
		return character(ordinal(char) & ~(Attribute.Flag.TRANSITIVE | Attribute.Flag.OPTIONAL))
github Exa-Networks / exabgp / lib / exabgp / bgp / message / open / capability / hostname.py View on Github external
def unpack_capability (instance, data, capability=None):  # pylint: disable=W0613
		l1 = ordinal(data[0])
		instance.host_name = data[1:l1+1].decode('utf-8')
		l2 = ordinal(data[l1+1])
		instance.domain_name = data[l1+2:l1+2+l2].decode('utf-8')
		return instance
github Exa-Networks / exabgp / lib / exabgp / bgp / message / open / capability / addpath.py View on Github external
def unpack_capability (instance, data, capability=None):  # pylint: disable=W0613
		# XXX: FIXME: should check that we have not yet seen the capability
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[2])
			sr = ordinal(data[3])
			instance.add_path(afi,safi,sr)
			data = data[4:]
		return instance
github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / nlri / evpn / segment.py View on Github external
def unpack (cls, data):
		rd = RouteDistinguisher.unpack(data[:8])
		esi = ESI.unpack(data[8:18])
		iplen = ordinal(data[18])

		if iplen not in (32,128):
			raise Notify(3,5,"IP length field is given as %d in current Segment, expecting 32 (IPv4) or 128 (IPv6) bits" % iplen)

		ip = IP.unpack(data[19:19+(iplen//8)])

		return cls(rd,esi,ip,data)
github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / attribute / community / extended / community.py View on Github external
def __repr__ (self):
		if self.klass:
			return self.klass.__repr__(self)
		h = 0x00
		for byte in self.community:
			h <<= 8
			h += ordinal(byte)
		return "0x%016X" % h
github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / nlri / qualifier / mac.py View on Github external
def unpack (cls, data):
		return cls(':'.join('%02X' % ordinal(_) for _ in data[:6]),data[:6])
github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / nlri / evpn / mac.py View on Github external
def unpack (cls, data):
		datalen = len(data)
		rd = RouteDistinguisher.unpack(data[:8])
		esi = ESI.unpack(data[8:18])
		etag = EthernetTag.unpack(data[18:22])
		maclength = ordinal(data[22])

		if (maclength > 48 or maclength < 0):
			raise Notify(3,5,'invalid MAC Address length in %s' % cls.NAME)
		end = 23 + 6  # MAC length MUST be 6

		mac = MACQUAL.unpack(data[23:end])

		length = ordinal(data[end])
		iplen = length / 8

		if datalen in [33,36]:  # No IP information (1 or 2 labels)
			iplenUnpack = 0
			if iplen != 0:
				raise Notify(3,5,"IP length is given as %d, but current MAC route has no IP information" % iplen)
		elif datalen in [37, 40]:  # Using IPv4 addresses (1 or 2 labels)
			iplenUnpack = 4
github Exa-Networks / exabgp / lib / exabgp / bgp / message / open / routerid.py View on Github external
def unpack (cls, data):  # pylint: disable=W0221
		return cls('.'.join(str(ordinal(_)) for _ in data),data)
github Exa-Networks / exabgp / lib / exabgp / bgp / message / update / nlri / qualifier / mac.py View on Github external
def __str__ (self):
		return ':'.join('%02X' % ordinal(_) for _ in self._packed)