[glib] Whitespace fixes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Whitespace fixes
- Date: Sun, 11 Dec 2011 02:47:09 +0000 (UTC)
commit 2d6d127c96de7317c6364ff7abfb29475e644df2
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 10 21:46:13 2011 -0500
Whitespace fixes
And add some missing since tags.
gio/gnetworkmonitor.c | 66 +++++++-------
gio/gnetworkmonitorbase.c | 166 +++++++++++++++++----------------
gio/gnetworkmonitornetlink.c | 210 +++++++++++++++++++++---------------------
3 files changed, 223 insertions(+), 219 deletions(-)
---
diff --git a/gio/gnetworkmonitor.c b/gio/gnetworkmonitor.c
index 33e9704..a997b85 100644
--- a/gio/gnetworkmonitor.c
+++ b/gio/gnetworkmonitor.c
@@ -47,7 +47,7 @@
*/
G_DEFINE_INTERFACE_WITH_CODE (GNetworkMonitor, g_network_monitor, G_TYPE_OBJECT,
- g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_INITABLE);)
+ g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_INITABLE);)
enum {
@@ -70,8 +70,8 @@ GNetworkMonitor *
g_network_monitor_get_default (void)
{
return _g_io_module_get_default (G_NETWORK_MONITOR_EXTENSION_POINT_NAME,
- "GIO_USE_NETWORK_MONITOR",
- NULL);
+ "GIO_USE_NETWORK_MONITOR",
+ NULL);
}
/**
@@ -127,9 +127,9 @@ g_network_monitor_get_network_available (GNetworkMonitor *monitor)
*/
gboolean
g_network_monitor_can_reach (GNetworkMonitor *monitor,
- GSocketConnectable *connectable,
- GCancellable *cancellable,
- GError **error)
+ GSocketConnectable *connectable,
+ GCancellable *cancellable,
+ GError **error)
{
GNetworkMonitorInterface *iface;
@@ -139,17 +139,17 @@ g_network_monitor_can_reach (GNetworkMonitor *monitor,
static void
g_network_monitor_real_can_reach_async (GNetworkMonitor *monitor,
- GSocketConnectable *connectable,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GSocketConnectable *connectable,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
simple = g_simple_async_result_new (G_OBJECT (monitor),
- callback, user_data,
- g_network_monitor_real_can_reach_async);
+ callback, user_data,
+ g_network_monitor_real_can_reach_async);
if (g_network_monitor_can_reach (monitor, connectable, cancellable, &error))
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
else
@@ -160,10 +160,10 @@ g_network_monitor_real_can_reach_async (GNetworkMonitor *monitor,
void
g_network_monitor_can_reach_async (GNetworkMonitor *monitor,
- GSocketConnectable *connectable,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GSocketConnectable *connectable,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GNetworkMonitorInterface *iface;
@@ -173,8 +173,8 @@ g_network_monitor_can_reach_async (GNetworkMonitor *monitor,
static gboolean
g_network_monitor_real_can_reach_finish (GNetworkMonitor *monitor,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
GSimpleAsyncResult *simple;
@@ -189,8 +189,8 @@ g_network_monitor_real_can_reach_finish (GNetworkMonitor *monitor,
gboolean
g_network_monitor_can_reach_finish (GNetworkMonitor *monitor,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
GNetworkMonitorInterface *iface;
@@ -219,13 +219,13 @@ g_network_monitor_default_init (GNetworkMonitorInterface *iface)
*/
signals[NETWORK_CHANGED] =
g_signal_new (I_("network-changed"),
- G_TYPE_NETWORK_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GNetworkMonitorInterface, network_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ G_TYPE_NETWORK_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GNetworkMonitorInterface, network_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
/**
* GNetworkMonitor:network-available:
@@ -252,10 +252,10 @@ g_network_monitor_default_init (GNetworkMonitorInterface *iface)
* Since: 2.32
*/
g_object_interface_install_property (iface,
- g_param_spec_boolean ("network-available",
- P_("Network available"),
- P_("Whether the network is available"),
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ g_param_spec_boolean ("network-available",
+ P_("Network available"),
+ P_("Whether the network is available"),
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
}
diff --git a/gio/gnetworkmonitorbase.c b/gio/gnetworkmonitorbase.c
index 2ac4115..2494ca3 100644
--- a/gio/gnetworkmonitorbase.c
+++ b/gio/gnetworkmonitorbase.c
@@ -36,15 +36,15 @@ static void g_network_monitor_base_iface_init (GNetworkMonitorInterface *iface);
static void g_network_monitor_base_initable_iface_init (GInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE (GNetworkMonitorBase, g_network_monitor_base, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
- g_network_monitor_base_initable_iface_init)
- G_IMPLEMENT_INTERFACE (G_TYPE_NETWORK_MONITOR,
- g_network_monitor_base_iface_init)
- _g_io_modules_ensure_extension_points_registered ();
- g_io_extension_point_implement (G_NETWORK_MONITOR_EXTENSION_POINT_NAME,
- g_define_type_id,
- "base",
- 0))
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ g_network_monitor_base_initable_iface_init)
+ G_IMPLEMENT_INTERFACE (G_TYPE_NETWORK_MONITOR,
+ g_network_monitor_base_iface_init)
+ _g_io_modules_ensure_extension_points_registered ();
+ g_io_extension_point_implement (G_NETWORK_MONITOR_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "base",
+ 0))
enum
{
@@ -73,8 +73,8 @@ static void
g_network_monitor_base_init (GNetworkMonitorBase *monitor)
{
monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor,
- G_TYPE_NETWORK_MONITOR_BASE,
- GNetworkMonitorBasePrivate);
+ G_TYPE_NETWORK_MONITOR_BASE,
+ GNetworkMonitorBasePrivate);
monitor->priv->networks = g_ptr_array_new_with_free_func (g_object_unref);
monitor->priv->context = g_main_context_get_thread_default ();
@@ -109,20 +109,20 @@ g_network_monitor_base_constructed (GObject *object)
static void
g_network_monitor_base_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GNetworkMonitorBase *monitor = G_NETWORK_MONITOR_BASE (object);
switch (prop_id)
{
case PROP_NETWORK_AVAILABLE:
- g_value_set_boolean (value, monitor->priv->is_available);
- break;
+ g_value_set_boolean (value, monitor->priv->is_available);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -160,9 +160,9 @@ g_network_monitor_base_class_init (GNetworkMonitorBaseClass *monitor_class)
static gboolean
g_network_monitor_base_can_reach (GNetworkMonitor *monitor,
- GSocketConnectable *connectable,
- GCancellable *cancellable,
- GError **error)
+ GSocketConnectable *connectable,
+ GCancellable *cancellable,
+ GError **error)
{
GNetworkMonitorBasePrivate *priv = G_NETWORK_MONITOR_BASE (monitor)->priv;
GSocketAddressEnumerator *enumerator;
@@ -175,7 +175,7 @@ g_network_monitor_base_can_reach (GNetworkMonitor *monitor,
if (priv->networks->len == 0)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NETWORK_UNREACHABLE,
- _("Network unreachable"));
+ _("Network unreachable"));
return FALSE;
}
@@ -191,21 +191,21 @@ g_network_monitor_base_can_reach (GNetworkMonitor *monitor,
while (addr)
{
if (G_IS_INET_SOCKET_ADDRESS (addr))
- {
- GInetAddress *iaddr;
- int i;
-
- iaddr = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (addr));
- for (i = 0; i < priv->networks->len; i++)
- {
- if (g_inet_address_mask_matches (priv->networks->pdata[i], iaddr))
- {
- g_object_unref (addr);
- g_object_unref (enumerator);
- return TRUE;
- }
- }
- }
+ {
+ GInetAddress *iaddr;
+ int i;
+
+ iaddr = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (addr));
+ for (i = 0; i < priv->networks->len; i++)
+ {
+ if (g_inet_address_mask_matches (priv->networks->pdata[i], iaddr))
+ {
+ g_object_unref (addr);
+ g_object_unref (enumerator);
+ return TRUE;
+ }
+ }
+ }
g_object_unref (addr);
addr = g_socket_address_enumerator_next (enumerator, cancellable, error);
@@ -215,7 +215,7 @@ g_network_monitor_base_can_reach (GNetworkMonitor *monitor,
if (error && !*error)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE,
- _("Host unreachable"));
+ _("Host unreachable"));
}
return FALSE;
}
@@ -230,8 +230,8 @@ g_network_monitor_base_iface_init (GNetworkMonitorInterface *monitor_iface)
static gboolean
g_network_monitor_base_initable_init (GInitable *initable,
- GCancellable *cancellable,
- GError **error)
+ GCancellable *cancellable,
+ GError **error)
{
return TRUE;
}
@@ -255,12 +255,12 @@ emit_network_changed (gpointer user_data)
else
{
is_available = (monitor->priv->have_ipv4_default_route ||
- monitor->priv->have_ipv6_default_route);
+ monitor->priv->have_ipv6_default_route);
if (monitor->priv->is_available != is_available)
- {
- monitor->priv->is_available = is_available;
- g_object_notify (G_OBJECT (monitor), "network-available");
- }
+ {
+ monitor->priv->is_available = is_available;
+ g_object_notify (G_OBJECT (monitor), "network-available");
+ }
g_signal_emit (monitor, network_changed_signal, 0, is_available);
}
@@ -298,7 +298,7 @@ queue_network_changed (GNetworkMonitorBase *monitor)
if (monitor->priv->initializing)
{
monitor->priv->is_available = (monitor->priv->have_ipv4_default_route ||
- monitor->priv->have_ipv6_default_route);
+ monitor->priv->have_ipv6_default_route);
}
}
@@ -308,33 +308,35 @@ queue_network_changed (GNetworkMonitorBase *monitor)
* @network: a #GInetAddressMask
*
* Adds @network to @monitor's list of available networks.
+ *
+ * Since: 2.32
*/
void
g_network_monitor_base_add_network (GNetworkMonitorBase *monitor,
- GInetAddressMask *network)
+ GInetAddressMask *network)
{
int i;
for (i = 0; i < monitor->priv->networks->len; i++)
{
if (g_inet_address_mask_equal (monitor->priv->networks->pdata[i], network))
- return;
+ return;
}
g_ptr_array_add (monitor->priv->networks, g_object_ref (network));
if (g_inet_address_mask_get_length (network) == 0)
{
switch (g_inet_address_mask_get_family (network))
- {
- case G_SOCKET_FAMILY_IPV4:
- monitor->priv->have_ipv4_default_route = TRUE;
- break;
- case G_SOCKET_FAMILY_IPV6:
- monitor->priv->have_ipv6_default_route = TRUE;
- break;
- default:
- break;
- }
+ {
+ case G_SOCKET_FAMILY_IPV4:
+ monitor->priv->have_ipv4_default_route = TRUE;
+ break;
+ case G_SOCKET_FAMILY_IPV6:
+ monitor->priv->have_ipv6_default_route = TRUE;
+ break;
+ default:
+ break;
+ }
}
/* Don't emit network-changed when multicast-link-local routing
@@ -353,37 +355,39 @@ g_network_monitor_base_add_network (GNetworkMonitorBase *monitor,
* @network: a #GInetAddressMask
*
* Removes @network from @monitor's list of available networks.
+ *
+ * Since: 2.32
*/
void
g_network_monitor_base_remove_network (GNetworkMonitorBase *monitor,
- GInetAddressMask *network)
+ GInetAddressMask *network)
{
int i;
for (i = 0; i < monitor->priv->networks->len; i++)
{
if (g_inet_address_mask_equal (monitor->priv->networks->pdata[i], network))
- {
- g_ptr_array_remove_index_fast (monitor->priv->networks, i);
-
- if (g_inet_address_mask_get_length (network) == 0)
- {
- switch (g_inet_address_mask_get_family (network))
- {
- case G_SOCKET_FAMILY_IPV4:
- monitor->priv->have_ipv4_default_route = FALSE;
- break;
- case G_SOCKET_FAMILY_IPV6:
- monitor->priv->have_ipv6_default_route = FALSE;
- break;
- default:
- break;
- }
- }
-
- queue_network_changed (monitor);
- return;
- }
+ {
+ g_ptr_array_remove_index_fast (monitor->priv->networks, i);
+
+ if (g_inet_address_mask_get_length (network) == 0)
+ {
+ switch (g_inet_address_mask_get_family (network))
+ {
+ case G_SOCKET_FAMILY_IPV4:
+ monitor->priv->have_ipv4_default_route = FALSE;
+ break;
+ case G_SOCKET_FAMILY_IPV6:
+ monitor->priv->have_ipv6_default_route = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ queue_network_changed (monitor);
+ return;
+ }
}
}
@@ -398,8 +402,8 @@ g_network_monitor_base_remove_network (GNetworkMonitorBase *monitor,
*/
void
g_network_monitor_base_set_networks (GNetworkMonitorBase *monitor,
- GInetAddressMask **networks,
- gint length)
+ GInetAddressMask **networks,
+ gint length)
{
int i;
diff --git a/gio/gnetworkmonitornetlink.c b/gio/gnetworkmonitornetlink.c
index ede8111..046c9e9 100644
--- a/gio/gnetworkmonitornetlink.c
+++ b/gio/gnetworkmonitornetlink.c
@@ -41,15 +41,15 @@ static void g_network_monitor_netlink_initable_iface_init (GInitableIface *iface
#define g_network_monitor_netlink_get_type _g_network_monitor_netlink_get_type
G_DEFINE_TYPE_WITH_CODE (GNetworkMonitorNetlink, g_network_monitor_netlink, G_TYPE_NETWORK_MONITOR_BASE,
- G_IMPLEMENT_INTERFACE (G_TYPE_NETWORK_MONITOR,
- g_network_monitor_netlink_iface_init)
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
- g_network_monitor_netlink_initable_iface_init)
- _g_io_modules_ensure_extension_points_registered ();
- g_io_extension_point_implement (G_NETWORK_MONITOR_EXTENSION_POINT_NAME,
- g_define_type_id,
- "netlink",
- 20))
+ G_IMPLEMENT_INTERFACE (G_TYPE_NETWORK_MONITOR,
+ g_network_monitor_netlink_iface_init)
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ g_network_monitor_netlink_initable_iface_init)
+ _g_io_modules_ensure_extension_points_registered ();
+ g_io_extension_point_implement (G_NETWORK_MONITOR_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "netlink",
+ 20))
struct _GNetworkMonitorNetlinkPrivate
{
@@ -60,24 +60,24 @@ struct _GNetworkMonitorNetlinkPrivate
};
static gboolean read_netlink_messages (GSocket *socket,
- GIOCondition condition,
- gpointer user_data);
+ GIOCondition condition,
+ gpointer user_data);
static gboolean request_dump (GNetworkMonitorNetlink *nl,
- GError **error);
+ GError **error);
static void
g_network_monitor_netlink_init (GNetworkMonitorNetlink *nl)
{
nl->priv = G_TYPE_INSTANCE_GET_PRIVATE (nl,
- G_TYPE_NETWORK_MONITOR_NETLINK,
- GNetworkMonitorNetlinkPrivate);
+ G_TYPE_NETWORK_MONITOR_NETLINK,
+ GNetworkMonitorNetlinkPrivate);
}
static gboolean
g_network_monitor_netlink_initable_init (GInitable *initable,
- GCancellable *cancellable,
- GError **error)
+ GCancellable *cancellable,
+ GError **error)
{
GNetworkMonitorNetlink *nl = G_NETWORK_MONITOR_NETLINK (initable);
gint sockfd, val;
@@ -91,8 +91,8 @@ g_network_monitor_netlink_initable_init (GInitable *initable,
{
int errsv = errno;
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
- _("Could not create network monitor: %s"),
- g_strerror (errno));
+ _("Could not create network monitor: %s"),
+ g_strerror (errno));
return FALSE;
}
@@ -103,8 +103,8 @@ g_network_monitor_netlink_initable_init (GInitable *initable,
{
int errsv = errno;
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
- _("Could not create network monitor: %s"),
- g_strerror (errno));
+ _("Could not create network monitor: %s"),
+ g_strerror (errno));
close (sockfd);
return FALSE;
}
@@ -114,8 +114,8 @@ g_network_monitor_netlink_initable_init (GInitable *initable,
{
int errsv = errno;
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
- _("Could not create network monitor: %s"),
- g_strerror (errno));
+ _("Could not create network monitor: %s"),
+ g_strerror (errno));
close (sockfd);
return FALSE;
}
@@ -138,22 +138,22 @@ g_network_monitor_netlink_initable_init (GInitable *initable,
while (nl->priv->dump_networks)
{
if (!read_netlink_messages (NULL, G_IO_IN, nl))
- break;
+ break;
}
g_socket_set_blocking (nl->priv->sock, FALSE);
nl->priv->source = g_socket_create_source (nl->priv->sock, G_IO_IN, NULL);
g_source_set_callback (nl->priv->source,
- (GSourceFunc) read_netlink_messages, nl, NULL);
+ (GSourceFunc) read_netlink_messages, nl, NULL);
g_source_attach (nl->priv->source,
- g_main_context_get_thread_default ());
+ g_main_context_get_thread_default ());
return TRUE;
}
static gboolean
request_dump (GNetworkMonitorNetlink *nl,
- GError **error)
+ GError **error)
{
struct nlmsghdr *n;
struct rtgenmsg *gen;
@@ -169,7 +169,7 @@ request_dump (GNetworkMonitorNetlink *nl,
gen->rtgen_family = AF_UNSPEC;
if (g_socket_send (nl->priv->sock, buf, sizeof (buf),
- NULL, error) < 0)
+ NULL, error) < 0)
{
g_prefix_error (error, "%s", _("Could not get network status: "));
return FALSE;
@@ -207,17 +207,17 @@ queue_request_dump (GNetworkMonitorNetlink *nl)
nl->priv->dump_source = g_timeout_source_new (1000);
g_source_set_callback (nl->priv->dump_source,
- (GSourceFunc) timeout_request_dump, nl, NULL);
+ (GSourceFunc) timeout_request_dump, nl, NULL);
g_source_attach (nl->priv->dump_source,
- g_main_context_get_thread_default ());
+ g_main_context_get_thread_default ());
}
static void
add_network (GNetworkMonitorNetlink *nl,
- GSocketFamily family,
- gint dest_len,
- guint8 *dest,
- guint8 *gateway)
+ GSocketFamily family,
+ gint dest_len,
+ guint8 *dest,
+ guint8 *gateway)
{
GInetAddress *dest_addr;
GInetAddressMask *network;
@@ -241,10 +241,10 @@ add_network (GNetworkMonitorNetlink *nl,
static void
remove_network (GNetworkMonitorNetlink *nl,
- GSocketFamily family,
- gint dest_len,
- guint8 *dest,
- guint8 *gateway)
+ GSocketFamily family,
+ gint dest_len,
+ guint8 *dest,
+ guint8 *gateway)
{
GInetAddress *dest_addr;
GInetAddressMask *network;
@@ -263,14 +263,14 @@ remove_network (GNetworkMonitorNetlink *nl,
int i;
for (i = 0; i < nl->priv->dump_networks->len; i++)
- {
- if (g_inet_address_mask_equal (network, dump_networks[i]))
- g_ptr_array_remove_index_fast (nl->priv->dump_networks, i--);
- }
+ {
+ if (g_inet_address_mask_equal (network, dump_networks[i]))
+ g_ptr_array_remove_index_fast (nl->priv->dump_networks, i--);
+ }
g_object_unref (network);
}
else
- {
+ {
g_network_monitor_base_remove_network (G_NETWORK_MONITOR_BASE (nl), network);
g_object_unref (network);
}
@@ -280,16 +280,16 @@ static void
finish_dump (GNetworkMonitorNetlink *nl)
{
g_network_monitor_base_set_networks (G_NETWORK_MONITOR_BASE (nl),
- (GInetAddressMask **)nl->priv->dump_networks->pdata,
- nl->priv->dump_networks->len);
+ (GInetAddressMask **)nl->priv->dump_networks->pdata,
+ nl->priv->dump_networks->len);
g_ptr_array_free (nl->priv->dump_networks, FALSE);
nl->priv->dump_networks = NULL;
}
static gboolean
read_netlink_messages (GSocket *socket,
- GIOCondition condition,
- gpointer user_data)
+ GIOCondition condition,
+ gpointer user_data)
{
GNetworkMonitorNetlink *nl = user_data;
GInputVector iv;
@@ -311,26 +311,26 @@ read_netlink_messages (GSocket *socket,
flags = MSG_PEEK | MSG_TRUNC;
len = g_socket_receive_message (nl->priv->sock, NULL, &iv, 1,
- NULL, NULL, &flags, NULL, &error);
+ NULL, NULL, &flags, NULL, &error);
if (len < 0)
{
g_warning ("Error on netlink socket: %s", error->message);
g_error_free (error);
if (nl->priv->dump_networks)
- finish_dump (nl);
+ finish_dump (nl);
return FALSE;
}
iv.buffer = g_malloc (len);
iv.size = len;
len = g_socket_receive_message (nl->priv->sock, NULL, &iv, 1,
- &cmsgs, &num_cmsgs, NULL, NULL, &error);
+ &cmsgs, &num_cmsgs, NULL, NULL, &error);
if (len < 0)
{
g_warning ("Error on netlink socket: %s", error->message);
g_error_free (error);
if (nl->priv->dump_networks)
- finish_dump (nl);
+ finish_dump (nl);
return FALSE;
}
@@ -346,63 +346,63 @@ read_netlink_messages (GSocket *socket,
for (; len > 0; msg = NLMSG_NEXT (msg, len))
{
if (!NLMSG_OK (msg, (size_t) len))
- {
- g_warning ("netlink message was truncated; shouldn't happen...");
- retval = FALSE;
- goto done;
- }
+ {
+ g_warning ("netlink message was truncated; shouldn't happen...");
+ retval = FALSE;
+ goto done;
+ }
switch (msg->nlmsg_type)
- {
- case RTM_NEWROUTE:
- case RTM_DELROUTE:
- rtmsg = NLMSG_DATA (msg);
-
- if (rtmsg->rtm_family != AF_INET && rtmsg->rtm_family != AF_INET6)
- continue;
- if (rtmsg->rtm_type == RTN_UNREACHABLE)
- continue;
-
- attrlen = NLMSG_PAYLOAD (msg, sizeof (struct rtmsg));
- attr = RTM_RTA (rtmsg);
- dest = gateway = NULL;
- while (RTA_OK (attr, attrlen))
- {
- if (attr->rta_type == RTA_DST)
- dest = RTA_DATA (attr);
- else if (attr->rta_type == RTA_GATEWAY)
- gateway = RTA_DATA (attr);
- attr = RTA_NEXT (attr, attrlen);
- }
-
- if (dest || gateway)
- {
- if (msg->nlmsg_type == RTM_NEWROUTE)
- add_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
- else
- remove_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
- queue_request_dump (nl);
- }
- break;
-
- case NLMSG_DONE:
- finish_dump (nl);
- goto done;
-
- case NLMSG_ERROR:
- {
- struct nlmsgerr *e = NLMSG_DATA (msg);
-
- g_warning ("netlink error: %s", g_strerror (-e->error));
- }
- retval = FALSE;
- goto done;
-
- default:
- g_warning ("unexpected netlink message %d", msg->nlmsg_type);
- retval = FALSE;
- goto done;
- }
+ {
+ case RTM_NEWROUTE:
+ case RTM_DELROUTE:
+ rtmsg = NLMSG_DATA (msg);
+
+ if (rtmsg->rtm_family != AF_INET && rtmsg->rtm_family != AF_INET6)
+ continue;
+ if (rtmsg->rtm_type == RTN_UNREACHABLE)
+ continue;
+
+ attrlen = NLMSG_PAYLOAD (msg, sizeof (struct rtmsg));
+ attr = RTM_RTA (rtmsg);
+ dest = gateway = NULL;
+ while (RTA_OK (attr, attrlen))
+ {
+ if (attr->rta_type == RTA_DST)
+ dest = RTA_DATA (attr);
+ else if (attr->rta_type == RTA_GATEWAY)
+ gateway = RTA_DATA (attr);
+ attr = RTA_NEXT (attr, attrlen);
+ }
+
+ if (dest || gateway)
+ {
+ if (msg->nlmsg_type == RTM_NEWROUTE)
+ add_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
+ else
+ remove_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
+ queue_request_dump (nl);
+ }
+ break;
+
+ case NLMSG_DONE:
+ finish_dump (nl);
+ goto done;
+
+ case NLMSG_ERROR:
+ {
+ struct nlmsgerr *e = NLMSG_DATA (msg);
+
+ g_warning ("netlink error: %s", g_strerror (-e->error));
+ }
+ retval = FALSE;
+ goto done;
+
+ default:
+ g_warning ("unexpected netlink message %d", msg->nlmsg_type);
+ retval = FALSE;
+ goto done;
+ }
}
done:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]