diff options
author | Thomas Haller <thaller@redhat.com> | 2019-12-31 02:54:07 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-09 10:42:31 +0100 |
commit | 9763d9f8a969cd4d4b210abf4028d6ee263e2287 (patch) | |
tree | fb5ecf46aa6f88d4f4618cd9f553a5f46f9b15a8 /src | |
parent | 4a743aba651a2234c502d7d468413494e343d6e2 (diff) | |
download | NetworkManager-9763d9f8a969cd4d4b210abf4028d6ee263e2287.tar.gz |
platform: move special link-add functions to header
These are thin abstractions over nm_platform_link_add(). Move them to
the header.
Diffstat (limited to 'src')
-rw-r--r-- | src/platform/nm-platform.c | 87 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 64 |
2 files changed, 60 insertions, 91 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 833ed63904..1e8e5514f1 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -1167,7 +1167,7 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, c * * Returns: the negative nm-error on failure. */ -static int +int nm_platform_link_add (NMPlatform *self, NMLinkType type, const char *name, @@ -1217,31 +1217,6 @@ nm_platform_link_add (NMPlatform *self, return klass->link_add (self, type, name, address, address_len, extra_data, out_link); } -int -nm_platform_link_veth_add (NMPlatform *self, - const char *name, - const char *peer, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_VETH, name, NULL, 0, peer, out_link); -} - -/** - * nm_platform_link_dummy_add: - * @self: platform instance - * @name: New interface name - * @out_link: on success, the link object - * - * Create a software ethernet-like interface - */ -int -nm_platform_link_dummy_add (NMPlatform *self, - const char *name, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_DUMMY, name, NULL, 0, NULL, out_link); -} - /** * nm_platform_link_delete: * @self: platform instance @@ -2263,14 +2238,6 @@ NM_UTILS_FLAGS2STR_DEFINE_STATIC (_wireguard_change_peer_flags_to_string, NMPlat ); int -nm_platform_link_wireguard_add (NMPlatform *self, - const char *name, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_WIREGUARD, name, NULL, 0, NULL, out_link); -} - -int nm_platform_link_wireguard_change (NMPlatform *self, int ifindex, const NMPlatformLnkWireGuard *lnk_wireguard, @@ -2329,58 +2296,6 @@ nm_platform_link_wireguard_change (NMPlatform *self, /*****************************************************************************/ /** - * nm_platform_link_bridge_add: - * @self: platform instance - * @name: New interface name - * @address: (allow-none): set the mac address of the new bridge - * @address_len: the length of the @address - * @out_link: on success, the link object - * - * Create a software bridge. - */ -int -nm_platform_link_bridge_add (NMPlatform *self, - const char *name, - const void *address, - size_t address_len, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_BRIDGE, name, address, address_len, NULL, out_link); -} - -/** - * nm_platform_link_bond_add: - * @self: platform instance - * @name: New interface name - * @out_link: on success, the link object - * - * Create a software bonding device. - */ -int -nm_platform_link_bond_add (NMPlatform *self, - const char *name, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_BOND, name, NULL, 0, NULL, out_link); -} - -/** - * nm_platform_link_team_add: - * @self: platform instance - * @name: New interface name - * @out_link: on success, the link object - * - * Create a software teaming device. - */ -int -nm_platform_link_team_add (NMPlatform *self, - const char *name, - const NMPlatformLink **out_link) -{ - return nm_platform_link_add (self, NM_LINK_TYPE_TEAM, name, NULL, 0, NULL, out_link); -} - -/** * nm_platform_link_vlan_add: * @self: platform instance * @name: New interface name diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 7850aa9563..05fd164fbe 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -1363,11 +1363,65 @@ const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const ch const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length); GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name); -int nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); -int nm_platform_link_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link); -int nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); -int nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); -int nm_platform_link_veth_add (NMPlatform *self, const char *name, const char *peer, const NMPlatformLink **out_link); + +int nm_platform_link_add (NMPlatform *self, + NMLinkType type, + const char *name, + const void *address, + size_t address_len, + gconstpointer extra_data, + const NMPlatformLink **out_link); + +static inline int +nm_platform_link_veth_add (NMPlatform *self, + const char *name, + const char *peer, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_VETH, name, NULL, 0, peer, out_link); +} + +static inline int +nm_platform_link_dummy_add (NMPlatform *self, + const char *name, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_DUMMY, name, NULL, 0, NULL, out_link); +} + +static inline int +nm_platform_link_bridge_add (NMPlatform *self, + const char *name, + const void *address, + size_t address_len, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_BRIDGE, name, address, address_len, NULL, out_link); +} + +static inline int +nm_platform_link_bond_add (NMPlatform *self, + const char *name, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_BOND, name, NULL, 0, NULL, out_link); +} + +static inline int +nm_platform_link_team_add (NMPlatform *self, + const char *name, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_TEAM, name, NULL, 0, NULL, out_link); +} + +static inline int +nm_platform_link_wireguard_add (NMPlatform *self, + const char *name, + const NMPlatformLink **out_link) +{ + return nm_platform_link_add (self, NM_LINK_TYPE_WIREGUARD, name, NULL, 0, NULL, out_link); +} gboolean nm_platform_link_delete (NMPlatform *self, int ifindex); |