+ def mac_to_int(mac_str):
+ """Convert MAC address from string format (e.g. 01:02:03:04:05:06) to
+ integer representation (1108152157446).
+
+ :param mac_str: MAC address in string representation.
+ :type mac_str: str
+ :returns: Integer representation of MAC address.
+ :rtype: int
+ """
+ return int(mac_str.replace(u":", u""), 16)
+
+ @staticmethod
+ def int_to_mac(mac_int):
+ """Convert MAC address from integer representation (e.g. 1108152157446)
+ to string format (01:02:03:04:05:06).
+
+ :param mac_int: MAC address in integer representation.
+ :type mac_int: int
+ :returns: String representation of MAC address.
+ :rtype: str
+ """
+ return u":".join(
+ f"{hex(mac_int)[2:]:0>12}"[i:i+2] for i in range(0, 12, 2)
+ )
+
+ @staticmethod
+ def mac_to_bin(mac_str):
+ """Convert MAC address from string format (e.g. 01:02:03:04:05:06) to
+ binary representation (\x01\x02\x03\x04\x05\x06).
+
+ :param mac_str: MAC address in string representation.
+ :type mac_str: str
+ :returns: Binary representation of MAC address.
+ :rtype: bytes
+ """
+ return bytes.fromhex(mac_str.replace(u":", u""))
+
+ @staticmethod
+ def bin_to_mac(mac_bin):
+ """Convert MAC address from binary representation
+ (\x01\x02\x03\x04\x05\x06) to string format (e.g. 01:02:03:04:05:06).
+
+ :param mac_bin: MAC address in binary representation.
+ :type mac_bin: bytes
+ :returns: String representation of MAC address.
+ :rtype: str
+ """
+ return u":".join(mac_bin.hex()[i:i + 2] for i in range(0, 12, 2))
+
+ @staticmethod
+ def vpp_add_l2fib_entry(
+ node, mac, interface, bd_id, static_mac=1, filter_mac=0, bvi_mac=0):
+ """ Create a static L2FIB entry on a VPP node.