Package netaddr :: Package strategy :: Module eui48 |
[hide private]
[frames] | no frames]

# Module eui48

IEEE 48-bit EUI (MAC address) logic.

Supports numerous MAC string formats including Cisco's triple hextet as well as bare MACs containing no delimiters.

Classes | [hide private]
| mac_eui48 A standard IEEE EUI-48 dialect class.
| mac_unix A UNIX-style MAC address dialect class.
| mac_cisco A Cisco 'triple hextet' MAC address dialect class.
| mac_bare A bare (no delimiters) MAC address dialect class.
| mac_pgsql A PostgreSQL style (2 x 24-bit words) MAC address dialect class.
| DEFAULT_DIALECT The default dialect to be used when not specified by the user.

Functions | [hide private]
valid_str(addr) Returns: `True` if MAC address string is valid, `False` otherwise. |
str_to_int(addr) Returns: An unsigned integer that is equivalent to value represented by EUI-48/MAC string address formatted according to the dialect settings. |
int_to_str(int_val, dialect=None) Returns: An IEEE EUI-48 (MAC) address string that is equivalent to unsigned integer formatted according to the dialect settings. |
int_to_packed(int_val) Returns: a packed string that is equivalent to value represented by an unsigned integer. |
packed_to_int(packed_int) Returns: An unsigned integer equivalent to value of network address represented by packed binary string. |
valid_words(words, dialect=None) |
int_to_words(int_val, dialect=None) |
words_to_int(words, dialect=None) |
valid_bits(bits, dialect=None) |
bits_to_int(bits, dialect=None) |
int_to_bits(int_val, dialect=None) |
valid_bin(bin_val, dialect=None) |
int_to_bin(int_val) |
bin_to_int(bin_val) |

Variables | [hide private]
| AF_LINK = `48`
| width = `48` The width (in bits) of this address type.
| family = `48` The AF_* constant value of this address type.
| family_name = ``'``MAC``'`` A friendly string name address type.
| version = `48` The version of this address type.
| max_int = `281474976710655` The maximum integer value that can be represented by this address type.
| RE_MAC_FORMATS = ``[`re.compile(r'`(?i)`^`(``[`0`-`9A`-`F`]``{1,2}``)`:`(``[`0`-`9A`-`F`]``{``...`` Regular expressions to match all supported MAC address formats.
| _ = ``'``^([0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F``...``

Function Details | [hide private]

### valid_str(addr) |
Parameters: `addr` - An IEEE EUI-48 (MAC) address in string form. Returns: `True` if MAC address string is valid, `False` otherwise.

### str_to_int(addr) |
Parameters: `addr` - An IEEE EUI-48 (MAC) address in string form. Returns: An unsigned integer that is equivalent to value represented by EUI-48/MAC string address formatted according to the dialect settings.

### int_to_str(int_val, dialect=None) |
Parameters: `int_val` - An unsigned integer. `dialect` - (optional) a Python class defining formatting options. Returns: An IEEE EUI-48 (MAC) address string that is equivalent to unsigned integer formatted according to the dialect settings.

### int_to_packed(int_val) |
Parameters: `int_val` - the integer to be packed. Returns: a packed string that is equivalent to value represented by an unsigned integer.

### packed_to_int(packed_int) |
Parameters: `packed_int` - a packed string containing an unsigned integer. It is assumed that string is packed in network byte order. Returns: An unsigned integer equivalent to value of network address represented by packed binary string.

Variables Details | [hide private]

  ### RE_MAC_FORMATS Regular expressions to match all supported MAC address formats. Value:
      [re.compile(r'(?i)^([0-9A-F]{1,2}):([0-9A-F]{1,2}):([0-9A-F]{1,2}):([0
      -9A-F]{1,2}):([0-9A-F]{1,2}):([0-9A-F]{1,2})$'),
       re.compile(r'(?i)^([0-9A-F]{1,2})-([0-9A-F]{1,2})-([0-9A-F]{1,2})-([0
      -9A-F]{1,2})-([0-9A-F]{1,2})-([0-9A-F]{1,2})$'),
       re.compile(r'(?i)^([0-9A-F]{1,4}):([0-9A-F]{1,4}):([0-9A-F]{1,4})$'),
       re.compile(r'(?i)^([0-9A-F]{1,4})-([0-9A-F]{1,4})-([0-9A-F]{1,4})$'),
       re.compile(r'(?i)^([0-9A-F]{1,4})\.([0-9A-F]{1,4})\.([0-9A-F]{1,4})$'
      ),
      ...

  ### _ Value:
      '^([0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-
      9A-F][0-9A-F][0-9A-F])$'