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
32 #if WIRELESS_EXT > 12
33 #include <net/iw_handler.h>
34 #endif
35
36
37 /***** Management *****/
zfLnxAuthNotify(zdev_t * dev,u16_t * macAddr)38 u16_t zfLnxAuthNotify(zdev_t* dev, u16_t* macAddr)
39 {
40 return 0;
41 }
42
zfLnxAsocNotify(zdev_t * dev,u16_t * macAddr,u8_t * body,u16_t bodySize,u16_t port)43 u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port)
44 {
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;
49 u16_t i, j;
50
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]);
56
57 for(i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++)
58 {
59 for(j = 0; j < IEEE80211_ADDR_LEN; j++)
60 {
61 if ((macp->stawpaie[i].wpa_macaddr[j] != 0) &&
62 (macp->stawpaie[i].wpa_macaddr[j] != addr[j]))
63 break;
64 }
65 if (j == 6)
66 break;
67 }
68 if (i < ZM_OAL_MAX_STA_SUPPORT)
69 {
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);
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 #if WIRELESS_EXT >= 15
79 //else if(macp->cardSetting.BssType == AP_BSS) {
80 // if (port == 0)
81 // {
82 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
83 // }
84 // else
85 // {
86 // /* Check whether the VAP device is valid */
87 // if (vap[port].dev != NULL)
88 // {
89 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
90 // }
91 // else
92 // {
93 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
94 // }
95 // }
96 //}
97 #endif
98 //#endif
99
100 return 0;
101 }
102
103
104 /* Notification that a STA is disassociated from AP */
105 /* AP mode only */
zfLnxDisAsocNotify(zdev_t * dev,u8_t * macAddr,u16_t port)106 u16_t zfLnxDisAsocNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
107 {
108 union iwreq_data wreq;
109 u8_t *addr = (u8_t *) macAddr;
110
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]);
116
117
118 return 0;
119 }
120
121 /* Notification that a STA is connect to AP */
122 /* AP mode only */
zfLnxApConnectNotify(zdev_t * dev,u8_t * macAddr,u16_t port)123 u16_t zfLnxApConnectNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
124 {
125 union iwreq_data wreq;
126 u8_t *addr = (u8_t *) macAddr;
127
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]);
133
134
135 return 0;
136 }
137
138
139
zfLnxConnectNotify(zdev_t * dev,u16_t status,u16_t * bssid)140 void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid)
141 {
142 union iwreq_data wreq;
143 u8_t *addr = (u8_t *) bssid;
144 struct usbdrv_private *macp = dev->ml_priv;
145
146 if (bssid != NULL)
147 {
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;
152
153 if (status == ZM_STATUS_MEDIA_CONNECT)
154 {
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]);
158 #else
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]);
161 #endif
162
163 netif_start_queue(dev);
164 }
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))
175 {
176 printk(KERN_DEBUG "Disconnection Notify\n");
177
178 netif_stop_queue(dev);
179 }
180
181 /* Save the connected status */
182 macp->adapterState = status;
183
184 if(zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE) {
185 // //wireless_send_event(dev, SIOCGIWSCAN, &wreq, NULL);
186 wireless_send_event(dev, SIOCGIWAP, &wreq, NULL);
187 }
188 #if WIRELESS_EXT >= 15
189 else if(zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
190 //if (port == 0)
191 //{
192 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
193 //}
194 //else
195 //{
196 // /* Check whether the VAP device is valid */
197 // if (vap[port].dev != NULL)
198 // {
199 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
200 // }
201 // else
202 // {
203 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
204 // }
205 //}
206 }
207 #endif
208 }
209 //return 0;
210 }
211
zfLnxScanNotify(zdev_t * dev,struct zsScanResult * result)212 void zfLnxScanNotify(zdev_t* dev, struct zsScanResult* result)
213 {
214 return;
215 }
216
zfLnxStatisticsNotify(zdev_t * dev,struct zsStastics * result)217 void zfLnxStatisticsNotify(zdev_t* dev, struct zsStastics* result)
218 {
219 return;
220 }
221
222 //void zfwMicFailureNotify(zdev_t* dev, u8_t* message, u16_t event)
zfLnxMicFailureNotify(zdev_t * dev,u16_t * addr,u16_t status)223 void zfLnxMicFailureNotify(zdev_t* dev, u16_t* addr, u16_t status)
224 {
225 static const char *tag = "MLME-MICHAELMICFAILURE.indication";
226 union iwreq_data wrqu;
227 char buf[128];
228
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));
233
234 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE)
235 {
236 strcpy(buf, tag);
237 }
238
239 memset(&wrqu, 0, sizeof(wrqu));
240 wrqu.data.length = strlen(buf);
241 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
242 }
243
244
zfLnxApMicFailureNotify(zdev_t * dev,u8_t * addr,zbuf_t * buf)245 void zfLnxApMicFailureNotify(zdev_t* dev, u8_t* addr, zbuf_t* buf)
246 {
247 union iwreq_data wreq;
248
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]);
254
255 return;
256 }
257
258 // status = 0 => partner lost
259 // = 1 => partner alive
260 //void zfwIbssPartnerNotify(zdev_t* dev, u8_t status)
zfLnxIbssPartnerNotify(zdev_t * dev,u16_t status,struct zsPartnerNotifyEvent * event)261 void zfLnxIbssPartnerNotify(zdev_t* dev, u16_t status, struct zsPartnerNotifyEvent *event)
262 {
263 }
264
zfLnxMacAddressNotify(zdev_t * dev,u8_t * addr)265 void zfLnxMacAddressNotify(zdev_t* dev, u8_t* addr)
266 {
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];
273 }
274
zfLnxSendCompleteIndication(zdev_t * dev,zbuf_t * buf)275 void zfLnxSendCompleteIndication(zdev_t* dev, zbuf_t* buf)
276 {
277 }
278
279
zfLnxRestoreBufData(zdev_t * dev,zbuf_t * buf)280 void zfLnxRestoreBufData(zdev_t* dev, zbuf_t* buf) {
281
282 }
283 /* Leave an empty line below to remove warning message on some compiler */
284