diff --git a/configure.ac b/configure.ac index d6419f3..ba5495c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([usb_moded], [0.61]) +AC_INIT([usb_moded], [0.62]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AM_CONFIG_HEADER([config.h]) diff --git a/debian/changelog b/debian/changelog index 50a585c..f5914ad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +usb-moded (0.62) unstable; urgency=low + + * Kernel command line parameters are now in sync with regular kernel command parameters + * Save the udev path setting in config file merging so it does not get lost on upgrades + + -- Philippe De Swert Fri, 24 May 2013 17:20:54 +0300 + usb-moded (0.61) unstable; urgency=low * Add basic version of usb_moded_util to not having to remember dbus-send commands diff --git a/docs/usb_moded-doc.txt b/docs/usb_moded-doc.txt index 9fce9b8..d187e28 100644 --- a/docs/usb_moded-doc.txt +++ b/docs/usb_moded-doc.txt @@ -124,9 +124,17 @@ change and udev rules / network manager etc will not think it is a new device ea This mac is stored using the default modprobe configuration and thus will be in /etc/modprobe.d/g_ether.conf If this file exits usb_moded will assume there is a default mac set and will not do anything. -It is possible to set the configuration on the kernel command line also. Just add a valid keypair in the kernel command line. +It is possible to set the configuration on the kernel command line also. For this the regular ip setting from the kernel is +being re-used. -for example : ip=192.168.2.15 gateway=192.168.2.2 mode=developer_mode +The format followed is: +ip=:::::: + +For more info see the kernel source: Documentation/filesystems/nfs/nfsroot.txt + +for example : ip=192.168.3.100::192.168.3.1:255.255.255.0::usb0:on + +NOTE: The device must be usb0! The autoconf value is ignored. Functional overview -------------------- diff --git a/src/usb_moded-config.c b/src/usb_moded-config.c index 951adc1..8f483d2 100644 --- a/src/usb_moded-config.c +++ b/src/usb_moded-config.c @@ -236,6 +236,7 @@ static const char * get_kcmdline_string(const char *entry) int len; gint argc = 0; gchar **argv = NULL; + gchar **arg_tokens = NULL, **network_tokens = NULL; GError *optErr = NULL; int i; @@ -257,24 +258,42 @@ static const char * get_kcmdline_string(const char *entry) cmdLine[len] = '\0'; /* we're looking for a piece of the kernel command line matching this: - ip=192.168.3.100:192.168.3.1::255.255.255.0::usb0:on */ + ip=192.168.3.100::192.168.3.1:255.255.255.0::usb0:on */ if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr)) { g_error_free(optErr); return(ret); } + /* find the ip token */ for (i=0; i < argc; i++) { - gchar ** arg_tokens; arg_tokens = g_strsplit(argv[i], "=", 2); - if (!g_ascii_strcasecmp(arg_tokens[0], entry)) + if (!g_ascii_strcasecmp(arg_tokens[0], "ip")) { - log_debug("use '%s' for '%s' from kernel command line", arg_tokens[1], entry); - ret = g_strdup(arg_tokens[1]); + network_tokens = g_strsplit(arg_tokens[1], ":", 7); + /* check if it is for the usb */ + if(!strcmp(network_tokens[5], "usb0")) + { + if(!strcmp(entry, NETWORK_IP_KEY)) + { + ret = g_strdup(network_tokens[0]); + log_debug("Command line ip = %s\n", ret); + } + if(!strcmp(entry, NETWORK_GATEWAY_KEY)) + { + /* gateway might be empty, so we do not want to return an empty string */ + if(strlen(network_tokens[2]) > 2) + { + ret = g_strdup(network_tokens[2]); + log_debug("Command line gateway = %s\n", ret); + } + } + } } - g_strfreev(arg_tokens); } + g_strfreev(arg_tokens); + g_strfreev(network_tokens); return(ret); } @@ -440,7 +459,7 @@ int conf_file_merge(void) #ifdef UDEV if(udev) { - set_settings_option(UDEV_PATH_ENTRY, UDEV_PATH_KEY, udev); + set_config_setting(UDEV_PATH_ENTRY, UDEV_PATH_KEY, udev); } #endif /* UDEV */ }