2 * Copyright (c) 2007-2008 Atheros Communications Inc.
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.
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.
17 /* Module Name : wrap_ev.c */
20 /* This module contains wrapper functions for events */
23 /* Platform dependent. */
25 /************************************************************************/
30 #include <linux/netlink.h>
33 #include <net/iw_handler.h>
37 /***** Management *****/
38 u16_t zfLnxAuthNotify(zdev_t* dev, u16_t* macAddr)
43 u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port)
45 //#ifdef ZM_HOSTAPD_SUPPORT
46 struct usbdrv_private *macp = dev->ml_priv;
47 union iwreq_data wreq;
48 u8_t *addr = (u8_t *) macAddr;
51 memset(&wreq, 0, sizeof(wreq));
52 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
53 wreq.addr.sa_family = ARPHRD_ETHER;
54 printk(KERN_DEBUG "join_event of MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
55 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
57 for(i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++)
59 for(j = 0; j < IEEE80211_ADDR_LEN; j++)
61 if ((macp->stawpaie[i].wpa_macaddr[j] != 0) &&
62 (macp->stawpaie[i].wpa_macaddr[j] != addr[j]))
68 if (i < ZM_OAL_MAX_STA_SUPPORT)
70 //printk("zfwAsocNotify - store wpa ie in macp, index = %d\n", i);
71 memcpy(macp->stawpaie[i].wpa_macaddr, macAddr, IEEE80211_ADDR_LEN);
72 memcpy(macp->stawpaie[i].wpa_ie, body, bodySize);
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);
78 #if WIRELESS_EXT >= 15
79 //else if(macp->cardSetting.BssType == AP_BSS) {
82 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
86 // /* Check whether the VAP device is valid */
87 // if (vap[port].dev != NULL)
89 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
93 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
104 /* Notification that a STA is disassociated from AP */
106 u16_t zfLnxDisAsocNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
108 union iwreq_data wreq;
109 u8_t *addr = (u8_t *) macAddr;
111 memset(&wreq, 0, sizeof(wreq));
112 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
113 wreq.addr.sa_family = ARPHRD_ETHER;
114 printk(KERN_DEBUG "zfwDisAsocNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
115 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
121 /* Notification that a STA is connect to AP */
123 u16_t zfLnxApConnectNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
125 union iwreq_data wreq;
126 u8_t *addr = (u8_t *) macAddr;
128 memset(&wreq, 0, sizeof(wreq));
129 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
130 wreq.addr.sa_family = ARPHRD_ETHER;
131 printk(KERN_DEBUG "zfwApConnectNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
132 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
140 void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid)
142 union iwreq_data wreq;
143 u8_t *addr = (u8_t *) bssid;
144 struct usbdrv_private *macp = dev->ml_priv;
148 memset(&wreq, 0, sizeof(wreq));
149 if (status == ZM_STATUS_MEDIA_CONNECT)
150 memcpy(wreq.addr.sa_data, bssid, ETH_ALEN);
151 wreq.addr.sa_family = ARPHRD_ETHER;
153 if (status == ZM_STATUS_MEDIA_CONNECT)
155 #ifdef ZM_CONFIG_BIG_ENDIAN
156 printk(KERN_DEBUG "Connected to AP, MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
157 addr[1], addr[0], addr[3], addr[2], addr[5], addr[4]);
159 printk(KERN_DEBUG "Connected to AP, MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
160 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
163 netif_start_queue(dev);
165 else if ((status == ZM_STATUS_MEDIA_DISCONNECT) ||
166 (status == ZM_STATUS_MEDIA_DISABLED) ||
167 (status == ZM_STATUS_MEDIA_CONNECTION_DISABLED) ||
168 (status == ZM_STATUS_MEDIA_CONNECTION_RESET) ||
169 (status == ZM_STATUS_MEDIA_RESET) ||
170 (status == ZM_STATUS_MEDIA_DISCONNECT_DEAUTH) ||
171 (status == ZM_STATUS_MEDIA_DISCONNECT_DISASOC) ||
172 (status == ZM_STATUS_MEDIA_DISCONNECT_BEACON_MISS) ||
173 (status == ZM_STATUS_MEDIA_DISCONNECT_NOT_FOUND) ||
174 (status == ZM_STATUS_MEDIA_DISCONNECT_TIMEOUT))
176 printk(KERN_DEBUG "Disconnection Notify\n");
178 netif_stop_queue(dev);
181 /* Save the connected status */
182 macp->adapterState = status;
184 if(zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE) {
185 // //wireless_send_event(dev, SIOCGIWSCAN, &wreq, NULL);
186 wireless_send_event(dev, SIOCGIWAP, &wreq, NULL);
188 #if WIRELESS_EXT >= 15
189 else if(zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
192 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
196 // /* Check whether the VAP device is valid */
197 // if (vap[port].dev != NULL)
199 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
203 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
212 void zfLnxScanNotify(zdev_t* dev, struct zsScanResult* result)
217 void zfLnxStatisticsNotify(zdev_t* dev, struct zsStastics* result)
222 //void zfwMicFailureNotify(zdev_t* dev, u8_t* message, u16_t event)
223 void zfLnxMicFailureNotify(zdev_t* dev, u16_t* addr, u16_t status)
225 static const char *tag = "MLME-MICHAELMICFAILURE.indication";
226 union iwreq_data wrqu;
229 /* TODO: needed parameters: count, type, src address */
230 //snprintf(buf, sizeof(buf), "%s(%scast addr=%s)", tag,
231 // (status == ZM_MIC_GROUP_ERROR) ? "broad" : "uni",
232 // ether_sprintf((u8_t *)addr));
234 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE)
239 memset(&wrqu, 0, sizeof(wrqu));
240 wrqu.data.length = strlen(buf);
241 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
245 void zfLnxApMicFailureNotify(zdev_t* dev, u8_t* addr, zbuf_t* buf)
247 union iwreq_data wreq;
249 memset(&wreq, 0, sizeof(wreq));
250 memcpy(wreq.addr.sa_data, addr, ETH_ALEN);
251 wreq.addr.sa_family = ARPHRD_ETHER;
252 printk(KERN_DEBUG "zfwApMicFailureNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
253 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
258 // status = 0 => partner lost
259 // = 1 => partner alive
260 //void zfwIbssPartnerNotify(zdev_t* dev, u8_t status)
261 void zfLnxIbssPartnerNotify(zdev_t* dev, u16_t status, struct zsPartnerNotifyEvent *event)
265 void zfLnxMacAddressNotify(zdev_t* dev, u8_t* addr)
267 dev->dev_addr[0] = addr[0];
268 dev->dev_addr[1] = addr[1];
269 dev->dev_addr[2] = addr[2];
270 dev->dev_addr[3] = addr[3];
271 dev->dev_addr[4] = addr[4];
272 dev->dev_addr[5] = addr[5];
275 void zfLnxSendCompleteIndication(zdev_t* dev, zbuf_t* buf)
280 void zfLnxRestoreBufData(zdev_t* dev, zbuf_t* buf) {
283 /* Leave an empty line below to remove warning message on some compiler */