netaddr.strategy

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

# Package strategy

Shared logic for various address types.

Submodules | [hide private]
netaddr.strategy.eui48: IEEE 48-bit EUI (MAC address) logic. netaddr.strategy.eui64: IEEE 64-bit EUI (Extended Unique Indentifier) logic. netaddr.strategy.ipv4: IPv4 address logic. netaddr.strategy.ipv6: IPv6 address logic.

Functions | [hide private]
bytes_to_bits() Returns: A 256 element list containing 8-bit binary digit strings. |
valid_words(words, word_size, num_words) Returns: `True` if word sequence is valid for this address type, `False` otherwise. |
int_to_words(int_val, word_size, num_words) Returns: A tuple contain unsigned integer word values split according to provided arguments. |
words_to_int(words, word_size, num_words) Returns: An unsigned integer that is equivalent to value represented by word sequence. |
valid_bits(bits, width, word_sep=`'````'`) Returns: `True` if network address is valid, `False` otherwise. |
bits_to_int(bits, width, word_sep=`'````'`) Returns: An unsigned integer that is equivalent to value represented by network address in readable binary form. |
int_to_bits(int_val, word_size, num_words, word_sep=`'````'`) Returns: A network address in a delimited binary string format that is equivalent in value to unsigned integer. |
valid_bin(bin_val, width) Returns: `True` if network address is valid, `False` otherwise. |
int_to_bin(int_val, width) Returns: Equivalent string value in Python's binary representation format ('0bxxx'). |
bin_to_int(bin_val, width) Returns: An unsigned integer that is equivalent to value represented by Python binary string format. |

Variables | [hide private]
| BYTES_TO_BITS = ``[``'``00000000``'``,` `'``00000001``'``,` `'``00000010``'``,` `'``00000011``...``
| __package__ = ``'``netaddr.strategy``'``

Function Details | [hide private]

### bytes_to_bits() |
Returns: A 256 element list containing 8-bit binary digit strings. The list index value is equivalent to its bit string value.

### valid_words(words, word_size, num_words) |
Parameters: `words` - A sequence of unsigned integer word values. `word_size` - Width (in bits) of each unsigned integer word value. `num_words` - Number of unsigned integer words expected. Returns: `True` if word sequence is valid for this address type, `False` otherwise.

### int_to_words(int_val, word_size, num_words) |
Parameters: `int_val` - Unsigned integer to be divided into words of equal size. `word_size` - Width (in bits) of each unsigned integer word value. `num_words` - Number of unsigned integer words expected. Returns: A tuple contain unsigned integer word values split according to provided arguments.

### words_to_int(words, word_size, num_words) |
Parameters: `words` - A sequence of unsigned integer word values. `word_size` - Width (in bits) of each unsigned integer word value. `num_words` - Number of unsigned integer words expected. Returns: An unsigned integer that is equivalent to value represented by word sequence.

### valid_bits(bits, width, word_sep=`'````'`) |
Parameters: `bits` - A network address in a delimited binary string format. `width` - Maximum width (in bits) of a network address (excluding delimiters). `word_sep` - (optional) character or string used to delimit word groups (default: '', no separator). Returns: `True` if network address is valid, `False` otherwise.

### bits_to_int(bits, width, word_sep=`'````'`) |
Parameters: `bits` - A network address in a delimited binary string format. `width` - Maximum width (in bits) of a network address (excluding delimiters). `word_sep` - (optional) character or string used to delimit word groups (default: '', no separator). Returns: An unsigned integer that is equivalent to value represented by network address in readable binary form.

### int_to_bits(int_val, word_size, num_words, word_sep=`'````'`) |
Parameters: `int_val` - An unsigned integer. `word_size` - Width (in bits) of each unsigned integer word value. `num_words` - Number of unsigned integer words expected. `word_sep` - (optional) character or string used to delimit word groups (default: '', no separator). Returns: A network address in a delimited binary string format that is equivalent in value to unsigned integer.

### valid_bin(bin_val, width) |
Parameters: `bin_val` - A network address in Python's binary representation format ('0bxxx'). `width` - Maximum width (in bits) of a network address (excluding delimiters). Returns: `True` if network address is valid, `False` otherwise.

### int_to_bin(int_val, width) |
Parameters: `int_val` - An unsigned integer. `width` - Maximum allowed width (in bits) of a unsigned integer. Returns: Equivalent string value in Python's binary representation format ('0bxxx').

### bin_to_int(bin_val, width) |
Parameters: `bin_val` - A string containing an unsigned integer in Python's binary representation format ('0bxxx'). `width` - Maximum allowed width (in bits) of a unsigned integer. Returns: An unsigned integer that is equivalent to value represented by Python binary string format.

Variables Details | [hide private]

  ### BYTES_TO_BITS Value:
      ['00000000',
       '00000001',
       '00000010',
       '00000011',
       '00000100',
       '00000101',
       '00000110',
       '00000111',
      ...