Skip to content

Commit

Permalink
Add network setting documentation. Add network gateway configuration …
Browse files Browse the repository at this point in the history
…option

Signed-off-by: Philippe De Swert <philippedeswert@gmail.com>
  • Loading branch information
philippedeswert committed Aug 12, 2012
1 parent d15c3e1 commit dd252c6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
14 changes: 13 additions & 1 deletion docs/usb_moded-doc.txt
Expand Up @@ -43,7 +43,7 @@ Even the configuration can be set over DBus (this will set either the gconf key

dbus-send --system --type=method_call --print-reply --dest=com.meego.usb_moded /com/meego/usb_moded com.meego.usb_moded.set_config string:'<mode_name>'

However this can also be optionally handled by setting the following GConf key.
However this can also be optionally handled by setting the following GConf key (gconf has to be compiled in).

/Meego/System/UsbMode (querying and setting can be done as follows:

Expand Down Expand Up @@ -90,6 +90,18 @@ mode = ask
The other settings and config dirs will be handled later in the appsync and dynamic modes part.
(This is optional and can be compiled out)

There is also an optional network configuration. The default ip set for usb networking is 192.168.2.15
(for Meego/Nemo). However this can be configured by hand in the ini file also.
For example:

[network]
ip = 10.0.0.2
interface = usb1
gateway = 10.0.0.1

By default usb0 will be used, so no need to fill it in if not needed. The gateway setting is also optional
and will not be set if there is no value filled in.

Functional overview
--------------------

Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -122,6 +122,11 @@ const char * get_network_interface(void)
return(get_conf_string(NETWORK_ENTRY, NETWORK_INTERFACE_KEY));
}

const char * get_network_gateway(void)
{
return(get_conf_string(NETWORK_ENTRY, NETWORK_GATEWAY_KEY));
}

static int get_conf_int(const gchar *entry, const gchar *key)
{
GKeyFile *settingsfile;
Expand Down
2 changes: 2 additions & 0 deletions src/usb_moded-config.h
Expand Up @@ -46,6 +46,7 @@
#define NETWORK_ENTRY "network"
#define NETWORK_IP_KEY "ip"
#define NETWORK_INTERFACE_KEY "interface"
#define NETWORK_GATEWAY_KEY "gateway"

const char * find_mounts(void);
int find_sync(void);
Expand All @@ -71,3 +72,4 @@ const char * get_trigger_value(void);

const char * get_network_ip(void);
const char * get_network_interface(void);
const char * get_network_gateway(void);
11 changes: 9 additions & 2 deletions src/usb_moded-network.c
Expand Up @@ -40,7 +40,7 @@
*/
int usb_network_up(void)
{
const char *ip, *interface;
const char *ip, *interface, *gateway;
char command[128];

#if CONNMAN
Expand Down Expand Up @@ -72,6 +72,7 @@ int usb_network_up(void)
#else
ip = get_network_ip();
interface = get_network_interface();
gateway = get_network_gateway();
if(ip == NULL)
{
system("ifconfig usb0 192.168.2.15");
Expand All @@ -81,8 +82,14 @@ int usb_network_up(void)
sprintf(command, "ifconfig usb0 %s\n", ip);
else
sprintf(command, "ifconfig %s %s\n", interface, ip);

system(command);

if(gateway)
{
sprintf(command, "route add default gw %s %s\n", gateway);
system(command);
}

return(0);
#endif /* CONNMAN */
}
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded.c
Expand Up @@ -359,7 +359,7 @@ inline const char * get_usb_mode(void)
* @param module The module name for the requested mode
*
*/
void set_usb_module(const char *module)
inline void set_usb_module(const char *module)
{
free(current_mode.module);
current_mode.module = strdup(module);
Expand Down

0 comments on commit dd252c6

Please sign in to comment.