summaryrefslogtreecommitdiffstats
path: root/wifi/wpa_supplicant_8_lib/driver_cmd_nl80211.c
blob: 9589e853f909cce62f7d8f5537ab62178c0f248f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * Driver interaction with extended Linux CFG8021
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Alternatively, this software may be distributed under the terms of BSD
 * license.
 */

#include "driver_cmd_nl80211.h"

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

//#if GCE_PLATFORM_SDK_AFTER(L_MR1)
// Android M exposes headers more directly.
#include <netinet/in.h>
#include <linux/if.h>
#include "driver_nl80211.h"
/*
#elif GCE_PLATFORM_SDK_AFTER(J_MR2)
// Android versions K and L put structures in hardware_legacy
#include "hardware_legacy/driver_nl80211.h"
#else
// Android version J does not expose structures directly. These structures are
// manually defined later.
#include <netinet/in.h>
#include <linux/if.h>
#endif
*/

#include "common.h"
#include "wpa_supplicant_i.h"
#include "config.h"
#include "android_drv.h"
#include "linux_ioctl.h"


int wpa_driver_nl80211_driver_cmd(
    void* priv, char* cmd, char* buf, size_t buf_len) {
  struct i802_bss* bss = priv;
  struct wpa_driver_nl80211_data* drv = bss->drv;
  int ret = 0;

  D("%s: called", __FUNCTION__);
  if (os_strcasecmp(cmd, "STOP") == 0) {
    linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
    wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
  } else if (os_strcasecmp(cmd, "START") == 0) {
    linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
    wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
  } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
    u8 macaddr[ETH_ALEN] = {};

    ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
    if (!ret)
      ret = os_snprintf(
          buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
  } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
    wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
  } else {  // Use private command
    return 0;
  }
  return ret;
}


int wpa_driver_set_p2p_noa(
    __attribute__((__unused__)) void* priv,
    __attribute__((__unused__)) u8 count,
    __attribute__((__unused__)) int start,
    __attribute__((__unused__)) int duration) {
  D("%s: called", __FUNCTION__);
  return 0;
}


int wpa_driver_get_p2p_noa(
    __attribute__((__unused__)) void* priv,
    __attribute__((__unused__)) u8* buf,
    __attribute__((__unused__)) size_t len) {
  D("%s: called", __FUNCTION__);
  return 0;
}


int wpa_driver_set_p2p_ps(
    __attribute__((__unused__)) void* priv,
    __attribute__((__unused__)) int legacy_ps,
    __attribute__((__unused__)) int opp_ps,
    __attribute__((__unused__)) int ctwindow) {
  D("%s: called", __FUNCTION__);
  return -1;
}


int wpa_driver_set_ap_wps_p2p_ie(
    __attribute__((__unused__)) void* priv,
    __attribute__((__unused__)) const struct wpabuf* beacon,
    __attribute__((__unused__)) const struct wpabuf* proberesp,
    __attribute__((__unused__)) const struct wpabuf* assocresp) {
  D("%s: called", __FUNCTION__);
  return 0;
}