Re: nm-tool showing default route



On Tue, 2008-06-03 at 08:46 +0200, Markus Becker wrote:
> Hi Dan,
> 
> below is a patch that shows the default route in nm-tool. Feel free to 
> modify it.

r3723, thanks!

Dan

> Markus
> 
> Index: test/nm-tool.c
> ===================================================================
> --- test/nm-tool.c	(revision 3715)
> +++ test/nm-tool.c	(working copy)
> @@ -198,11 +198,14 @@
>   detail_device (gpointer data, gpointer user_data)
>   {
>   	NMDevice *device = NM_DEVICE (data);
> +	NMClient *client = NM_CLIENT (user_data);
>   	char *tmp;
>   	NMDeviceState state;
>   	guint32 caps;
>   	guint32 speed;
>   	const GArray *array;
> +	const GPtrArray *connections;
> +	int j;
> 
>   	state = nm_device_get_state (device);
> 
> @@ -223,6 +226,21 @@
> 
>   	print_string ("State", get_dev_state_string (state));
> 
> +	connections = nm_client_get_active_connections (client);
> +	for (j = 0; connections && (j < connections->len); j++) {
> +		NMActiveConnection *candidate = g_ptr_array_index (connections, j);
> +		const GPtrArray *devices = nm_active_connection_get_devices (candidate);
> +		NMDevice *candidate_dev;
> +
> +		if (!devices || !devices->len)
> +			continue;
> +		candidate_dev = g_ptr_array_index (devices, 0);
> +
> +		if ( candidate_dev == device &&
> +		     nm_active_connection_get_default(candidate))
> +			print_string ("Route", "IPv4 Default Route");
> +	}
> +
>   	tmp = NULL;
>   	if (NM_IS_DEVICE_802_3_ETHERNET (device))
>   		tmp = g_strdup (nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device)));
> @@ -362,7 +380,7 @@
>   	}
> 
>   	devices = nm_client_get_devices (client);
> -	g_ptr_array_foreach ((GPtrArray *) devices, detail_device, NULL);
> +	g_ptr_array_foreach ((GPtrArray *) devices, detail_device, client);
> 
>   	g_object_unref (client);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]