| Home | Trees | Index | Help |
|---|
| Module ipaddr :: Class BaseIP |
|
object --+
|
BaseIP
IPv4,
IPv6A generic IP object.
This IP class contains most of the methods which are used by the IPv4 and IPv6 classes.| Method Summary | |
|---|---|
__cmp__(self,
other)
| |
Return True if other is contained by self. | |
__eq__(self,
other)
| |
__getitem__(self,
n)
| |
__hash__(self)
| |
__hex__(self)
| |
__int__(self)
| |
__ne__(self,
other)
| |
__repr__(self)
| |
__str__(self)
| |
Remove an address from a larger block. | |
Compare two IP objects. | |
Return True if other is contained by self. | |
Turn the prefix length netmask into a int for comparison. | |
Turn a prefix length into a dotted decimal string. | |
Return prefix length from the decimal netmask. | |
| Inherited from object | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
| Property Summary | |
|---|---|
broadcast | |
broadcast_ext | |
hostmask | |
hostmask_ext | |
ip_ext | |
ip_ext_full | |
netmask_ext | |
network | |
network_ext | |
numhosts | |
version | |
| Method Details |
|---|
__contains__(self,
other)
|
AddressExclude(self, other)
Remove an address from a larger block.
For example:
addr1 = IP('10.1.1.0/24')
addr2 = IP('10.1.1.0/26')
addr1.AddressExclude(addr2) =
[IP('10.1.1.64/26'), IP('10.1.1.128/25')]
or IPv6:
addr1 = IP('::1/32')
addr2 = IP('::1/128')
addr1.AddressExclude(addr2) = [IP('::0/128'),
IP('::2/127'),
IP('::4/126'),
IP('::8/125'),
...
IP('0:0:8000::/33')]
Args:
other: An IP object of the same type.
Returns:
A sorted list of IP objects addresses which is self minus
other.
Raises:
IPTypeError: If self and other are of difffering address
versions.
IPAddressExclusionError: There was some unknown error in the
address exclusion process. This likely points to a bug
elsewhere in this code.
ValueError: If other is not completely contained by self.
|
CompareNetworks(self, other)
Compare two IP objects.
This is only concerned about the comparison of the integer
representation of the network addresses. This means that the
host bits aren't considered at all in this method. If you want
to compare host bits, you can easily enough do a
'HostA.ip < HostB.ip'
Args:
other: An IP object.
Returns:
If the IP versions of self and other are the same, returns:
-1 if self < other:
eg: IPv4('1.1.1.0/24') < IPv4('1.1.2.0/24')
IPv6('1080::200C:417A') < IPv6('1080::200B:417B')
0 if self == other
eg: IPv4('1.1.1.1/24') == IPv4('1.1.1.2/24')
IPv6('1080::200C:417A/96') == IPv6('1080::200C:417B/96')
1 if self > other
eg: IPv4('1.1.1.0/24') > IPv4('1.1.0.0/24')
IPv6('1080::1:200C:417A/112') >
IPv6('1080::0:200C:417A/112')
If the IP versions of self and other are different, returns:
-1 if self.version < other.version
eg: IPv4('10.0.0.1/24') < IPv6('::1/128')
1 if self.version > other.version
eg: IPv6('::1/128') > IPv4('255.255.255.0/24')
|
Contains(self, other)
Return True if other is contained by self.
Args:
other: An IP object.
Returns:
A boolean.
|
_IpIntFromPrefixlen(self, prefixlen=None)
Turn the prefix length netmask into a int for comparison.
Args:
prefixlen: An integer, the prefix length.
Returns:
An integer.
|
_IpStrFromPrefixlen(self, prefixlen=None)
Turn a prefix length into a dotted decimal string.
Args:
prefixlen: An integer, the netmask prefix length.
Returns:
A string, the dotted decimal netmask string.
|
_PrefixlenFromIpInt(self, ip_int, mask=32)
Return prefix length from the decimal netmask.
Args:
ip_int: An integer, the IP address.
mask: The netmask. Defaults to 32.
Returns:
An integer, the prefix length.
|
| Property Details |
|---|
broadcast
|
broadcast_ext
|
hostmask
|
hostmask_ext
|
ip_ext
|
ip_ext_full
|
netmask_ext
|
network
|
network_ext
|
numhosts
|
version
|
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Tue Feb 3 11:02:37 2009 | http://epydoc.sf.net |