Deleted Added
full compact
driver_privsep.c (209139) driver_privsep.c (214501)
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"
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"
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
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)
105static int wpa_driver_privsep_scan(void *priv,
106 struct wpa_driver_scan_params *params)
106{
107 struct wpa_driver_privsep_data *drv = priv;
107{
108 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;
109 const u8 *ssid = params->ssids[0].ssid;
110 size_t ssid_len = params->ssids[0].ssid_len;
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
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
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)
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)
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
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
329static void wpa_driver_privsep_event_assoc(void *ctx, wpa_event_type event,
324static void wpa_driver_privsep_event_assoc(void *ctx,
325 enum 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;
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;
441
442 wpa_supplicant_rx_eapol(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
437 drv_event_eapol_rx(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
443}
444
445
438}
439
440
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;
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;
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
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
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",
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",
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 */
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,
813};
814
815
751};
752
753
816struct wpa_driver_ops *wpa_supplicant_drivers[] =
754struct wpa_driver_ops *wpa_drivers[] =
817{
818 &wpa_driver_privsep_ops,
819 NULL
820};
755{
756 &wpa_driver_privsep_ops,
757 NULL
758};