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

Module ipv4

IPv4 address logic.

Functions [hide private]
 
valid_str(addr)
Returns: True if IPv4 address is valid, False otherwise.
 
str_to_int(addr)
Returns: The equivalent unsigned integer for a given IPv4 address.
 
int_to_str(int_val, dialect=None)
Returns: The IPv4 presentation (string) format address equivalent to the unsigned integer provided.
 
int_to_arpa(int_val)
Returns: The reverse DNS lookup for an IPv4 address in network byte order integer form.
 
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)
 
int_to_words(int_val)
Returns: An integer word (octet) sequence that is equivalent to value represented by an unsigned integer.
 
words_to_int(words)
Returns: An unsigned integer that is equivalent to value represented by word (octet) sequence.
 
valid_bits(bits)
 
bits_to_int(bits)
 
int_to_bits(int_val, word_sep=None)
 
valid_bin(bin_val)
 
int_to_bin(int_val)
 
bin_to_int(bin_val)
Variables [hide private]
  OPT_IMPORTS = True
  width = 32
The width (in bits) of this address type.
  word_size = 8
The individual word size (in bits) of this address type.
  word_fmt = '%d'
The format string to be used when converting words to string values.
  word_sep = '.'
The separator character used between each word.
  family = 2
The AF_* constant value of this address type.
  family_name = 'IPv4'
A friendly string name address type.
  version = 4
The version of this address type.
  word_base = 10
The number base to be used when interpreting word values as integers.
  max_int = 4294967295
The maximum integer value that can be represented by this address type.
  num_words = 4
The number of words in this address type.
  max_word = 255
The maximum integer value for an individual word in this address type.
Function Details [hide private]

valid_str(addr)

 
Parameters:
  • addr - An IPv4 address in presentation (string) format.
Returns:
True if IPv4 address is valid, False otherwise.

str_to_int(addr)

 
Parameters:
  • addr - An IPv4 dotted decimal address in string form.
Returns:
The equivalent unsigned integer for a given IPv4 address.

int_to_str(int_val, dialect=None)

 
Parameters:
  • int_val - An unsigned integer.
  • dialect - (unused) Any value passed in is ignored.
Returns:
The IPv4 presentation (string) format address equivalent to the unsigned integer provided.

int_to_arpa(int_val)

 
Parameters:
  • int_val - An unsigned integer.
Returns:
The reverse DNS lookup for an IPv4 address in network byte order integer form.

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.

int_to_words(int_val)

 
Parameters:
  • int_val - An unsigned integer.
Returns:
An integer word (octet) sequence that is equivalent to value represented by an unsigned integer.

words_to_int(words)

 
Parameters:
  • words - A list or tuple containing integer octets.
Returns:
An unsigned integer that is equivalent to value represented by word (octet) sequence.