netdef.h¶
Functions for manipulating NetplanNetDefinition objects and querying properties of individual Netplan IDs.
Functions
-
ssize_t netplan_netdef_get_output_filename(const NetplanNetDefinition *netdef, const char *ssid, char *out_buffer, size_t out_buf_size)¶
Get the full path that a NetplanNetDefinition will be written to by its backend renderer.
Copies a
NUL
-terminated string into a sizedout_buffer
. If the buffer is too small, its content is notNUL
-terminated.Note
Used by the NetworkManager YAML backend but also applicable to the systemd-networkd renderer.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
ssid -- [in] Wi-Fi SSID of this connection, or
NULL
out_buffer -- [out] A pre-allocated buffer to write the output string into, owned by the caller
out_buf_size -- [in] The maximum size (in bytes) available for
out_buffer
- Returns:
The size of the copied string, including the final
NUL
character. If the buffer is too small, returns NETPLAN_BUFFER_TOO_SMALL instead.
-
ssize_t netplan_netdef_get_filepath(const NetplanNetDefinition *netdef, char *out_buffer, size_t out_buffer_size)¶
Get the origin filepath of a given NetplanNetDefinition.
Copies a
NUL
-terminated string into a sizedout_buffer
. If the buffer is too small, its content is notNUL
-terminated.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
out_buffer -- [out] A pre-allocated buffer to write the output string into, owned by the caller
out_buffer_size -- [in] The maximum size (in bytes) available for
out_buffer
- Returns:
The size of the copied string, including the final
NUL
character. If the buffer is too small, returns NETPLAN_BUFFER_TOO_SMALL instead.
-
NetplanBackend netplan_netdef_get_backend(const NetplanNetDefinition *netdef)¶
Get the specific NetplanBackend defined for this NetplanNetDefinition.
- Parameters:
np_state -- [in] The NetplanState to query
- Returns:
Enumeration value, specifiying the NetplanBackend
-
NetplanDefType netplan_netdef_get_type(const NetplanNetDefinition *netdef)¶
Get the interface type for a given NetplanNetDefinition.
- Parameters:
np_state -- [in] The NetplanState to query
- Returns:
Enumeration value of NetplanDefType, specifiying the interface type
-
ssize_t netplan_netdef_get_id(const NetplanNetDefinition *netdef, char *out_buffer, size_t out_buffer_size)¶
Get the Netplan ID of a given NetplanNetDefinition.
Copies a
NUL
-terminated string into a sizedout_buffer
. If the buffer is too small, its content is notNUL
-terminated.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
out_buffer -- [out] A pre-allocated buffer to write the output string into, owned by the caller
out_buffer_size -- [in] The maximum size (in bytes) available for
out_buffer
- Returns:
The size of the copied string, including the final
NUL
character. If the buffer is too small, returns NETPLAN_BUFFER_TOO_SMALL instead.
-
NetplanNetDefinition *netplan_netdef_get_bridge_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the parent-child relationship between bridged interfaces.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the parent of
netdef
-
NetplanNetDefinition *netplan_netdef_get_bond_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the parent-child relationship between bonded interfaces.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the parent of
netdef
-
NetplanNetDefinition *netplan_netdef_get_peer_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the peer relationship between veth or Open vSwitch interfaces.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the peer of
netdef
-
NetplanNetDefinition *netplan_netdef_get_vlan_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the parent-child relationship of VLAN interfaces.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the parent of
netdef
-
NetplanNetDefinition *netplan_netdef_get_sriov_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the parent-child relationship of SR-IOV virtual functions.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the physical function of
netdef
-
NetplanNetDefinition *netplan_netdef_get_vrf_link(const NetplanNetDefinition *netdef)¶
Get a reference to a linked NetplanNetDefinition for a given
netdef
.This defines the parent-child relationship of VRF interfaces.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Reference to the parent of
netdef
-
ssize_t netplan_netdef_get_set_name(const NetplanNetDefinition *netdef, char *out_buffer, size_t out_buffer_size)¶
Get the
set-name
setting of a given NetplanNetDefinition.Copies a
NUL
-terminated string into a sizedout_buffer
. If the buffer is too small, its content is notNUL
-terminated.Note
This is unrelated to the
match.name
setting.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
out_buffer -- [out] A pre-allocated buffer to write the output string into, owned by the caller
out_buffer_size -- [in] The maximum size (in bytes) available for
out_buffer
- Returns:
The size of the copied string, including the final
NUL
character. If the buffer is too small, returns NETPLAN_BUFFER_TOO_SMALL instead.
-
gboolean netplan_netdef_has_match(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for a
match
stanza in its configuration.In the absence of a
match
stanza, the Netplan ID can be considered to be the interface name of a single interface. Otherwise, it could match multiple interfaces.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
uses custom interface matching rules
-
gboolean netplan_netdef_match_interface(const NetplanNetDefinition *netdef, const char *name, const char *mac, const char *driver_name)¶
Check if a NetplanNetDefinition matches on given interface parameters.
If defined in
netdef
, calculate if it would match on givenmac
ANDname
ANDdriver_name
parameters.Note
Matching a single driver out of a list given in the YAML configuration is enough to satisfy the condition.
- Parameters:
netdef -- [in] The NetplanNetDefinition to query
name -- [in] The interface name match, optionally using shell wildcard patterns (
fnmatch()
)mac -- [in] The exact, case insensitive match on the interface MAC address
driver_name -- [in] The driver match, optionally using shell wildcard patterns (
fnmatch()
)
- Returns:
Indication if
netdef
uses custom interface matching rules
-
gboolean netplan_netdef_get_dhcp4(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for the value of its
dhcp4
setting.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
is configured to enable DHCP for IPv4
-
gboolean netplan_netdef_get_dhcp6(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for the value of its
dhcp6
setting.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
is configured to enable DHCP for IPv6
-
gboolean netplan_netdef_get_link_local_ipv4(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for the value of its
link-local
setting for IPv4.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
is configured to enable the link-local address for IPv4
-
gboolean netplan_netdef_get_link_local_ipv6(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for the value of its
link-local
setting for IPv6.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
is configured to enable the link-local address for IPv6
-
int netplan_netdef_get_accept_ra(const NetplanNetDefinition *netdef)¶
Query a NetplanNetDefinition for the value of its
accept-ra
setting.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
- Returns:
Indication if
netdef
is configured to accept Router Advertisements. Possible values are: 0) not set (will use kernel or back end defaults), 1) enabled and 2) disabled.
-
ssize_t netplan_netdef_get_macaddress(const NetplanNetDefinition *netdef, char *out_buffer, size_t out_buffer_size)¶
Get the
macaddress
setting of a given NetplanNetDefinition.Copies a
NUL
-terminated string into a sizedout_buffer
. If the buffer is too small, its content is notNUL
-terminated.Note
This is unrelated to the
match.macaddress
setting.- Parameters:
netdef -- [in] The NetplanNetDefinition to query
out_buffer -- [out] A pre-allocated buffer to write the output string into, owned by the caller
out_buffer_size -- [in] The maximum size (in bytes) available for
out_buffer
- Returns:
The size of the copied string, including the final
NUL
character. If the buffer is too small, returns NETPLAN_BUFFER_TOO_SMALL instead.