diff options
| author | Manikandan Mohan <manikand@qca.qualcomm.com> | 2015-08-24 21:34:03 -0700 |
|---|---|---|
| committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:20:09 -0600 |
| commit | 24ed3efe545e0e9a7669da944ba484d91afb4e70 (patch) | |
| tree | 9f2bf5ec4c3fdac30adccac0fd9ae8355ff96a26 /src/common | |
| parent | 7a178f7ac60ce9cf1570f412c8b40af312f66673 (diff) | |
| download | android_external_wpa_supplicant_8-24ed3efe545e0e9a7669da944ba484d91afb4e70.tar.gz android_external_wpa_supplicant_8-24ed3efe545e0e9a7669da944ba484d91afb4e70.tar.bz2 android_external_wpa_supplicant_8-24ed3efe545e0e9a7669da944ba484d91afb4e70.zip | |
Allow wpa_cli/hostapd_cli client socket directory to be specified
This adds a new helper function wpa_ctrl_open2() that can be used
instead of wpa_ctrl_open() to override the default client socket
directory. Add optional -s<directory path> argument to hostapd_cli and
wpa_cli to allow the client socket directory to be specified.
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Git-commit: 4ae7120919b16b8994212cd2675364159eeac5c7
Git-repo : git://w1.fi/srv/git/hostap.git
Change-Id: I07f81b365d4f02d4590f91baa5de9f493612a9da
CRs-fixed: 908558
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/wpa_ctrl.c | 23 | ||||
| -rw-r--r-- | src/common/wpa_ctrl.h | 14 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c index 82d46552..820dd128 100644 --- a/src/common/wpa_ctrl.c +++ b/src/common/wpa_ctrl.c @@ -85,6 +85,13 @@ struct wpa_ctrl { struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path) { + return wpa_ctrl_open2(ctrl_path, NULL); +} + + +struct wpa_ctrl * wpa_ctrl_open2(const char *ctrl_path, + const char *cli_path) +{ struct wpa_ctrl *ctrl; static int counter = 0; int ret; @@ -108,10 +115,18 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path) ctrl->local.sun_family = AF_UNIX; counter++; try_again: - ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path), - CONFIG_CTRL_IFACE_CLIENT_DIR "/" - CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d", - (int) getpid(), counter); + if (cli_path && cli_path[0] == '/') { + ret = os_snprintf(ctrl->local.sun_path, + sizeof(ctrl->local.sun_path), + "%s/" CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d", + cli_path, (int) getpid(), counter); + } else { + ret = os_snprintf(ctrl->local.sun_path, + sizeof(ctrl->local.sun_path), + CONFIG_CTRL_IFACE_CLIENT_DIR "/" + CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d", + (int) getpid(), counter); + } if (os_snprintf_error(sizeof(ctrl->local.sun_path), ret)) { close(ctrl->s); os_free(ctrl); diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index f10d43ba..8738031c 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -316,6 +316,20 @@ enum wpa_vendor_elem_frame { */ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path); +/** + * wpa_ctrl_open2 - Open a control interface to wpa_supplicant/hostapd + * @ctrl_path: Path for UNIX domain sockets; ignored if UDP sockets are used. + * @cli_path: Path for client UNIX domain sockets; ignored if UDP socket + * is used. + * Returns: Pointer to abstract control interface data or %NULL on failure + * + * This function is used to open a control interface to wpa_supplicant/hostapd + * when the socket path for client need to be specified explicitly. Default + * ctrl_path is usually /var/run/wpa_supplicant or /var/run/hostapd and client + * socket path is /tmp. + */ +struct wpa_ctrl * wpa_ctrl_open2(const char *ctrl_path, const char *cli_path); + /** * wpa_ctrl_close - Close a control interface to wpa_supplicant/hostapd |
