Package netaddr :: Module strategy :: Class EUI48Strategy
[frames] | no frames]

Class EUI48Strategy

source code

  object --+    
           |    
AddrStrategy --+
               |
              EUI48Strategy

Implements the operations that can be performed on an IEEE 48-bit EUI (Extended Unique Identifer). For all intents and purposes here, a MAC address.

Supports most common MAC address formats including Cisco's string format.

Instance Methods
 
__init__(self)
Constructor.
source code
 
valid_str(self, addr)
Returns: True if MAC address string is valid, False otherwise.
source code
 
str_to_words(self, addr)
Returns: An integer word sequence that is equivalent in value to the network address in string form.
source code
 
int_to_str(self, int_val, delimiter=None, word_fmt=None, to_upper=True)
Returns: A MAC address in string form that is equivalent to value represented by a network byte order integer.
source code

Inherited from AddrStrategy: __repr__, bits_to_int, bits_to_str, bits_to_words, description, int_to_bits, int_to_words, str_to_bits, str_to_int, valid_bits, valid_int, valid_words, word_to_bits, words_to_bits, words_to_int, words_to_str

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

Constructor.

Overrides: object.__init__

valid_str(self, addr)

source code 
Parameters:
  • addr - An EUI-48 or MAC address in string form.
Returns:
True if MAC address string is valid, False otherwise.
Overrides: AddrStrategy.valid_str

str_to_words(self, addr)

source code 
Parameters:
  • addr - An EUI-48 or MAC address in string form.

    Returns an integer word sequence that is equivalent in value to MAC address in string form.

Returns:
An integer word sequence that is equivalent in value to the network address in string form.
Overrides: AddrStrategy.str_to_words

int_to_str(self, int_val, delimiter=None, word_fmt=None, to_upper=True)

source code 
Parameters:
  • int_val - A network byte order integer.
  • delimiter - (optional) A delimiter string override to be used instead of the default between words in string value returned.
  • word_fmt - (optional) A Python format string override used to format each word of address instead of the default.
Returns:
A MAC address in string form that is equivalent to value represented by a network byte order integer.
Overrides: AddrStrategy.int_to_str