Skip to content

Commit

Permalink
Add dhcp client config on usb network (depends on dhclient)
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippedeswert@gmail.com>
  • Loading branch information
philippedeswert committed Sep 14, 2012
1 parent 36251d1 commit 0408e3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/usb_moded-doc.txt
Expand Up @@ -101,6 +101,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)

Functional overview
--------------------
Expand Down
8 changes: 8 additions & 0 deletions src/usb_moded-network.c
Expand Up @@ -23,6 +23,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "usb_moded-network.h"
#include "usb_moded-config.h"
Expand Down Expand Up @@ -79,6 +80,13 @@ int usb_network_up(void)
system("ifconfig usb0 192.168.2.15");
return(0);
}
if(!strcmp(ip, "dhcp"))
{
if(interface == NULL)
sprintf(command, "dhclient -d usb0\n");
else
sprintf(command, "dhclient -d %s\n", interface);
}
if(interface == NULL)
sprintf(command, "ifconfig usb0 %s\n", ip);
else
Expand Down

0 comments on commit 0408e3f

Please sign in to comment.