Home | Trees | Index | Help |
---|
Module ipaddr :: Class IPv4 |
|
object
--+ |BaseIP
--+ | IPv4
This class represents and manipulates 32-bit IPv4 addresses. Attributes: [examples for IPv4('1.2.3.4/27')] .ip: 16909060 .ip_ext: '1.2.3.4' .ip_ext_full: '1.2.3.4' .network: 16909056L .network_ext: '1.2.3.0' .hostmask: 31L (0x1F) .hostmask_ext: '0.0.0.31' .broadcast: 16909087L (0x102031F) .broadcast_ext: '1.2.3.31' .netmask: 4294967040L (0xFFFFFFE0) .netmask_ext: '255.255.255.224' .prefixlen: 27
Method Summary | |
---|---|
Instantiate a new IPv4 object. | |
Test if the address is reserved for LinkLocal. | |
Test if the address is a loopback adddress. | |
Test if the address is reserved for multicast use. | |
Test if the IPv4 address is reserved per RFC1918. | |
Change the prefix length. | |
The subnets which join to make the current subnet. | |
The supernet containing the current network. | |
Turn the given IP string into an integer for comparison. | |
Test if the IP string is a hostmask (rather than a netmask). | |
Validate the dotted decimal notation IP/netmask string. | |
Verify that the netmask is valid. | |
Turns a 32-bit integer into dotted decimal notation. | |
Inherited from BaseIP | |
| |
Return True if other is contained by 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.__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 | |
---|---|
version | |
Inherited from BaseIP | |
broadcast | |
broadcast_ext | |
hostmask | |
hostmask_ext | |
ip_ext | |
ip_ext_full | |
netmask_ext | |
network | |
network_ext | |
numhosts |
Class Variable Summary | |
---|---|
long |
_ALL_ONES = 4294967295L
|
Method Details |
---|
__init__(self,
ipaddr)
|
IsLinkLocal(self)Test if the address is reserved for LinkLocal. Returns: A boolean, True if the address is link local. |
IsLoopback(self)Test if the address is a loopback adddress. Returns: A boolean, True if the address is a loopback. |
IsMulticast(self)Test if the address is reserved for multicast use. Returns: A boolean, True if the address is multicast. |
IsRFC1918(self)Test if the IPv4 address is reserved per RFC1918. Returns: A boolean, True if the address is reserved. |
SetPrefix(self, prefixlen)Change the prefix length. Args: prefixlen: An integer, the new prefix length. Raises: IPv4NetmaskValidationError: If prefixlen is out of bounds. |
Subnet(self, prefixlen_diff=1)The subnets which join to make the current subnet. In the case that self contains only one IP (self.prefixlen == 32), return a list with just ourself. Args: prefixlen_diff: An integer, the amount the prefix length should be increased by. Given a /24 network and a prefixlen_diff of 3, for example, 8 subnets of size /27 will be returned. The default value of 1 splits the current network into two halves. Returns: A list of IPv4 objects. Raises: PrefixlenDiffInvalidError: The prefixlen_diff is too small or too large. |
Supernet(self, prefixlen_diff=1)The supernet containing the current network. Args: prefixlen_diff: An integer, the amount the prefix length of the network should be decreased by. For example, given a /24 network and a prefixlen_diff of 3, a supernet with a /21 netmask is returned. Returns: An IPv4 object. Raises: PrefixlenDiffInvalidError: If self.prefixlen - prefixlen_diff < 0. I.e., you have a negative prefix length. |
_IpIntFromStr(self, ip_str)Turn the given IP string into an integer for comparison. Args: ip_str: A string, the IP address. Returns: The IP address as an integer. |
_IsHostMask(self, ip_str)Test if the IP string is a hostmask (rather than a netmask). Args: ip_str: A string, the potential hostmask. Returns: A boolean, True if the IP string is a hostmask. |
_IsValidIp(self, ip_str)Validate the dotted decimal notation IP/netmask string. Args: ip_str: A string, the IP address. Returns: A boolean, True if the string is a valid dotted decimal IP string. |
_IsValidNetmask(self, netmask)Verify that the netmask is valid. Args: netmask: A string, either a prefix or dotted decimal netmask. Returns: A boolean, True if the prefix represents a valid IPv4 netmask. |
_StrFromIpInt(self, ip_int)Turns a 32-bit integer into dotted decimal notation. Args: ip_int: An integer, the IP address. Returns: The IP address as a string in dotted decimal notation. |
Property Details |
---|
version
|
Class Variable Details |
---|
_ALL_ONES
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Tue Feb 3 11:02:37 2009 | http://epydoc.sf.net |