diff --git a/ChangeLog b/ChangeLog index 6926a19cd1..26399d241f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2008-05-23 Dan Williams + + Patch from Benoit Boissinot + + * src/NetworkManagerSystem.c + - (nm_system_device_flush_ip4_addresses_with_iface): implement with + libnl + + * src/backends/NetworkManagerArch.c + src/backends/NetworkManagerDebian.c + src/backends/NetworkManagerFrugalware.c + src/backends/NetworkManagerGentoo.c + src/backends/NetworkManagerMandriva.c + src/backends/NetworkManagerPaldo.c + src/backends/NetworkManagerRedHat.c + src/backends/NetworkManagerSlackware.c + src/backends/NetworkManagerSuSE.c + - (nm_system_device_flush_ip4_addresses, + nm_system_device_flush_ip4_addresses_with_iface): remove + + * src/backends/NetworkManagerGeneric.c + - (nm_generic_device_flush_ip4_addresses, + nm_generic_device_flush_ip4_addresses_with_iface): remove + 2008-05-23 Dan Williams * src/supplicant-manager/nm-supplicant-settings-verify.c diff --git a/src/NetworkManagerSystem.c b/src/NetworkManagerSystem.c index 1287e57910..80acebc38a 100644 --- a/src/NetworkManagerSystem.c +++ b/src/NetworkManagerSystem.c @@ -654,3 +654,54 @@ out: rtnl_route_put (route); } +/* + * nm_system_device_flush_ip4_addresses + * + * Flush all network addresses associated with a network device + * + */ +void nm_system_device_flush_ip4_addresses (NMDevice *dev) +{ + g_return_if_fail (dev != NULL); + + nm_system_device_flush_ip4_addresses_with_iface (nm_device_get_iface (dev)); +} + + +/* + * nm_system_device_flush_ip4_addresses_with_iface + * + * Flush all network addresses associated with a network device + * + */ +void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) +{ + struct nl_handle *nlh = NULL; + struct nl_cache *addr_cache = NULL; + int iface_idx; + AddrCheckData check_data; + + g_return_if_fail (iface != NULL); + iface_idx = nm_netlink_iface_to_index (iface); + g_return_if_fail (iface_idx >= 0); + + nlh = nm_netlink_get_default_handle (); + g_return_if_fail (nlh != NULL); + + memset (&check_data, 0, sizeof (check_data)); + check_data.iface = iface; + check_data.nlh = nlh; + check_data.family = AF_INET; + check_data.ifindex = nm_netlink_iface_to_index (iface); + + addr_cache = rtnl_addr_alloc_cache (nlh); + if (!addr_cache) + return; + nl_cache_mngt_provide (addr_cache); + + /* Remove all IP addresses for a device */ + nl_cache_foreach (addr_cache, check_one_address, &check_data); + + nl_cache_free (addr_cache); +} + diff --git a/src/backends/NetworkManagerArch.c b/src/backends/NetworkManagerArch.c index f9cad1ee3d..a0462f5dba 100644 --- a/src/backends/NetworkManagerArch.c +++ b/src/backends/NetworkManagerArch.c @@ -89,29 +89,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface) nm_generic_device_flush_ip4_routes_with_iface (iface); } -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - /* * nm_system_device_setup_static_ip4_config * diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c index 7a8e483dae..51528f892b 100644 --- a/src/backends/NetworkManagerDebian.c +++ b/src/backends/NetworkManagerDebian.c @@ -78,29 +78,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface) nm_generic_device_flush_ip4_routes_with_iface (iface); } -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - /* * nm_system_enable_loopback * diff --git a/src/backends/NetworkManagerFrugalware.c b/src/backends/NetworkManagerFrugalware.c index 8d6ee0d7f2..2e72b69549 100644 --- a/src/backends/NetworkManagerFrugalware.c +++ b/src/backends/NetworkManagerFrugalware.c @@ -81,38 +81,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface) g_free (buf); } - -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - g_return_if_fail (dev != NULL); - - nm_system_device_flush_ip4_addresses_with_iface (nm_device_get_iface (dev)); -} - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - char *buf; - - g_return_if_fail (iface != NULL); - - /* Remove all IP addresses for a device */ - buf = g_strdup_printf ("/usr/sbin/ip -4 addr flush dev %s", iface); - nm_spawn_process (buf); - g_free (buf); -} - /* * nm_system_device_has_active_routes * diff --git a/src/backends/NetworkManagerGeneric.c b/src/backends/NetworkManagerGeneric.c index 8c0f194f7e..c16d2eea3d 100644 --- a/src/backends/NetworkManagerGeneric.c +++ b/src/backends/NetworkManagerGeneric.c @@ -82,38 +82,6 @@ void nm_generic_device_flush_ip4_routes_with_iface (const char *iface) g_free (buf); } -/* - * nm_generic_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_generic_device_flush_ip4_addresses (NMDevice *dev) -{ - g_return_if_fail (dev != NULL); - - nm_system_device_flush_ip4_addresses_with_iface (nm_device_get_iface (dev)); -} - - -/* - * nm_generic_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_generic_device_flush_ip4_addresses_with_iface (const char *iface) -{ - char *buf; - - g_return_if_fail (iface != NULL); - - /* Remove all IP addresses for a device */ - buf = g_strdup_printf (IP_BINARY_PATH" -4 addr flush dev %s", iface); - nm_spawn_process (buf); - g_free (buf); -} - /* * nm_generic_enable_loopback * diff --git a/src/backends/NetworkManagerGentoo.c b/src/backends/NetworkManagerGentoo.c index eec48480aa..a6ac548c6d 100644 --- a/src/backends/NetworkManagerGentoo.c +++ b/src/backends/NetworkManagerGentoo.c @@ -90,28 +90,6 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev) } -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - #if 0 /* Alert other computers of our new address */ temp_addr.s_addr = addr; diff --git a/src/backends/NetworkManagerMandriva.c b/src/backends/NetworkManagerMandriva.c index 31a05b79d8..9db21c89c8 100644 --- a/src/backends/NetworkManagerMandriva.c +++ b/src/backends/NetworkManagerMandriva.c @@ -88,31 +88,6 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev) return (FALSE); } - -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - - #if 0 /* Alert other computers of our new address */ temp_addr.s_addr = addr; diff --git a/src/backends/NetworkManagerPaldo.c b/src/backends/NetworkManagerPaldo.c index 5ea5287b22..c6f235222c 100644 --- a/src/backends/NetworkManagerPaldo.c +++ b/src/backends/NetworkManagerPaldo.c @@ -89,31 +89,6 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev) return (FALSE); } - -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - - /* * nm_system_enable_loopback * diff --git a/src/backends/NetworkManagerRedHat.c b/src/backends/NetworkManagerRedHat.c index 33908d72fd..f0f39217d3 100644 --- a/src/backends/NetworkManagerRedHat.c +++ b/src/backends/NetworkManagerRedHat.c @@ -87,30 +87,6 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev) } -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - - #if 0 /* Alert other computers of our new address */ temp_addr.s_addr = addr; diff --git a/src/backends/NetworkManagerSlackware.c b/src/backends/NetworkManagerSlackware.c index 3e2d3d5543..32ea6c0540 100644 --- a/src/backends/NetworkManagerSlackware.c +++ b/src/backends/NetworkManagerSlackware.c @@ -75,29 +75,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface) nm_generic_device_flush_ip4_routes_with_iface (iface); } - -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - /* * nm_system_device_has_active_routes * diff --git a/src/backends/NetworkManagerSuSE.c b/src/backends/NetworkManagerSuSE.c index 7af55a075f..303fb0afec 100644 --- a/src/backends/NetworkManagerSuSE.c +++ b/src/backends/NetworkManagerSuSE.c @@ -96,30 +96,6 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev) } -/* - * nm_system_device_flush_ip4_addresses - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses (NMDevice *dev) -{ - nm_generic_device_flush_ip4_addresses (dev); -} - - -/* - * nm_system_device_flush_ip4_addresses_with_iface - * - * Flush all network addresses associated with a network device - * - */ -void nm_system_device_flush_ip4_addresses_with_iface (const char *iface) -{ - nm_generic_device_flush_ip4_addresses_with_iface (iface); -} - - /* * nm_system_enable_loopback *