| 1 | /* |
| 2 | * Copyright (c) 2007-2008 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | /* */ |
| 17 | /* Module Name : wrap_ev.c */ |
| 18 | /* */ |
| 19 | /* Abstract */ |
| 20 | /* This module contains wrapper functions for events */ |
| 21 | /* */ |
| 22 | /* NOTES */ |
| 23 | /* Platform dependent. */ |
| 24 | /* */ |
| 25 | /************************************************************************/ |
| 26 | |
| 27 | #include "oal_dt.h" |
| 28 | #include "usbdrv.h" |
| 29 | |
| 30 | #include <linux/netlink.h> |
| 31 | #include <net/iw_handler.h> |
| 32 | |
| 33 | |
| 34 | /***** Management *****/ |
| 35 | u16_t zfLnxAuthNotify(zdev_t *dev, u16_t *macAddr) |
| 36 | { |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | u16_t zfLnxAsocNotify(zdev_t *dev, u16_t *macAddr, u8_t *body, u16_t bodySize, |
| 41 | u16_t port) |
| 42 | { |
| 43 | /* #ifdef ZM_HOSTAPD_SUPPORT */ |
| 44 | struct usbdrv_private *macp = dev->ml_priv; |
| 45 | union iwreq_data wreq; |
| 46 | u8_t *addr = (u8_t *) macAddr; |
| 47 | u16_t i, j; |
| 48 | |
| 49 | memset(&wreq, 0, sizeof(wreq)); |
| 50 | memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN); |
| 51 | wreq.addr.sa_family = ARPHRD_ETHER; |
| 52 | printk(KERN_DEBUG "join_event of MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 53 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 54 | |
| 55 | for (i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++) { |
| 56 | for (j = 0; j < IEEE80211_ADDR_LEN; j++) { |
| 57 | if ((macp->stawpaie[i].wpa_macaddr[j] != 0) && |
| 58 | (macp->stawpaie[i].wpa_macaddr[j] != addr[j])) |
| 59 | break; |
| 60 | } |
| 61 | if (j == 6) |
| 62 | break; |
| 63 | } |
| 64 | if (i < ZM_OAL_MAX_STA_SUPPORT) { |
| 65 | /* |
| 66 | * printk("zfwAsocNotify - store wpa ie in macp, |
| 67 | * index = %d\n", i); |
| 68 | */ |
| 69 | memcpy(macp->stawpaie[i].wpa_macaddr, macAddr, |
| 70 | IEEE80211_ADDR_LEN); |
| 71 | memcpy(macp->stawpaie[i].wpa_ie, body, bodySize); |
| 72 | } |
| 73 | /* |
| 74 | * if(macp->cardSetting.BssType == INFRASTRUCTURE_BSS) { |
| 75 | * wireless_send_event(macp->device, SIOCGIWSCAN, &wreq, NULL); |
| 76 | * wireless_send_event(macp->device, SIOCGIWAP, &wreq, NULL); |
| 77 | * } |
| 78 | * else if(macp->cardSetting.BssType == AP_BSS) { |
| 79 | * if (port == 0) |
| 80 | * { |
| 81 | */ |
| 82 | wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL); |
| 83 | /* |
| 84 | * } |
| 85 | * else |
| 86 | * { |
| 87 | * Check whether the VAP device is valid |
| 88 | * if (vap[port].dev != NULL) |
| 89 | * { |
| 90 | * wireless_send_event(vap[port].dev, |
| 91 | * IWEVREGISTERED, &wreq, NULL); |
| 92 | * } |
| 93 | * else |
| 94 | * { |
| 95 | * printk(KERN_ERR "Can' find a valid VAP device, |
| 96 | * port: %d\n", port); |
| 97 | * } |
| 98 | * } |
| 99 | * } |
| 100 | */ |
| 101 | /* #endif */ |
| 102 | |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | /* Notification that a STA is disassociated from AP */ |
| 108 | /* AP mode only */ |
| 109 | u16_t zfLnxDisAsocNotify(zdev_t *dev, u8_t *macAddr, u16_t port) |
| 110 | { |
| 111 | union iwreq_data wreq; |
| 112 | u8_t *addr = (u8_t *) macAddr; |
| 113 | |
| 114 | memset(&wreq, 0, sizeof(wreq)); |
| 115 | memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN); |
| 116 | wreq.addr.sa_family = ARPHRD_ETHER; |
| 117 | printk(KERN_DEBUG "zfwDisAsocNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 118 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 119 | |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | /* Notification that a STA is connect to AP */ |
| 125 | /* AP mode only */ |
| 126 | u16_t zfLnxApConnectNotify(zdev_t *dev, u8_t *macAddr, u16_t port) |
| 127 | { |
| 128 | union iwreq_data wreq; |
| 129 | u8_t *addr = (u8_t *) macAddr; |
| 130 | |
| 131 | memset(&wreq, 0, sizeof(wreq)); |
| 132 | memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN); |
| 133 | wreq.addr.sa_family = ARPHRD_ETHER; |
| 134 | printk(KERN_DEBUG "zfwApConnectNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 135 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 136 | |
| 137 | |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | |
| 143 | void zfLnxConnectNotify(zdev_t *dev, u16_t status, u16_t *bssid) |
| 144 | { |
| 145 | union iwreq_data wreq; |
| 146 | u8_t *addr = (u8_t *) bssid; |
| 147 | struct usbdrv_private *macp = dev->ml_priv; |
| 148 | |
| 149 | if (bssid != NULL) { |
| 150 | memset(&wreq, 0, sizeof(wreq)); |
| 151 | if (status == ZM_STATUS_MEDIA_CONNECT) |
| 152 | memcpy(wreq.addr.sa_data, bssid, ETH_ALEN); |
| 153 | wreq.addr.sa_family = ARPHRD_ETHER; |
| 154 | |
| 155 | if (status == ZM_STATUS_MEDIA_CONNECT) { |
| 156 | #ifdef ZM_CONFIG_BIG_ENDIAN |
| 157 | printk(KERN_DEBUG "Connected to AP, MAC:" |
| 158 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 159 | addr[1], addr[0], addr[3], addr[2], |
| 160 | addr[5], addr[4]); |
| 161 | #else |
| 162 | printk(KERN_DEBUG "Connected to AP, MAC:" |
| 163 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 164 | addr[0], addr[1], addr[2], addr[3], |
| 165 | addr[4], addr[5]); |
| 166 | #endif |
| 167 | |
| 168 | netif_start_queue(dev); |
| 169 | } else if ((status == ZM_STATUS_MEDIA_DISCONNECT) || |
| 170 | (status == ZM_STATUS_MEDIA_DISABLED) || |
| 171 | (status == ZM_STATUS_MEDIA_CONNECTION_DISABLED) || |
| 172 | (status == ZM_STATUS_MEDIA_CONNECTION_RESET) || |
| 173 | (status == ZM_STATUS_MEDIA_RESET) || |
| 174 | (status == ZM_STATUS_MEDIA_DISCONNECT_DEAUTH) || |
| 175 | (status == ZM_STATUS_MEDIA_DISCONNECT_DISASOC) || |
| 176 | (status == ZM_STATUS_MEDIA_DISCONNECT_BEACON_MISS) || |
| 177 | (status == ZM_STATUS_MEDIA_DISCONNECT_NOT_FOUND) || |
| 178 | (status == ZM_STATUS_MEDIA_DISCONNECT_TIMEOUT)) { |
| 179 | printk(KERN_DEBUG "Disconnection Notify\n"); |
| 180 | |
| 181 | netif_stop_queue(dev); |
| 182 | } |
| 183 | |
| 184 | /* Save the connected status */ |
| 185 | macp->adapterState = status; |
| 186 | |
| 187 | if (zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE) { |
| 188 | /*wireless_send_event(dev, SIOCGIWSCAN, &wreq, NULL);*/ |
| 189 | wireless_send_event(dev, SIOCGIWAP, &wreq, NULL); |
| 190 | } else if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) { |
| 191 | /* |
| 192 | * if (port == 0) |
| 193 | * { |
| 194 | * wireless_send_event(dev, IWEVREGISTERED, |
| 195 | * &wreq, NULL); |
| 196 | * } |
| 197 | * else |
| 198 | * { |
| 199 | * Check whether the VAP device is valid |
| 200 | * if (vap[port].dev != NULL) |
| 201 | * { |
| 202 | * wireless_send_event(vap[port].dev, |
| 203 | * IWEVREGISTERED, &wreq, NULL); |
| 204 | * } |
| 205 | * else |
| 206 | * { |
| 207 | * printk(KERN_ERR "Can' find a valid VAP" |
| 208 | * " device, port: %d\n", port); |
| 209 | * } |
| 210 | * } |
| 211 | */ |
| 212 | } |
| 213 | } |
| 214 | /* return 0; */ |
| 215 | } |
| 216 | |
| 217 | void zfLnxScanNotify(zdev_t *dev, struct zsScanResult *result) |
| 218 | { |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | void zfLnxStatisticsNotify(zdev_t *dev, struct zsStastics *result) |
| 223 | { |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | /* void zfwMicFailureNotify(zdev_t *dev, u8_t *message, u16_t event) */ |
| 228 | void zfLnxMicFailureNotify(zdev_t *dev, u16_t *addr, u16_t status) |
| 229 | { |
| 230 | static const char *tag = "MLME-MICHAELMICFAILURE.indication"; |
| 231 | union iwreq_data wrqu; |
| 232 | char buf[128]; |
| 233 | |
| 234 | /* TODO: needed parameters: count, type, src address */ |
| 235 | /* |
| 236 | * snprintf(buf, sizeof(buf), "%s(%scast addr=%s)", tag, |
| 237 | * (status == ZM_MIC_GROUP_ERROR) ? "broad" : "uni", |
| 238 | * ether_sprintf((u8_t *)addr)); |
| 239 | */ |
| 240 | |
| 241 | if (zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE) |
| 242 | strcpy(buf, tag); |
| 243 | |
| 244 | memset(&wrqu, 0, sizeof(wrqu)); |
| 245 | wrqu.data.length = strlen(buf); |
| 246 | wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); |
| 247 | } |
| 248 | |
| 249 | |
| 250 | void zfLnxApMicFailureNotify(zdev_t *dev, u8_t *addr, zbuf_t *buf) |
| 251 | { |
| 252 | union iwreq_data wreq; |
| 253 | |
| 254 | memset(&wreq, 0, sizeof(wreq)); |
| 255 | memcpy(wreq.addr.sa_data, addr, ETH_ALEN); |
| 256 | wreq.addr.sa_family = ARPHRD_ETHER; |
| 257 | printk(KERN_DEBUG "zfwApMicFailureNotify(), " |
| 258 | "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 259 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 260 | |
| 261 | return; |
| 262 | } |
| 263 | /* |
| 264 | * status = 0 => partner lost |
| 265 | * = 1 => partner alive |
| 266 | * void zfwIbssPartnerNotify(zdev_t* dev, u8_t status) |
| 267 | */ |
| 268 | void zfLnxIbssPartnerNotify(zdev_t *dev, u16_t status, |
| 269 | struct zsPartnerNotifyEvent *event) |
| 270 | { |
| 271 | } |
| 272 | |
| 273 | void zfLnxMacAddressNotify(zdev_t *dev, u8_t *addr) |
| 274 | { |
| 275 | dev->dev_addr[0] = addr[0]; |
| 276 | dev->dev_addr[1] = addr[1]; |
| 277 | dev->dev_addr[2] = addr[2]; |
| 278 | dev->dev_addr[3] = addr[3]; |
| 279 | dev->dev_addr[4] = addr[4]; |
| 280 | dev->dev_addr[5] = addr[5]; |
| 281 | } |
| 282 | |
| 283 | void zfLnxSendCompleteIndication(zdev_t *dev, zbuf_t *buf) |
| 284 | { |
| 285 | } |
| 286 | |
| 287 | |
| 288 | void zfLnxRestoreBufData(zdev_t *dev, zbuf_t *buf) |
| 289 | { |
| 290 | |
| 291 | } |
| 292 | /* Leave an empty line below to remove warning message on some compiler */ |