1/*
2 * WPA Supplicant - privilege separated driver interface
3 * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
--- 4 unchanged lines hidden (view full) ---
13 */
14
15#include "includes.h"
16#include <sys/un.h>
17
18#include "common.h"
19#include "driver.h"
20#include "eloop.h"
21#include "common/privsep_commands.h"
22
23
24struct wpa_driver_privsep_data {
25 void *ctx;
26 u8 own_addr[ETH_ALEN];
27 int priv_socket;
28 char *own_socket_path;
29 int cmd_socket;
--- 67 unchanged lines hidden (view full) ---
97 return -1;
98 }
99 }
100
101 return 0;
102}
103
104
105static int wpa_driver_privsep_scan(void *priv,
106 struct wpa_driver_scan_params *params)
107{
108 struct wpa_driver_privsep_data *drv = priv;
109 const u8 *ssid = params->ssids[0].ssid;
110 size_t ssid_len = params->ssids[0].ssid_len;
111 wpa_printf(MSG_DEBUG, "%s: priv=%p", __func__, priv);
112 return wpa_priv_cmd(drv, PRIVSEP_CMD_SCAN, ssid, ssid_len,
113 NULL, NULL);
114}
115
116
117static struct wpa_scan_results *
118wpa_driver_privsep_get_scan_results2(void *priv)
--- 66 unchanged lines hidden (view full) ---
185 results->res[results->num++] = r;
186 }
187
188 os_free(buf);
189 return results;
190}
191
192
193static int wpa_driver_privsep_set_key(const char *ifname, void *priv,
194 enum wpa_alg alg, const u8 *addr,
195 int key_idx, int set_tx,
196 const u8 *seq, size_t seq_len,
197 const u8 *key, size_t key_len)
198{
199 struct wpa_driver_privsep_data *drv = priv;
200 struct privsep_cmd_set_key cmd;
201
202 wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
203 __func__, priv, alg, key_idx, set_tx);
204
205 os_memset(&cmd, 0, sizeof(cmd));
--- 110 unchanged lines hidden (view full) ---
316 //struct wpa_driver_privsep_data *drv = priv;
317 wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
318 __func__, MAC2STR(addr), reason_code);
319 wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
320 return 0;
321}
322
323
324static void wpa_driver_privsep_event_assoc(void *ctx,
325 enum wpa_event_type event,
326 u8 *buf, size_t len)
327{
328 union wpa_event_data data;
329 int inc_data = 0;
330 u8 *pos, *end;
331 int ie_len;
332
333 os_memset(&data, 0, sizeof(data));
--- 95 unchanged lines hidden (view full) ---
429 wpa_supplicant_event(ctx, EVENT_FT_RESPONSE, &data);
430}
431
432
433static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
434{
435 if (len < ETH_ALEN)
436 return;
437 drv_event_eapol_rx(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
438}
439
440
441static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
442 void *sock_ctx)
443{
444 struct wpa_driver_privsep_data *drv = eloop_ctx;
445 u8 *buf, *event_buf;
446 size_t event_len;
447 int res, event;
448 enum privsep_event e;
--- 60 unchanged lines hidden (view full) ---
509 case PRIVSEP_EVENT_FT_RESPONSE:
510 wpa_driver_privsep_event_ft_response(drv->ctx, event_buf,
511 event_len);
512 break;
513 case PRIVSEP_EVENT_RX_EAPOL:
514 wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
515 event_len);
516 break;
517 }
518
519 os_free(buf);
520}
521
522
523static void * wpa_driver_privsep_init(void *ctx, const char *ifname)
524{
--- 192 unchanged lines hidden (view full) ---
717static const u8 * wpa_driver_privsep_get_mac_addr(void *priv)
718{
719 struct wpa_driver_privsep_data *drv = priv;
720 wpa_printf(MSG_DEBUG, "%s", __func__);
721 return drv->own_addr;
722}
723
724
725static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
726{
727 struct wpa_driver_privsep_data *drv = priv;
728 wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
729 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
730 os_strlen(alpha2), NULL, NULL);
731}
732
733
734struct wpa_driver_ops wpa_driver_privsep_ops = {
735 "privsep",
736 "wpa_supplicant privilege separated driver",
737 .get_bssid = wpa_driver_privsep_get_bssid,
738 .get_ssid = wpa_driver_privsep_get_ssid,
739 .set_key = wpa_driver_privsep_set_key,
740 .init = wpa_driver_privsep_init,
741 .deinit = wpa_driver_privsep_deinit,
742 .set_param = wpa_driver_privsep_set_param,
743 .scan2 = wpa_driver_privsep_scan,
744 .deauthenticate = wpa_driver_privsep_deauthenticate,
745 .disassociate = wpa_driver_privsep_disassociate,
746 .associate = wpa_driver_privsep_associate,
747 .get_capa = wpa_driver_privsep_get_capa,
748 .get_mac_addr = wpa_driver_privsep_get_mac_addr,
749 .get_scan_results2 = wpa_driver_privsep_get_scan_results2,
750 .set_country = wpa_driver_privsep_set_country,
751};
752
753
754struct wpa_driver_ops *wpa_drivers[] =
755{
756 &wpa_driver_privsep_ops,
757 NULL
758};
2 * WPA Supplicant - privilege separated driver interface
3 * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
--- 4 unchanged lines hidden (view full) ---
13 */
14
15#include "includes.h"
16#include <sys/un.h>
17
18#include "common.h"
19#include "driver.h"
20#include "eloop.h"
21#include "common/privsep_commands.h"
22
23
24struct wpa_driver_privsep_data {
25 void *ctx;
26 u8 own_addr[ETH_ALEN];
27 int priv_socket;
28 char *own_socket_path;
29 int cmd_socket;
--- 67 unchanged lines hidden (view full) ---
97 return -1;
98 }
99 }
100
101 return 0;
102}
103
104
105static int wpa_driver_privsep_scan(void *priv,
106 struct wpa_driver_scan_params *params)
107{
108 struct wpa_driver_privsep_data *drv = priv;
109 const u8 *ssid = params->ssids[0].ssid;
110 size_t ssid_len = params->ssids[0].ssid_len;
111 wpa_printf(MSG_DEBUG, "%s: priv=%p", __func__, priv);
112 return wpa_priv_cmd(drv, PRIVSEP_CMD_SCAN, ssid, ssid_len,
113 NULL, NULL);
114}
115
116
117static struct wpa_scan_results *
118wpa_driver_privsep_get_scan_results2(void *priv)
--- 66 unchanged lines hidden (view full) ---
185 results->res[results->num++] = r;
186 }
187
188 os_free(buf);
189 return results;
190}
191
192
193static int wpa_driver_privsep_set_key(const char *ifname, void *priv,
194 enum wpa_alg alg, const u8 *addr,
195 int key_idx, int set_tx,
196 const u8 *seq, size_t seq_len,
197 const u8 *key, size_t key_len)
198{
199 struct wpa_driver_privsep_data *drv = priv;
200 struct privsep_cmd_set_key cmd;
201
202 wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
203 __func__, priv, alg, key_idx, set_tx);
204
205 os_memset(&cmd, 0, sizeof(cmd));
--- 110 unchanged lines hidden (view full) ---
316 //struct wpa_driver_privsep_data *drv = priv;
317 wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
318 __func__, MAC2STR(addr), reason_code);
319 wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
320 return 0;
321}
322
323
324static void wpa_driver_privsep_event_assoc(void *ctx,
325 enum wpa_event_type event,
326 u8 *buf, size_t len)
327{
328 union wpa_event_data data;
329 int inc_data = 0;
330 u8 *pos, *end;
331 int ie_len;
332
333 os_memset(&data, 0, sizeof(data));
--- 95 unchanged lines hidden (view full) ---
429 wpa_supplicant_event(ctx, EVENT_FT_RESPONSE, &data);
430}
431
432
433static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
434{
435 if (len < ETH_ALEN)
436 return;
437 drv_event_eapol_rx(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
438}
439
440
441static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
442 void *sock_ctx)
443{
444 struct wpa_driver_privsep_data *drv = eloop_ctx;
445 u8 *buf, *event_buf;
446 size_t event_len;
447 int res, event;
448 enum privsep_event e;
--- 60 unchanged lines hidden (view full) ---
509 case PRIVSEP_EVENT_FT_RESPONSE:
510 wpa_driver_privsep_event_ft_response(drv->ctx, event_buf,
511 event_len);
512 break;
513 case PRIVSEP_EVENT_RX_EAPOL:
514 wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
515 event_len);
516 break;
517 }
518
519 os_free(buf);
520}
521
522
523static void * wpa_driver_privsep_init(void *ctx, const char *ifname)
524{
--- 192 unchanged lines hidden (view full) ---
717static const u8 * wpa_driver_privsep_get_mac_addr(void *priv)
718{
719 struct wpa_driver_privsep_data *drv = priv;
720 wpa_printf(MSG_DEBUG, "%s", __func__);
721 return drv->own_addr;
722}
723
724
725static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
726{
727 struct wpa_driver_privsep_data *drv = priv;
728 wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
729 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
730 os_strlen(alpha2), NULL, NULL);
731}
732
733
734struct wpa_driver_ops wpa_driver_privsep_ops = {
735 "privsep",
736 "wpa_supplicant privilege separated driver",
737 .get_bssid = wpa_driver_privsep_get_bssid,
738 .get_ssid = wpa_driver_privsep_get_ssid,
739 .set_key = wpa_driver_privsep_set_key,
740 .init = wpa_driver_privsep_init,
741 .deinit = wpa_driver_privsep_deinit,
742 .set_param = wpa_driver_privsep_set_param,
743 .scan2 = wpa_driver_privsep_scan,
744 .deauthenticate = wpa_driver_privsep_deauthenticate,
745 .disassociate = wpa_driver_privsep_disassociate,
746 .associate = wpa_driver_privsep_associate,
747 .get_capa = wpa_driver_privsep_get_capa,
748 .get_mac_addr = wpa_driver_privsep_get_mac_addr,
749 .get_scan_results2 = wpa_driver_privsep_get_scan_results2,
750 .set_country = wpa_driver_privsep_set_country,
751};
752
753
754struct wpa_driver_ops *wpa_drivers[] =
755{
756 &wpa_driver_privsep_ops,
757 NULL
758};