NM.IPAddress

Fields

None

Methods

class

new (family, addr, prefix)

class

new_binary (family, addr, prefix)

cmp_full (b, cmp_flags)

dup ()

equal (other)

get_address ()

get_attribute (name)

get_attribute_names ()

get_family ()

get_prefix ()

ref ()

set_address (addr)

set_attribute (name, value)

set_prefix (prefix)

unref ()

Details

class NM.IPAddress
classmethod new(family, addr, prefix)
Parameters:
  • family (int) – the IP address family (AF_INET or AF_INET6)

  • addr (str) – the IP address

  • prefix (int) – the address prefix length

Raises:

GLib.Error

Returns:

the new NM.IPAddress object, or None on error

Return type:

NM.IPAddress

Creates a new NM.IPAddress object.

classmethod new_binary(family, addr, prefix)
Parameters:
  • family (int) – the IP address family (AF_INET or AF_INET6)

  • addr (object or None) – the IP address

  • prefix (int) – the address prefix length

Raises:

GLib.Error

Returns:

the new NM.IPAddress object, or None on error

Return type:

NM.IPAddress

Creates a new NM.IPAddress object. addr must point to a buffer of the correct size for family.

cmp_full(b, cmp_flags)
Parameters:
Returns:

0 if the two objects have the same values (according to their flags) or a integer indicating the compare order.

Return type:

int

Note that with cmp_flags NM.IPAddressCmpFlags.WITH_ATTRS, there is no total order for comparing GLib.Variant. That means, if the two addresses only differ by their attributes, the sort order is undefined and the return value only indicates equality.

New in version 1.22.

dup()
Returns:

a copy of self

This API was part of public headers before 1.32.0 but was erroneously not exported in the ABI. It is thus only usable since 1.32.0.

Return type:

NM.IPAddress

Creates a copy of self

New in version 1.32.

equal(other)
Parameters:

other (NM.IPAddress) – the NM.IPAddress to compare self to.

Returns:

True if the objects contain the same values, False if they do not.

Return type:

bool

Determines if two NM.IPAddress objects contain the same address and prefix (attributes are not compared).

get_address()
Returns:

the IP address

Return type:

str

Gets the IP address property of this address object.

get_attribute(name)
Parameters:

name (str) – the name of an address attribute

Returns:

the value of the attribute with name name on self, or None if self has no such attribute.

Return type:

GLib.Variant

Gets the value of the attribute with name name on self

get_attribute_names()
Returns:

a None-terminated array of attribute names,

Return type:

[str]

Gets an array of attribute names defined on self.

get_family()
Returns:

the IP address family

Return type:

int

Gets the IP address family (eg, AF_INET) property of this address object.

get_prefix()
Returns:

the IP address prefix

Return type:

int

Gets the IP address prefix (ie “24” or “30” etc) property of this address object.

ref()

Increases the reference count of the object.

set_address(addr)
Parameters:

addr (str) – the IP address, as a string

Sets the IP address property of this address object.

addr must be a valid address of self's family. If you aren’t sure you have a valid address, use NM.utils_ipaddr_valid() to check it.

set_attribute(name, value)
Parameters:

Sets or clears the named attribute on self to the given value.

set_prefix(prefix)
Parameters:

prefix (int) – the IP address prefix

Sets the IP address prefix property of this address object.

unref()

Decreases the reference count of the object. If the reference count reaches zero, the object will be destroyed.