diff options
author | Dan Williams <dcbw@redhat.com> | 2007-08-26 15:55:27 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2007-08-26 15:55:27 +0000 |
commit | cd00315325e9e540172f1bfe559b30402cabe254 (patch) | |
tree | cbbfeeea852eea81eff84aa54e909728586d7758 /src/nm-netlink-monitor.c | |
parent | c7b06312e75cfafbd9d2a217be2b05c98736a701 (diff) | |
download | NetworkManager-cd00315325e9e540172f1bfe559b30402cabe254.tar.gz |
2007-08-26 Dan Williams <dcbw@redhat.com>
Convert to using interface indexes as the primary method of identifying
devices inside NetworkManager. Indexes are (?) stable, but devices can
be renamed at any time. Device object paths now refer to the device
index rather than the name, and you can map those two manually if you like
by looking in the /sys/class/net/<name>/ifindex file. Also moves most
netlink-related code to nm-netlink.c, and cleans up nm-netlink-monitor.c
to use interface indexes rather than names.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2731 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'src/nm-netlink-monitor.c')
-rw-r--r-- | src/nm-netlink-monitor.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c index 82b917cf8c..cb54a2192c 100644 --- a/src/nm-netlink-monitor.c +++ b/src/nm-netlink-monitor.c @@ -121,7 +121,7 @@ nm_netlink_monitor_class_init (NMNetlinkMonitorClass *monitor_class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (NMNetlinkMonitorClass, interface_connected), NULL, NULL, g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); + G_TYPE_NONE, 1, G_TYPE_INT); signals[INTERFACE_DISCONNECTED] = g_signal_new ("interface-disconnected", @@ -129,7 +129,7 @@ nm_netlink_monitor_class_init (NMNetlinkMonitorClass *monitor_class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (NMNetlinkMonitorClass, interface_disconnected), NULL, NULL, g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); + G_TYPE_NONE, 1, G_TYPE_INT); signals[ERROR] = g_signal_new ("error", @@ -690,26 +690,20 @@ nm_netlink_monitor_event_handler (GIOChannel *channel, attribute = RTA_NEXT (attribute, num_attribute_bytes_to_process)) { int data_len = RTA_PAYLOAD (attribute); - + if (attribute->rta_type == IFLA_IFNAME) { - char * iface = g_malloc0 (data_len + 1); - memcpy (iface, RTA_DATA (attribute), data_len); - if (strlen (iface)) - { - /* The !! weirdness is to cannonicalize the value to 0 or 1. */ - gboolean is_connected = !!((gboolean) (interface_info->ifi_flags & IFF_RUNNING)); - - if (is_connected) { - g_signal_emit (G_OBJECT (monitor), - signals[INTERFACE_CONNECTED], - 0, iface); - } else { - g_signal_emit (G_OBJECT (monitor), - signals[INTERFACE_DISCONNECTED], - 0, iface); - } + /* The !! weirdness is to cannonicalize the value to 0 or 1. */ + gboolean is_connected = !!((gboolean) (interface_info->ifi_flags & IFF_RUNNING)); + + if (is_connected) { + g_signal_emit (G_OBJECT (monitor), + signals[INTERFACE_CONNECTED], + 0, interface_info->ifi_index); + } else { + g_signal_emit (G_OBJECT (monitor), + signals[INTERFACE_DISCONNECTED], + 0, interface_info->ifi_index); } - g_free (iface); } } } |