Table of contents Index

class InetDomain

Declared in module Domain

Inheritance hierarchy:

Domain.InetDomain
  Domain.Domain

Synopsis

class InetDomain(Domain):
    def Domain.InetDomain.__cmp__(self, other) # Compare this instance to another.
    def Domain.InetDomain.__init__(self, addr) # Initializes an InetDomain instance
    def Domain.InetDomain.__str__(self) # Returns the string representation of this instance.
    def Domain.InetDomain.broadcast(self) # Calculate the broadcast address of this domain
    def Domain.InetDomain.netaddr(self) # Calculate the network address of this domain.
    def Domain.InetDomain.netmask(self) # Calculate netmask of this domain.

    # Inherited from Domain.Domain
    def Domain.Domain.__cmp__(self, other)
    def Domain.Domain.__init__(self)

Description

A class representing internet addresses. The inet objects are comparable, comparison means "contains", "equal to" and "contained by". The comparison can raise ValueError for incomparable ip addresses.

Attributes:

mask_bits
number of bits in the netmask
mask
netmask in network byte order
ip
network addresss in network byte order


Domain.InetDomain.__cmp__(self, other)

Compare this instance to another.

self
this instance
other
the other InetDomain object to compare to
Compare this instance to another InetDomain instance or to a SockAddrInet instance.

Exceptions:

Raises ValueError if self and other are incomparable

Notes:

standard comparison operator, using set inclusion on addresses looks into the netmask and then the ip numbers masked with the lesser mask if AttributeError is raised, it assumes that self or other is not of Inet type.

Returns:

-1, 0, or 1

Domain.InetDomain.__init__(self, addr)

Initializes an InetDomain instance

addr
the string representation of an address, or address range
Parses the argument addr and fills in attributes accordingly.

Domain.InetDomain.__str__(self)

Returns the string representation of this instance.

self
this instance
Returns the string representation of the address/mask

Returns:

string

Domain.InetDomain.broadcast(self)

Calculate the broadcast address of this domain

Return the broadcast address of this domain calculated based on attributes.

Arguments:

self
this instance

Returns:

the broadcast address in network byte order Notes:

does bitwise or with the network address and the bits outside the netmask it handles the mask=0 case specially, because the '>>" semantics regarding the highest bit



Domain.InetDomain.netaddr(self)

Calculate the network address of this domain.

self
this instance
Return the network address of this domain.

Returns:

ip address in network byte order

Notes:

just returns the ip address, which is already masked by the constructor

Domain.InetDomain.netmask(self)

Calculate netmask of this domain.

self
this instance
Calculates and returns the netmask of this domain as an integer in network byte order.

Returns:

the network mask as ip in network byte order

Notes:

rotate and mask handles the mask=0 case specially, because the rotation semantics regarding the highest bit
Copyright © 2000 BalaBit IT Ltd.
Written by: Balázs Scheidler