int wmesh_request_set_softap_config(const char* softap_interface,
const char *ssid, const char* mode, int channel, int visibility,
int max_sta, int security, const char* passphrase);
+int wmesh_request_get_softap_config(char **softap_interface, char **ssid,
+ char **mode, int *channel, int *visibility,
+ int *max_sta, int *security, char **passphrase);
int wmesh_request_enable_softap(
const char* bridge_interface, const char* softap_interface);
int wmesh_request_disable_softap(
int wmesh_softap_set_configuration(const char* softap_interface,
const char *ssid, const char* mode, int channel, int visibility,
int max_sta, int security, const char* passphrase);
+int wmesh_softap_get_configuration(char **softap_interface, char **ssid,
+ char **mode, int *channel, int *visibility,
+ int *max_sta, int *security, char **passphrase);
int wmesh_softap_enable_softap();
int wmesh_softap_disable_softap();
<arg type="i" name="security" direction="in"/>\r
<arg type="i" name="result" direction="out"/>\r
</method>\r
+ <method name="get_softap">\r
+ <arg type="s" name="ssid" direction="out"/>\r
+ <arg type="s" name="mode" direction="out"/>\r
+ <arg type="i" name="channel" direction="out"/>\r
+ <arg type="i" name="visibility" direction="out"/>\r
+ <arg type="i" name="max_sta" direction="out"/>\r
+ <arg type="i" name="security" direction="out"/>\r
+ <arg type="s" name="passphrase" direction="out"/>\r
+ <arg type="i" name="result" direction="out"/>\r
+ </method>\r
<method name="enable_softap">\r
<arg type="i" name="result" direction="out"/>\r
</method>\r
return ret;
}
+int wmesh_request_get_softap_config(char **softap_interface, char **ssid,
+ char **mode, int *channel, int *visibility,
+ int *max_sta, int *security, char **passphrase)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Get configuration for SoftAP");
+
+ ret = wmesh_softap_get_configuration(softap_interface, ssid, mode, channel,
+ visibility, max_sta, security, passphrase);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get Configuration for SoftAP");
+ return ret;
+ }
+
+ return ret;
+}
+
int wmesh_request_enable_softap(
const char* bridge_interface, const char* softap_interface)
{
return TRUE;
}
+static gboolean _wmeshd_dbus_handle_get_softap(NetWmesh *object,
+ GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ char *interface, *ssid, *mode, *passphrase;
+ int channel, visibility, max_sta, security;
+ (void) service; // unused
+
+ /* Get softAP information */
+ ret = wmesh_request_get_softap_config(&interface, &ssid, &mode, &channel,
+ &visibility, &max_sta, &security, &passphrase);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to wmesh_request_get_softap_config [%d]", ret);
+ net_wmesh_complete_get_softap(object, invocation, "", "", 0, 0, 0, 0,
+ "", ret);
+ }
+
+ WMESH_LOGD("SSID : %s", ssid);
+ WMESH_LOGD("mode : %s", mode);
+ WMESH_LOGD("channel : %d", channel);
+ WMESH_LOGD("visibility: %d", visibility);
+ WMESH_LOGD("max_sta : %d", max_sta);
+ WMESH_LOGD("security : %d", security);
+ WMESH_LOGD("Passphrase : %s", passphrase ? passphrase : "NULL");
+
+ if (security == 1)
+ net_wmesh_complete_get_softap(object, invocation, ssid, mode, channel,
+ visibility, max_sta, security, passphrase, ret);
+ else
+ net_wmesh_complete_get_softap(object, invocation, ssid, mode, channel,
+ visibility, max_sta, security, "", ret);
+
+ return TRUE;
+}
+
static gboolean _wmeshd_dbus_handle_enable_softap(NetWmesh *object,
GDBusMethodInvocation *invocation, gpointer user_data)
{
G_CALLBACK(_wmeshd_dbus_handle_unset_gate), service);
g_signal_connect(meshd_dbus_object, "handle-set-softap",
G_CALLBACK(_wmeshd_dbus_handle_set_softap), service);
+ g_signal_connect(meshd_dbus_object, "handle-get-softap",
+ G_CALLBACK(_wmeshd_dbus_handle_get_softap), service);
g_signal_connect(meshd_dbus_object, "handle-enable-softap",
G_CALLBACK(_wmeshd_dbus_handle_enable_softap), service);
g_signal_connect(meshd_dbus_object, "handle-disable-softap",
#define MAX_BUF_SIZE (256u)
static int hostapd_ctrl_fd = 0;
+static char *g_passphrase = NULL;
static int __get_psk_hexascii(const char *pass, const unsigned char *salt,
char *psk, unsigned int psk_len)
return WMESHD_ERROR_NONE;
}
+static int __read_hostapd_config(char **softap_interface, char **ssid,
+ char **mode, int *channel, int *visibility, int *max_sta, int *security,
+ char **passphrase)
+{
+ FILE *fp = NULL;
+ char buf[256];
+
+ fp = fopen(HOSTAPD_MESH_CONF_FILE, "r");
+ if (fp == NULL) {
+ WMESH_LOGE("Failed to read file");
+ return WMESHD_ERROR_IO_ERROR;
+ }
+
+ if (!softap_interface || !ssid || !security || !passphrase || !mode ||
+ !channel || !visibility || !max_sta)
+ return WMESHD_ERROR_INVALID_PARAMETER;
+
+ *security = 0;
+
+ while (NULL != fgets(buf, sizeof(buf), fp)) {
+ if (strncmp(buf, "interface", strlen("interface")) == 0) {
+ *softap_interface = g_strdup(strrchr(buf, '=') + 1);
+ WMESH_LOGD("Interface: %s", *softap_interface);
+ } else if (strncmp(buf, "ssid", strlen("ssid")) == 0) {
+ *ssid = g_strdup(strrchr(buf, '=') + 1);
+ WMESH_LOGD("SSID: %s", *ssid);
+ } else if (strncmp(buf, "hw_mode", strlen("hw_mode")) == 0) {
+ *mode = g_strdup(strrchr(buf, '=') + 1);
+ WMESH_LOGD("Mode: %s", *mode);
+ } else if (strncmp(buf, "channel", strlen("channel")) == 0) {
+ *channel = atoi(strrchr(buf, '=') + 1);
+ WMESH_LOGD("Channel: %d", *channel);
+ } else if (strncmp(buf, "ignore_broadcast_ssid",
+ strlen("ignore_broadcast_ssid")) == 0) {
+ *visibility = atoi(strrchr(buf, '=') + 1) == 0 ? 1 : 0;
+ WMESH_LOGD("Visibility: %d", *visibility);
+ } else if (strncmp(buf, "max_num_sta", strlen("max_num_sta")) == 0) {
+ *max_sta = atoi(strrchr(buf, '=') + 1);
+ WMESH_LOGD("Max Station: %d", *max_sta);
+ } else if (strncmp(buf, "wpa=", strlen("wpa=")) == 0) {
+ *security = 1;
+ *passphrase = g_strdup(g_passphrase);
+ WMESH_LOGD("Security: %d", *security);
+ WMESH_LOGD("Passphrase: %s", *passphrase);
+ }
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
static int __open_hostapd_intf(const char* softap_interface, int *fd,
const char *intf)
{
ret = __config_hostapd(softap_interface, ssid, sec, passphrase,
mode, channel, visibility, mac_filter, max_sta);
+ if (ret == WMESHD_ERROR_NONE) {
+ g_free(g_passphrase);
+ g_passphrase = g_strdup(passphrase);
+ }
+
+ return ret;
+}
+
+int wmesh_softap_get_configuration(char **softap_interface, char **ssid,
+ char **mode, int *channel, int *visibility,
+ int *max_sta, int *security, char **passphrase)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ ret = __read_hostapd_config(softap_interface, ssid, mode, channel,
+ visibility, max_sta, security, passphrase);
+
return ret;
}