NM.IPRoutingRule

Fields

None

Methods

class

from_string (str, to_string_flags, extra_args)

class

new (addr_family)

cmp (other)

get_action ()

get_addr_family ()

get_destination_port_end ()

get_destination_port_start ()

get_from ()

get_from_len ()

get_fwmark ()

get_fwmask ()

get_iifname ()

get_invert ()

get_ipproto ()

get_oifname ()

get_priority ()

get_source_port_end ()

get_source_port_start ()

get_suppress_prefixlength ()

get_table ()

get_to ()

get_to_len ()

get_tos ()

get_uid_range ()

is_sealed ()

new_clone ()

ref ()

seal ()

set_action (action)

set_destination_port (start, end)

set_from (from_, len)

set_fwmark (fwmark, fwmask)

set_iifname (iifname)

set_invert (invert)

set_ipproto (ipproto)

set_oifname (oifname)

set_priority (priority)

set_source_port (start, end)

set_suppress_prefixlength (suppress_prefixlength)

set_table (table)

set_to (to, len)

set_tos (tos)

set_uid_range (uid_range_start, uid_range_end)

to_string (to_string_flags, extra_args)

unref ()

validate ()

Details

class NM.IPRoutingRule
classmethod from_string(str, to_string_flags, extra_args)
Parameters:
Raises:

GLib.Error

Returns:

the new NM.IPRoutingRule or None on error.

Return type:

NM.IPRoutingRule

Added in version 1.18.

classmethod new(addr_family)
Parameters:

addr_family (int) – the address family of the routing rule. Must be either %AF_INET (2) or %AF_INET6 (10).

Returns:

a newly created rule instance with the provided address family. The instance is unsealed.

Return type:

NM.IPRoutingRule

Added in version 1.18.

cmp(other)
Parameters:

other (NM.IPRoutingRule or None) – the other NM.IPRoutingRule instance to compare

Returns:

zero, a positive, or a negative integer to indicate equality or how the arguments compare.

Return type:

int

Added in version 1.18.

get_action()
Returns:

the set action.

Return type:

int

Added in version 1.18.

get_addr_family()
Returns:

the address family of the rule. Either %AF_INET or %AF_INET6.

Return type:

int

Added in version 1.18.

get_destination_port_end()
Returns:

the destination port end setting.

Return type:

int

Added in version 1.18.

get_destination_port_start()
Returns:

the destination port start setting.

Return type:

int

Added in version 1.18.

get_from()
Returns:

the set from/src parameter or None, if no value is set.

Return type:

str

Added in version 1.18.

get_from_len()
Returns:

the set prefix length for the from/src parameter.

Return type:

int

Added in version 1.18.

get_fwmark()
Returns:

the fwmark setting.

Return type:

int

Added in version 1.18.

get_fwmask()
Returns:

the fwmask setting.

Return type:

int

Added in version 1.18.

get_iifname()
Returns:

the set iifname or None if unset.

Return type:

str

Added in version 1.18.

get_invert()
Returns:

the “invert” setting of the rule.

Return type:

bool

Added in version 1.18.

get_ipproto()
Returns:

the ipproto of the rule.

Return type:

int

Added in version 1.18.

get_oifname()
Returns:

the set oifname or None if unset.

Return type:

str

Added in version 1.18.

get_priority()
Returns:

the priority. A valid priority is in the range from 0 to GObject.G_MAXUINT32. If unset, -1 is returned.

Return type:

int

Added in version 1.18.

get_source_port_end()
Returns:

the source port end setting.

Return type:

int

Added in version 1.18.

get_source_port_start()
Returns:

the source port start setting.

Return type:

int

Added in version 1.18.

get_suppress_prefixlength()
Returns:

the suppress_prefixlength of the rule. -1 means that the value is unset.

Return type:

int

Added in version 1.20.

get_table()
Returns:

the set table.

Return type:

int

Added in version 1.18.

get_to()
Returns:

the set to/dst parameter or None, if no value is set.

Return type:

str

Added in version 1.18.

get_to_len()
Returns:

the set prefix length for the to/dst parameter.

Return type:

int

Added in version 1.18.

get_tos()
Returns:

the tos of the rule.

Return type:

int

Added in version 1.18.

get_uid_range()
Returns:

True if a uid range is set.

This API was wrongly introduced in the header files for 1.32, but the symbols were not exported. The API only works since 1.34 and newer.

out_range_start:

returns the start of the range or 0 if the range is not set.

out_range_end:

returns the end of the range or 0 if the range is not set.

