aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/wpa_ctrl.c
diff options
context:
space:
mode:
authorManikandan Mohan <manikand@qca.qualcomm.com>2015-08-25 04:34:03 (GMT)
committerJouni Malinen <j@w1.fi>2015-09-01 08:17:43 (GMT)
commit4ae7120919b16b8994212cd2675364159eeac5c7 (patch)
tree51803db019d328d0ffa002ee145ba672bdbd0e54 /src/common/wpa_ctrl.c
parent89a72e1c7f25b2e77619e6277f76e7603e3465f5 (diff)
downloadhostap-4ae7120919b16b8994212cd2675364159eeac5c7.zip
hostap-4ae7120919b16b8994212cd2675364159eeac5c7.tar.gz
hostap-4ae7120919b16b8994212cd2675364159eeac5c7.tar.bz2
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>
Diffstat (limited to 'src/common/wpa_ctrl.c')
-rw-r--r--src/common/wpa_ctrl.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 82d4655..820dd12 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);