Home | History | Annotate | Download | only in wpa_supplicant_8_lib
      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 
     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   int ret = 0;
     47 
     48   D("%s: called", __FUNCTION__);
     49   if (os_strcasecmp(cmd, "STOP") == 0) {
     50     linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
     51     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
     52   } else if (os_strcasecmp(cmd, "START") == 0) {
     53     linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
     54     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
     55   } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
     56     u8 macaddr[ETH_ALEN] = {};
     57 
     58     ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
     59     if (!ret)
     60       ret = os_snprintf(
     61           buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
     62   } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
     63     wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
     64   } else {  // Use private command
     65     return 0;
     66   }
     67   return ret;
     68 }
     69 
     70 
     71 int wpa_driver_set_p2p_noa(
     72     __attribute__((__unused__)) void* priv,
     73     __attribute__((__unused__)) u8 count,
     74     __attribute__((__unused__)) int start,
     75     __attribute__((__unused__)) int duration) {
     76   D("%s: called", __FUNCTION__);
     77   return 0;
     78 }
     79 
     80 
     81 int wpa_driver_get_p2p_noa(
     82     __attribute__((__unused__)) void* priv,
     83     __attribute__((__unused__)) u8* buf,
     84     __attribute__((__unused__)) size_t len) {
     85   D("%s: called", __FUNCTION__);
     86   return 0;
     87 }
     88 
     89 
     90 int wpa_driver_set_p2p_ps(
     91     __attribute__((__unused__)) void* priv,
     92     __attribute__((__unused__)) int legacy_ps,
     93     __attribute__((__unused__)) int opp_ps,
     94     __attribute__((__unused__)) int ctwindow) {
     95   D("%s: called", __FUNCTION__);
     96   return -1;
     97 }
     98 
     99 
    100 int wpa_driver_set_ap_wps_p2p_ie(
    101     __attribute__((__unused__)) void* priv,
    102     __attribute__((__unused__)) const struct wpabuf* beacon,
    103     __attribute__((__unused__)) const struct wpabuf* proberesp,
    104     __attribute__((__unused__)) const struct wpabuf* assocresp) {
    105   D("%s: called", __FUNCTION__);
    106   return 0;
    107 }
    108