• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "driver_cmd_nl80211.h"
13 
14 #include <stddef.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 //#if GCE_PLATFORM_SDK_AFTER(L_MR1)
19 // Android M exposes headers more directly.
20 #include <netinet/in.h>
21 #include <linux/if.h>
22 #include "driver_nl80211.h"
23 /*
24 #elif GCE_PLATFORM_SDK_AFTER(J_MR2)
25 // Android versions K and L put structures in hardware_legacy
26 #include "hardware_legacy/driver_nl80211.h"
27 #else
28 // Android version J does not expose structures directly. These structures are
29 // manually defined later.
30 #include <netinet/in.h>
31 #include <linux/if.h>
32 #endif
33 */
34 
35 #include "common.h"
36 #include "wpa_supplicant_i.h"
37 #include "config.h"
38 #include "android_drv.h"
39 #include "linux_ioctl.h"
40 
41 
wpa_driver_nl80211_driver_cmd(void * priv,char * cmd,char * buf,size_t buf_len)42 int wpa_driver_nl80211_driver_cmd(
43     void* priv, char* cmd, char* buf, size_t buf_len) {
44   struct i802_bss* bss = priv;
45   struct wpa_driver_nl80211_data* drv = bss->drv;
46   struct ifreq ifr;
47   android_wifi_priv_cmd priv_cmd;
48   int ret = 0;
49 
50   D("%s: called", __FUNCTION__);
51   if (os_strcasecmp(cmd, "STOP") == 0) {
52     linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
53     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
54   } else if (os_strcasecmp(cmd, "START") == 0) {
55     linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
56     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
57   } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
58     u8 macaddr[ETH_ALEN] = {};
59 
60     ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
61     if (!ret)
62       ret = os_snprintf(
63           buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
64   } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
65     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
66   } else {  // Use private command
67     return 0;
68   }
69   return ret;
70 }
71 
72 
wpa_driver_set_p2p_noa(void * priv,u8 count,int start,int duration)73 int wpa_driver_set_p2p_noa(void* priv, u8 count, int start, int duration) {
74   D("%s: called", __FUNCTION__);
75   return 0;
76 }
77 
78 
wpa_driver_get_p2p_noa(void * priv,u8 * buf,size_t len)79 int wpa_driver_get_p2p_noa(void* priv, u8* buf, size_t len) {
80   D("%s: called", __FUNCTION__);
81   return 0;
82 }
83 
84 
wpa_driver_set_p2p_ps(void * priv,int legacy_ps,int opp_ps,int ctwindow)85 int wpa_driver_set_p2p_ps(void* priv, int legacy_ps, int opp_ps, int ctwindow) {
86   D("%s: called", __FUNCTION__);
87   return -1;
88 }
89 
90 
wpa_driver_set_ap_wps_p2p_ie(void * priv,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)91 int wpa_driver_set_ap_wps_p2p_ie(
92     void* priv, const struct wpabuf* beacon,
93     const struct wpabuf* proberesp, const struct wpabuf* assocresp) {
94   D("%s: called", __FUNCTION__);
95   return 0;
96 }
97