1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/*
* Copyright (C) 2021 Canonical, Ltd.
* Author: Lukas Märdian <slyon@ubuntu.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdlib.h>
#include "types.h"
NETPLAN_PUBLIC NetplanState*
netplan_state_new();
NETPLAN_PUBLIC void
netplan_state_reset(NetplanState* np_state);
NETPLAN_PUBLIC void
netplan_state_clear(NetplanState** np_state);
NETPLAN_PUBLIC NetplanBackend
netplan_state_get_backend(const NetplanState* np_state);
NETPLAN_PUBLIC guint
netplan_state_get_netdefs_size(const NetplanState* np_state);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_state_get_netdef(const NetplanState* np_state, const char* id);
NETPLAN_PUBLIC gboolean
netplan_state_finish_nm_write(
const NetplanState* np_state,
const char* rootdir,
NetplanError** error);
NETPLAN_PUBLIC gboolean
netplan_state_finish_ovs_write(
const NetplanState* np_state,
const char* rootdir,
NetplanError** error);
NETPLAN_PUBLIC gboolean
netplan_state_finish_sriov_write(
const NetplanState* np_state,
const char* rootdir,
NetplanError** error);
/* Write the selected yaml file. All definitions that originate from this file,
* as well as those without any given origin, are written to it.
*/
NETPLAN_PUBLIC gboolean
netplan_state_write_yaml_file(
const NetplanState* np_state,
const char* filename,
const char* rootdir,
NetplanError** error);
/* Update all the YAML files that were used to create this state.
* The definitions without clear origin are written to @default_filename.
*/
NETPLAN_PUBLIC gboolean
netplan_state_update_yaml_hierarchy(
const NetplanState* np_state,
const char* default_filename,
const char* rootdir,
NetplanError** error);
/* Dump the whole yaml configuration into the given file, regardless of the origin
* of each definition.
*/
NETPLAN_PUBLIC gboolean
netplan_state_dump_yaml(
const NetplanState* np_state,
int output_fd,
NetplanError** error);
NETPLAN_PUBLIC gboolean
netplan_netdef_write_yaml(
const NetplanState* np_state,
const NetplanNetDefinition* netdef,
const char* rootdir,
NetplanError** error);
NETPLAN_PUBLIC ssize_t
netplan_netdef_get_filepath(const NetplanNetDefinition* netdef, char* out_buffer, size_t out_buffer_size);
NETPLAN_PUBLIC NetplanBackend
netplan_netdef_get_backend(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC NetplanDefType
netplan_netdef_get_type(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC ssize_t
netplan_netdef_get_id(const NetplanNetDefinition* netdef, char* out_buffer, size_t out_buffer_size);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_netdef_get_bridge_link(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_netdef_get_bond_link(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_netdef_get_peer_link(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_netdef_get_vlan_link(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC NetplanNetDefinition*
netplan_netdef_get_sriov_link(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC ssize_t
netplan_netdef_get_set_name(const NetplanNetDefinition* netdef, char* out_buffer, size_t out_buffer_size);
NETPLAN_PUBLIC gboolean
netplan_netdef_has_match(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC gboolean
netplan_netdef_match_interface(const NetplanNetDefinition* netdef, const char* name, const char* mac, const char* driver_name);
/********** Old API below this ***********/
NETPLAN_DEPRECATED NETPLAN_PUBLIC const char *
netplan_netdef_get_filename(const NetplanNetDefinition* netdef);
NETPLAN_PUBLIC void
write_netplan_conf(const NetplanNetDefinition* def, const char* rootdir);
|