util.h#

A set of high-level helper functions that can be used when working with datastructures of the library.

For example, it can be used to initialize iterators or clear error structures.

Functions

NETPLAN_PUBLIC gboolean netplan_delete_connection (const char *id, const char *rootdir)

Parses YAML hierarchy from @rootdir, drops the configuration for @id from the state and re-generates the YAML files.

Parameters:
  • id -- The NetplanID for a specific configuration block of network interface(s)

  • rootdir -- The location where the YAML hierarchy is read from and written to.

Returns:

gboolean, Indicating success.

NETPLAN_PUBLIC gboolean netplan_generate (const char *rootdir)
NETPLAN_PUBLIC ssize_t netplan_get_id_from_nm_filepath (const char *filename, const char *ssid, char *out_buffer, size_t out_buf_size)

Extract the netplan netdef ID from a NetworkManager connection profile (keyfile), generated by netplan. Used by the NetworkManager YAML backend.

NETPLAN_PUBLIC ssize_t netplan_netdef_get_output_filename (const NetplanNetDefinition *netdef, const char *ssid, char *out_buffer, size_t out_buf_size)
NETPLAN_PUBLIC void netplan_error_clear (NetplanError **error)
NETPLAN_PUBLIC ssize_t netplan_error_message (NetplanError *error, char *buf, size_t buf_size)
NETPLAN_PUBLIC uint64_t netplan_error_code (NetplanError *error)
NETPLAN_PUBLIC void netplan_state_iterator_init (const NetplanState *np_state, NetplanStateIterator *iter)
NETPLAN_PUBLIC NetplanNetDefinition * netplan_state_iterator_next (NetplanStateIterator *iter)
NETPLAN_PUBLIC gboolean netplan_state_iterator_has_next (const NetplanStateIterator *iter)
NETPLAN_PUBLIC gboolean netplan_util_create_yaml_patch (const char *conf_obj_path, const char *obj_payload, int out_fd, NetplanError **error)

create a yaml patch from a “set expression”

A “set expression” here consists of a path formed of TAB-separated keys, indicating where in the YAML doc we want to make our changes, and a valid YAML expression that will be the payload to insert at that place. The result is a well-formed YAML document.

@conf_obj_path: TAB-separated YAML path @obj_payload: YAML expression @output_file: file path to write out the result document

NETPLAN_PUBLIC gboolean netplan_util_dump_yaml_subtree (const char *prefix, int input_fd, int output_fd, NetplanError **error)
NETPLAN_DEPRECATED NETPLAN_PUBLIC gchar * netplan_get_filename_by_id (const char *netdef_id, const char *rootdir)

Deprecated:

Use netplan_netdef_get_filepath() instead.

NETPLAN_DEPRECATED NETPLAN_PUBLIC gchar * netplan_get_id_from_nm_filename (const char *filename, const char *ssid)

Deprecated:

Use netplan_get_id_from_nm_filepath() instead.