1 /* src/p80211/p80211req.c
3 * Request/Indication/MacMgmt interface handling functions
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file contains the functions, types, and macros to support the
48 * MLME request interface that's implemented via the device ioctls.
50 * --------------------------------------------------------------------
53 #include <linux/module.h>
54 #include <linux/kernel.h>
55 #include <linux/sched.h>
56 #include <linux/types.h>
57 #include <linux/skbuff.h>
58 #include <linux/wireless.h>
59 #include <linux/netdevice.h>
60 #include <linux/etherdevice.h>
62 #include <linux/netlink.h>
64 #include "p80211types.h"
65 #include "p80211hdr.h"
66 #include "p80211mgmt.h"
67 #include "p80211conv.h"
68 #include "p80211msg.h"
69 #include "p80211netdev.h"
70 #include "p80211ioctl.h"
71 #include "p80211metadef.h"
72 #include "p80211metastruct.h"
73 #include "p80211req.h"
75 static void p80211req_handlemsg(struct wlandevice
*wlandev
, struct p80211msg
*msg
);
76 static void p80211req_mibset_mibget(struct wlandevice
*wlandev
,
77 struct p80211msg_dot11req_mibget
*mib_msg
,
80 static void p80211req_handle_action(struct wlandevice
*wlandev
, u32
*data
,
84 if (wlandev
->hostwep
& flag
)
85 *data
= P80211ENUM_truth_true
;
87 *data
= P80211ENUM_truth_false
;
89 wlandev
->hostwep
&= ~flag
;
90 if (*data
== P80211ENUM_truth_true
)
91 wlandev
->hostwep
|= flag
;
95 /*----------------------------------------------------------------
98 * Handles an MLME request/confirm message.
101 * wlandev WLAN device struct
102 * msgbuf Buffer containing a request message
105 * 0 on success, an errno otherwise
108 * Potentially blocks the caller, so it's a good idea to
109 * not call this function from an interrupt context.
110 ----------------------------------------------------------------*/
111 int p80211req_dorequest(struct wlandevice
*wlandev
, u8
*msgbuf
)
113 struct p80211msg
*msg
= (struct p80211msg
*)msgbuf
;
115 /* Check to make sure the MSD is running */
116 if (!((wlandev
->msdstate
== WLAN_MSD_HWPRESENT
&&
117 msg
->msgcode
== DIDmsg_lnxreq_ifstate
) ||
118 wlandev
->msdstate
== WLAN_MSD_RUNNING
||
119 wlandev
->msdstate
== WLAN_MSD_FWLOAD
)) {
123 /* Check Permissions */
124 if (!capable(CAP_NET_ADMIN
) &&
125 (msg
->msgcode
!= DIDmsg_dot11req_mibget
)) {
126 netdev_err(wlandev
->netdev
,
127 "%s: only dot11req_mibget allowed for non-root.\n",
132 /* Check for busy status */
133 if (test_and_set_bit(1, &(wlandev
->request_pending
)))
136 /* Allow p80211 to look at msg and handle if desired. */
137 /* So far, all p80211 msgs are immediate, no waitq/timer necessary */
138 /* This may change. */
139 p80211req_handlemsg(wlandev
, msg
);
141 /* Pass it down to wlandev via wlandev->mlmerequest */
142 if (wlandev
->mlmerequest
!= NULL
)
143 wlandev
->mlmerequest(wlandev
, msg
);
145 clear_bit(1, &(wlandev
->request_pending
));
146 return 0; /* if result==0, msg->status still may contain an err */
149 /*----------------------------------------------------------------
150 * p80211req_handlemsg
152 * p80211 message handler. Primarily looks for messages that
153 * belong to p80211 and then dispatches the appropriate response.
154 * TODO: we don't do anything yet. Once the linuxMIB is better
155 * defined we'll need a get/set handler.
158 * wlandev WLAN device struct
159 * msg message structure
162 * nothing (any results are set in the status field of the msg)
166 ----------------------------------------------------------------*/
167 static void p80211req_handlemsg(struct wlandevice
*wlandev
, struct p80211msg
*msg
)
169 switch (msg
->msgcode
) {
171 case DIDmsg_lnxreq_hostwep
:{
172 struct p80211msg_lnxreq_hostwep
*req
=
173 (struct p80211msg_lnxreq_hostwep
*)msg
;
175 ~(HOSTWEP_DECRYPT
| HOSTWEP_ENCRYPT
);
176 if (req
->decrypt
.data
== P80211ENUM_truth_true
)
177 wlandev
->hostwep
|= HOSTWEP_DECRYPT
;
178 if (req
->encrypt
.data
== P80211ENUM_truth_true
)
179 wlandev
->hostwep
|= HOSTWEP_ENCRYPT
;
183 case DIDmsg_dot11req_mibget
:
184 case DIDmsg_dot11req_mibset
:{
185 int isget
= (msg
->msgcode
== DIDmsg_dot11req_mibget
);
186 struct p80211msg_dot11req_mibget
*mib_msg
=
187 (struct p80211msg_dot11req_mibget
*)msg
;
188 p80211req_mibset_mibget(wlandev
, mib_msg
, isget
);
191 } /* switch msg->msgcode */
194 static void p80211req_mibset_mibget(struct wlandevice
*wlandev
,
195 struct p80211msg_dot11req_mibget
*mib_msg
,
198 struct p80211itemd
*mibitem
= (struct p80211itemd
*)mib_msg
->mibattribute
.data
;
199 struct p80211pstrd
*pstr
= (struct p80211pstrd
*)mibitem
->data
;
200 u8
*key
= mibitem
->data
+ sizeof(struct p80211pstrd
);
202 switch (mibitem
->did
) {
203 case DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(1):
204 case DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(2):
205 case DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(3):
206 case DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(4):
208 wep_change_key(wlandev
,
209 P80211DID_ITEM(mibitem
->did
) - 1,
213 case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID
:{
214 u32
*data
= (u32
*)mibitem
->data
;
217 *data
= wlandev
->hostwep
& HOSTWEP_DEFAULTKEY_MASK
;
219 wlandev
->hostwep
&= ~(HOSTWEP_DEFAULTKEY_MASK
);
220 wlandev
->hostwep
|= (*data
& HOSTWEP_DEFAULTKEY_MASK
);
224 case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked
:{
225 u32
*data
= (u32
*)mibitem
->data
;
227 p80211req_handle_action(wlandev
, data
, isget
,
228 HOSTWEP_PRIVACYINVOKED
);
231 case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted
:{
232 u32
*data
= (u32
*)mibitem
->data
;
234 p80211req_handle_action(wlandev
, data
, isget
,
235 HOSTWEP_EXCLUDEUNENCRYPTED
);