Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions macaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ class OUI(HWAddress):
'xxxxxx',
)

class NIC(HWAddress):
"""Network Interface Card"""

__slots__ = ()

size = 24

formats = (
'xx-xx-xx',
'xx:xx:xx',
'xxxxxx',
)


class _StartsWithOUI(HWAddress):
__slots__ = ()
Expand All @@ -224,6 +237,12 @@ def oui(self):
"""Get the OUI part of this hardware address."""
return OUI(int(self) >> (type(self).size - OUI.size))

@property
def nic(self):
"""Get the NIC part of this hardware address."""
nic_size = self.size - OUI.size # Calculate the size of the NIC based on the hardware address size
return NIC(int(self) & ((1 << nic_size) - 1))


class CDI32(_StartsWithOUI):
"""32-bit Context Dependent Identifier (CDI-32)."""
Expand Down