Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GI.NM.Functions
Contents
- Methods
- connWireguardImport
- ethtoolOptnameIsChannels
- ethtoolOptnameIsCoalesce
- ethtoolOptnameIsEee
- ethtoolOptnameIsFeature
- ethtoolOptnameIsPause
- ethtoolOptnameIsRing
- keyfileRead
- keyfileWrite
- utilsApModeSecurityValid
- utilsBase64secretDecode
- utilsBin2hexstr
- utilsBondModeIntToString
- utilsBondModeStringToInt
- utilsCheckVirtualDeviceCompatibility
- utilsEnsureGtypes
- utilsEnumFromStr
- utilsEnumGetValues
- utilsEnumToStr
- utilsEscapeSsid
- utilsFileIsCertificate
- utilsFileIsPkcs12
- utilsFileIsPrivateKey
- utilsFileSearchInPaths
- utilsGetTimestampMsec
- utilsHexstr2bin
- utilsHwaddrAtoba
- utilsHwaddrAton
- utilsHwaddrCanonical
- utilsHwaddrLen
- utilsHwaddrMatches
- utilsHwaddrNtoa
- utilsHwaddrValid
- utilsIfaceValidName
- utilsIp4AddressesFromVariant
- utilsIp4AddressesToVariant
- utilsIp4DnsFromVariant
- utilsIp4DnsToVariant
- utilsIp4GetDefaultPrefix
- utilsIp4NetmaskToPrefix
- utilsIp4PrefixToNetmask
- utilsIp4RoutesFromVariant
- utilsIp4RoutesToVariant
- utilsIp6AddressesFromVariant
- utilsIp6AddressesToVariant
- utilsIp6DnsFromVariant
- utilsIp6DnsToVariant
- utilsIp6RoutesFromVariant
- utilsIp6RoutesToVariant
- utilsIpAddressesFromVariant
- utilsIpAddressesToVariant
- utilsIpRoutesFromVariant
- utilsIpRoutesToVariant
- utilsIpaddrValid
- utilsIsEmptySsid
- utilsIsJsonObject
- utilsIsUuid
- utilsIsValidIfaceName
- utilsPrint
- utilsSameSsid
- utilsSecurityValid
- utilsSriovVfFromStr
- utilsSriovVfToStr
- utilsSsidToUtf8
- utilsTcActionFromStr
- utilsTcActionToStr
- utilsTcQdiscFromStr
- utilsTcQdiscToStr
- utilsTcTfilterFromStr
- utilsTcTfilterToStr
- utilsUuidGenerate
- utilsVersion
- utilsWepKeyValid
- utilsWifi2ghzFreqs
- utilsWifi5ghzFreqs
- utilsWifiChannelToFreq
- utilsWifiFindNextChannel
- utilsWifiFreqToChannel
- utilsWifiIsChannelValid
- utilsWifiStrengthBars
- utilsWpaPskValid
Description
Synopsis
- connWireguardImport :: (HasCallStack, MonadIO m) => Text -> m Connection
- ethtoolOptnameIsChannels :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- ethtoolOptnameIsCoalesce :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- ethtoolOptnameIsEee :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- ethtoolOptnameIsFeature :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- ethtoolOptnameIsPause :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- ethtoolOptnameIsRing :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- keyfileRead :: (HasCallStack, MonadIO m) => KeyFile -> Text -> [KeyfileHandlerFlags] -> Maybe KeyfileReadHandler -> m Connection
- keyfileWrite :: (HasCallStack, MonadIO m, IsConnection a) => a -> [KeyfileHandlerFlags] -> Maybe KeyfileWriteHandler -> m KeyFile
- utilsApModeSecurityValid :: (HasCallStack, MonadIO m) => UtilsSecurityType -> [DeviceWifiCapabilities] -> m Bool
- utilsBase64secretDecode :: (HasCallStack, MonadIO m) => Text -> CSize -> m (Bool, Word8)
- utilsBin2hexstr :: (HasCallStack, MonadIO m) => ByteString -> Int32 -> m Text
- utilsBondModeIntToString :: (HasCallStack, MonadIO m) => Int32 -> m Text
- utilsBondModeStringToInt :: (HasCallStack, MonadIO m) => Text -> m Int32
- utilsCheckVirtualDeviceCompatibility :: (HasCallStack, MonadIO m) => GType -> GType -> m Bool
- utilsEnsureGtypes :: (HasCallStack, MonadIO m) => m ()
- utilsEnumFromStr :: (HasCallStack, MonadIO m) => GType -> Text -> m (Bool, Int32, Maybe Text)
- utilsEnumGetValues :: (HasCallStack, MonadIO m) => GType -> Int32 -> Int32 -> m [Text]
- utilsEnumToStr :: (HasCallStack, MonadIO m) => GType -> Int32 -> m Text
- utilsEscapeSsid :: (HasCallStack, MonadIO m) => ByteString -> m Text
- utilsFileIsCertificate :: (HasCallStack, MonadIO m) => Text -> m Bool
- utilsFileIsPkcs12 :: (HasCallStack, MonadIO m) => Text -> m Bool
- utilsFileIsPrivateKey :: (HasCallStack, MonadIO m) => Text -> m (Bool, Bool)
- utilsFileSearchInPaths :: (HasCallStack, MonadIO m) => Text -> Maybe Text -> Maybe Text -> [FileTest] -> UtilsFileSearchInPathsPredicate -> m Text
- utilsGetTimestampMsec :: (HasCallStack, MonadIO m) => m Int64
- utilsHexstr2bin :: (HasCallStack, MonadIO m) => Text -> m Bytes
- utilsHwaddrAtoba :: (HasCallStack, MonadIO m) => Text -> CSize -> m ByteString
- utilsHwaddrAton :: (HasCallStack, MonadIO m) => Text -> ByteString -> m Word8
- utilsHwaddrCanonical :: (HasCallStack, MonadIO m) => Text -> Int64 -> m Text
- utilsHwaddrLen :: (HasCallStack, MonadIO m) => Int32 -> m CSize
- utilsHwaddrMatches :: (HasCallStack, MonadIO m) => Ptr () -> Int64 -> Ptr () -> Int64 -> m Bool
- utilsHwaddrNtoa :: (HasCallStack, MonadIO m) => ByteString -> m Text
- utilsHwaddrValid :: (HasCallStack, MonadIO m) => Text -> Int64 -> m Bool
- utilsIfaceValidName :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- utilsIp4AddressesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m ([IPAddress], Maybe Text)
- utilsIp4AddressesToVariant :: (HasCallStack, MonadIO m) => [IPAddress] -> Maybe Text -> m GVariant
- utilsIp4DnsFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m Text
- utilsIp4DnsToVariant :: (HasCallStack, MonadIO m) => Text -> m GVariant
- utilsIp4GetDefaultPrefix :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- utilsIp4NetmaskToPrefix :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- utilsIp4PrefixToNetmask :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- utilsIp4RoutesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m [IPRoute]
- utilsIp4RoutesToVariant :: (HasCallStack, MonadIO m) => [IPRoute] -> m GVariant
- utilsIp6AddressesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m ([IPAddress], Maybe Text)
- utilsIp6AddressesToVariant :: (HasCallStack, MonadIO m) => [IPAddress] -> Maybe Text -> m GVariant
- utilsIp6DnsFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m Text
- utilsIp6DnsToVariant :: (HasCallStack, MonadIO m) => Text -> m GVariant
- utilsIp6RoutesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> m [IPRoute]
- utilsIp6RoutesToVariant :: (HasCallStack, MonadIO m) => [IPRoute] -> m GVariant
- utilsIpAddressesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> Int32 -> m [IPAddress]
- utilsIpAddressesToVariant :: (HasCallStack, MonadIO m) => [IPAddress] -> m GVariant
- utilsIpRoutesFromVariant :: (HasCallStack, MonadIO m) => GVariant -> Int32 -> m [IPRoute]
- utilsIpRoutesToVariant :: (HasCallStack, MonadIO m) => [IPRoute] -> m GVariant
- utilsIpaddrValid :: (HasCallStack, MonadIO m) => Int32 -> Text -> m Bool
- utilsIsEmptySsid :: (HasCallStack, MonadIO m) => ByteString -> m Bool
- utilsIsJsonObject :: (HasCallStack, MonadIO m) => Text -> m ()
- utilsIsUuid :: (HasCallStack, MonadIO m) => Maybe Text -> m Bool
- utilsIsValidIfaceName :: (HasCallStack, MonadIO m) => Maybe Text -> m ()
- utilsPrint :: (HasCallStack, MonadIO m) => Int32 -> Text -> m ()
- utilsSameSsid :: (HasCallStack, MonadIO m) => ByteString -> ByteString -> Bool -> m Bool
- utilsSecurityValid :: (HasCallStack, MonadIO m) => UtilsSecurityType -> [DeviceWifiCapabilities] -> Bool -> Bool -> [NM80211ApFlags] -> [NM80211ApSecurityFlags] -> [NM80211ApSecurityFlags] -> m Bool
- utilsSriovVfFromStr :: (HasCallStack, MonadIO m) => Text -> m SriovVF
- utilsSriovVfToStr :: (HasCallStack, MonadIO m) => SriovVF -> Bool -> m Text
- utilsSsidToUtf8 :: (HasCallStack, MonadIO m) => ByteString -> m Text
- utilsTcActionFromStr :: (HasCallStack, MonadIO m) => Text -> m TCAction
- utilsTcActionToStr :: (HasCallStack, MonadIO m) => TCAction -> m Text
- utilsTcQdiscFromStr :: (HasCallStack, MonadIO m) => Text -> m TCQdisc
- utilsTcQdiscToStr :: (HasCallStack, MonadIO m) => TCQdisc -> m Text
- utilsTcTfilterFromStr :: (HasCallStack, MonadIO m) => Text -> m TCTfilter
- utilsTcTfilterToStr :: (HasCallStack, MonadIO m) => TCTfilter -> m Text
- utilsUuidGenerate :: (HasCallStack, MonadIO m) => m Text
- utilsVersion :: (HasCallStack, MonadIO m) => m Word32
- utilsWepKeyValid :: (HasCallStack, MonadIO m) => Text -> WepKeyType -> m Bool
- utilsWifi2ghzFreqs :: (HasCallStack, MonadIO m) => m Word32
- utilsWifi5ghzFreqs :: (HasCallStack, MonadIO m) => m Word32
- utilsWifiChannelToFreq :: (HasCallStack, MonadIO m) => Word32 -> Text -> m Word32
- utilsWifiFindNextChannel :: (HasCallStack, MonadIO m) => Word32 -> Int32 -> Text -> m Word32
- utilsWifiFreqToChannel :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- utilsWifiIsChannelValid :: (HasCallStack, MonadIO m) => Word32 -> Text -> m Bool
- utilsWifiStrengthBars :: (HasCallStack, MonadIO m) => Word8 -> m Text
- utilsWpaPskValid :: (HasCallStack, MonadIO m) => Text -> m Bool
Methods
connWireguardImport
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Connection | Returns: a new |
No description available in the introspection data.
Since: 1.40
ethtoolOptnameIsChannels
ethtoolOptnameIsChannels Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: |
Checks whether optname
is a valid option name for a channels setting.
Since: 1.46
ethtoolOptnameIsCoalesce
ethtoolOptnameIsCoalesce Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: |
Checks whether optname
is a valid option name for a coalesce setting.
Since: 1.26
ethtoolOptnameIsEee
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: |
Checks whether optname
is a valid option name for an eee setting.
Since: 1.46
ethtoolOptnameIsFeature
ethtoolOptnameIsFeature Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: Note that |
Checks whether optname
is a valid option name for an offload feature.
Since: 1.20
ethtoolOptnameIsPause
ethtoolOptnameIsPause Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: |
Checks whether optname
is a valid option name for a pause setting.
Since: 1.32
ethtoolOptnameIsRing
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: |
Checks whether optname
is a valid option name for a ring setting.
Since: 1.26
keyfileRead
Arguments
:: (HasCallStack, MonadIO m) | |
=> KeyFile |
|
-> Text |
|
-> [KeyfileHandlerFlags] |
|
-> Maybe KeyfileReadHandler |
|
-> m Connection | Returns: on success, returns the created connection. (Can throw |
Tries to create a NMConnection from a keyfile. The resulting keyfile is not normalized and might not even verify.
Since: 1.30
keyfileWrite
Arguments
:: (HasCallStack, MonadIO m, IsConnection a) | |
=> a |
|
-> [KeyfileHandlerFlags] |
|
-> Maybe KeyfileWriteHandler |
|
-> m KeyFile | Returns: a new |
connection
should verify as a valid profile according to
connectionVerify
. If it does not verify, the keyfile may
be incomplete and the parser may not be able to fully recreate
the original profile.
Since: 1.30
utilsApModeSecurityValid
utilsApModeSecurityValid Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> UtilsSecurityType |
|
-> [DeviceWifiCapabilities] |
|
-> m Bool | Returns: |
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.
utilsBase64secretDecode
utilsBase64secretDecode Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> CSize |
|
-> m (Bool, Word8) | Returns: |
No description available in the introspection data.
Since: 1.16
utilsBin2hexstr
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> Int32 |
|
-> m Text | Returns: the textual form of |
Converts the byte array src
into a hexadecimal string. If finalLen
is
greater than -1, the returned string is terminated at that index
(returned_string[final_len] == '\0'),
utilsBondModeIntToString
utilsBondModeIntToString Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> m Text | Returns: bonding mode string, or NULL on error |
Convert bonding mode from integer value to descriptive name. See https://www.kernel.org/doc/Documentation/networking/bonding.txt for available modes.
Since: 1.2
utilsBondModeStringToInt
utilsBondModeStringToInt Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Int32 | Returns: numeric bond mode, or -1 on error |
Convert bonding mode from string representation to numeric value.
See https://www.kernel.org/doc/Documentation/networking/bonding.txt for
available modes.
The mode
string can be either a descriptive name or a number (as string).
Since: 1.2
utilsCheckVirtualDeviceCompatibility
utilsCheckVirtualDeviceCompatibility Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> GType |
|
-> m Bool |
Determines if a connection of type virtualType
can (in the
general case) work with connections of type otherType
.
If virtualType
is NM_TYPE_SETTING_VLAN
, then this checks if
otherType
is a valid type for the parent of a VLAN.
If virtualType
is a "controller" type (eg, NM_TYPE_SETTING_BRIDGE
),
then this checks if otherType
is a valid type for a port of that
controller.
Note that even if this returns True
it is not guaranteed that
<emphasis>every</emphasis> connection of type otherType
is
compatible with virtualType
; it may depend on the exact
configuration of the two connections, or on the capabilities of an
underlying device driver.
utilsEnsureGtypes
utilsEnsureGtypes :: (HasCallStack, MonadIO m) => m () Source #
This ensures that all NMSetting GTypes are created. For example, after this call, g_type_from_name("NMSettingConnection") will work.
This cannot fail and does nothing if the type already exists.
Since: 1.42
utilsEnumFromStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Text |
|
-> m (Bool, Int32, Maybe Text) | Returns: |
Converts a string to the matching enum value.
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 errToken
.
Since: 1.2
utilsEnumGetValues
Arguments
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Int32 |
|
-> Int32 |
|
-> m [Text] | Returns: a NULL-terminated dynamically-allocated array of static strings
or |
Returns the list of possible values for a given enum.
Since: 1.2
utilsEnumToStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Int32 |
|
-> m Text | Returns: a newly allocated string or |
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.
Since: 1.2
utilsEscapeSsid
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> m Text | Returns: pointer to the escaped SSID, which uses an internal static buffer and will be overwritten by subsequent calls to this function |
Deprecated: (Since version 1.46)use utilsSsidToUtf8
or utilsBin2hexstr
.
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.
Warning: this function uses a static buffer. It is not thread-safe. Don't use this function.
utilsFileIsCertificate
utilsFileIsCertificate Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Bool | Returns: |
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.
utilsFileIsPkcs12
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Bool | Returns: |
Tests if filename
is a PKCS#<!-- -->12 file.
utilsFileIsPrivateKey
utilsFileIsPrivateKey Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Bool, Bool) | Returns: |
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.
utilsFileSearchInPaths
utilsFileSearchInPaths Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Maybe Text |
|
-> Maybe Text |
|
-> [FileTest] |
|
-> UtilsFileSearchInPathsPredicate |
|
-> m Text | Returns: the full path to the helper, if found, or |
Searches for a progname
file in a list of search paths
.
utilsGetTimestampMsec
utilsGetTimestampMsec Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Int64 | Returns: time in milliseconds |
Gets current time in milliseconds of CLOCK_BOOTTIME.
Since: 1.12
utilsHexstr2bin
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Bytes | Returns: the converted bytes, or |
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 ':'.
utilsHwaddrAtoba
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> CSize |
|
-> m ByteString | Returns: a new |
Parses asc
and converts it to binary form in a ByteArray
. See
utilsHwaddrAton
if you don't want a ByteArray
.
utilsHwaddrAton
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> ByteString |
|
-> m Word8 | Returns: |
Parses asc
and converts it to binary form in buffer
.
Bytes in asc
can be separated by colons (:), or hyphens (-), but not mixed.
utilsHwaddrCanonical
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Int64 |
|
-> m Text | Returns: the canonicalized address if |
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).
utilsHwaddrLen
Arguments
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> m CSize | Returns: the length or zero if the type is unrecognized. |
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 <literal>ARPHRD_ETHER</literal> or <literal>ARPHRD_INFINIBAND</literal>.
utilsHwaddrMatches
Arguments
:: (HasCallStack, MonadIO m) | |
=> Ptr () |
|
-> Int64 |
|
-> Ptr () |
|
-> Int64 |
|
-> m Bool | Returns: |
Generalized hardware address comparison function. Tests if hwaddr1
and
hwaddr2
"equal" (or more precisely, "equivalent"), with several advantages
over a simple memcmp()
:
- If
hwaddr1Len
orhwaddr2Len
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
orhwaddr2
isNothing
, it is treated instead as though it was a zero-filled bufferhwaddr1Len
orhwaddr2Len
bytes long. - If
hwaddr1
andhwaddr2
are InfiniBand hardware addresses (that is, if they are <literal>INFINIBAND_ALEN</literal> 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 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.)
utilsHwaddrNtoa
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> m Text | Returns: the textual form of |
Converts addr
to textual form.
utilsHwaddrValid
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Int64 |
|
-> m Bool | Returns: |
Parses asc
to see if it is a valid hardware address of the given
length.
utilsIfaceValidName
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: Before 1.20, this function did not accept |
Deprecated: (Since version 1.6)Use utilsIsValidIfaceName
instead, with better error reporting.
Validate the network interface name.
utilsIp4AddressesFromVariant
utilsIp4AddressesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m ([IPAddress], Maybe Text) |
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 PtrArray
of IPAddress
objects. The "gateway" field of
the first address (if set) will be returned in outGateway
; the "gateway" fields
of the other addresses are ignored. Note that invalid addresses are discarded
but the valid addresses are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp4AddressesToVariant
utilsIp4AddressesToVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> [IPAddress] |
|
-> Maybe Text |
|
-> m GVariant | Returns: a new floating |
Utility function to convert a PtrArray
of IPAddress
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-Nothing
). In all of the other addresses, that field will be 0.
utilsIp4DnsFromVariant
utilsIp4DnsFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m Text | Returns: a |
Utility function to convert a GVariant
of type 'au' representing a list of
IPv4 addresses into an array of IP address strings.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp4DnsToVariant
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m GVariant | Returns: a new floating |
Utility function to convert an array of IP address strings int a GVariant
of
type 'au' representing an array of IPv4 addresses.
utilsIp4GetDefaultPrefix
utilsIp4GetDefaultPrefix Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the default class prefix for the given IP |
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.
utilsIp4NetmaskToPrefix
utilsIp4NetmaskToPrefix Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the CIDR prefix represented by the netmask |
No description available in the introspection data.
utilsIp4PrefixToNetmask
utilsIp4PrefixToNetmask Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the netmask represented by the prefix, in network byte order |
No description available in the introspection data.
utilsIp4RoutesFromVariant
utilsIp4RoutesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m [IPRoute] |
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 PtrArray
of IPRoute
objects. Note that invalid routes
are discarded but the valid routes are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp4RoutesToVariant
utilsIp4RoutesToVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> [IPRoute] |
|
-> m GVariant | Returns: a new floating |
utilsIp6AddressesFromVariant
utilsIp6AddressesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m ([IPAddress], Maybe Text) |
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 PtrArray
of IPAddress
objects. The "gateway" field
of the first address (if set) will be returned in outGateway
; the "gateway"
fields of the other addresses are ignored. Note that invalid addresses are
discarded but the valid addresses are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp6AddressesToVariant
utilsIp6AddressesToVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> [IPAddress] |
|
-> Maybe Text |
|
-> m GVariant | Returns: a new floating |
Utility function to convert a PtrArray
of IPAddress
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-Nothing
). In all of the other addresses, that field will be
all 0s.
utilsIp6DnsFromVariant
utilsIp6DnsFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m Text | Returns: a |
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.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp6DnsToVariant
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m GVariant | Returns: a new floating |
Utility function to convert an array of IP address strings int a GVariant
of
type 'aay' representing an array of IPv6 addresses.
If a string cannot be parsed, it will be silently ignored.
utilsIp6RoutesFromVariant
utilsIp6RoutesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m [IPRoute] |
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 PtrArray
of IPRoute
objects. Note that invalid
routes are ignored but the valid ones are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
utilsIp6RoutesToVariant
utilsIpAddressesFromVariant
utilsIpAddressesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> Int32 |
|
-> m [IPAddress] |
Utility function to convert a GVariant
representing a list of new-style
NetworkManager IPv4 or IPv6 addresses (as described in the documentation for
utilsIpAddressesToVariant
) into a PtrArray
of IPAddress
objects. Note that invalid addresses are discarded but the valid addresses
are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
Since: 1.42
utilsIpAddressesToVariant
utilsIpAddressesToVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> [IPAddress] |
|
-> m GVariant | Returns: a new floating |
Utility function to convert a PtrArray
of IPAddress
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.
Since: 1.42
utilsIpRoutesFromVariant
utilsIpRoutesFromVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> Int32 |
|
-> m [IPRoute] |
Utility function to convert a GVariant
representing a list of new-style
NetworkManager IPv4 or IPv6 addresses (as described in the documentation for
utilsIpRoutesToVariant
) into a PtrArray
of IPRoute
objects.
Invalid routes are discarded but the valid routes are still returned.
Since 1.46, an empty list is returned if the variant type is not valid (before it was checked as assertion)
Since: 1.42
utilsIpRoutesToVariant
utilsIpRoutesToVariant Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> [IPRoute] |
|
-> m GVariant | Returns: a new floating |
Utility function to convert a PtrArray
of IPRoute
objects representing
IPv4 or IPv6 routes into a GVariant
of type 'aa{sv}' representing an array
of new-style NetworkManager IP routes. All routes will include "dest" (an IP
address string), "prefix" (an uint) and optionally "next-hop" (an IP address
string) and "metric" (an uint). Some routes may include additional attributes.
Note that invalid routes are discarded and only a warning is emitted, but the
valid routes are still returned.
Since: 1.42
utilsIpaddrValid
Arguments
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> Text |
|
-> m Bool |
Checks if ip
contains a valid IP address of the given family.
utilsIsEmptySsid
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> m Bool |
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.
utilsIsJsonObject
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m () | (Can throw |
No description available in the introspection data.
Since: 1.6
utilsIsUuid
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m Bool | Returns: In older versions, |
Deprecated: (Since version 1.32)older versions of NetworkManager had a wrongunderstanding of what makes a valid UUID. This function can thusaccept some inputs as valid, which in fact are not valid UUIDs.
Checks if str
is a UUID
utilsIsValidIfaceName
utilsIsValidIfaceName Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> m () | (Can throw |
Validate the network interface name.
This function is a 1:1 copy of the kernel's interface validation function in net/core/dev.c.
Since: 1.6
utilsPrint
Arguments
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> Text |
|
-> m () |
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 utilsPrint
, the same logging mechanisms can be used.
LIBNM_CLIENT_DEBUG is a list of keywords separated by commas. The keyword
"trace" enables printing messages of the lowest up to the highest severity.
Likewise, the severities "debug", "warn" ("warning") and "error" are honored
in similar way. Setting the flags "ERROR" or "WARN" ("WARNING") implies that
respective levels are enabled, but also are ERROR messages printed with
g_critical()
and WARN messages with g_warning()
. Together with G_DEBUG="fatal-warnings"
or G_DEBUG="fatal-critical" this can be used to abort the program on errors.
Note that all <error> messages imply an unexpected data on the D-Bus API
(due to a bug). <warn> also implies unexepected data, but that can happen
when using different versions of libnm and daemon. For testing, it is
good to turn these into assertions.
By default, messages are printed to stderr, unless LIBNM_CLIENT_DEBUG
contains "stdout" flag. Also, libnm honors LIBNM_CLIENT_DEBUG_FILE
environment. If this is set to a filename pattern (accepting "%p
" for the
process ID), then the debug log is written to that file instead of
stderr/stdout. With outputMode
zero, the same location will be written.
LIBNM_CLIENT_DEBUG_FILE is supported since 1.44. "ERROR", "WARN" and "WARNING" are supported since 1.46.
Since: 1.30
utilsSameSsid
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> ByteString |
|
-> Bool |
|
-> m Bool | Returns: |
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.
utilsSecurityValid
Arguments
:: (HasCallStack, MonadIO m) | |
=> UtilsSecurityType |
|
-> [DeviceWifiCapabilities] |
|
-> Bool |
|
-> Bool |
|
-> [NM80211ApFlags] |
|
-> [NM80211ApSecurityFlags] |
|
-> [NM80211ApSecurityFlags] |
|
-> m Bool | Returns: |
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 utilsApModeSecurityValid
instead.
utilsSriovVfFromStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m SriovVF | Returns: the virtual function object (Can throw |
Converts a string to a SR-IOV virtual function object.
Since: 1.14
utilsSriovVfToStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> SriovVF |
|
-> Bool |
|
-> m Text | Returns: a newly allocated string or |
Converts a SR-IOV virtual function object to its string representation.
Since: 1.14
utilsSsidToUtf8
Arguments
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> m Text | Returns: an allocated string containing a UTF-8
representation of the SSID, which must be freed by the caller using |
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:
1) if the input data is already UTF-8 safe, no conversion is performed 2) 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 '?'. 3) If the system language was unable to be determined, falls back to the ISO-8859-1 encoding, then to the Windows-1251 encoding. 4) If step 3 fails, replaces non-UTF-8 characters with '?'.
Again, this function should be used for debugging and display purposes _only_.
utilsTcActionFromStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m TCAction |
Parses the tc style string action representation of the queueing
discipline to a NMTCAction
instance. Supports a subset of the tc language.
Since: 1.12
utilsTcActionToStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> TCAction |
|
-> m Text |
Turns the NMTCAction
into a tc style string representation of the queueing
discipline.
Since: 1.12
utilsTcQdiscFromStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m TCQdisc |
Parses the tc style string qdisc representation of the queueing
discipline to a NMTCQdisc
instance. Supports a subset of the tc language.
Since: 1.12
utilsTcQdiscToStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> TCQdisc |
|
-> m Text |
Turns the NMTCQdisc
into a tc style string representation of the queueing
discipline.
Since: 1.12
utilsTcTfilterFromStr
utilsTcTfilterFromStr Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m TCTfilter |
Parses the tc style string tfilter representation of the queueing
discipline to a NMTCTfilter
instance. Supports a subset of the tc language.
Since: 1.12
utilsTcTfilterToStr
Arguments
:: (HasCallStack, MonadIO m) | |
=> TCTfilter |
|
-> m Text |
Turns the NMTCTfilter
into a tc style string representation of the queueing
discipline.
Since: 1.12
utilsUuidGenerate
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Text | Returns: a newly allocated UUID suitable for use as the |
No description available in the introspection data.
utilsVersion
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Word32 | Returns: the version ID of the libnm version. That is, the |
No description available in the introspection data.
Since: 1.6
utilsWepKeyValid
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> WepKeyType |
|
-> m Bool |
Checks if key
is a valid WEP key
utilsWifi2ghzFreqs
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Word32 | Returns: zero-terminated array of frequencies numbers (in MHz) |
Utility function to return 2.4 GHz Wi-Fi frequencies (802.11bg band).
Since: 1.2
utilsWifi5ghzFreqs
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Word32 | Returns: zero-terminated array of frequencies numbers (in MHz) |
Utility function to return 5 GHz Wi-Fi frequencies (802.11a band).
Since: 1.2
utilsWifiChannelToFreq
utilsWifiChannelToFreq Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> Text |
|
-> m Word32 | Returns: the frequency represented by the channel of the band, or -1 when the freq is invalid, or 0 when the band is invalid |
Utility function to translate a Wi-Fi channel to its corresponding frequency.
utilsWifiFindNextChannel
utilsWifiFindNextChannel Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> Int32 |
|
-> Text |
|
-> m Word32 | Returns: the next channel in the specified direction or 0 |
Utility function to find out next/previous Wi-Fi channel for a channel.
utilsWifiFreqToChannel
utilsWifiFreqToChannel Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the channel represented by the frequency or 0 |
Utility function to translate a Wi-Fi frequency to its corresponding channel.
utilsWifiIsChannelValid
utilsWifiIsChannelValid Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> Text |
|
-> m Bool |
Utility function to verify Wi-Fi channel validity.
utilsWifiStrengthBars
utilsWifiStrengthBars Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word8 |
|
-> m Text | Returns: the graphical representation of the access point strength |
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.
utilsWpaPskValid
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Bool |
Checks if psk
is a valid WPA PSK