Re: connect to internet via android phone as usb-modem



On Wed, 2011-03-16 at 15:50 -0500, Dan Williams wrote:
...
> That said, the best way to go about this is likely to use udev scripts
> to initially create the easytether0 interface, and then we could add
> some custom code to NM to recognize the easytether0 interface as a
> normal ethernet device and run DHCP on it.  That wouldn't be *too* hard,
> probably < 30 lines of code.  It would involve using g_str_has_prefix()
> looking for easytether in the nm-udev-manager.c code, and if so,
> bypassing some of the udev /sysfs hierarchy checks that determine
> hardware relationships and device attributes like driver and
> description.  That's not something we should be doing for most "virtual"
> network interfaces, but it's probably OK in the case of easytether.

Thanks for the advice where to patch network manager. Attached is a very
first version, plus a basic udev rule for a Motorola Milestone and
connect script. It works fine on my Ubuntu 10.04 machine right now,
though it could use some polishing.

Torsten

diff -ruN NetworkManager/src/nm-device-ethernet.c NetworkManager-easytether/src/nm-device-ethernet.c
--- NetworkManager/src/nm-device-ethernet.c	2011-03-16 14:25:18.834800697 +0100
+++ NetworkManager-easytether/src/nm-device-ethernet.c	2011-03-16 22:19:58.388510568 +0100
@@ -567,7 +567,10 @@
 {
 	g_return_val_if_fail (udi != NULL, NULL);
 	g_return_val_if_fail (iface != NULL, NULL);
-	g_return_val_if_fail (driver != NULL, NULL);
+	if (strcmp("easytether0", iface))
+		g_return_val_if_fail (driver != NULL, NULL);
+	else
+		nm_log_warn (LOGD_HW, "Ignoring driver = NULL for easytether");
 
 	return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET,
 	                                  NM_DEVICE_INTERFACE_UDI, udi,
diff -ruN NetworkManager/src/nm-udev-manager.c NetworkManager-easytether/src/nm-udev-manager.c
--- NetworkManager/src/nm-udev-manager.c	2011-03-10 23:38:01.298038845 +0100
+++ NetworkManager-easytether/src/nm-udev-manager.c	2011-03-16 22:06:32.976528041 +0100
@@ -386,7 +386,10 @@
 
 	if (!driver) {
 		nm_log_warn (LOGD_HW, "%s: couldn't determine device driver; ignoring...", path);
-		goto out;
+		if (!strcmp("easytether0", ifname))
+			nm_log_warn (LOGD_HW, "%s: is an easytether device, ignorning device driver not found", ifname)
+                else
+			goto out;
 	}
 
 	ifindex = g_udev_device_get_sysfs_attr_as_int (udev_device, "ifindex");
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="41da", RUN+="/usr/local/bin/easytether"

Attachment: easytether
Description: application/shellscript



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