InetAddressMask

Added in version 2.32.

class InetAddressMask(**properties: Any)

Superclasses: Object

Implemented Interfaces: Initable

GInetAddressMask represents a range of IPv4 or IPv6 addresses described by a base address and a length indicating how many bits of the base address are relevant for matching purposes. These are often given in string form. For example, 10.0.0.0/8, or fe80::/10.

Constructors

class InetAddressMask
classmethod new(addr: InetAddress, length: int) InetAddressMask

Creates a new InetAddressMask representing all addresses whose first length bits match addr.

Added in version 2.32.

Parameters:
  • addr – a InetAddress

  • length – number of bits of addr to use

classmethod new_from_string(mask_string: str) InetAddressMask

Parses mask_string as an IP address and (optional) length, and creates a new InetAddressMask. The length, if present, is delimited by a “/”. If it is not present, then the length is assumed to be the full length of the address.

Added in version 2.32.

Parameters:

mask_string – an IP address or address/length string

Methods

class InetAddressMask
equal(mask2: InetAddressMask) bool

Tests if mask and mask2 are the same mask.

Added in version 2.32.

Parameters:

mask2 – another InetAddressMask

get_address() InetAddress

Gets mask’s base address

Added in version 2.32.

get_family() SocketFamily

Gets the SocketFamily of mask’s address

Added in version 2.32.

get_length() int

Gets mask’s length

Added in version 2.32.

matches(address: InetAddress) bool

Tests if address falls within the range described by mask.

Added in version 2.32.

Parameters:

address – a InetAddress

to_string() str

Converts mask back to its corresponding string form.

Added in version 2.32.

Properties

class InetAddressMask
props.address: InetAddress

The base address.

Added in version 2.32.

props.family: SocketFamily

The address family (IPv4 or IPv6).

Added in version 2.32.

props.length: int

The prefix length, in bytes.

Added in version 2.32.

Fields

class InetAddressMask
parent_instance
priv