[show private | hide private]

Module iplib


iplib module (daxfi package).

The representations of an IPv4 address and a netmask.
You can use this module to convert amongst many different IP notations.

  Copyright 2001 Davide Alberani <alberanid@mail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Classes
IpAddress An IPv4 Internet address.
IpNetMask A CIDR netmask.

Function Summary
  convert(ip, notation, iformat)
  convert_nm(nm, notation, iformat)
Convert among netmask notations.
  detect(ip)
Return the kind of an Internet address.
  detect_nm(nm)
Return the kind of the netmask.
  is_bin(ip)
Return true if the address is in binary notation.
  is_bin_nm(nm)
Return true if the netmask is in binary notatation.
  is_dec(ip)
Return true if the address is in decimal notation.
  is_dec_nm(nm)
Return true if the netmask is in decimal notatation.
  is_dot(ip)
Return true if the address is in dotted decimal notation.
  is_dot_nm(nm)
Return true if the netmask is in dotted decimal notatation.
  is_hex(ip)
Return true if the address is in hexadecimal notation.
  is_oct(ip)
Return true if the address is in octal notation.
  p_detect(ip)
Return the kind of an Internet address (string).
  p_detect_nm(nm)
Return the kind of the netmask (string).

Function Details

convert

convert(ip, notation=1, iformat=0)

Convert among ip notations.

Given an ip address, this functions returns the ip in another
notation.

*ip* -- The ip address.

*notation* -- The format of the output.

*iformat* -- Force the input to be considered of the given type
                (otherwise it's autodetected).

convert_nm

convert_nm(nm, notation=1, iformat=0)

Convert among netmask notations.

Given a netmask, this functions returns the netmask in another notation.

*nm* -- The netmask.

*notation* -- The format of the output.

detect

detect(ip)

Return the kind of an Internet address.

Given an ip, returns the kind of the notation (one of IP_DOT, IP_HEX, IP_BIN, IP_DEC, IP_UNKNOWN).

detect_nm

detect_nm(nm)

Return the kind of the netmask.

Given a netmask, returns the kind of notation (one of NM_DOT, NM_DEC, NM_BIN, NM_UNKNOWN).

is_bin

is_bin(ip)

Return true if the address is in binary notation.

is_bin_nm

is_bin_nm(nm)

Return true if the netmask is in binary notatation.

is_dec

is_dec(ip)

Return true if the address is in decimal notation.

is_dec_nm

is_dec_nm(nm)

Return true if the netmask is in decimal notatation.

is_dot

is_dot(ip)

Return true if the address is in dotted decimal notation.

is_dot_nm

is_dot_nm(nm)

Return true if the netmask is in dotted decimal notatation.

is_hex

is_hex(ip)

Return true if the address is in hexadecimal notation.

is_oct

is_oct(ip)

Return true if the address is in octal notation.

p_detect

p_detect(ip)

Return the kind of an Internet address (string).

Given an ip, returns a string that represents the kind of notation.

p_detect_nm

p_detect_nm(nm)

Return the kind of the netmask (string).

Given a netmask, returns a string that represents the notation.

Generated by Epydoc on Fri Oct 4 14:00:41 2002 http://epydoc.sf.net