1 /*
2 * Driver interaction with extended Linux CFG8021
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Alternatively, this software may be distributed under the terms of BSD
9 * license.
10 */
11
12 #include "includes.h"
13 #include "driver_cmd_nl80211.h"
14
15 #include <stddef.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 //#if GCE_PLATFORM_SDK_AFTER(L_MR1)
20 // Android M exposes headers more directly.
21 #include <netinet/in.h>
22 #include <linux/if.h>
23 #include "driver_nl80211.h"
24 /*
25 #elif GCE_PLATFORM_SDK_AFTER(J_MR2)
26 // Android versions K and L put structures in hardware_legacy
27 #include "hardware_legacy/driver_nl80211.h"
28 #else
29 // Android version J does not expose structures directly. These structures are
30 // manually defined later.
31 #include <netinet/in.h>
32 #include <linux/if.h>
33 #endif
34 */
35
36 #include "common.h"
37 #include "wpa_supplicant_i.h"
38 #include "config.h"
39 #include "android_drv.h"
40 #include "linux_ioctl.h"
41
42
wpa_driver_nl80211_driver_cmd(void * priv,char * cmd,char * buf,size_t buf_len)43 int wpa_driver_nl80211_driver_cmd(
44 void* priv, char* cmd, char* buf, size_t buf_len) {
45 struct i802_bss* bss = priv;
46 struct wpa_driver_nl80211_data* drv = bss->drv;
47 int ret = 0;
48
49 D("%s: called", __FUNCTION__);
50 if (os_strcasecmp(cmd, "STOP") == 0) {
51 linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
52 wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
53 } else if (os_strcasecmp(cmd, "START") == 0) {
54 linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
55 wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
56 } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
57 u8 macaddr[ETH_ALEN] = {};
58
59 ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
60 if (!ret)
61 ret = os_snprintf(
62 buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
63 } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
64 wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
65 } else { // Use private command
66 return 0;
67 }
68 return ret;
69 }
70
71
wpa_driver_set_p2p_noa(void * priv,u8 count,int start,int duration)72 int wpa_driver_set_p2p_noa(
73 __attribute__((__unused__)) void* priv,
74 __attribute__((__unused__)) u8 count,
75 __attribute__((__unused__)) int start,
76 __attribute__((__unused__)) int duration) {
77 D("%s: called", __FUNCTION__);
78 return 0;
79 }
80
81
wpa_driver_get_p2p_noa(void * priv,u8 * buf,size_t len)82 int wpa_driver_get_p2p_noa(
83 __attribute__((__unused__)) void* priv,
84 __attribute__((__unused__)) u8* buf,
85 __attribute__((__unused__)) size_t len) {
86 D("%s: called", __FUNCTION__);
87 return 0;
88 }
89
90
wpa_driver_set_p2p_ps(void * priv,int legacy_ps,int opp_ps,int ctwindow)91 int wpa_driver_set_p2p_ps(
92 __attribute__((__unused__)) void* priv,
93 __attribute__((__unused__)) int legacy_ps,
94 __attribute__((__unused__)) int opp_ps,
95 __attribute__((__unused__)) int ctwindow) {
96 D("%s: called", __FUNCTION__);
97 return -1;
98 }
99
100
wpa_driver_set_ap_wps_p2p_ie(void * priv,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)101 int wpa_driver_set_ap_wps_p2p_ie(
102 __attribute__((__unused__)) void* priv,
103 __attribute__((__unused__)) const struct wpabuf* beacon,
104 __attribute__((__unused__)) const struct wpabuf* proberesp,
105 __attribute__((__unused__)) const struct wpabuf* assocresp) {
106 D("%s: called", __FUNCTION__);
107 return 0;
108 }
109