First Support on Ginger and OMAP TI
[linux-ginger.git] / drivers / staging / otus / wrap_ev.c
blobbcda0b9673dc8db5c69af57f8a60e7423ee1b425
1 /*
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.
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 /************************************************************************/
27 #include "oal_dt.h"
28 #include "usbdrv.h"
30 #include <linux/netlink.h>
31 #include <net/iw_handler.h>
34 /***** Management *****/
35 u16_t zfLnxAuthNotify(zdev_t* dev, u16_t* macAddr)
37 return 0;
40 u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port)
42 //#ifdef ZM_HOSTAPD_SUPPORT
43 struct usbdrv_private *macp = dev->ml_priv;
44 union iwreq_data wreq;
45 u8_t *addr = (u8_t *) macAddr;
46 u16_t i, j;
48 memset(&wreq, 0, sizeof(wreq));
49 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
50 wreq.addr.sa_family = ARPHRD_ETHER;
51 printk(KERN_DEBUG "join_event of MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
52 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
54 for(i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++)
56 for(j = 0; j < IEEE80211_ADDR_LEN; j++)
58 if ((macp->stawpaie[i].wpa_macaddr[j] != 0) &&
59 (macp->stawpaie[i].wpa_macaddr[j] != addr[j]))
60 break;
62 if (j == 6)
63 break;
65 if (i < ZM_OAL_MAX_STA_SUPPORT)
67 //printk("zfwAsocNotify - store wpa ie in macp, index = %d\n", i);
68 memcpy(macp->stawpaie[i].wpa_macaddr, macAddr, IEEE80211_ADDR_LEN);
69 memcpy(macp->stawpaie[i].wpa_ie, body, bodySize);
71 //if(macp->cardSetting.BssType == INFRASTRUCTURE_BSS) {
72 // //wireless_send_event(macp->device, SIOCGIWSCAN, &wreq, NULL);
73 // wireless_send_event(macp->device, SIOCGIWAP, &wreq, NULL);
74 //}
75 //else if(macp->cardSetting.BssType == AP_BSS) {
76 // if (port == 0)
77 // {
78 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
79 // }
80 // else
81 // {
82 // /* Check whether the VAP device is valid */
83 // if (vap[port].dev != NULL)
84 // {
85 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
86 // }
87 // else
88 // {
89 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
90 // }
91 // }
92 //}
93 //#endif
95 return 0;
99 /* Notification that a STA is disassociated from AP */
100 /* AP mode only */
101 u16_t zfLnxDisAsocNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
103 union iwreq_data wreq;
104 u8_t *addr = (u8_t *) macAddr;
106 memset(&wreq, 0, sizeof(wreq));
107 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
108 wreq.addr.sa_family = ARPHRD_ETHER;
109 printk(KERN_DEBUG "zfwDisAsocNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
110 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
113 return 0;
116 /* Notification that a STA is connect to AP */
117 /* AP mode only */
118 u16_t zfLnxApConnectNotify(zdev_t* dev, u8_t* macAddr, u16_t port)
120 union iwreq_data wreq;
121 u8_t *addr = (u8_t *) macAddr;
123 memset(&wreq, 0, sizeof(wreq));
124 memcpy(wreq.addr.sa_data, macAddr, ETH_ALEN);
125 wreq.addr.sa_family = ARPHRD_ETHER;
126 printk(KERN_DEBUG "zfwApConnectNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
127 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
130 return 0;
135 void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid)
137 union iwreq_data wreq;
138 u8_t *addr = (u8_t *) bssid;
139 struct usbdrv_private *macp = dev->ml_priv;
141 if (bssid != NULL)
143 memset(&wreq, 0, sizeof(wreq));
144 if (status == ZM_STATUS_MEDIA_CONNECT)
145 memcpy(wreq.addr.sa_data, bssid, ETH_ALEN);
146 wreq.addr.sa_family = ARPHRD_ETHER;
148 if (status == ZM_STATUS_MEDIA_CONNECT)
150 #ifdef ZM_CONFIG_BIG_ENDIAN
151 printk(KERN_DEBUG "Connected to AP, MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
152 addr[1], addr[0], addr[3], addr[2], addr[5], addr[4]);
153 #else
154 printk(KERN_DEBUG "Connected to AP, MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
155 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
156 #endif
158 netif_start_queue(dev);
160 else if ((status == ZM_STATUS_MEDIA_DISCONNECT) ||
161 (status == ZM_STATUS_MEDIA_DISABLED) ||
162 (status == ZM_STATUS_MEDIA_CONNECTION_DISABLED) ||
163 (status == ZM_STATUS_MEDIA_CONNECTION_RESET) ||
164 (status == ZM_STATUS_MEDIA_RESET) ||
165 (status == ZM_STATUS_MEDIA_DISCONNECT_DEAUTH) ||
166 (status == ZM_STATUS_MEDIA_DISCONNECT_DISASOC) ||
167 (status == ZM_STATUS_MEDIA_DISCONNECT_BEACON_MISS) ||
168 (status == ZM_STATUS_MEDIA_DISCONNECT_NOT_FOUND) ||
169 (status == ZM_STATUS_MEDIA_DISCONNECT_TIMEOUT))
171 printk(KERN_DEBUG "Disconnection Notify\n");
173 netif_stop_queue(dev);
176 /* Save the connected status */
177 macp->adapterState = status;
179 if(zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE) {
180 // //wireless_send_event(dev, SIOCGIWSCAN, &wreq, NULL);
181 wireless_send_event(dev, SIOCGIWAP, &wreq, NULL);
183 else if(zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
184 //if (port == 0)
186 wireless_send_event(dev, IWEVREGISTERED, &wreq, NULL);
188 //else
190 // /* Check whether the VAP device is valid */
191 // if (vap[port].dev != NULL)
192 // {
193 // wireless_send_event(vap[port].dev, IWEVREGISTERED, &wreq, NULL);
194 // }
195 // else
196 // {
197 // printk(KERN_ERR "Can' find a valid VAP device, port: %d\n", port);
198 // }
202 //return 0;
205 void zfLnxScanNotify(zdev_t* dev, struct zsScanResult* result)
207 return;
210 void zfLnxStatisticsNotify(zdev_t* dev, struct zsStastics* result)
212 return;
215 //void zfwMicFailureNotify(zdev_t* dev, u8_t* message, u16_t event)
216 void zfLnxMicFailureNotify(zdev_t* dev, u16_t* addr, u16_t status)
218 static const char *tag = "MLME-MICHAELMICFAILURE.indication";
219 union iwreq_data wrqu;
220 char buf[128];
222 /* TODO: needed parameters: count, type, src address */
223 //snprintf(buf, sizeof(buf), "%s(%scast addr=%s)", tag,
224 // (status == ZM_MIC_GROUP_ERROR) ? "broad" : "uni",
225 // ether_sprintf((u8_t *)addr));
227 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_INFRASTRUCTURE)
229 strcpy(buf, tag);
232 memset(&wrqu, 0, sizeof(wrqu));
233 wrqu.data.length = strlen(buf);
234 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
238 void zfLnxApMicFailureNotify(zdev_t* dev, u8_t* addr, zbuf_t* buf)
240 union iwreq_data wreq;
242 memset(&wreq, 0, sizeof(wreq));
243 memcpy(wreq.addr.sa_data, addr, ETH_ALEN);
244 wreq.addr.sa_family = ARPHRD_ETHER;
245 printk(KERN_DEBUG "zfwApMicFailureNotify(), MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
246 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
248 return;
251 // status = 0 => partner lost
252 // = 1 => partner alive
253 //void zfwIbssPartnerNotify(zdev_t* dev, u8_t status)
254 void zfLnxIbssPartnerNotify(zdev_t* dev, u16_t status, struct zsPartnerNotifyEvent *event)
258 void zfLnxMacAddressNotify(zdev_t* dev, u8_t* addr)
260 dev->dev_addr[0] = addr[0];
261 dev->dev_addr[1] = addr[1];
262 dev->dev_addr[2] = addr[2];
263 dev->dev_addr[3] = addr[3];
264 dev->dev_addr[4] = addr[4];
265 dev->dev_addr[5] = addr[5];
268 void zfLnxSendCompleteIndication(zdev_t* dev, zbuf_t* buf)
273 void zfLnxRestoreBufData(zdev_t* dev, zbuf_t* buf) {
276 /* Leave an empty line below to remove warning message on some compiler */