return SOFTAP_ERROR_NONE;
}
+API int softap_set_passphrase_changed_cb(softap_h softap, softap_passphrase_changed_cb callback, void *user_data)
+{
+ _retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(softap) is NULL\n");
+ _retvm_if(callback == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(callback) is NULL\n");
+
+ __softap_h *sa = (__softap_h *)softap;
+
+ sa->passphrase_changed_cb = callback;
+ sa->passphrase_user_data = user_data;
+
+ return SOFTAP_ERROR_NONE;
+}
+
+API int softap_unset_passphrase_changed_cb(softap_h softap)
+{
+ _retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(softap) is NULL\n");
+
+ __softap_h *sa = (__softap_h *)softap;
+
+ sa->passphrase_changed_cb = NULL;
+ sa->passphrase_user_data = NULL;
+
+ return SOFTAP_ERROR_NONE;
+}
+
API int softap_set_security_type(softap_h softap, softap_security_type_e type)
{
_retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
_retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
"parameter(softap) is NULL\n");
_retvm_if(visible == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
- "parameter(visible) is NULL\n");
+ "parameter(visible) is NULL\n");
return __get_visibility(visible);
}
+
+API int softap_set_passphrase(softap_h softap, const char *passphrase)
+{
+ _retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(softap) is NULL\n");
+ _retvm_if(passphrase == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(passphrase) is NULL\n");
+
+ __softap_h *sa = (__softap_h *)softap;
+ int passphrase_len = 0;
+
+ DBG("+");
+ passphrase_len = strlen(passphrase);
+ if (passphrase_len < SOFTAP_KEY_MIN_LEN ||
+ passphrase_len > SOFTAP_KEY_MAX_LEN) {
+ ERR("parameter(passphrase) is too short or long\n");
+ return SOFTAP_ERROR_INVALID_PARAMETER;
+ }
+
+ g_strlcpy(sa->passphrase, passphrase, sizeof(sa->passphrase));
+
+ DBG("-");
+ return SOFTAP_ERROR_NONE;
+}
+
+API int softap_get_passphrase(softap_h softap, char **passphrase)
+{
+ _retvm_if(softap == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(softap) is NULL\n");
+ _retvm_if(passphrase == NULL, SOFTAP_ERROR_INVALID_PARAMETER,
+ "parameter(passphrase) is NULL\n");
+
+ __softap_h *sa = (__softap_h *) softap;
+
+ char val[SOFTAP_KEY_MAX_LEN + 1] = {0, };
+ bool enable;
+
+ softap_is_enabled(softap, &enable);
+
+ if (!enable) {
+ if (sa->passphrase != NULL) {
+ *passphrase = strdup(sa->passphrase);
+ } else {
+ g_strlcpy(val, vconf_get_str(VCONFKEY_SOFTAP_KEY), sizeof(val));
+ *passphrase = strdup(val);
+ }
+ } else {
+ g_strlcpy(val, vconf_get_str(VCONFKEY_SOFTAP_KEY), sizeof(val));
+ *passphrase = strdup(val);
+ }
+
+ if (*passphrase == NULL) {
+ ERR("strdup is failed\n");
+ return SOFTAP_ERROR_OUT_OF_MEMORY;
+ }
+
+ return SOFTAP_ERROR_NONE;
+}
{
int ret = SOFTAP_ERROR_NONE;
char *ssid = NULL;
+ char *passphrase = NULL;
char *mac_address = NULL;
char *interface_name = NULL;
char *ip_address = NULL;
if (ret != SOFTAP_ERROR_NONE)
return 0;
+ ret = softap_get_passphrase(sa, &passphrase);
+ if (ret != SOFTAP_ERROR_NONE)
+ return 0;
+
ret = softap_get_ssid_visibility(sa, &visible);
if (ret != SOFTAP_ERROR_NONE)
return 0;
printf("* SSID: %s\n", ssid);
printf("* SSID visibility: %d\n", visible);
printf("* Security type: %d\n", security_type);
+ printf("* Passphrase: %s\n", passphrase);
printf("* MAC address: %s\n", mac_address);
printf("* Network Interface: %s\n", interface_name);
printf("* IP address: %s\n", ip_address);
printf("* subnet_mask: %s\n", subnet_mask);
if (ssid) g_free(ssid);
+ if (passphrase) g_free(passphrase);
if (mac_address) g_free(mac_address);
if (interface_name) g_free(interface_name);
if (ip_address) g_free(ip_address);
return 1;
}
+static int test_softap_set_passphrase(void)
+{
+ int ret;
+ char passphrase[65];
+
+ printf("Input passphrase for Softap: ");
+ ret = scanf("%64s", passphrase);
+ if (ret < 0) {
+ printf("scanf is failed!!\n");
+ return 0;
+ }
+
+ ret = softap_set_passphrase(sa, passphrase);
+ if (ret != SOFTAP_ERROR_NONE)
+ return 0;
+
+ return 1;
+}
+
static int test_softap_reload_settings(void)
{
int ret = softap_reload_settings(sa, __settings_reloaded_cb, NULL);
case '9':
rv = test_softap_set_security_type();
break;
+ case 'a':
+ rv = test_softap_set_passphrase();
+ break;
case 'b':
rv = test_softap_get_client_info();
break;