diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-05-07 10:15:10 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2019-05-07 18:30:06 +0200 |
commit | 02e859e5930b890af52e4b7090bf863f01ff4995 (patch) | |
tree | 813388fa3e38d4e55001a259f6771015ccc3ac50 | |
parent | 2f4e80a8184d31e41a4bfb4fc89bba22bb5464a7 (diff) | |
download | NetworkManager-02e859e5930b890af52e4b7090bf863f01ff4995.tar.gz |
utils: add ifname argument to nm_utils_complete_generic()
It's a common thing to complete a connection with an interface name;
adding it to the common path is goint to save as a few tens of lines
later on.
-rw-r--r-- | src/NetworkManagerUtils.c | 12 | ||||
-rw-r--r-- | src/NetworkManagerUtils.h | 1 | ||||
-rw-r--r-- | src/devices/adsl/nm-device-adsl.c | 1 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-6lowpan.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-bond.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-bridge.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-dummy.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-infiniband.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-ip-tunnel.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-macvlan.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-tun.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-vxlan.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-wpan.c | 1 | ||||
-rw-r--r-- | src/devices/team/nm-device-team.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-iwd.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-olpc-mesh.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi-p2p.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 1 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 2 | ||||
-rw-r--r-- | src/nm-manager.c | 1 |
23 files changed, 31 insertions, 4 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 13cb1daedb..c2621fbf19 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -249,13 +249,15 @@ nm_utils_complete_generic (NMPlatform *platform, const char *preferred_id, const char *fallback_id_prefix, const char *ifname_prefix, + const char *ifname, gboolean default_enable_ipv6) { NMSettingConnection *s_con; - char *id, *ifname; + char *id, *generated_ifname; GHashTable *parameters; g_assert (fallback_id_prefix); + g_return_if_fail (ifname_prefix == NULL || ifname == NULL); s_con = nm_connection_get_setting_connection (connection); if (!s_con) { @@ -278,10 +280,12 @@ nm_utils_complete_generic (NMPlatform *platform, } /* Add an interface name, if requested */ - if (ifname_prefix && !nm_setting_connection_get_interface_name (s_con)) { - ifname = get_new_connection_ifname (platform, existing_connections, ifname_prefix); + if (ifname) { g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, NULL); - g_free (ifname); + } else if (ifname_prefix && !nm_setting_connection_get_interface_name (s_con)) { + generated_ifname = get_new_connection_ifname (platform, existing_connections, ifname_prefix); + g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, generated_ifname, NULL); + g_free (generated_ifname); } /* Normalize */ diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index 2b1f5ed891..c82b2cb161 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -41,6 +41,7 @@ void nm_utils_complete_generic (NMPlatform *platform, const char *preferred_id, const char *fallback_id_prefix, const char *ifname_prefix, + const char *ifname, gboolean default_enable_ipv6); typedef gboolean (NMUtilsMatchFilterFunc) (NMConnection *connection, gpointer user_data); diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index b3b87dc7e9..ef1b467b78 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -131,6 +131,7 @@ complete_connection (NMDevice *device, NULL, _("ADSL connection"), NULL, + NULL, FALSE); /* No IPv6 yet by default */ return TRUE; } diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index e79251ced3..1ea9589b60 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -341,6 +341,7 @@ complete_connection (NMDevice *device, preferred, fallback_prefix, NULL, + NULL, is_dun ? FALSE : TRUE); /* No IPv6 yet for DUN */ setting_bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt); diff --git a/src/devices/nm-device-6lowpan.c b/src/devices/nm-device-6lowpan.c index 4010374717..7a27943139 100644 --- a/src/devices/nm-device-6lowpan.c +++ b/src/devices/nm-device-6lowpan.c @@ -190,6 +190,7 @@ complete_connection (NMDevice *device, NULL, _("6LOWPAN connection"), NULL, + NULL, TRUE); s_6lowpan = NM_SETTING_6LOWPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_6LOWPAN)); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 37159fca8c..b180b0cd67 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -70,6 +70,7 @@ complete_connection (NMDevice *device, NULL, _("Bond connection"), "bond", + NULL, TRUE); s_bond = nm_connection_get_setting_bond (connection); diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 4275af912a..00fbf822e4 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -153,6 +153,7 @@ complete_connection (NMDevice *device, NULL, _("Bridge connection"), "bridge", + NULL, TRUE); s_bridge = nm_connection_get_setting_bridge (connection); diff --git a/src/devices/nm-device-dummy.c b/src/devices/nm-device-dummy.c index 47a45342d8..23240c0338 100644 --- a/src/devices/nm-device-dummy.c +++ b/src/devices/nm-device-dummy.c @@ -66,6 +66,7 @@ complete_connection (NMDevice *device, NULL, _("Dummy connection"), NULL, + NULL, TRUE); s_dummy = nm_connection_get_setting_dummy (connection); diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index e845e592d3..ad7066113e 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1411,6 +1411,7 @@ complete_connection (NMDevice *device, NULL, s_pppoe ? _("PPPoE connection") : _("Wired connection"), NULL, + NULL, s_pppoe ? FALSE : TRUE); /* No IPv6 by default yet for PPPoE */ s_wired = nm_connection_get_setting_wired (connection); diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index d4bbc163d9..b19b7c4c95 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -169,6 +169,7 @@ complete_connection (NMDevice *device, NULL, _("InfiniBand connection"), NULL, + NULL, TRUE); s_infiniband = nm_connection_get_setting_infiniband (connection); diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 9627594748..f5de244f5c 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -421,6 +421,7 @@ complete_connection (NMDevice *device, NULL, _("IP tunnel connection"), NULL, + NULL, TRUE); s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection); diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index aa2a0ac05f..df791ea538 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -364,6 +364,7 @@ complete_connection (NMDevice *device, NULL, _("MACVLAN connection"), NULL, + NULL, TRUE); s_macvlan = nm_connection_get_setting_macvlan (connection); diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 90360c9ea1..07908b5dad 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -156,6 +156,7 @@ complete_connection (NMDevice *device, NULL, _("TUN connection"), NULL, + NULL, TRUE); s_tun = nm_connection_get_setting_tun (connection); diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index ace6a24bdb..72f3b40681 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -399,6 +399,7 @@ complete_connection (NMDevice *device, NULL, _("VLAN connection"), NULL, + NULL, TRUE); s_vlan = nm_connection_get_setting_vlan (connection); diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index fc73c09975..248d549f44 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -368,6 +368,7 @@ complete_connection (NMDevice *device, NULL, _("VXLAN connection"), NULL, + NULL, TRUE); s_vxlan = nm_connection_get_setting_vxlan (connection); diff --git a/src/devices/nm-device-wpan.c b/src/devices/nm-device-wpan.c index cdfd1f70aa..882344121d 100644 --- a/src/devices/nm-device-wpan.c +++ b/src/devices/nm-device-wpan.c @@ -67,6 +67,7 @@ complete_connection (NMDevice *device, NULL, _("WPAN connection"), NULL, + NULL, TRUE); s_wpan = NM_SETTING_WPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_WPAN)); diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 287f4d1b18..69227fa30a 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -101,6 +101,7 @@ complete_connection (NMDevice *device, NULL, _("Team connection"), "team", + NULL, TRUE); s_team = nm_connection_get_setting_team (connection); diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c index 45e50235f4..1a8e458902 100644 --- a/src/devices/wifi/nm-device-iwd.c +++ b/src/devices/wifi/nm-device-iwd.c @@ -874,6 +874,7 @@ complete_connection (NMDevice *device, ssid_utf8, ssid_utf8, NULL, + NULL, TRUE); perm_hw_addr = nm_device_get_permanent_hw_address (device); diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 1172a61337..ec9a5fe8cc 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -133,6 +133,7 @@ complete_connection (NMDevice *device, NULL, _("Mesh"), NULL, + NULL, FALSE); /* No IPv6 by default */ return TRUE; diff --git a/src/devices/wifi/nm-device-wifi-p2p.c b/src/devices/wifi/nm-device-wifi-p2p.c index 8381ebc769..c5826e24ae 100644 --- a/src/devices/wifi/nm-device-wifi-p2p.c +++ b/src/devices/wifi/nm-device-wifi-p2p.c @@ -331,6 +331,7 @@ complete_connection (NMDevice *device, setting_name, setting_name, NULL, + NULL, TRUE); return TRUE; diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 7aa5445e9c..680fd5d8c0 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -906,6 +906,7 @@ complete_connection (NMDevice *device, ssid_utf8, ssid_utf8, NULL, + NULL, TRUE); if (hidden) diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index b63440c2e8..eeca8249d2 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -700,6 +700,7 @@ complete_connection (NMModem *modem, NULL, _("GSM connection"), NULL, + NULL, FALSE); /* No IPv6 yet by default */ return TRUE; @@ -724,6 +725,7 @@ complete_connection (NMModem *modem, NULL, _("CDMA connection"), NULL, + NULL, FALSE); /* No IPv6 yet by default */ return TRUE; diff --git a/src/nm-manager.c b/src/nm-manager.c index 3622a0a5ad..31f77d491f 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -5538,6 +5538,7 @@ impl_manager_add_and_activate_connection (NMDBusObject *obj, NULL, _("VPN connection"), NULL, + NULL, FALSE); /* No IPv6 by default for now */ } else { conns = nm_settings_connections_array_to_connections (nm_settings_get_connections (priv->settings, NULL), -1); |