Changed IP address order (N900 comes last now)
authorGregor Riepl <onitake@gmail.com>
Wed, 18 Aug 2010 16:44:54 +0000 (18:44 +0200)
committerGregor Riepl <onitake@gmail.com>
Wed, 18 Aug 2010 16:44:54 +0000 (18:44 +0200)
Fixed usb-net load/unload scripts

mtetherd-usbnet-disable.sh
mtetherd-usbnet-enable.sh
net.c

index 317e350..62a368c 100755 (executable)
@@ -28,5 +28,13 @@ if [ $? != 0 ]; then
 fi
 
 /sbin/rmmod g_ether
+if [ $? != 0 ]; then
+    logger "$0: failed to unload g_ether"
+    exit 1
+fi
+
+# load this here or the system will not receive any USB events
+/sbin/modprobe g_file_storage
 
 exit 0
+
index fcea859..ae7c215 100755 (executable)
@@ -64,29 +64,9 @@ if [ $? = 0 ]; then
     LUN0='gadget-lun0'
     LUN1='gadget-lun1'
 
-    if [ $# = 0 ]; then
-      # unload all
-      echo "" > $GADGETPATH/$LUN0/file
-      echo "" > $GADGETPATH/$LUN1/file
-      exit 0
-    fi
-
-    # NOTE: works only for 1 or 2 device arguments
-    for lun in $LUN0 $LUN1; do
-      grep $1 $GADGETPATH/$lun/file > /dev/null
-      RC=$?
-
-      if [ $# = 2 ]; then
-        grep $2 $GADGETPATH/$lun/file > /dev/null
-        RC2=$?
-      else
-        RC2=1
-      fi
-
-      if [ $RC = 0 -o $RC2 = 0 ]; then
-        echo "" > $GADGETPATH/$lun/file
-      fi
-    done
+    # unload all
+    echo "" > $GADGETPATH/$LUN0/file
+    echo "" > $GADGETPATH/$LUN1/file
 
     /sbin/rmmod g_file_storage
     if [ $? != 0 ]; then
@@ -105,5 +85,6 @@ if [ $RC != 0 ]; then
     logger "$0: failed to install g_ether"
     exit 1
 fi
-
+        
 exit 0
+
diff --git a/net.c b/net.c
index a727605..230b082 100644 (file)
--- a/net.c
+++ b/net.c
@@ -32,10 +32,10 @@ static const guint MAX_DEVICES = 64;
 static const in_addr_t HOST_BASE_ADDRESS = 0xc0a8ff00;
 // Host order 255.255.255.252
 static const in_addr_t HOST_NETMASK = 0xfffffffc;
-// Host order 0.0.0.2
-static const in_addr_t HOST_ROUTER = 0x00000002;
 // Host order 0.0.0.1
-static const in_addr_t HOST_DHCP = 0x00000001;
+static const in_addr_t HOST_ROUTER = 0x00000001;
+// Host order 0.0.0.1
+static const in_addr_t HOST_DHCP = 0x00000002;
 
 struct _MTetherDDevicePrivate {
        gchar *interface;
@@ -122,11 +122,11 @@ void mtetherd_device_set_index(MTetherDDevice *self, guint index) {
                if (index < 64) {
                        in_addr_t subnet = HOST_BASE_ADDRESS | (index << 2);
                        in_addr_t addr = subnet | HOST_ROUTER;
-                       in_addr_t start = subnet | HOST_DHCP;
+                       in_addr_t end = subnet | HOST_DHCP;
                        self->priv->addr = htonl(addr);
                        self->priv->netmask = htonl(HOST_NETMASK);
-                       self->priv->dhcp_start = htonl(start);
-                       self->priv->dhcp_end = htonl(addr);
+                       self->priv->dhcp_start = htonl(addr);
+                       self->priv->dhcp_end = htonl(end);
                } else {
                        g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Invalid subnet index: %u (0..%u expected)", index, MAX_DEVICES - 1);
                }