Skip to content

Commit

Permalink
Add network configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
philippedeswert committed Aug 7, 2012
1 parent 9d7f660 commit c457986
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -112,6 +112,16 @@ const char * get_trigger_value(void)
}
#endif /* UDEV */

const char * get_network_ip(void)
{
return(get_conf_string(NETWORK_ENTRY, NETWORK_IP_KEY));
}

const char * get_network_interface(void)
{
return(get_conf_string(NETWORK_ENTRY, NETWORK_INTERFACE_KEY));
}

static int get_conf_int(const gchar *entry, const gchar *key)
{
GKeyFile *settingsfile;
Expand Down
6 changes: 6 additions & 0 deletions src/usb_moded-config.h
Expand Up @@ -43,6 +43,9 @@
#define TRIGGER_MODE_KEY "mode"
#define TRIGGER_PROPERTY_KEY "property"
#define TRIGGER_PROPERTY_VALUE_KEY "value"
#define NETWORK_ENTRY "network"
#define NETWORK_IP_KEY "ip"
#define NETWORK_INTERFACE_KEY "interface"

const char * find_mounts(void);
int find_sync(void);
Expand All @@ -65,3 +68,6 @@ const char * get_trigger_mode(void);
const char * get_trigger_property(void);
const char * get_trigger_value(void);
#endif /* UDEV */

const char * get_network_ip(void);
const char * get_network_interface(void);
14 changes: 13 additions & 1 deletion src/usb_moded-network.c
Expand Up @@ -40,6 +40,9 @@
*/
int usb_network_up(void)
{
const char *ip, *interface;
char command[128];

#if CONNMAN
DBusConnection *dbus_conn_connman = NULL;
DBusMessage *msg = NULL, *reply = NULL;
Expand Down Expand Up @@ -67,7 +70,16 @@ int usb_network_up(void)
return(ret);

#else
system("ifconfig usb0 192.168.2.15");
ip = get_network_ip();
interface = get_network_interface();
if(ip == NULL)
system("ifconfig usb0 192.168.2.15");
if(interface == NULL)
sprintf(command, "ifconfig usb0 %s\n", ip);
else
sprintf(command, "ifconfig %s %s\n", interface, ip);

system(command);
return(0);
#endif /* CONNMAN */
}
Expand Down

0 comments on commit c457986

Please sign in to comment.