Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for using udhcpc dhcp client
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Dec 1, 2013
1 parent b376f49 commit 41d1622
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/usb_moded-doc.txt
Expand Up @@ -112,7 +112,7 @@ 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.
If the ip is set to dhcp, usb_moded will try to use dhcp to configure the network (requires dhclient atm)
If the ip is set to dhcp, usb_moded will try to use dhcp to configure the network (requires dhclient or udhcpc atm)

The network configuration can also be set with dbus method calls via the net_config method.
This requires two strings as arguments. Supported are: ip, interface and gateway
Expand Down
11 changes: 10 additions & 1 deletion src/usb_moded-network.c
Expand Up @@ -101,6 +101,7 @@ int usb_network_up(struct mode_list_elem *data)
{
const char *ip, *interface, *gateway;
char command[128];
int ret = -1;

#if CONNMAN
DBusConnection *dbus_conn_connman = NULL;
Expand Down Expand Up @@ -143,7 +144,13 @@ int usb_network_up(struct mode_list_elem *data)
else if(!strcmp(ip, "dhcp"))
{
sprintf(command, "dhclient -d %s\n", interface);
system(command);
ret = system(command);
if(ret != 0)
{
sprintf(command, "udhcpc -i %s\n", interface);
system(command);
}

}
else
{
Expand Down Expand Up @@ -186,6 +193,8 @@ int usb_network_down(struct mode_list_elem *data)
sprintf(command, "ifconfig %s down\n", interface);
system(command);

/* TODO: Do dhcp client shutdown */

free((char *)interface);

return(0);
Expand Down

0 comments on commit 41d1622

Please sign in to comment.