---
 src/tethering.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/tethering.c b/src/tethering.c
index 0357530..e310cf0 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -58,9 +58,6 @@
 
 #define DEFAULT_MTU    1500
 
-#define PRIVATE_NETWORK_IP "192.168.219.1"
-#define PRIVATE_NETWORK_PEER_IP "192.168.219.2"
-#define PRIVATE_NETWORK_NETMASK "255.255.255.0"
 #define PRIVATE_NETWORK_PRIMARY_DNS BRIDGE_DNS
 #define PRIVATE_NETWORK_SECONDARY_DNS "8.8.4.4"
 
@@ -80,8 +77,10 @@ struct connman_private_network {
        char *interface;
        int index;
        guint iface_watch;
+       struct connman_ippool *pool;
        const char *server_ip;
        const char *peer_ip;
+       const char *subnet_mask;
        const char *primary_dns;
        const char *secondary_dns;
 };
@@ -430,7 +429,7 @@ static void setup_tun_interface(unsigned int flags, 
unsigned change,
                return;
 
        prefixlen =
-               __connman_ipconfig_netmask_prefix_len(PRIVATE_NETWORK_NETMASK);
+               __connman_ipconfig_netmask_prefix_len(pn->subnet_mask);
 
        if ((__connman_inet_modify_address(RTM_NEWADDR,
                                NLM_F_REPLACE | NLM_F_ACK, pn->index, AF_INET,
@@ -485,6 +484,7 @@ static void remove_private_network(gpointer user_data)
 
        disable_nat(default_interface);
        connman_rtnl_remove_watch(pn->iface_watch);
+       __connman_ippool_remove(pn->pool);
 
        if (pn->watch > 0) {
                g_dbus_remove_watch(connection, pn->watch);
@@ -561,8 +561,12 @@ int __connman_private_network_request(DBusMessage *msg, 
const char *owner)
        pn->fd = fd;
        pn->interface = iface;
        pn->index = index;
-       pn->server_ip = PRIVATE_NETWORK_IP;
-       pn->peer_ip = PRIVATE_NETWORK_PEER_IP;
+       pn->pool = __connman_ippool_create(iface, 1, 0, NULL, NULL,
+                                               &pn->server_ip, &pn->peer_ip,
+                                               &pn->subnet_mask, &err);
+       if (pn->pool == NULL)
+               goto error;
+
        pn->primary_dns = PRIVATE_NETWORK_PRIMARY_DNS;
        pn->secondary_dns = PRIVATE_NETWORK_SECONDARY_DNS;
 
-- 
1.7.1

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to