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 "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_set_wpa(void *priv, int enabled)
106{
107 struct wpa_driver_privsep_data *drv = priv;
108 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
109 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_WPA, &enabled,
110 sizeof(enabled), NULL, NULL);
111}
112
113
114static int wpa_driver_privsep_scan(void *priv, const u8 *ssid, size_t ssid_len)
115{
116 struct wpa_driver_privsep_data *drv = priv;
117 wpa_printf(MSG_DEBUG, "%s: priv=%p", __func__, priv);
118 return wpa_priv_cmd(drv, PRIVSEP_CMD_SCAN, ssid, ssid_len,
119 NULL, NULL);
120}
121
122
123static struct wpa_scan_results *
124wpa_driver_privsep_get_scan_results2(void *priv)
--- 66 unchanged lines hidden (view full) ---
191 results->res[results->num++] = r;
192 }
193
194 os_free(buf);
195 return results;
196}
197
198
199static int wpa_driver_privsep_set_key(void *priv, wpa_alg alg, const u8 *addr,
200 int key_idx, int set_tx,
201 const u8 *seq, size_t seq_len,
202 const u8 *key, size_t key_len)
203{
204 struct wpa_driver_privsep_data *drv = priv;
205 struct privsep_cmd_set_key cmd;
206
207 wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
208 __func__, priv, alg, key_idx, set_tx);
209
210 os_memset(&cmd, 0, sizeof(cmd));
--- 110 unchanged lines hidden (view full) ---
321 //struct wpa_driver_privsep_data *drv = priv;
322 wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
323 __func__, MAC2STR(addr), reason_code);
324 wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
325 return 0;
326}
327
328
329static void wpa_driver_privsep_event_assoc(void *ctx, wpa_event_type event,
330 u8 *buf, size_t len)
331{
332 union wpa_event_data data;
333 int inc_data = 0;
334 u8 *pos, *end;
335 int ie_len;
336
337 os_memset(&data, 0, sizeof(data));
--- 95 unchanged lines hidden (view full) ---
433 wpa_supplicant_event(ctx, EVENT_FT_RESPONSE, &data);
434}
435
436
437static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
438{
439 if (len < ETH_ALEN)
440 return;
441
442 wpa_supplicant_rx_eapol(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
443}
444
445
446static void wpa_driver_privsep_event_sta_rx(void *ctx, u8 *buf, size_t len)
447{
448#ifdef CONFIG_CLIENT_MLME
449 struct ieee80211_rx_status *rx_status;
450
451 if (len < sizeof(*rx_status))
452 return;
453 rx_status = (struct ieee80211_rx_status *) buf;
454 buf += sizeof(*rx_status);
455 len -= sizeof(*rx_status);
456
457 wpa_supplicant_sta_rx(ctx, buf, len, rx_status);
458#endif /* CONFIG_CLIENT_MLME */
459}
460
461
462static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
463 void *sock_ctx)
464{
465 struct wpa_driver_privsep_data *drv = eloop_ctx;
466 u8 *buf, *event_buf;
467 size_t event_len;
468 int res, event;
469 enum privsep_event e;
--- 60 unchanged lines hidden (view full) ---
530 case PRIVSEP_EVENT_FT_RESPONSE:
531 wpa_driver_privsep_event_ft_response(drv->ctx, event_buf,
532 event_len);
533 break;
534 case PRIVSEP_EVENT_RX_EAPOL:
535 wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
536 event_len);
537 break;
538 case PRIVSEP_EVENT_STA_RX:
539 wpa_driver_privsep_event_sta_rx(drv->ctx, event_buf,
540 event_len);
541 break;
542 }
543
544 os_free(buf);
545}
546
547
548static void * wpa_driver_privsep_init(void *ctx, const char *ifname)
549{
--- 192 unchanged lines hidden (view full) ---
742static const u8 * wpa_driver_privsep_get_mac_addr(void *priv)
743{
744 struct wpa_driver_privsep_data *drv = priv;
745 wpa_printf(MSG_DEBUG, "%s", __func__);
746 return drv->own_addr;
747}
748
749
750static int wpa_driver_privsep_set_mode(void *priv, int mode)
751{
752 struct wpa_driver_privsep_data *drv = priv;
753 wpa_printf(MSG_DEBUG, "%s mode=%d", __func__, mode);
754 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_MODE, &mode, sizeof(mode),
755 NULL, NULL);
756}
757
758
759static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
760{
761 struct wpa_driver_privsep_data *drv = priv;
762 wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
763 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
764 os_strlen(alpha2), NULL, NULL);
765}
766
767
768struct wpa_driver_ops wpa_driver_privsep_ops = {
769 "privsep",
770 "wpa_supplicant privilege separated driver",
771 wpa_driver_privsep_get_bssid,
772 wpa_driver_privsep_get_ssid,
773 wpa_driver_privsep_set_wpa,
774 wpa_driver_privsep_set_key,
775 wpa_driver_privsep_init,
776 wpa_driver_privsep_deinit,
777 wpa_driver_privsep_set_param,
778 NULL /* set_countermeasures */,
779 NULL /* set_drop_unencrypted */,
780 wpa_driver_privsep_scan,
781 NULL /* get_scan_results */,
782 wpa_driver_privsep_deauthenticate,
783 wpa_driver_privsep_disassociate,
784 wpa_driver_privsep_associate,
785 NULL /* set_auth_alg */,
786 NULL /* add_pmkid */,
787 NULL /* remove_pmkid */,
788 NULL /* flush_pmkid */,
789 wpa_driver_privsep_get_capa,
790 NULL /* poll */,
791 NULL /* get_ifname */,
792 wpa_driver_privsep_get_mac_addr,
793 NULL /* send_eapol */,
794 NULL /* set_operstate */,
795 NULL /* mlme_setprotection */,
796 NULL /* get_hw_feature_data */,
797 NULL /* set_channel */,
798 NULL /* set_ssid */,
799 NULL /* set_bssid */,
800 NULL /* send_mlme */,
801 NULL /* mlme_add_sta */,
802 NULL /* mlme_remove_sta */,
803 NULL /* update_ft_ies */,
804 NULL /* send_ft_action */,
805 wpa_driver_privsep_get_scan_results2,
806 NULL /* set_probe_req_ie */,
807 wpa_driver_privsep_set_mode,
808 wpa_driver_privsep_set_country,
809 NULL /* global_init */,
810 NULL /* global_deinit */,
811 NULL /* init2 */,
812 NULL /* get_interfaces */
813};
814
815
816struct wpa_driver_ops *wpa_supplicant_drivers[] =
817{
818 &wpa_driver_privsep_ops,
819 NULL
820};
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 "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_set_wpa(void *priv, int enabled)
106{
107 struct wpa_driver_privsep_data *drv = priv;
108 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
109 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_WPA, &enabled,
110 sizeof(enabled), NULL, NULL);
111}
112
113
114static int wpa_driver_privsep_scan(void *priv, const u8 *ssid, size_t ssid_len)
115{
116 struct wpa_driver_privsep_data *drv = priv;
117 wpa_printf(MSG_DEBUG, "%s: priv=%p", __func__, priv);
118 return wpa_priv_cmd(drv, PRIVSEP_CMD_SCAN, ssid, ssid_len,
119 NULL, NULL);
120}
121
122
123static struct wpa_scan_results *
124wpa_driver_privsep_get_scan_results2(void *priv)
--- 66 unchanged lines hidden (view full) ---
191 results->res[results->num++] = r;
192 }
193
194 os_free(buf);
195 return results;
196}
197
198
199static int wpa_driver_privsep_set_key(void *priv, wpa_alg alg, const u8 *addr,
200 int key_idx, int set_tx,
201 const u8 *seq, size_t seq_len,
202 const u8 *key, size_t key_len)
203{
204 struct wpa_driver_privsep_data *drv = priv;
205 struct privsep_cmd_set_key cmd;
206
207 wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
208 __func__, priv, alg, key_idx, set_tx);
209
210 os_memset(&cmd, 0, sizeof(cmd));
--- 110 unchanged lines hidden (view full) ---
321 //struct wpa_driver_privsep_data *drv = priv;
322 wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
323 __func__, MAC2STR(addr), reason_code);
324 wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
325 return 0;
326}
327
328
329static void wpa_driver_privsep_event_assoc(void *ctx, wpa_event_type event,
330 u8 *buf, size_t len)
331{
332 union wpa_event_data data;
333 int inc_data = 0;
334 u8 *pos, *end;
335 int ie_len;
336
337 os_memset(&data, 0, sizeof(data));
--- 95 unchanged lines hidden (view full) ---
433 wpa_supplicant_event(ctx, EVENT_FT_RESPONSE, &data);
434}
435
436
437static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
438{
439 if (len < ETH_ALEN)
440 return;
441
442 wpa_supplicant_rx_eapol(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
443}
444
445
446static void wpa_driver_privsep_event_sta_rx(void *ctx, u8 *buf, size_t len)
447{
448#ifdef CONFIG_CLIENT_MLME
449 struct ieee80211_rx_status *rx_status;
450
451 if (len < sizeof(*rx_status))
452 return;
453 rx_status = (struct ieee80211_rx_status *) buf;
454 buf += sizeof(*rx_status);
455 len -= sizeof(*rx_status);
456
457 wpa_supplicant_sta_rx(ctx, buf, len, rx_status);
458#endif /* CONFIG_CLIENT_MLME */
459}
460
461
462static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
463 void *sock_ctx)
464{
465 struct wpa_driver_privsep_data *drv = eloop_ctx;
466 u8 *buf, *event_buf;
467 size_t event_len;
468 int res, event;
469 enum privsep_event e;
--- 60 unchanged lines hidden (view full) ---
530 case PRIVSEP_EVENT_FT_RESPONSE:
531 wpa_driver_privsep_event_ft_response(drv->ctx, event_buf,
532 event_len);
533 break;
534 case PRIVSEP_EVENT_RX_EAPOL:
535 wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
536 event_len);
537 break;
538 case PRIVSEP_EVENT_STA_RX:
539 wpa_driver_privsep_event_sta_rx(drv->ctx, event_buf,
540 event_len);
541 break;
542 }
543
544 os_free(buf);
545}
546
547
548static void * wpa_driver_privsep_init(void *ctx, const char *ifname)
549{
--- 192 unchanged lines hidden (view full) ---
742static const u8 * wpa_driver_privsep_get_mac_addr(void *priv)
743{
744 struct wpa_driver_privsep_data *drv = priv;
745 wpa_printf(MSG_DEBUG, "%s", __func__);
746 return drv->own_addr;
747}
748
749
750static int wpa_driver_privsep_set_mode(void *priv, int mode)
751{
752 struct wpa_driver_privsep_data *drv = priv;
753 wpa_printf(MSG_DEBUG, "%s mode=%d", __func__, mode);
754 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_MODE, &mode, sizeof(mode),
755 NULL, NULL);
756}
757
758
759static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
760{
761 struct wpa_driver_privsep_data *drv = priv;
762 wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
763 return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
764 os_strlen(alpha2), NULL, NULL);
765}
766
767
768struct wpa_driver_ops wpa_driver_privsep_ops = {
769 "privsep",
770 "wpa_supplicant privilege separated driver",
771 wpa_driver_privsep_get_bssid,
772 wpa_driver_privsep_get_ssid,
773 wpa_driver_privsep_set_wpa,
774 wpa_driver_privsep_set_key,
775 wpa_driver_privsep_init,
776 wpa_driver_privsep_deinit,
777 wpa_driver_privsep_set_param,
778 NULL /* set_countermeasures */,
779 NULL /* set_drop_unencrypted */,
780 wpa_driver_privsep_scan,
781 NULL /* get_scan_results */,
782 wpa_driver_privsep_deauthenticate,
783 wpa_driver_privsep_disassociate,
784 wpa_driver_privsep_associate,
785 NULL /* set_auth_alg */,
786 NULL /* add_pmkid */,
787 NULL /* remove_pmkid */,
788 NULL /* flush_pmkid */,
789 wpa_driver_privsep_get_capa,
790 NULL /* poll */,
791 NULL /* get_ifname */,
792 wpa_driver_privsep_get_mac_addr,
793 NULL /* send_eapol */,
794 NULL /* set_operstate */,
795 NULL /* mlme_setprotection */,
796 NULL /* get_hw_feature_data */,
797 NULL /* set_channel */,
798 NULL /* set_ssid */,
799 NULL /* set_bssid */,
800 NULL /* send_mlme */,
801 NULL /* mlme_add_sta */,
802 NULL /* mlme_remove_sta */,
803 NULL /* update_ft_ies */,
804 NULL /* send_ft_action */,
805 wpa_driver_privsep_get_scan_results2,
806 NULL /* set_probe_req_ie */,
807 wpa_driver_privsep_set_mode,
808 wpa_driver_privsep_set_country,
809 NULL /* global_init */,
810 NULL /* global_deinit */,
811 NULL /* init2 */,
812 NULL /* get_interfaces */
813};
814
815
816struct wpa_driver_ops *wpa_supplicant_drivers[] =
817{
818 &wpa_driver_privsep_ops,
819 NULL
820};