Return type:

(bool, out_range_start: int, out_range_end: int)

Added in version 1.34.

is_sealed()
Returns:

whether self is sealed. Once sealed, an instance cannot be modified nor unsealed.

Return type:

bool

Added in version 1.18.

new_clone()
Returns:

a newly created rule instance with the same settings as self. Note that the instance will always be unsealed.

Return type:

NM.IPRoutingRule

Since 1.42, ref-counting of NM.IPRoutingRule is thread-safe.

Added in version 1.18.

ref()
Returns:

the self argument with incremented reference count.

Since 1.42, ref-counting of NM.IPRoutingRule is thread-safe.

Return type:

NM.IPRoutingRule

Increases the reference count of the instance.

Added in version 1.18.

seal()

Seals the routing rule. Afterwards, the instance can no longer be modified, and it is a bug to call any of the accessors that would modify the rule. If self was already sealed, this has no effect.

Added in version 1.18.

set_action(action)
Parameters:

action (int) – the action to set

Note that currently only certain actions are allowed. NM.IPRoutingRule.validate() will reject unsupported actions as invalid.

Added in version 1.18.

set_destination_port(start, end)
Parameters:
  • start (int) – the start port to set.

  • end (int) – the end port to set.

Added in version 1.18.

set_from(from_, len)
Parameters:
  • from (str or None) – the from/src address to set. The address family must match.

  • len (int) – the corresponding prefix length of the address.

Setting invalid values is accepted, but will later fail during NM.IPRoutingRule.validate().

Added in version 1.18.

set_fwmark(fwmark, fwmask)
Parameters:
  • fwmark (int) – the fwmark

  • fwmask (int) – the fwmask

Added in version 1.18.

set_iifname(iifname)
Parameters:

iifname (str or None) – the iifname to set or None to unset.

The name supports C backslash escaping for non-UTF-8 characters. Note that NM.IPRoutingRule.from_string() too uses backslash escaping when tokenizing the words by whitespace. So, in string representation you’d get double backslashes.

Added in version 1.18.

set_invert(invert)
Parameters:

invert (bool) – the new value to set

Added in version 1.18.

set_ipproto(ipproto)
Parameters:

ipproto (int) – the ipproto to set

Added in version 1.18.

set_oifname(oifname)
Parameters:

oifname (str or None) – the oifname to set or None to unset.

The name supports C backslash escaping for non-UTF-8 characters. Note that NM.IPRoutingRule.from_string() too uses backslash escaping when tokenizing the words by whitespace. So, in string representation you’d get double backslashes.

Added in version 1.18.

set_priority(priority)
Parameters:

priority (int) – the priority to set

A valid priority ranges from 0 to GObject.G_MAXUINT32. “-1” is also allowed to reset the priority. It is a bug calling this function with any other value.

Added in version 1.18.

set_source_port(start, end)
Parameters:
  • start (int) – the start port to set.

  • end (int) – the end port to set.

Added in version 1.18.

set_suppress_prefixlength(suppress_prefixlength)
Parameters:

suppress_prefixlength (int) – the suppress_prefixlength to set. The value -1 means unset.

Added in version 1.20.

set_table(table)
Parameters:

table (int) – the table to set

Added in version 1.18.

set_to(to, len)
Parameters:
  • to (str or None) – the to/dst address to set. The address family must match.

  • len (int) – the corresponding prefix length of the address. If to is None, this valid is ignored.

Setting invalid values is accepted, but will later fail during NM.IPRoutingRule.validate().

Added in version 1.18.

set_tos(tos)
Parameters:

tos (int) – the tos to set

Added in version 1.18.

set_uid_range(uid_range_start, uid_range_end)
Parameters:
  • uid_range_start (int) – the uid_range start to set.

  • uid_range_end (int) – the uid_range start to set.

For a valid range, start must be less or equal to end. If set to an invalid range, the range gets unset.

This API was wrongly introduced in the header files for 1.32, but the symbols were not exported. The API only works since 1.34 and newer.

Added in version 1.34.

to_string(to_string_flags, extra_args)
Parameters:
Raises:

GLib.Error

Returns:

the string representation or None on error.

Return type:

str

Added in version 1.18.

unref()

Decreases the reference count of the instance and destroys the instance if the reference count reaches zero.

Since 1.42, ref-counting of NM.IPRoutingRule is thread-safe.

Added in version 1.18.

validate()
Raises:

GLib.Error

Returns:

True if the rule validates.

Return type:

bool

Added in version 1.18.