---
src/tethering.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/src/tethering.c b/src/tethering.c
index 9ab90e0..36ae1c8 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -3,6 +3,7 @@
* Connection Manager
*
* Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ProFUSION embedded systems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -50,6 +51,9 @@
#define BRIDGE_IP_END "192.168.218.200"
#define BRIDGE_DNS "8.8.8.8"
+#define PRIVATE_NETWORK_IP "192.168.219.1"
+#define PRIVATE_NETWORK_NETMASK "255.255.255.0"
+
static char *default_interface = NULL;
static volatile gint tethering_enabled;
static GDHCPServer *tethering_dhcp_server = NULL;
@@ -423,11 +427,42 @@ static void setup_tun_interface(unsigned int flags,
unsigned change,
void *data)
{
struct connman_private_network *pn = data;
+ struct connman_ipaddress ipaddress;
+ DBusMessage *reply;
+ int err;
DBG("index %d flags %d change %d", pn->index, flags, change);
+ if (flags & IFF_UP)
+ return;
+
+ ipaddress.family = AF_INET;
+ ipaddress.prefixlen =
+ __connman_ipconfig_netmask_prefix_len(PRIVATE_NETWORK_NETMASK);
+ ipaddress.local = PRIVATE_NETWORK_IP;
+ ipaddress.peer = PRIVATE_NETWORK_IP;
+ ipaddress.broadcast = NULL;
+ ipaddress.gateway = NULL;
+
+ connman_inet_set_address(pn->index, &ipaddress);
+
+ connman_inet_ifup(pn->index);
+
+ err = enable_nat(default_interface);
+ if (err < 0) {
+ connman_error("failed to enable NAT on %s", default_interface);
+ goto error;
+ }
+
g_dbus_send_reply(connection, pn->msg, DBUS_TYPE_UNIX_FD, &pn->fd,
DBUS_TYPE_INVALID);
+ return;
+
+error:
+ reply = __connman_error_failed(pn->msg, -err);
+ g_dbus_send_message(connection, reply);
+
+ g_hash_table_remove(pn_hash, pn->owner);
}
static void remove_private_network(gpointer user_data)
@@ -438,6 +473,8 @@ static void remove_private_network(gpointer user_data)
connman_rtnl_remove_watch(pn->iface_watch);
+ disable_nat(default_interface);
+
if (pn->watch > 0) {
g_dbus_remove_watch(connection, pn->watch);
pn->watch = 0;
--
1.7.4.1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman