字符串mac地址轉換:
def str2mac(s):
return ("%02x:" * 6)[:-1] % tuple(orb(x) for x in s)
mac地址轉字符串:
def mac2str(mac):
return b"".join(chb(int(x, 16)) for x in plain_str(mac).split(':'))
參考鏈接:
https://github.com/secdev/scapy/blob/2e87889089e5593988911309bb4a1ca4f632d716/scapy/utils.py#L467