Skip to content

Commit

Permalink
Add configuration support for ip forwarding/nat support
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Nov 27, 2013
1 parent fa5488f commit a72e9c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/usb_moded-doc.txt
Expand Up @@ -138,6 +138,16 @@ for example : usb_moded_ip=192.168.3.100::192.168.3.1:255.255.255.0::usb0:off

NOTE: The device must be usb0! The autoconf value is ignored.

Ip forwarding or nat can also be set up by usb_moded. This is in case you want to use an interface
on the device to route traffic coming from your pc/laptop. The best use case example would be connecting
to the internet over USB using the data connection of your smartphone.

To enable this you need to add the following lines to your network config (the example expects rmnet0 to be
your internet facing interface). When a nat_interface is defined it will be enabled.

nat_interface = rmnet0


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

Expand Down Expand Up @@ -238,7 +248,7 @@ sysfs_value = /* the values */
sysfs_reset_value = /* in case a reset value needs to be written */
softconnect_path = /* a path in case the module needs activation with a softconnect option */
softconnect = /* value to be written to enable */
softconneci_disconnect = /* value to be written for disable */
softconnect_disconnect = /* value to be written for disable */

Only the mode name and module are mandatory. In case you do not use modules, use none as the value
for module (as for the android gadget for example. See the android section for more info)
Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -143,6 +143,11 @@ const char * get_network_gateway(void)
return(get_conf_string(NETWORK_ENTRY, NETWORK_GATEWAY_KEY));
}

const char * get_network_nat_interface(void)
{
return(get_conf_string(NETWORK_ENTRY, NETWORK_NAT_INTERFACE_KEY));
}

/* create basic conffile with sensible defaults */
static void create_conf_file(void)
{
Expand Down
2 changes: 2 additions & 0 deletions src/usb_moded-config.h
Expand Up @@ -48,6 +48,7 @@
#define NETWORK_IP_KEY "ip"
#define NETWORK_INTERFACE_KEY "interface"
#define NETWORK_GATEWAY_KEY "gateway"
#define NETWORK_NAT_INTERFACE_KEY "nat_interface"
#define ANDROID_ENTRY "android"
#define ANDROID_MANUFACTURER_KEY "iManufacturer"
#define ANDROID_VENDOR_ID_KEY "idVendor"
Expand Down Expand Up @@ -79,6 +80,7 @@ const char * get_trigger_value(void);
const char * get_network_ip(void);
const char * get_network_interface(void);
const char * get_network_gateway(void);
const char * get_network_nat_interface(void);

const char * get_android_manufacturer(void);
const char * get_android_vendor_id(void);
Expand Down

0 comments on commit a72e9c6

Please sign in to comment.