NM.IPRoute

Fields

None

Methods

class

attribute_validate (name, value, family)

class

get_variant_attribute_spec ()

class

new (family, dest, prefix, next_hop, metric)

class

new_binary (family, dest, prefix, next_hop, metric)

dup ()

equal (other)

equal_full (other, cmp_flags)

get_attribute (name)

get_attribute_names ()

get_dest ()

get_family ()

get_metric ()

get_next_hop ()

get_prefix ()

ref ()

set_attribute (name, value)

set_dest (dest)

set_metric (metric)

set_next_hop (next_hop)

set_prefix (prefix)

unref ()

Details

class NM.IPRoute
classmethod attribute_validate(name, value, family)
Parameters:
  • name (str) – the attribute name

  • value (GLib.Variant) – the attribute value

  • family (int) – IP address family of the route

Raises:

GLib.Error

Returns:

True if the attribute is valid, False otherwise

known:

on return, whether the attribute name is a known one

Return type:

(bool, known: bool)

Validates a route attribute, i.e. checks that the attribute is a known one and the value is of the correct type and well-formed.

New in version 1.8.

classmethod get_variant_attribute_spec()
Returns:

the specifiers for route attributes

Return type:

NM.VariantAttributeSpec

New in version 1.8.

classmethod new(family, dest, prefix, next_hop, metric)
Parameters:
  • family (int) – the IP address family (AF_INET or AF_INET6)

  • dest (str) – the IP address of the route’s destination

  • prefix (int) – the address prefix length

  • next_hop (str or None) – the IP address of the next hop (or None)

  • metric (int) – the route metric (or -1 for “default”)

Raises:

GLib.Error

Returns:

the new NM.IPRoute object, or None on error

Return type:

NM.IPRoute

Creates a new NM.IPRoute object.

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

  • dest (object or None) – the IP address of the route’s destination

  • prefix (int) – the address prefix length

  • next_hop (object or None) – the IP address of the next hop (or None)

  • metric (int) – the route metric (or -1 for “default”)

Raises:

GLib.Error

Returns:

the new NM.IPRoute object, or None on error

Return type:

NM.IPRoute

Creates a new NM.IPRoute object. dest and next_hop (if non-None) must point to buffers of the correct size for family.

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.IPRoute

Creates a copy of self

New in version 1.32.

equal(other)
Parameters:

other (NM.IPRoute) – the NM.IPRoute 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.IPRoute objects contain the same destination, prefix, next hop, and metric. (Attributes are not compared.)

equal_full(other, cmp_flags)
Parameters:
  • other (NM.IPRoute) – the NM.IPRoute to compare self to.

  • cmp_flags (int) – tune how to compare attributes. Currently, only NM_IP_ROUTE_EQUAL_CMP_FLAGS_NONE (0) and NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS (1) is supported.

Returns:

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

Return type:

bool

Determines if two NM.IPRoute objects contain the same destination, prefix, next hop, and metric.

New in version 1.10.

get_attribute(name)
Parameters:

name (str) – the name of an route 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_dest()
Returns:

the IP address of the route’s destination

Return type:

str

Gets the IP destination address property of this route object.

get_family()
Returns:

the IP address family

Return type:

int

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

get_metric()
Returns:

the route metric

Return type:

int

Gets the route metric property of this route object; lower values indicate “better” or more preferred routes; -1 indicates “default” (meaning NetworkManager will set it appropriately).

get_next_hop()
Returns:

the IP address of the next hop, or None if this is a device route.

Return type:

str

Gets the IP address of the next hop of this route; this will be None if the route has no next hop.

get_prefix()
Returns:

the IP prefix

Return type:

int

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

ref()

Increases the reference count of the object.

set_attribute(name, value)
Parameters:

Sets the named attribute on self to the given value.

set_dest(dest)
Parameters:

dest (str) – the route’s destination, as a string

Sets the destination property of this route object.

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

set_metric(metric)
Parameters:

metric (int) – the route metric (or -1 for “default”)

Sets the metric property of this route object.

set_next_hop(next_hop)
Parameters:

next_hop (str or None) – the route’s next hop, as a string

Sets the next-hop property of this route object.

next_hop (if non-None) 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_prefix(prefix)
Parameters:

prefix (int) – the route prefix

Sets the prefix property of this route object.

unref()

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