[capi-tethering] Add APIs for dhcp feature
[platform/core/api/tethering.git] / src / tethering.c
index 8c178ab..5c39b85 100755 (executable)
 #include <ckmc/ckmc-manager.h>
 #include "tethering_private.h"
 
+#define ALLOWED_LIST   "/etc/hostapd.accept"
+#define BLOCKED_LIST   "/etc/hostapd.deny"
+#define TEMP_LIST      "/etc/hostapd_tmp"
+#define MAC_ADDR_LEN   18
+#define MAX_BUF_SIZE   80
+
 static void __handle_wifi_tether_on(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                        GVariant *parameters, gpointer user_data);
@@ -95,8 +101,6 @@ static void __handle_dhcp(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data);
 
-static void __get_key_manager_alias(char* alias, size_t buff_len);
-
 static __tethering_sig_t sigs[] = {
        {0, SIGNAL_NAME_NET_CLOSED, __handle_net_closed},
        {0, SIGNAL_NAME_WIFI_TETHER_ON, __handle_wifi_tether_on},
@@ -251,80 +255,6 @@ static unsigned int __generate_initial_passphrase(char *passphrase, unsigned int
        return index;
 }
 
-static tethering_error_e __set_passphrase(const char *passphrase, const unsigned int size)
-{
-       if (passphrase == NULL || size == 0)
-               return TETHERING_ERROR_INVALID_PARAMETER;
-
-       int ret = -1;
-       char alias[MAX_ALIAS_LEN] = {0, };
-       ckmc_raw_buffer_s ckmc_buf;
-       ckmc_policy_s ckmc_policy;
-
-       ckmc_policy.password = NULL;
-       ckmc_policy.extractable = true;
-
-       ckmc_buf.data = (unsigned char *) passphrase;
-       ckmc_buf.size = strlen(passphrase);
-
-       __get_key_manager_alias(alias, sizeof(alias));
-       ret = ckmc_save_data(alias, ckmc_buf, ckmc_policy);
-       if (ret != CKMC_ERROR_NONE) {
-               ERR("Fail to save the passphrase : %d\n", ret);
-               return TETHERING_ERROR_OPERATION_FAILED;
-       }
-
-       return TETHERING_ERROR_NONE;
-}
-
-static void __get_key_manager_alias(char* alias, size_t buff_len)
-{
-       snprintf(alias, buff_len, "%s%s%s", ckmc_owner_id_system,
-                                       ckmc_owner_id_separator,
-                                       TETHERING_WIFI_PASSPHRASE_STORE_KEY);
-}
-
-static tethering_error_e __get_passphrase(char *passphrase,
-               unsigned int passphrase_size, unsigned int *passphrase_len)
-{
-       if (passphrase == NULL || passphrase_size == 0) {
-               ERR("Invalid parameter\n");
-               return TETHERING_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       char tmp[TETHERING_WIFI_KEY_MAX_LEN + 1] = {0, };
-       char alias[MAX_ALIAS_LEN] = {0, };
-       ckmc_raw_buffer_s *ckmc_buf;
-
-       __get_key_manager_alias(alias, sizeof(alias));
-       ret = ckmc_get_data(alias, NULL, &ckmc_buf);
-       if (ret < 0) {
-               DBG("Create new password\n");
-               ret = __generate_initial_passphrase(tmp, sizeof(tmp));
-
-               if (ret == 0) {
-                       ERR("generate_initial_passphrase failed : %d\n", *passphrase_len);
-                       return TETHERING_ERROR_OPERATION_FAILED;
-               } else {
-                       *passphrase_len = ret;
-                       g_strlcpy(passphrase, tmp, (*passphrase_len)+1);
-
-                       if (__set_passphrase(passphrase, *passphrase_len) != TETHERING_ERROR_NONE) {
-                               DBG("set_passphrase is failed : %s, %d", passphrase, *passphrase_len);
-                               return TETHERING_ERROR_OPERATION_FAILED;
-                       }
-               }
-       } else {
-               *passphrase_len = ckmc_buf->size;
-               g_strlcpy(passphrase, (char *)ckmc_buf->data, (*passphrase_len) + 1);
-       }
-
-       g_free(alias);
-
-       return TETHERING_ERROR_NONE;
-}
-
 static tethering_error_e __get_error(int agent_error)
 {
        tethering_error_e err = TETHERING_ERROR_NONE;
@@ -1388,12 +1318,11 @@ static int __get_common_ssid(char *ssid, unsigned int size)
 
        ptr = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
        if (ptr == NULL) {
-               ERR("vconf_get_str is failed\n");
-               DBG("-\n");
-               return TETHERING_ERROR_OPERATION_FAILED;
-       }
+               ERR("vconf_get_str is failed and set default ssid");
+               g_strlcpy(ssid, TETHERING_DEFAULT_SSID, size);
+       } else
+               g_strlcpy(ssid, ptr, size);
 
-       g_strlcpy(ssid, ptr, size);
        free(ptr);
 
        if (!g_utf8_validate(ssid, -1, (const char **)&ptr_tmp))
@@ -1402,12 +1331,37 @@ static int __get_common_ssid(char *ssid, unsigned int size)
        return TETHERING_ERROR_NONE;
 }
 
+static bool __get_wifi_mode_type(tethering_wifi_mode_type_e type, char **buf)
+{
+       _retvm_if(buf == NULL, false, "parameter(buf) is NULL\n");
+
+       switch (type) {
+               case TETHERING_WIFI_MODE_TYPE_B:
+                       *buf = g_strdup("b");
+                       break;
+               case TETHERING_WIFI_MODE_TYPE_G:
+                       *buf = g_strdup("g");
+                       break;
+               case TETHERING_WIFI_MODE_TYPE_A:
+                       *buf = g_strdup("a");
+                       break;
+               case TETHERING_WIFI_MODE_TYPE_AD:
+                       *buf = g_strdup("ad");
+                       break;
+               default:
+                       ERR("Not supported type : %d\n", type);
+                       return false;
+       }
+       return true;
+}
+
 static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *set)
 {
        DBG("+\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
        tethering_error_e ret = TETHERING_ERROR_NONE;
+       char *ptr = NULL;
 
        if (th == NULL || set == NULL) {
                ERR("null parameter\n-\n");
@@ -1427,18 +1381,47 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
        if (ret != TETHERING_ERROR_NONE)
                set->visibility = th->visibility;
 
+       set->mac_filter = th->mac_filter;
+       set->channel = th->channel;
+
+       __get_wifi_mode_type (th->mode_type, &ptr);
+       if (ptr == NULL) {
+               g_strlcpy(set->mode, "", sizeof(set->mode));
+       } else {
+               g_strlcpy(set->mode, ptr, sizeof(set->mode));
+               free(ptr);
+       }
+
        if (set->sec_type == TETHERING_WIFI_SECURITY_TYPE_NONE) {
                g_strlcpy(set->key, "", sizeof(set->key));
        } else {
-               char pass[TETHERING_WIFI_KEY_MAX_LEN + 1] = {0, };
+               GDBusProxy *proxy = th->client_bus_proxy;
+               GVariant *parameters;
+               GError *error = NULL;
+               char *passphrase = NULL;
                unsigned int len = 0;
 
-               ret = __get_passphrase(pass, sizeof(pass), &len);
-               if (ret != TETHERING_ERROR_NONE) {
-                       ERR("getting passphrase failed\n");
-                       return TETHERING_ERROR_OPERATION_FAILED;
+               parameters = g_dbus_proxy_call_sync(proxy, "get_wifi_tethering_passphrase",
+                               NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+               if (error) {
+                       ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+                       if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                               ret = TETHERING_ERROR_PERMISSION_DENIED;
+                       else
+                               ret = TETHERING_ERROR_OPERATION_FAILED;
+
+                       g_error_free(error);
+                       return ret;
+               }
+
+               if (parameters != NULL) {
+                       g_variant_get(parameters, "(siu)", &passphrase, &len, &ret);
+                       g_variant_unref(parameters);
                }
-               g_strlcpy(set->key, pass, sizeof(set->key));
+
+               g_strlcpy(set->key, passphrase, sizeof(set->key));
        }
        DBG("-\n");
        return TETHERING_ERROR_NONE;
@@ -1533,6 +1516,9 @@ API int tethering_create(tethering_h *tethering)
        memset(th, 0x00, sizeof(__tethering_h));
        th->sec_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
        th->visibility = true;
+       th->mac_filter = false;
+       th->channel = 6;
+       th->mode_type = TETHERING_WIFI_MODE_TYPE_G;
 
        if (__generate_initial_passphrase(th->passphrase,
                        sizeof(th->passphrase)) == 0) {
@@ -1680,7 +1666,7 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                break;
 
        case TETHERING_TYPE_WIFI: {
-               _softap_settings_t set = {"", "", 0, false};
+               _softap_settings_t set = {"", "", "", 0, false};
 
                ret = __prepare_wifi_settings(tethering, &set);
                if (ret != TETHERING_ERROR_NONE) {
@@ -1692,7 +1678,7 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                                sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
 
                g_dbus_proxy_call(proxy, "enable_wifi_tethering",
-                               g_variant_new("(ssii)", set.ssid, set.key, set.visibility, set.sec_type),
+                               g_variant_new("(sssiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.sec_type),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1709,7 +1695,7 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                break;
 
        case TETHERING_TYPE_RESERVED: {
-               _softap_settings_t set = {"", "", 0, false};
+               _softap_settings_t set = {"", "", "", 0, false};
 
                ret = __prepare_wifi_ap_settings(tethering, &set);
                if (ret != TETHERING_ERROR_NONE) {
@@ -1726,7 +1712,7 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                break;
        }
        case TETHERING_TYPE_ALL: {
-               _softap_settings_t set = {"", "", 0, false};
+               _softap_settings_t set = {"", "", "", 0, false};
 
                ret = __prepare_wifi_settings(tethering, &set);
                if (ret != TETHERING_ERROR_NONE) {
@@ -3019,12 +3005,13 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr
                        "parameter(passphrase) is NULL\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters;
+       GError *error = NULL;
        int passphrase_len = 0;
+       int ret = 0;
 
-       char old_passphrase[TETHERING_WIFI_KEY_MAX_LEN + 1] = {0, };
-       unsigned int old_len = 0;
-       tethering_error_e ret = TETHERING_ERROR_NONE;
-
+       DBG("+");
        passphrase_len = strlen(passphrase);
        if (passphrase_len < TETHERING_WIFI_KEY_MIN_LEN ||
                        passphrase_len > TETHERING_WIFI_KEY_MAX_LEN) {
@@ -3032,17 +3019,30 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
-       ret = __get_passphrase(old_passphrase, sizeof(old_passphrase), &old_len);
-       if (ret == TETHERING_ERROR_NONE && old_len == passphrase_len &&
-                       !g_strcmp0(old_passphrase, passphrase)) {
-               return TETHERING_ERROR_NONE;
+       parameters = g_dbus_proxy_call_sync(proxy, "set_wifi_tethering_passphrase",
+                       g_variant_new("(s)", passphrase), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
        }
 
-       ret = __set_passphrase(passphrase, passphrase_len);
+       g_variant_get(parameters, "(u)", &ret);
+       g_variant_unref(parameters);
+
        if (ret == TETHERING_ERROR_NONE) {
                __send_dbus_signal(th->client_bus,
                                SIGNAL_NAME_PASSPHRASE_CHANGED, NULL);
        }
+
+       DBG("-");
        return ret;
 }
 
@@ -3071,23 +3071,91 @@ API int tethering_wifi_get_passphrase(tethering_h tethering, char **passphrase)
        _retvm_if(passphrase == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(passphrase) is NULL\n");
 
-       char passphrase_buf[TETHERING_WIFI_KEY_MAX_LEN + 1] = {0, };
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters;
+       GError *error = NULL;
        unsigned int len = 0;
        tethering_error_e ret = TETHERING_ERROR_NONE;
 
-       ret = __get_passphrase(passphrase_buf, sizeof(passphrase_buf), &len);
-       if (ret != TETHERING_ERROR_NONE)
+       parameters = g_dbus_proxy_call_sync(proxy, "get_wifi_tethering_passphrase",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
                return ret;
+       }
 
-       *passphrase = strdup(passphrase_buf);
-       if (*passphrase == NULL) {
-               ERR("strdup is failed\n");
-               return TETHERING_ERROR_OUT_OF_MEMORY;
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(siu)", passphrase, &len, &ret);
+               g_variant_unref(parameters);
        }
 
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_wifi_set_channel(tethering_h tethering, int channel)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       th->channel = channel;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_get_channel(tethering_h tethering, int *channel)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       _retvm_if(channel == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(channel) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       *channel = th->channel;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_set_mode(tethering_h tethering, tethering_wifi_mode_type_e type)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+
+       th->mode_type = type;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_get_mode(tethering_h tethering, tethering_wifi_mode_type_e *type)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(type) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       *type = th->mode_type;
+
+       return TETHERING_ERROR_NONE;
+}
+
+
 /**
  * @internal
  * @brief Reload the settings (SSID / Passphrase / Security type / SSID visibility).
@@ -3114,7 +3182,7 @@ API int tethering_wifi_reload_settings(tethering_h tethering, tethering_wifi_set
                        "parameter(callback) is NULL\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
-       _softap_settings_t set = {"", "", 0, false};
+       _softap_settings_t set = {"", "", "", 0, false};
        GDBusProxy *proxy = th->client_bus_proxy;
        int ret = 0;
 
@@ -3135,13 +3203,248 @@ API int tethering_wifi_reload_settings(tethering_h tethering, tethering_wifi_set
        th->settings_reloaded_user_data = user_data;
 
        g_dbus_proxy_call(proxy, "reload_wifi_settings",
-                       g_variant_new("(ssii)", set.ssid, set.key, set.visibility, set.sec_type),
+                       g_variant_new("(sssiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.sec_type),
                        G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                        (GAsyncReadyCallback) __settings_reloaded_cb, (gpointer)tethering);
 
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_wifi_set_mac_filter(tethering_h tethering, bool mac_filter)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       th->mac_filter = mac_filter;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_get_mac_filter(tethering_h tethering, bool *mac_filter)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(mac_filter == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(mac_filter) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       *mac_filter = th->mac_filter;
+
+       return TETHERING_ERROR_NONE;
+}
+
+static int __add_mac_to_file(const char *filepath, const char *mac)
+{
+       FILE *fp = NULL;
+       char line[MAX_BUF_SIZE] = "\0";
+       bool mac_exist = false;
+
+       fp = fopen(filepath, "a+");
+       if (!fp) {
+               ERR("fopen is failed\n");
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+
+       while (fgets(line, MAX_BUF_SIZE, fp) != NULL) {
+               if (strncmp(mac, line, 17) == 0) {
+                       DBG("MAC %s already exist in the list\n", mac);
+                       mac_exist = true;
+                       break;
+               }
+       }
+
+       if (!mac_exist)
+               fprintf(fp, "%s\n", mac);
+
+       fclose(fp);
+
+       return TETHERING_ERROR_NONE;
+}
+
+static int __remove_mac_from_file(const char *filepath, const char *mac)
+{
+       FILE *fp = NULL;
+       FILE *fp1 = NULL;
+       char line[MAX_BUF_SIZE] = "\0";
+
+       fp = fopen(filepath, "r");
+       if (!fp) {
+               ERR("fopen is failed\n");
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+
+       fp1 = fopen(TEMP_LIST, "w+");
+       if (!fp1) {
+               fclose(fp);
+               ERR("fopen is failed\n");
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+
+       while (fgets(line, MAX_BUF_SIZE, fp) != NULL) {
+               if (strncmp(mac, line, 17) == 0)
+                       DBG("MAC %s found in the list\n", mac);
+               else
+                       fprintf(fp1, "%s", line);
+       }
+
+       fclose(fp);
+       fclose(fp1);
+
+       if ((strcmp(filepath, ALLOWED_LIST) == 0))
+               rename(TEMP_LIST, ALLOWED_LIST);
+       else if ((strcmp(filepath, BLOCKED_LIST) == 0))
+               rename(TEMP_LIST, BLOCKED_LIST);
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_add_allowed_mac_list(tethering_h tethering, const char *mac)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(mac == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(mac) is NULL\n");
+
+       return __add_mac_to_file(ALLOWED_LIST, mac);
+}
+
+API int tethering_wifi_remove_allowed_mac_list(tethering_h tethering, const char *mac)
+{
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(mac == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(mac) is NULL\n");
+
+       return __remove_mac_from_file(ALLOWED_LIST, mac);
+}
+
+API int tethering_wifi_add_blocked_mac_list(tethering_h tethering, const char *mac)
+{
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(mac == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(mac) is NULL\n");
+
+       return __add_mac_to_file(BLOCKED_LIST, mac);
+}
+
+API int tethering_wifi_remove_blocked_mac_list(tethering_h tethering, const char *mac)
+{
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(mac == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(mac) is NULL\n");
+
+       return __remove_mac_from_file(BLOCKED_LIST, mac);
+}
+
+API int tethering_wifi_enable_dhcp(tethering_h tethering, bool enable)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       GVariant *parameters;
+       GError *error = NULL;
+       guint result;
+
+       __tethering_h *th = (__tethering_h *)tethering;
+
+       GDBusProxy *proxy = th->client_bus_proxy;
+
+       parameters = g_dbus_proxy_call_sync (proxy, "enable_dhcp",
+                       g_variant_new("(b)", enable),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       result = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       result = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               th->dhcp_enabled = false;
+
+               return result;
+       }
+
+       g_variant_get (parameters, "(u)", &result);
+       g_variant_unref(parameters);
+
+       if (enable) {
+               th->dhcp_enabled = true;
+       } else {
+               th->dhcp_enabled = false;
+       }
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_set_dhcp_range(tethering_h tethering, char *rangestart, char *rangestop)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(rangestart == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(rangestart) is NULL\n");
+       _retvm_if(rangestop == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(rangestop) is NULL\n");
+
+       GVariant *parameters;
+       GError *error = NULL;
+       guint result;
+
+       __tethering_h *th = (__tethering_h *)tethering;
+
+       GDBusProxy *proxy = th->client_bus_proxy;
+
+       parameters = g_dbus_proxy_call_sync (proxy, "dhcp_range",
+                       g_variant_new("(ss)", rangestart, rangestop),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       result = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       result = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               th->dhcp_enabled = false;
+
+               return result;
+       }
+
+       g_variant_get (parameters, "(u)", &result);
+       g_variant_unref(parameters);
+
+       th->dhcp_enabled = true;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_is_dhcp_enabled(tethering_h tethering, bool *dhcp_enabled)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(dhcp_enabled == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(dhcp_enabled) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       *dhcp_enabled = th->dhcp_enabled;
+
+       return TETHERING_ERROR_NONE;
+}
+
 /**
  * @internal
  * @brief Sets the security type of Wi-Fi AP.
@@ -3437,7 +3740,7 @@ API int tethering_wifi_ap_reload_settings(tethering_h tethering, tethering_wifi_
                        "parameter(callback) is NULL\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
-       _softap_settings_t set = {"", "", 0, false};
+       _softap_settings_t set = {"", "", "", 0, false};
        GDBusProxy *proxy = th->client_bus_proxy;
        int ret = 0;