hal/tools/linux hal_hotplug.c,1.22,1.23
David Zeuthen
david at freedesktop.org
Thu Sep 16 15:04:17 PDT 2004
Update of /cvs/hal/hal/tools/linux
In directory gabe:/tmp/cvs-serv3493/tools/linux
Modified Files:
hal_hotplug.c
Log Message:
2004-09-16 David Zeuthen <david at fubar.dk>
Revisit networking. Basically a) split ethernet and wireless into
net.80203 and net.80211 properties; b) support renaming of
devices; c) use uint64 datatype; d) add property for whether an
interface is up and track this; and e) general cleanups when
properties are available and not
* doc/spec/hal-spec.xml.in: Update spec with changes made. Also
add uint64 property type
* hald/device_store.c (hal_device_store_match_key_value_int): New
function
* hald/device_store.h: Add prototype for function
hal_device_store_match_key_value_int
* hald/linux/hald_helper.h: Add net_ifindex member
* hald/linux/net_class_device.c:
(mii_get_rate): Rename net.ethernet.rate to net.80203.rate and make
the type uint64
(mii_get_link): Rename net.ethernet.link to net.80203.link
(set_device_link_status): Remove function
(link_detection_handle_message): Also listen for interface up/down
messages on the netlink socket; maintains net.interface_up. Also
handle renaming messages. Remove net.80203.* properties if the
interface is down. Remove net.80203.rate if net.80203.link is FALSE.
Only check rate for net.80203 devices (fixes crasher for my new
Atheros card; remember?)
(net_class_pre_process): Rename from net.ethernet to net.80203 and
also have separate net.80211 namespace. Add net.interface_up and
net.linux.ifindex properties. Set net.{80203,80211}.mac_address
as a uint64 rather than net.ethernet.{mac_addr,mac_addr_upper24,
mac_addr_lower24}.
(net_class_accept): Small reorg of code
(net_class_post_merge): Always start listening to netlink socket
* hald/linux/osspec.c:
(process_coldplug_list): Use NULL for hotplug_msg when invoking
add_device
(recover_net_device): New function
(add_device): Use net_ifindex and recover net device to handle
renaming of networking devices by udev and/or initscripts. Now
optionally uses the hotplug msg which may be NULL.
(rem_device): Optionally use the hotplug msg which may be NULL.
(hald_helper_hotplug): Pass on hotplug msg
(hald_helper_device_name): Pass on hotplug msg
(hald_helper_hotplug_process_queue): Pass on hotplug msg
(hald_helper_data): Pass on hotplug msg
* tools/linux/hal_hotplug.c:
(wait_for_sysfs_info): Wait for ifindex for net devices and
extract the value
(main): pass on net_ifindex value to hotplug msg
Index: hal_hotplug.c
===================================================================
RCS file: /cvs/hal/hal/tools/linux/hal_hotplug.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- hal_hotplug.c 14 Sep 2004 12:26:24 -0000 1.22
+++ hal_hotplug.c 16 Sep 2004 22:04:15 -0000 1.23
@@ -84,7 +84,12 @@
return ret;
}
-static const char *file_list_class_device[] ={
+static const char *file_list_net[] = {
+ "ifindex",
+ NULL
+};
+
+static const char *file_list_class_device[] = {
"dev",
NULL
};
@@ -150,7 +155,7 @@
} while(0)
static int
-wait_for_sysfs_info (char *devpath, char *hotplug_type)
+wait_for_sysfs_info (char *devpath, char *hotplug_type, int *net_ifindex)
{
size_t devpath_len;
const char **file_list;
@@ -192,6 +197,8 @@
file_list = file_list_scsi_host;
} else if (strcmp (hotplug_type, "block") == 0) {
file_list = file_list_block;
+ } else if (strcmp (hotplug_type, "net") == 0) {
+ file_list = file_list_net;
}
if (file_list == NULL) {
@@ -242,6 +249,24 @@
if (rc != 0)
goto try_again;
}
+
+ /* lip service for 'net' */
+ if (strcmp (hotplug_type, "net") == 0) {
+ FILE *f;
+ char buf[80];
+
+ strncpy (path, sysfs_mnt_path, PATH_MAX);
+ strcat_len (path, devpath);
+ strcat_len (path, "/ifindex");
+ if ((f = fopen (path, "r")) != NULL) {
+ memset (buf, 0, sizeof (buf));
+ fread (buf, sizeof (buf) - 1, 1, f);
+ fclose (f);
+
+ *net_ifindex = atoi(buf);
+ }
+ }
+
return 0;
}
@@ -263,6 +288,7 @@
char *devpath;
char *action;
char *seqnum_str;
+ int net_ifindex = -1;
unsigned long long seqnum;
if (argc != 2)
@@ -308,7 +334,7 @@
/* wait for information to be published in sysfs */
if (strcmp (action, "add") == 0)
- wait_for_sysfs_info (devpath, subsystem);
+ wait_for_sysfs_info (devpath, subsystem, &net_ifindex);
memset (&saddr, 0x00, sizeof(struct sockaddr_un));
saddr.sun_family = AF_LOCAL;
@@ -323,6 +349,7 @@
strncpy (msg.action, action, HALD_HELPER_STRLEN-1);
strncpy (msg.subsystem, subsystem, HALD_HELPER_STRLEN-1);
strncpy (msg.sysfs_path, devpath, HALD_HELPER_STRLEN-1);
+ msg.net_ifindex = net_ifindex;
if (sendto (fd, &msg, sizeof(struct hald_helper_msg), 0,
(struct sockaddr *)&saddr, addrlen) == -1) {
More information about the hal-commit
mailing list