]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow the privsep driver to pass the set_country to the real driver
authorDaniel Mierswa <impulze@impulze.org>
Sun, 15 Feb 2009 12:13:27 +0000 (14:13 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 15 Feb 2009 12:13:27 +0000 (14:13 +0200)
src/common/privsep_commands.h
src/drivers/driver_privsep.c
wpa_supplicant/wpa_priv.c

index f8f9c1b3428e5bfa195e43539f2d9f6323a3c6ba..81b7f5432eccd8303a25cef4c1aedec6b5fb40f2 100644 (file)
@@ -31,6 +31,7 @@ enum privsep_cmd {
        PRIVSEP_CMD_L2_NOTIFY_AUTH_START,
        PRIVSEP_CMD_L2_SEND,
        PRIVSEP_CMD_SET_MODE,
+       PRIVSEP_CMD_SET_COUNTRY,
 };
 
 struct privsep_cmd_associate
index abe4303ebbfc768a569dc2145d7741f08f8326c9..d1bfe29df748218edb60ef22ee424ee5492ae2ba 100644 (file)
@@ -756,6 +756,15 @@ static int wpa_driver_privsep_set_mode(void *priv, int mode)
 }
 
 
+static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
+{
+       struct wpa_driver_privsep_data *drv = priv;
+       wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
+       return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
+                           os_strlen(alpha2), NULL, NULL);
+}
+
+
 struct wpa_driver_ops wpa_driver_privsep_ops = {
        "privsep",
        "wpa_supplicant privilege separated driver",
@@ -796,7 +805,7 @@ struct wpa_driver_ops wpa_driver_privsep_ops = {
        wpa_driver_privsep_get_scan_results2,
        NULL /* set_probe_req_ie */,
        wpa_driver_privsep_set_mode,
-       NULL /* set_country */,
+       wpa_driver_privsep_set_country,
        NULL /* global_init */,
        NULL /* global_deinit */,
        NULL /* init2 */,
index 8ad20caba1b0e47f4c7102b5e108381416d4293a..4a27125d9c87a311e00e4c1df03d28fb6ea7b4f7 100644 (file)
@@ -575,10 +575,21 @@ static void wpa_priv_cmd_set_mode(struct wpa_priv_interface *iface,
 }
 
 
+static void wpa_priv_cmd_set_country(struct wpa_priv_interface *iface,
+                                    char *buf)
+{
+       if (iface->drv_priv == NULL || iface->driver->set_country == NULL ||
+           *buf == '\0')
+               return;
+
+       iface->driver->set_country(iface->drv_priv, buf);
+}
+
+
 static void wpa_priv_receive(int sock, void *eloop_ctx, void *sock_ctx)
 {
        struct wpa_priv_interface *iface = eloop_ctx;
-       char buf[2000];
+       char buf[2000], *pos;
        void *cmd_buf;
        size_t cmd_len;
        int res, cmd;
@@ -649,6 +660,13 @@ static void wpa_priv_receive(int sock, void *eloop_ctx, void *sock_ctx)
        case PRIVSEP_CMD_SET_MODE:
                wpa_priv_cmd_set_mode(iface, cmd_buf, cmd_len);
                break;
+       case PRIVSEP_CMD_SET_COUNTRY:
+               pos = cmd_buf;
+               if (pos + cmd_len >= buf + sizeof(buf))
+                       break;
+               pos[cmd_len] = '\0';
+               wpa_priv_cmd_set_country(iface, pos);
+               break;
        }
 }