IPv4 configuration should be automatically determined via a method appropriate
for the hardware interface, ie DHCP or PPP or some other device-specific
manner.
Const SETTING_IP4_CONFIG_METHOD_DISABLED
SETTING_IP4_CONFIG_METHOD_DISABLED:string
This connection does not use or require IPv4 address and it should be disabled.
Const SETTING_IP4_CONFIG_METHOD_LINK_LOCAL
SETTING_IP4_CONFIG_METHOD_LINK_LOCAL:string
IPv4 configuration should be automatically configured for link-local-only
operation.
Const SETTING_IP4_CONFIG_METHOD_MANUAL
SETTING_IP4_CONFIG_METHOD_MANUAL:string
All necessary IPv4 configuration (addresses, prefix, DNS, etc) is specified
in the setting's properties.
Const SETTING_IP4_CONFIG_METHOD_SHARED
SETTING_IP4_CONFIG_METHOD_SHARED:string
This connection specifies configuration that allows other computers to
connect through it to the default network (usually the Internet). The
connection's interface will be assigned a private address, and a DHCP server,
caching DNS server, and Network Address Translation (NAT) functionality will
be started on this connection's interface to allow other devices to connect
through that interface to the default network.
Const SETTING_IP4_CONFIG_SETTING_NAME
SETTING_IP4_CONFIG_SETTING_NAME:string
Const SETTING_IP6_CONFIG_ADDR_GEN_MODE
SETTING_IP6_CONFIG_ADDR_GEN_MODE:string
Const SETTING_IP6_CONFIG_DHCP_DUID
SETTING_IP6_CONFIG_DHCP_DUID:string
Const SETTING_IP6_CONFIG_IP6_PRIVACY
SETTING_IP6_CONFIG_IP6_PRIVACY:string
Const SETTING_IP6_CONFIG_METHOD_AUTO
SETTING_IP6_CONFIG_METHOD_AUTO:string
IPv6 configuration should be automatically determined via a method appropriate
for the hardware interface, ie router advertisements, DHCP, or PPP or some
other device-specific manner.
Const SETTING_IP6_CONFIG_METHOD_DHCP
SETTING_IP6_CONFIG_METHOD_DHCP:string
IPv6 configuration should be automatically determined via DHCPv6 only and
router advertisements should be ignored.
Const SETTING_IP6_CONFIG_METHOD_DISABLED
SETTING_IP6_CONFIG_METHOD_DISABLED:string
IPv6 is disabled for the connection.
Const SETTING_IP6_CONFIG_METHOD_IGNORE
SETTING_IP6_CONFIG_METHOD_IGNORE:string
IPv6 is not required or is handled by some other mechanism, and NetworkManager
should not configure IPv6 for this connection.
Const SETTING_IP6_CONFIG_METHOD_LINK_LOCAL
SETTING_IP6_CONFIG_METHOD_LINK_LOCAL:string
IPv6 configuration should be automatically configured for link-local-only
operation.
Const SETTING_IP6_CONFIG_METHOD_MANUAL
SETTING_IP6_CONFIG_METHOD_MANUAL:string
All necessary IPv6 configuration (addresses, prefix, DNS, etc) is specified
in the setting's properties.
Const SETTING_IP6_CONFIG_METHOD_SHARED
SETTING_IP6_CONFIG_METHOD_SHARED:string
This connection specifies configuration that allows other computers to
connect through it to the default network (usually the Internet). The
connection's interface will be assigned a private address, and router
advertisements, a caching DNS server, and Network Address Translation (NAT)
functionality will be started on this connection's interface to allow other
devices to connect through that interface to the default network. (not yet
supported for IPv6)
Given a set of device capabilities, and a desired security type to check
against, determines whether the combination of device capabilities and
desired security type are valid for AP/Hotspot connections.
Converts the byte array src into a hexadecimal string. If final_len is
greater than -1, the returned string is terminated at that index
(returned_string[final_len] == '\0'),
Parameters
src: Uint8Array
an array of bytes
final_len: number
an index where to cut off the returned string, or -1
Determines if a connection of type virtual_type can (in the
general case) work with connections of type other_type.
If virtual_type is %NM_TYPE_SETTING_VLAN, then this checks if
other_type is a valid type for the parent of a VLAN.
If virtual_type is a "master" type (eg, %NM_TYPE_SETTING_BRIDGE),
then this checks if other_type is a valid type for a slave of that
master.
Note that even if this returns %TRUE it is not guaranteed that
every connection of type other_type is
compatible with virtual_type; it may depend on the exact
configuration of the two connections, or on the capabilities of an
underlying device driver.
If the enum is a %G_TYPE_FLAGS the function returns the logical OR of values
matching the comma-separated tokens in the string; if an unknown token is found
the function returns %FALSE and stores a pointer to a newly allocated string
containing the unrecognized token in err_token.
Converts an enum value to its string representation. If the enum is a
%G_TYPE_FLAGS the function returns a comma-separated list of matching values.
If the value has no corresponding string representation, it is converted
to a number. For enums it is converted to a decimal number, for flags
to an (unsigned) hex number.
This function does a quick printable character conversion of the SSID, simply
replacing embedded NULLs and non-printable characters with the hexadecimal
representation of that character. Intended for debugging only, should not
be used for display of SSIDs.
Tests if filename has a valid extension for an X.509 certificate file
(".cer", ".crt", ".der", or ".pem"), and contains a certificate in a format
recognized by NetworkManager.
Tests if filename has a valid extension for an X.509 private key file
(".der", ".key", ".pem", or ".p12"), and contains a private key in a format
recognized by NetworkManager.
if given, pass the file name to this function for additional checks. This check is performed after the check for file_test_flags. You cannot omit both file_test_flags and predicate.
Returns string
utils_format_variant_attributes
utils_format_variant_attributes(attributes: HashTable<string | number | symbol, string | number | boolean>, attr_separator: number, key_value_separator: number): string
Parameters
attributes: HashTable<string | number | symbol, string | number | boolean>
Converts a hexadecimal string hex into an array of bytes. The optional
separator ':' may be used between single or pairs of hexadecimal characters,
eg "00:11" or "0:1". Any "0x" at the beginning of hex is ignored. hex
may not start or end with ':'.
Parameters
hex: string
a string of hexadecimal characters with optional ':' separators
Parses asc to see if it is a valid hardware address of the given
length, and if so, returns it in canonical form (uppercase, with
leading 0s as needed, and with colons rather than hyphens).
Parameters
asc: string
the ASCII representation of a hardware address
length: number
the length of address that asc is expected to convert to (or -1 to accept any length up to %NM_UTILS_HWADDR_LEN_MAX)
Returns string
utils_hwaddr_len
utils_hwaddr_len(type: number): number
Returns the length in octets of a hardware address of type type.
Before 1.28, it was an error to call this function with any value other than
ARPHRD_ETHER or ARPHRD_INFINIBAND.
Parameters
type: number
the type of address; either ARPHRD_ETHER or ARPHRD_INFINIBAND
Generalized hardware address comparison function. Tests if hwaddr1 and
hwaddr2 "equal" (or more precisely, "equivalent"), with several advantages
over a simple memcmp():
If hwaddr1_len or hwaddr2_len is -1, then the corresponding address is
assumed to be ASCII rather than binary, and will be converted to binary
before being compared.
If hwaddr1 or hwaddr2 is %NULL, it is treated instead as though it was
a zero-filled buffer hwaddr1_len or hwaddr2_len bytes long.
If hwaddr1 and hwaddr2 are InfiniBand hardware addresses (that is, if
they are INFINIBAND_ALEN bytes long in binary form)
then only the last 8 bytes are compared, since those are the only bytes
that actually identify the hardware. (The other 12 bytes will change
depending on the configuration of the InfiniBand fabric that the device
is connected to.)
If a passed-in ASCII hardware address cannot be parsed, or would parse to an
address larger than %NM_UTILS_HWADDR_LEN_MAX, then it will silently fail to
match. (This means that externally-provided address strings do not need to be
sanity-checked before comparing them against known good addresses; they are
guaranteed to not match if they are invalid.)
Parameters
hwaddr1: object
pointer to a binary or ASCII hardware address, or %NULL
hwaddr1_len: number
size of hwaddr1, or -1 if hwaddr1 is ASCII
hwaddr2: object
pointer to a binary or ASCII hardware address, or %NULL
Utility function to convert a #GVariant of type 'aau' representing a list of
NetworkManager IPv4 addresses (which are tuples of address, prefix, and
gateway) into a #GPtrArray of #NMIPAddress objects. The "gateway" field of
the first address (if set) will be returned in out_gateway; the "gateway" fields
of the other addresses are ignored.
Utility function to convert a #GPtrArray of #NMIPAddress objects representing
IPv4 addresses into a #GVariant of type 'aau' representing an array of
NetworkManager IPv4 addresses (which are tuples of address, prefix, and
gateway). The "gateway" field of the first address will get the value of
gateway (if non-%NULL). In all of the other addresses, that field will be 0.
When the Internet was originally set up, various ranges of IP addresses were
segmented into three network classes: A, B, and C. This function will return
a prefix that is associated with the IP address specified defining where it
falls in the predefined classes.
Parameters
ip: number
an IPv4 address (in network byte order)
Returns number
utils_ip4_netmask_to_prefix
utils_ip4_netmask_to_prefix(netmask: number): number
Parameters
netmask: number
Returns number
utils_ip4_prefix_to_netmask
utils_ip4_prefix_to_netmask(prefix: number): number
Utility function to convert a #GVariant of type 'aau' representing an array
of NetworkManager IPv4 routes (which are tuples of route, prefix, next hop,
and metric) into a #GPtrArray of #NMIPRoute objects.
Utility function to convert a #GPtrArray of #NMIPRoute objects representing
IPv4 routes into a #GVariant of type 'aau' representing an array of
NetworkManager IPv4 routes (which are tuples of route, prefix, next hop, and
metric).
Utility function to convert a #GVariant of type 'a(ayuay)' representing a
list of NetworkManager IPv6 addresses (which are tuples of address, prefix,
and gateway) into a #GPtrArray of #NMIPAddress objects. The "gateway" field
of the first address (if set) will be returned in out_gateway; the "gateway"
fields of the other addresses are ignored.
Utility function to convert a #GPtrArray of #NMIPAddress objects representing
IPv6 addresses into a #GVariant of type 'a(ayuay)' representing an array of
NetworkManager IPv6 addresses (which are tuples of address, prefix, and
gateway). The "gateway" field of the first address will get the value of
gateway (if non-%NULL). In all of the other addresses, that field will be
all 0s.
Utility function to convert a #GVariant of type 'aay' representing a list of
IPv6 addresses into an array of IP address strings. Each "ay" entry must be
a IPv6 address in binary form (16 bytes long). Invalid entries are silently
ignored.
Utility function to convert a #GVariant of type 'a(ayuayu)' representing an
array of NetworkManager IPv6 routes (which are tuples of route, prefix, next
hop, and metric) into a #GPtrArray of #NMIPRoute objects.
Utility function to convert a #GPtrArray of #NMIPRoute objects representing
IPv6 routes into a #GVariant of type 'a(ayuayu)' representing an array of
NetworkManager IPv6 routes (which are tuples of route, prefix, next hop, and
metric).
Utility function to convert a #GVariant representing a list of new-style
NetworkManager IPv4 or IPv6 addresses (as described in the documentation for
nm_utils_ip_addresses_to_variant()) into a #GPtrArray of #NMIPAddress
objects.
Utility function to convert a #GPtrArray of #NMIPAddress objects representing
IPv4 or IPv6 addresses into a #GVariant of type 'aa{sv}' representing an
array of new-style NetworkManager IP addresses. All addresses will include
"address" (an IP address string), and "prefix" (a uint). Some addresses may
include additional attributes.
Utility function to convert a #GVariant representing a list of new-style
NetworkManager IPv4 or IPv6 addresses (which are tuples of destination,
prefix, next hop, metric, and additional attributes) into a #GPtrArray of
#NMIPRoute objects.
Utility function to convert a #GPtrArray of #NMIPRoute objects representing
IPv4 or IPv6 routes into a #GVariant of type 'aa{sv}' representing an array
of new-style NetworkManager IP routes (which are tuples of destination,
prefix, next hop, metric, and additional attributes).
Checks if ip contains a valid IP address of the given family.
Parameters
family: number
AF_INET or AF_INET6, or AF_UNSPEC to accept either
ip: string
an IP address
Returns boolean
utils_is_empty_ssid
utils_is_empty_ssid(ssid: Uint8Array): boolean
Different manufacturers use different mechanisms for not broadcasting the
AP's SSID. This function attempts to detect blank/empty SSIDs using a
number of known SSID-cloaking methods.
Parameters
ssid: Uint8Array
pointer to a buffer containing the SSID data
Returns boolean
utils_is_json_object
utils_is_json_object(str: string): boolean
Parameters
str: string
Returns boolean
utils_is_uuid
utils_is_uuid(str: string): boolean
Checks if str is a UUID
Parameters
str: string
a string that might be a UUID
Returns boolean
utils_is_valid_iface_name
utils_is_valid_iface_name(name: string): boolean
Validate the network interface name.
This function is a 1:1 copy of the kernel's interface validation
function in net/core/dev.c.
The only purpose of this function is to give access to g_print()
or g_printerr() from pygobject. libnm can do debug logging by
setting LIBNM_CLIENT_DEBUG and uses thereby g_printerr() or
g_print(). A plain "print()" function in python is not in sync
with these functions (it implements additional buffering). By
using nm_utils_print(), the same logging mechanisms can be used.
Parameters
output_mode: number
if 1 it uses g_print(). If 2, it uses g_printerr(). If 0, it uses either g_print() or g_printerr(), depending on LIBNM_CLIENT_DEBUG (and the "stdout" flag).
msg: string
the message to print. The function does not append a trailing newline.
Earlier versions of the Linux kernel added a NULL byte to the end of the
SSID to enable easy printing of the SSID on the console or in a terminal,
but this behavior was problematic (SSIDs are simply byte arrays, not strings)
and thus was changed. This function compensates for that behavior at the
cost of some compatibility with odd SSIDs that may legitimately have trailing
NULLs, even though that is functionally pointless.
Given a set of device capabilities, and a desired security type to check
against, determines whether the combination of device, desired security
type, and AP capabilities intersect.
NOTE: this function cannot handle checking security for AP/Hotspot mode;
use nm_utils_ap_mode_security_valid() instead.
if %TRUE, the VF index will be omitted from output string
Returns string
utils_ssid_to_utf8
utils_ssid_to_utf8(ssid: Uint8Array): string
Wi-Fi SSIDs are byte arrays, they are not strings. Thus, an SSID may
contain embedded NULLs and other unprintable characters. Often it is
useful to print the SSID out for debugging purposes, but that should be the
only use of this function. Do not use this function for any persistent
storage of the SSID, since the printable SSID returned from this function
cannot be converted back into the real SSID of the access point.
This function does almost everything humanly possible to convert the input
into a printable UTF-8 string, using roughly the following procedure:
if the input data is already UTF-8 safe, no conversion is performed
attempts to get the current system language from the LANG environment
variable, and depending on the language, uses a table of alternative
encodings to try. For example, if LANG=hu_HU, the table may first try
the ISO-8859-2 encoding, and if that fails, try the Windows-1250 encoding.
If all fallback encodings fail, replaces non-UTF-8 characters with '?'.
If the system language was unable to be determined, falls back to the
ISO-8859-1 encoding, then to the Windows-1251 encoding.
If step 3 fails, replaces non-UTF-8 characters with '?'.
Again, this function should be used for debugging and display purposes
only.
Converts strength into a 4-character-wide graphical representation of
strength suitable for printing to stdout.
Previous versions used to take a guess at the terminal type and possibly
return a wide UTF-8 encoded string. Now it always returns a 7-bit
clean strings of one to 0 to 4 asterisks. Users that actually need
the functionality are encouraged to make their implementations instead.
Load the shared library plugin_name and create a new
#NMVpnEditorPlugin instance via the #NMVpnEditorPluginFactory
function.
This is similar to nm_vpn_editor_plugin_load_from_file(), but
it does no validation of the plugin name, instead passes it directly
to dlopen(). If you have the full path to a plugin file,
nm_vpn_editor_plugin_load_from_file() is preferred.
Parameters
plugin_name: string
The name of the shared library to load. This path will be directly passed to dlopen() without further checks.
check_service: string
if not-null, check that the loaded plugin advertises the given service.
Load the shared library plugin_name and create a new
#NMVpnEditorPlugin instance via the #NMVpnEditorPluginFactory
function.
If plugin_name is not an absolute path name, it assumes the file
is in the plugin directory of NetworkManager. In any case, the call
will do certain checks on the file before passing it to dlopen.
A consequence for that is, that you cannot omit the ".so" suffix
as you could for nm_vpn_editor_plugin_load().
Parameters
plugin_name: string
The path or name of the shared library to load. The path must either be an absolute filename to an existing file. Alternatively, it can be the name (without path) of a library in the plugin directory of NetworkManager.
check_service: string
if not-null, check that the loaded plugin advertises the given service.
check_owner: number
if non-negative, check whether the file is owned by UID check_owner or by root. In this case also check that the file is not writable by anybody else.
Evaluates to the major version number of NetworkManager which this source is compiled against.