Commit | Line | Data |
---|---|---|
68c0bdff HG |
1 | /******************************************************************************* |
2 | * Agere Systems Inc. | |
3 | * Wireless device driver for Linux (wlags49). | |
4 | * | |
5 | * Copyright (c) 1998-2003 Agere Systems Inc. | |
6 | * All rights reserved. | |
7 | * http://www.agere.com | |
8 | * | |
9 | * Initially developed by TriplePoint, Inc. | |
10 | * http://www.triplepoint.com | |
11 | * | |
12 | *------------------------------------------------------------------------------ | |
13 | * | |
14 | * This file defines routines required to parse configuration parameters | |
15 | * listed in a config file, if that config file exists. | |
16 | * | |
17 | *------------------------------------------------------------------------------ | |
18 | * | |
19 | * SOFTWARE LICENSE | |
20 | * | |
21 | * This software is provided subject to the following terms and conditions, | |
22 | * which you should read carefully before using the software. Using this | |
23 | * software indicates your acceptance of these terms and conditions. If you do | |
24 | * not agree with these terms and conditions, do not use the software. | |
25 | * | |
d36b6910 | 26 | * Copyright © 2003 Agere Systems Inc. |
68c0bdff HG |
27 | * All rights reserved. |
28 | * | |
29 | * Redistribution and use in source or binary forms, with or without | |
30 | * modifications, are permitted provided that the following conditions are met: | |
31 | * | |
32 | * . Redistributions of source code must retain the above copyright notice, this | |
33 | * list of conditions and the following Disclaimer as comments in the code as | |
34 | * well as in the documentation and/or other materials provided with the | |
35 | * distribution. | |
36 | * | |
37 | * . Redistributions in binary form must reproduce the above copyright notice, | |
38 | * this list of conditions and the following Disclaimer in the documentation | |
39 | * and/or other materials provided with the distribution. | |
40 | * | |
41 | * . Neither the name of Agere Systems Inc. nor the names of the contributors | |
42 | * may be used to endorse or promote products derived from this software | |
43 | * without specific prior written permission. | |
44 | * | |
45 | * Disclaimer | |
46 | * | |
d36b6910 | 47 | * THIS SOFTWARE IS PROVIDED \93AS IS\94 AND ANY EXPRESS OR IMPLIED WARRANTIES, |
68c0bdff HG |
48 | * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF |
49 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY | |
50 | * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN | |
51 | * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY | |
52 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
53 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
54 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
55 | * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
57 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
58 | * DAMAGE. | |
59 | * | |
60 | ******************************************************************************/ | |
61 | ||
68c0bdff HG |
62 | /* Only include this file if USE_PROFILE is defined */ |
63 | #ifdef USE_PROFILE | |
64 | ||
65 | ||
66 | ||
67 | ||
68 | /******************************************************************************* | |
69 | * constant definitions | |
70 | ******************************************************************************/ | |
71 | ||
72 | ||
73 | /* Allow support for calling system fcns to parse config file */ | |
74 | #define __KERNEL_SYSCALLS__ | |
75 | ||
76 | ||
77 | ||
78 | ||
79 | /******************************************************************************* | |
80 | * include files | |
81 | ******************************************************************************/ | |
82 | #include <wl_version.h> | |
83 | ||
84 | #include <linux/netdevice.h> | |
85 | #include <linux/etherdevice.h> | |
86 | #include <linux/unistd.h> | |
87 | #include <asm/uaccess.h> | |
88 | #include <limits.h> | |
89 | ||
90 | #define BIN_DL 1 | |
91 | ||
92 | #include <debug.h> | |
93 | #include <hcf.h> | |
801de523 | 94 | /* #include <hcfdef.h> */ |
68c0bdff HG |
95 | |
96 | #include <wl_if.h> | |
97 | #include <wl_internal.h> | |
98 | #include <wl_util.h> | |
99 | #include <wl_enc.h> | |
100 | #include <wl_main.h> | |
101 | #include <wl_profile.h> | |
102 | ||
103 | ||
104 | /******************************************************************************* | |
105 | * global variables | |
106 | ******************************************************************************/ | |
107 | ||
108 | /* Definition needed to prevent unresolved external in unistd.h */ | |
109 | static int errno; | |
110 | ||
111 | #if DBG | |
112 | extern p_u32 DebugFlag; | |
113 | extern dbg_info_t *DbgInfo; | |
114 | #endif | |
115 | ||
d101b958 | 116 | int parse_yes_no(char *value); |
68c0bdff HG |
117 | |
118 | ||
d101b958 PS |
119 | int parse_yes_no(char *value) |
120 | { | |
801de523 | 121 | int rc = 0; /* default to NO for invalid parameters */ |
68c0bdff | 122 | |
d101b958 PS |
123 | if (strlen(value) == 1) { |
124 | if ((value[0] | ('Y'^'y')) == 'y') | |
125 | rc = 1; | |
801de523 PS |
126 | /* } else { */ |
127 | /* this should not be debug time info, it is an enduser data entry error ;? */ | |
128 | /* DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_MICROWAVE_ROBUSTNESS); */ | |
68c0bdff HG |
129 | } |
130 | return rc; | |
801de523 | 131 | } /* parse_yes_no */ |
68c0bdff HG |
132 | |
133 | ||
134 | /******************************************************************************* | |
135 | * parse_config() | |
136 | ******************************************************************************* | |
137 | * | |
138 | * DESCRIPTION: | |
139 | * | |
140 | * This function opens the device's config file and parses the options from | |
141 | * it, so that it can properly configure itself. If no configuration file | |
142 | * or configuration is present, then continue to use the options already | |
143 | * parsed from config.opts or wireless.opts. | |
144 | * | |
145 | * PARAMETERS: | |
146 | * | |
147 | * dev - a pointer to the device's net_device structure | |
148 | * | |
149 | * RETURNS: | |
150 | * | |
151 | * N/A | |
152 | * | |
153 | ******************************************************************************/ | |
d101b958 | 154 | void parse_config(struct net_device *dev) |
68c0bdff HG |
155 | { |
156 | int file_desc; | |
801de523 | 157 | #if 0 /* BIN_DL */ |
d101b958 | 158 | int rc; |
68c0bdff | 159 | char *cp = NULL; |
801de523 | 160 | #endif /* BIN_DL */ |
68c0bdff HG |
161 | char buffer[MAX_LINE_SIZE]; |
162 | char filename[MAX_LINE_SIZE]; | |
163 | mm_segment_t fs; | |
164 | struct wl_private *wvlan_config = NULL; | |
165 | ENCSTRCT sEncryption; | |
166 | /*------------------------------------------------------------------------*/ | |
167 | ||
d101b958 PS |
168 | DBG_FUNC("parse_config"); |
169 | DBG_ENTER(DbgInfo); | |
68c0bdff HG |
170 | |
171 | /* Get the wavelan specific info for this device */ | |
82942ca2 | 172 | wvlan_config = dev->priv; |
d101b958 PS |
173 | if (wvlan_config == NULL) { |
174 | DBG_ERROR(DbgInfo, "Wavelan specific info struct not present?\n"); | |
68c0bdff HG |
175 | return; |
176 | } | |
177 | ||
178 | /* setup the default encryption string */ | |
d101b958 | 179 | strcpy(wvlan_config->szEncryption, DEF_CRYPT_STR); |
68c0bdff HG |
180 | |
181 | /* Obtain a user-space process context, storing the original context */ | |
d101b958 PS |
182 | fs = get_fs(); |
183 | set_fs(get_ds()); | |
68c0bdff HG |
184 | |
185 | /* Determine the filename for this device and attempt to open it */ | |
d101b958 PS |
186 | sprintf(filename, "%s%s", ROOT_CONFIG_FILENAME, dev->name); |
187 | file_desc = open(filename, O_RDONLY, 0); | |
188 | if (file_desc != -1) { | |
189 | DBG_TRACE(DbgInfo, "Wireless config file found. Parsing options...\n"); | |
68c0bdff HG |
190 | |
191 | /* Read out the options */ | |
ce7f6389 | 192 | while (readline(file_desc, buffer)) |
d101b958 | 193 | translate_option(buffer, wvlan_config); |
68c0bdff | 194 | /* Close the file */ |
801de523 | 195 | close(file_desc); /* ;?even if file_desc == -1 ??? */ |
68c0bdff | 196 | } else { |
d101b958 PS |
197 | DBG_TRACE(DbgInfo, "No iwconfig file found for this device; " |
198 | "config.opts or wireless.opts will be used\n"); | |
68c0bdff HG |
199 | } |
200 | /* Return to the original context */ | |
d101b958 | 201 | set_fs(fs); |
68c0bdff HG |
202 | |
203 | /* convert the WEP keys, if read in as key1, key2, type of data */ | |
d101b958 PS |
204 | if (wvlan_config->EnableEncryption) { |
205 | memset(&sEncryption, 0, sizeof(sEncryption)); | |
68c0bdff | 206 | |
d101b958 PS |
207 | wl_wep_decode(CRYPT_CODE, &sEncryption, |
208 | wvlan_config->szEncryption); | |
68c0bdff HG |
209 | |
210 | /* the Linux driver likes to use 1-4 for the key IDs, and then | |
211 | convert to 0-3 when sending to the card. The Windows code | |
212 | base used 0-3 in the API DLL, which was ported to Linux. For | |
213 | the sake of the user experience, we decided to keep 0-3 as the | |
214 | numbers used in the DLL; and will perform the +1 conversion here. | |
215 | We could have converted the entire Linux driver, but this is | |
216 | less obtrusive. This may be a "todo" to convert the whole driver */ | |
217 | sEncryption.wEnabled = wvlan_config->EnableEncryption; | |
218 | sEncryption.wTxKeyID = wvlan_config->TransmitKeyID - 1; | |
219 | ||
d101b958 PS |
220 | memcpy(&sEncryption.EncStr, &wvlan_config->DefaultKeys, |
221 | sizeof(CFG_DEFAULT_KEYS_STRCT)); | |
68c0bdff | 222 | |
d101b958 | 223 | memset(wvlan_config->szEncryption, 0, sizeof(wvlan_config->szEncryption)); |
68c0bdff | 224 | |
d101b958 PS |
225 | wl_wep_code(CRYPT_CODE, wvlan_config->szEncryption, &sEncryption, |
226 | sizeof(sEncryption)); | |
68c0bdff HG |
227 | } |
228 | ||
229 | /* decode the encryption string for the call to wl_commit() */ | |
d101b958 | 230 | wl_wep_decode(CRYPT_CODE, &sEncryption, wvlan_config->szEncryption); |
68c0bdff HG |
231 | |
232 | wvlan_config->TransmitKeyID = sEncryption.wTxKeyID + 1; | |
233 | wvlan_config->EnableEncryption = sEncryption.wEnabled; | |
234 | ||
d101b958 PS |
235 | memcpy(&wvlan_config->DefaultKeys, &sEncryption.EncStr, |
236 | sizeof(CFG_DEFAULT_KEYS_STRCT)); | |
68c0bdff | 237 | |
801de523 | 238 | #if 0 /* BIN_DL */ |
68c0bdff | 239 | /* Obtain a user-space process context, storing the original context */ |
d101b958 PS |
240 | fs = get_fs(); |
241 | set_fs(get_ds()); | |
68c0bdff | 242 | |
801de523 | 243 | /* ;?just to fake something */ |
d101b958 PS |
244 | strcpy(/*wvlan_config->fw_image_*/filename, "/etc/agere/fw.bin"); |
245 | file_desc = open(/*wvlan_config->fw_image_*/filename, 0, 0); | |
246 | if (file_desc == -1) { | |
247 | DBG_ERROR(DbgInfo, "No image file found\n"); | |
68c0bdff | 248 | } else { |
d101b958 | 249 | DBG_TRACE(DbgInfo, "F/W image file found\n"); |
801de523 | 250 | #define DHF_ALLOC_SIZE 96000 /* just below 96K, let's hope it suffices for now and for the future */ |
5ef3df5b | 251 | cp = vmalloc(DHF_ALLOC_SIZE); |
d101b958 PS |
252 | if (cp == NULL) { |
253 | DBG_ERROR(DbgInfo, "error in vmalloc\n"); | |
68c0bdff | 254 | } else { |
d101b958 PS |
255 | rc = read(file_desc, cp, DHF_ALLOC_SIZE); |
256 | if (rc == DHF_ALLOC_SIZE) { | |
257 | DBG_ERROR(DbgInfo, "buffer too small, %d\n", DHF_ALLOC_SIZE); | |
258 | } else if (rc > 0) { | |
259 | DBG_TRACE(DbgInfo, "read O.K.: %d bytes %.12s\n", rc, cp); | |
260 | rc = read(file_desc, &cp[rc], 1); | |
ce7f6389 | 261 | if (rc == 0) |
d101b958 | 262 | DBG_TRACE(DbgInfo, "no more to read\n"); |
68c0bdff | 263 | } |
d101b958 PS |
264 | if (rc != 0) { |
265 | DBG_ERROR(DbgInfo, "file not read in one swoop or other error"\ | |
266 | ", give up, too complicated, rc = %0X\n", rc); | |
68c0bdff | 267 | } |
d101b958 | 268 | vfree(cp); |
68c0bdff | 269 | } |
d101b958 | 270 | close(file_desc); |
68c0bdff | 271 | } |
d101b958 | 272 | set_fs(fs); /* Return to the original context */ |
801de523 | 273 | #endif /* BIN_DL */ |
68c0bdff | 274 | |
d101b958 | 275 | DBG_LEAVE(DbgInfo); |
68c0bdff | 276 | return; |
801de523 | 277 | } /* parse_config */ |
68c0bdff HG |
278 | |
279 | /******************************************************************************* | |
280 | * readline() | |
281 | ******************************************************************************* | |
282 | * | |
283 | * DESCRIPTION: | |
284 | * | |
285 | * This function reads in data from a given file one line at a time, | |
286 | * converting the detected newline character '\n' to a null '\0'. Note that | |
287 | * the file descriptor must be valid before calling this function. | |
288 | * | |
289 | * PARAMETERS: | |
290 | * | |
291 | * filedesc - the file descriptor for the open configuration file | |
292 | * buffer - a buffer pointer, passed in by the caller, to which the | |
293 | * line will be stored. | |
294 | * | |
295 | * RETURNS: | |
296 | * | |
297 | * the number of bytes read | |
298 | * -1 on error | |
299 | * | |
300 | ******************************************************************************/ | |
d101b958 | 301 | int readline(int filedesc, char *buffer) |
68c0bdff HG |
302 | { |
303 | int result = -1; | |
304 | int bytes_read = 0; | |
305 | /*------------------------------------------------------------------------*/ | |
306 | ||
307 | /* Make sure the file descriptor is good */ | |
d101b958 | 308 | if (filedesc != -1) { |
68c0bdff | 309 | /* Read in from the file byte by byte until a newline is reached */ |
d101b958 PS |
310 | while ((result = read(filedesc, &buffer[bytes_read], 1)) == 1) { |
311 | if (buffer[bytes_read] == '\n') { | |
68c0bdff HG |
312 | buffer[bytes_read] = '\0'; |
313 | bytes_read++; | |
314 | break; | |
315 | } | |
316 | bytes_read++; | |
317 | } | |
318 | } | |
319 | ||
320 | /* Return the number of bytes read */ | |
ce7f6389 | 321 | if (result == -1) |
68c0bdff | 322 | return result; |
ce7f6389 | 323 | else |
68c0bdff | 324 | return bytes_read; |
801de523 | 325 | } /* readline */ |
68c0bdff HG |
326 | /*============================================================================*/ |
327 | ||
328 | /******************************************************************************* | |
329 | * translate_option() | |
330 | ******************************************************************************* | |
331 | * | |
332 | * DESCRIPTION: | |
333 | * | |
334 | * This function takes a line read in from the config file and parses out | |
335 | * the key/value pairs. It then determines which key has been parsed and sets | |
336 | * the card's configuration based on the value given. | |
337 | * | |
338 | * PARAMETERS: | |
339 | * | |
340 | * buffer - a buffer containing a line to translate | |
341 | * config - a pointer to the device's private adapter structure | |
342 | * | |
343 | * RETURNS: | |
344 | * | |
345 | * N/A | |
346 | * | |
347 | ******************************************************************************/ | |
d101b958 | 348 | void translate_option(char *buffer, struct wl_private *lp) |
68c0bdff HG |
349 | { |
350 | unsigned int value_convert = 0; | |
351 | int string_length = 0; | |
352 | char *key = NULL; | |
353 | char *value = NULL; | |
354 | u_char mac_value[ETH_ALEN]; | |
355 | /*------------------------------------------------------------------------*/ | |
356 | ||
d101b958 | 357 | DBG_FUNC("translate_option"); |
68c0bdff | 358 | |
d101b958 PS |
359 | if (buffer == NULL || lp == NULL) { |
360 | DBG_ERROR(DbgInfo, "Config file buffer and/or wavelan buffer ptr NULL\n"); | |
68c0bdff HG |
361 | return; |
362 | } | |
363 | ||
d101b958 | 364 | ParseConfigLine(buffer, &key, &value); |
68c0bdff | 365 | |
ce7f6389 | 366 | if (key == NULL || value == NULL) |
68c0bdff | 367 | return; |
68c0bdff HG |
368 | |
369 | /* Determine which key it is and perform the appropriate action */ | |
370 | ||
371 | /* Configuration parameters used in all scenarios */ | |
372 | #if DBG | |
373 | /* handle DebugFlag as early as possible so it starts its influence as early | |
374 | * as possible | |
375 | */ | |
d101b958 PS |
376 | if (strcmp(key, PARM_NAME_DEBUG_FLAG) == 0) { |
377 | if (DebugFlag == ~0) { /* if DebugFlag is not specified on the command line */ | |
378 | if (DbgInfo->DebugFlag == 0) { /* if pc_debug did not set DebugFlag (i.e.pc_debug is | |
68c0bdff HG |
379 | * not specified or specified outside the 4-8 range |
380 | */ | |
381 | DbgInfo->DebugFlag |= DBG_DEFAULTS; | |
382 | } | |
383 | } else { | |
801de523 | 384 | DbgInfo->DebugFlag = simple_strtoul(value, NULL, 0); /* ;?DebugFlag; */ |
68c0bdff | 385 | } |
801de523 | 386 | DbgInfo->DebugFlag = simple_strtoul(value, NULL, 0); /* ;?Delete ASAP */ |
68c0bdff HG |
387 | } |
388 | #endif /* DBG */ | |
d101b958 PS |
389 | if (strcmp(key, PARM_NAME_AUTH_KEY_MGMT_SUITE) == 0) { |
390 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_AUTH_KEY_MGMT_SUITE, value); | |
68c0bdff | 391 | |
9f648592 | 392 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 393 | if ((value_convert >= PARM_MIN_AUTH_KEY_MGMT_SUITE) || (value_convert <= PARM_MAX_AUTH_KEY_MGMT_SUITE)) |
68c0bdff | 394 | lp->AuthKeyMgmtSuite = value_convert; |
ce7f6389 | 395 | else |
d101b958 | 396 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_AUTH_KEY_MGMT_SUITE); |
d101b958 PS |
397 | } else if (strcmp(key, PARM_NAME_BRSC_2GHZ) == 0) { |
398 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_BRSC_2GHZ, value); | |
68c0bdff | 399 | |
9f648592 | 400 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 401 | if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC)) |
68c0bdff | 402 | lp->brsc[0] = value_convert; |
ce7f6389 | 403 | else |
73e18893 | 404 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_BRSC_2GHZ); |
d101b958 PS |
405 | } else if (strcmp(key, PARM_NAME_BRSC_5GHZ) == 0) { |
406 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_BRSC_5GHZ, value); | |
68c0bdff | 407 | |
9f648592 | 408 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 409 | if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC)) |
68c0bdff | 410 | lp->brsc[1] = value_convert; |
ce7f6389 | 411 | else |
73e18893 | 412 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_BRSC_5GHZ); |
d101b958 PS |
413 | } else if ((strcmp(key, PARM_NAME_DESIRED_SSID) == 0) || (strcmp(key, PARM_NAME_OWN_SSID) == 0)) { |
414 | DBG_TRACE(DbgInfo, "SSID, value: %s\n", value); | |
68c0bdff | 415 | |
d101b958 | 416 | memset(lp->NetworkName, 0, (PARM_MAX_NAME_LEN + 1)); |
68c0bdff HG |
417 | |
418 | /* Make sure the value isn't too long */ | |
d101b958 PS |
419 | string_length = strlen(value); |
420 | if (string_length > PARM_MAX_NAME_LEN) { | |
421 | DBG_WARNING(DbgInfo, "SSID too long; will be truncated\n"); | |
68c0bdff HG |
422 | string_length = PARM_MAX_NAME_LEN; |
423 | } | |
424 | ||
d101b958 | 425 | memcpy(lp->NetworkName, value, string_length); |
68c0bdff HG |
426 | } |
427 | #if 0 | |
d101b958 PS |
428 | else if (strcmp(key, PARM_NAME_DOWNLOAD_FIRMWARE) == 0) { |
429 | DBG_TRACE(DbgInfo, "DOWNLOAD_FIRMWARE, value: %s\n", value); | |
430 | memset(lp->fw_image_filename, 0, (MAX_LINE_SIZE + 1)); | |
68c0bdff | 431 | /* Make sure the value isn't too long */ |
d101b958 | 432 | string_length = strlen(value); |
ce7f6389 | 433 | if (string_length > MAX_LINE_SIZE) |
d101b958 | 434 | DBG_WARNING(DbgInfo, "F/W image file name too long; will be ignored\n"); |
ce7f6389 | 435 | else |
d101b958 | 436 | memcpy(lp->fw_image_filename, value, string_length); |
68c0bdff HG |
437 | } |
438 | #endif | |
d101b958 PS |
439 | else if (strcmp(key, PARM_NAME_ENABLE_ENCRYPTION) == 0) { |
440 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_ENABLE_ENCRYPTION, value); | |
68c0bdff | 441 | |
9f648592 | 442 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 443 | if ((value_convert >= PARM_MIN_ENABLE_ENCRYPTION) && (value_convert <= PARM_MAX_ENABLE_ENCRYPTION)) |
68c0bdff | 444 | lp->EnableEncryption = value_convert; |
ce7f6389 | 445 | else |
d101b958 | 446 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_ENABLE_ENCRYPTION); |
d101b958 PS |
447 | } else if (strcmp(key, PARM_NAME_ENCRYPTION) == 0) { |
448 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_ENCRYPTION, value); | |
68c0bdff | 449 | |
d101b958 | 450 | memset(lp->szEncryption, 0, sizeof(lp->szEncryption)); |
68c0bdff HG |
451 | |
452 | /* Make sure the value isn't too long */ | |
d101b958 PS |
453 | string_length = strlen(value); |
454 | if (string_length > sizeof(lp->szEncryption)) { | |
455 | DBG_WARNING(DbgInfo, "%s too long; will be truncated\n", PARM_NAME_ENCRYPTION); | |
456 | string_length = sizeof(lp->szEncryption); | |
68c0bdff HG |
457 | } |
458 | ||
d101b958 PS |
459 | memcpy(lp->szEncryption, value, string_length); |
460 | } else if (strcmp(key, PARM_NAME_KEY1) == 0) { | |
461 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY1, value); | |
68c0bdff | 462 | |
d101b958 PS |
463 | if (is_valid_key_string(value)) { |
464 | memset(lp->DefaultKeys.key[0].key, 0, MAX_KEY_SIZE); | |
68c0bdff | 465 | |
d101b958 | 466 | key_string2key(value, &lp->DefaultKeys.key[0]); |
68c0bdff | 467 | } else { |
d101b958 | 468 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY1); |
68c0bdff | 469 | } |
d101b958 PS |
470 | } else if (strcmp(key, PARM_NAME_KEY2) == 0) { |
471 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY2, value); | |
68c0bdff | 472 | |
d101b958 PS |
473 | if (is_valid_key_string(value)) { |
474 | memset(lp->DefaultKeys.key[1].key, 0, MAX_KEY_SIZE); | |
68c0bdff | 475 | |
d101b958 | 476 | key_string2key(value, &lp->DefaultKeys.key[1]); |
68c0bdff | 477 | } else { |
d101b958 | 478 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY2); |
68c0bdff | 479 | } |
d101b958 PS |
480 | } else if (strcmp(key, PARM_NAME_KEY3) == 0) { |
481 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY3, value); | |
68c0bdff | 482 | |
d101b958 PS |
483 | if (is_valid_key_string(value)) { |
484 | memset(lp->DefaultKeys.key[2].key, 0, MAX_KEY_SIZE); | |
68c0bdff | 485 | |
d101b958 | 486 | key_string2key(value, &lp->DefaultKeys.key[2]); |
68c0bdff | 487 | } else { |
d101b958 | 488 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY3); |
68c0bdff | 489 | } |
d101b958 PS |
490 | } else if (strcmp(key, PARM_NAME_KEY4) == 0) { |
491 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY4, value); | |
68c0bdff | 492 | |
d101b958 PS |
493 | if (is_valid_key_string(value)) { |
494 | memset(lp->DefaultKeys.key[3].key, 0, MAX_KEY_SIZE); | |
68c0bdff | 495 | |
d101b958 | 496 | key_string2key(value, &lp->DefaultKeys.key[3]); |
68c0bdff | 497 | } else { |
d101b958 | 498 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY4); |
68c0bdff HG |
499 | } |
500 | } | |
501 | /* New Parameters for WARP */ | |
d101b958 PS |
502 | else if (strcmp(key, PARM_NAME_LOAD_BALANCING) == 0) { |
503 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_LOAD_BALANCING, value); | |
68c0bdff | 504 | lp->loadBalancing = parse_yes_no(value); |
d101b958 PS |
505 | } else if (strcmp(key, PARM_NAME_MEDIUM_DISTRIBUTION) == 0) { |
506 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MEDIUM_DISTRIBUTION, value); | |
68c0bdff | 507 | lp->mediumDistribution = parse_yes_no(value); |
d101b958 PS |
508 | } else if (strcmp(key, PARM_NAME_MICROWAVE_ROBUSTNESS) == 0) { |
509 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MICROWAVE_ROBUSTNESS, value); | |
68c0bdff | 510 | lp->MicrowaveRobustness = parse_yes_no(value); |
d101b958 PS |
511 | } else if (strcmp(key, PARM_NAME_MULTICAST_RATE) == 0) { |
512 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_RATE, value); | |
68c0bdff | 513 | |
9f648592 | 514 | value_convert = simple_strtoul(value, NULL, 0); |
68c0bdff | 515 | |
ce7f6389 | 516 | if ((value_convert >= PARM_MIN_MULTICAST_RATE) && (value_convert <= PARM_MAX_MULTICAST_RATE)) |
68c0bdff | 517 | lp->MulticastRate[0] = value_convert; |
ce7f6389 | 518 | else |
d101b958 | 519 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_MULTICAST_RATE); |
d101b958 PS |
520 | } else if (strcmp(key, PARM_NAME_OWN_CHANNEL) == 0) { |
521 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_CHANNEL, value); | |
68c0bdff | 522 | |
9f648592 | 523 | value_convert = simple_strtoul(value, NULL, 0); |
d101b958 | 524 | if (wl_is_a_valid_chan(value_convert)) { |
ce7f6389 | 525 | if (value_convert > 14) |
68c0bdff | 526 | value_convert = value_convert | 0x100; |
68c0bdff HG |
527 | lp->Channel = value_convert; |
528 | } else { | |
d101b958 | 529 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_CHANNEL); |
68c0bdff | 530 | } |
d101b958 PS |
531 | } else if (strcmp(key, PARM_NAME_OWN_NAME) == 0) { |
532 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_NAME, value); | |
68c0bdff | 533 | |
d101b958 | 534 | memset(lp->StationName, 0, (PARM_MAX_NAME_LEN + 1)); |
68c0bdff HG |
535 | |
536 | /* Make sure the value isn't too long */ | |
d101b958 PS |
537 | string_length = strlen(value); |
538 | if (string_length > PARM_MAX_NAME_LEN) { | |
539 | DBG_WARNING(DbgInfo, "%s too long; will be truncated\n", PARM_NAME_OWN_NAME); | |
68c0bdff HG |
540 | string_length = PARM_MAX_NAME_LEN; |
541 | } | |
542 | ||
d101b958 PS |
543 | memcpy(lp->StationName, value, string_length); |
544 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD) == 0) { | |
545 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD, value); | |
68c0bdff | 546 | |
9f648592 | 547 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 548 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 549 | lp->RTSThreshold = value_convert; |
ce7f6389 | 550 | else |
d101b958 | 551 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD); |
d101b958 PS |
552 | } else if (strcmp(key, PARM_NAME_SRSC_2GHZ) == 0) { |
553 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SRSC_2GHZ, value); | |
68c0bdff | 554 | |
9f648592 | 555 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 556 | if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC)) |
68c0bdff | 557 | lp->srsc[0] = value_convert; |
ce7f6389 | 558 | else |
73e18893 | 559 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SRSC_2GHZ); |
d101b958 PS |
560 | } else if (strcmp(key, PARM_NAME_SRSC_5GHZ) == 0) { |
561 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SRSC_5GHZ, value); | |
68c0bdff | 562 | |
9f648592 | 563 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 564 | if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC)) |
68c0bdff | 565 | lp->srsc[1] = value_convert; |
ce7f6389 | 566 | else |
73e18893 | 567 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SRSC_5GHZ); |
d101b958 PS |
568 | } else if (strcmp(key, PARM_NAME_SYSTEM_SCALE) == 0) { |
569 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SYSTEM_SCALE, value); | |
68c0bdff | 570 | |
9f648592 | 571 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 572 | if ((value_convert >= PARM_MIN_SYSTEM_SCALE) && (value_convert <= PARM_MAX_SYSTEM_SCALE)) |
68c0bdff | 573 | lp->DistanceBetweenAPs = value_convert; |
ce7f6389 | 574 | else |
d101b958 | 575 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SYSTEM_SCALE); |
d101b958 PS |
576 | } else if (strcmp(key, PARM_NAME_TX_KEY) == 0) { |
577 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_KEY, value); | |
68c0bdff | 578 | |
9f648592 | 579 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 580 | if ((value_convert >= PARM_MIN_TX_KEY) && (value_convert <= PARM_MAX_TX_KEY)) |
9f648592 | 581 | lp->TransmitKeyID = simple_strtoul(value, NULL, 0); |
ce7f6389 | 582 | else |
d101b958 | 583 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_KEY); |
d101b958 PS |
584 | } else if (strcmp(key, PARM_NAME_TX_RATE) == 0) { |
585 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE, value); | |
68c0bdff | 586 | |
9f648592 | 587 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 588 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 589 | lp->TxRateControl[0] = value_convert; |
ce7f6389 | 590 | else |
d101b958 | 591 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE); |
d101b958 PS |
592 | } else if (strcmp(key, PARM_NAME_TX_POW_LEVEL) == 0) { |
593 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_POW_LEVEL, value); | |
68c0bdff | 594 | |
9f648592 | 595 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 596 | if ((value_convert >= PARM_MIN_TX_POW_LEVEL) || (value_convert <= PARM_MAX_TX_POW_LEVEL)) |
68c0bdff | 597 | lp->txPowLevel = value_convert; |
ce7f6389 | 598 | else |
d101b958 | 599 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_POW_LEVEL); |
68c0bdff HG |
600 | } |
601 | ||
602 | /* Need to add? : Country code, Short/Long retry */ | |
603 | ||
604 | /* Configuration parameters specific to STA mode */ | |
801de523 PS |
605 | #if 1 /* ;? (HCF_TYPE) & HCF_TYPE_STA */ |
606 | /* ;?seems reasonable that even an AP-only driver could afford this small additional footprint */ | |
d101b958 | 607 | if (CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_STA) { |
801de523 | 608 | /* ;?should we return an error status in AP mode */ |
d101b958 PS |
609 | if (strcmp(key, PARM_NAME_PORT_TYPE) == 0) { |
610 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PORT_TYPE, value); | |
68c0bdff | 611 | |
9f648592 | 612 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 613 | if ((value_convert == PARM_MIN_PORT_TYPE) || (value_convert == PARM_MAX_PORT_TYPE)) |
68c0bdff | 614 | lp->PortType = value_convert; |
ce7f6389 | 615 | else |
d101b958 | 616 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PORT_TYPE); |
d101b958 PS |
617 | } else if (strcmp(key, PARM_NAME_PM_ENABLED) == 0) { |
618 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PM_ENABLED, value); | |
9f648592 | 619 | value_convert = simple_strtoul(value, NULL, 0); |
68c0bdff | 620 | /* ;? how about wl_main.c containing |
d101b958 PS |
621 | * VALID_PARAM(PARM_PM_ENABLED <= WVLAN_PM_STATE_STANDARD || |
622 | * (PARM_PM_ENABLED & 0x7FFF) <= WVLAN_PM_STATE_STANDARD); | |
68c0bdff | 623 | */ |
d101b958 | 624 | if ((value_convert & 0x7FFF) <= PARM_MAX_PM_ENABLED) { |
68c0bdff HG |
625 | lp->PMEnabled = value_convert; |
626 | } else { | |
d101b958 | 627 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PM_ENABLED); |
801de523 | 628 | /* ;?this is a data entry error, hence not a DBG_WARNING */ |
68c0bdff | 629 | } |
d101b958 PS |
630 | } else if (strcmp(key, PARM_NAME_CREATE_IBSS) == 0) { |
631 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_CREATE_IBSS, value); | |
68c0bdff | 632 | lp->CreateIBSS = parse_yes_no(value); |
d101b958 PS |
633 | } else if (strcmp(key, PARM_NAME_MULTICAST_RX) == 0) { |
634 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_RX, value); | |
68c0bdff | 635 | lp->MulticastReceive = parse_yes_no(value); |
d101b958 PS |
636 | } else if (strcmp(key, PARM_NAME_MAX_SLEEP) == 0) { |
637 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MAX_SLEEP, value); | |
68c0bdff | 638 | |
9f648592 | 639 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 640 | if ((value_convert >= 0) && (value_convert <= 65535)) |
68c0bdff | 641 | lp->MaxSleepDuration = value_convert; |
ce7f6389 | 642 | else |
d101b958 | 643 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_MAX_SLEEP); |
d101b958 PS |
644 | } else if (strcmp(key, PARM_NAME_NETWORK_ADDR) == 0) { |
645 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_NETWORK_ADDR, value); | |
68c0bdff | 646 | |
ce7f6389 | 647 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 648 | memcpy(lp->MACAddress, mac_value, ETH_ALEN); |
ce7f6389 | 649 | else |
d101b958 | 650 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_NETWORK_ADDR); |
d101b958 PS |
651 | } else if (strcmp(key, PARM_NAME_AUTHENTICATION) == 0) { |
652 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_AUTHENTICATION, value); | |
68c0bdff | 653 | |
9f648592 | 654 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 655 | if ((value_convert >= PARM_MIN_AUTHENTICATION) && (value_convert <= PARM_MAX_AUTHENTICATION)) |
68c0bdff | 656 | lp->authentication = value_convert; |
ce7f6389 | 657 | else |
d101b958 | 658 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_AUTHENTICATION); |
d101b958 PS |
659 | } else if (strcmp(key, PARM_NAME_OWN_ATIM_WINDOW) == 0) { |
660 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_ATIM_WINDOW, value); | |
68c0bdff | 661 | |
9f648592 | 662 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 663 | if ((value_convert >= PARM_MIN_OWN_ATIM_WINDOW) && (value_convert <= PARM_MAX_OWN_ATIM_WINDOW)) |
68c0bdff | 664 | lp->atimWindow = value_convert; |
ce7f6389 | 665 | else |
d101b958 | 666 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_ATIM_WINDOW); |
d101b958 PS |
667 | } else if (strcmp(key, PARM_NAME_PM_HOLDOVER_DURATION) == 0) { |
668 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PM_HOLDOVER_DURATION, value); | |
68c0bdff | 669 | |
9f648592 | 670 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 671 | if ((value_convert >= PARM_MIN_PM_HOLDOVER_DURATION) && (value_convert <= PARM_MAX_PM_HOLDOVER_DURATION)) |
68c0bdff | 672 | lp->holdoverDuration = value_convert; |
ce7f6389 | 673 | else |
d101b958 | 674 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PM_HOLDOVER_DURATION); |
d101b958 PS |
675 | } else if (strcmp(key, PARM_NAME_PROMISCUOUS_MODE) == 0) { |
676 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PROMISCUOUS_MODE, value); | |
68c0bdff | 677 | lp->promiscuousMode = parse_yes_no(value); |
d101b958 PS |
678 | } else if (strcmp(key, PARM_NAME_CONNECTION_CONTROL) == 0) { |
679 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_CONNECTION_CONTROL, value); | |
68c0bdff | 680 | |
9f648592 | 681 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 682 | if ((value_convert >= PARM_MIN_CONNECTION_CONTROL) && (value_convert <= PARM_MAX_CONNECTION_CONTROL)) |
68c0bdff | 683 | lp->connectionControl = value_convert; |
ce7f6389 | 684 | else |
d101b958 | 685 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_CONNECTION_CONTROL); |
68c0bdff HG |
686 | } |
687 | ||
688 | /* Need to add? : Probe Data Rate */ | |
689 | } | |
690 | #endif /* (HCF_TYPE) & HCF_TYPE_STA */ | |
691 | ||
692 | /* Configuration parameters specific to AP mode */ | |
801de523 PS |
693 | #if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */ |
694 | /* ;?should we restore this to allow smaller memory footprint */ | |
d101b958 PS |
695 | if (CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_AP) { |
696 | if (strcmp(key, PARM_NAME_OWN_DTIM_PERIOD) == 0) { | |
697 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_DTIM_PERIOD, value); | |
68c0bdff | 698 | |
9f648592 | 699 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 700 | if (value_convert >= PARM_MIN_OWN_DTIM_PERIOD) |
68c0bdff | 701 | lp->DTIMPeriod = value_convert; |
ce7f6389 | 702 | else |
d101b958 | 703 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_DTIM_PERIOD); |
d101b958 PS |
704 | } else if (strcmp(key, PARM_NAME_REJECT_ANY) == 0) { |
705 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_REJECT_ANY, value); | |
68c0bdff | 706 | lp->RejectAny = parse_yes_no(value); |
d101b958 PS |
707 | } else if (strcmp(key, PARM_NAME_EXCLUDE_UNENCRYPTED) == 0) { |
708 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_EXCLUDE_UNENCRYPTED, value); | |
68c0bdff | 709 | lp->ExcludeUnencrypted = parse_yes_no(value); |
d101b958 PS |
710 | } else if (strcmp(key, PARM_NAME_MULTICAST_PM_BUFFERING) == 0) { |
711 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_PM_BUFFERING, value); | |
68c0bdff | 712 | lp->ExcludeUnencrypted = parse_yes_no(value); |
d101b958 PS |
713 | } else if (strcmp(key, PARM_NAME_INTRA_BSS_RELAY) == 0) { |
714 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_INTRA_BSS_RELAY, value); | |
68c0bdff | 715 | lp->ExcludeUnencrypted = parse_yes_no(value); |
d101b958 PS |
716 | } else if (strcmp(key, PARM_NAME_OWN_BEACON_INTERVAL) == 0) { |
717 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_BEACON_INTERVAL, value); | |
68c0bdff | 718 | |
9f648592 | 719 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 720 | if (value_convert >= PARM_MIN_OWN_BEACON_INTERVAL) |
68c0bdff | 721 | lp->ownBeaconInterval = value_convert; |
ce7f6389 | 722 | else |
d101b958 | 723 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_BEACON_INTERVAL); |
d101b958 PS |
724 | } else if (strcmp(key, PARM_NAME_COEXISTENCE) == 0) { |
725 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_COEXISTENCE, value); | |
68c0bdff | 726 | |
9f648592 | 727 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 728 | if (value_convert >= PARM_MIN_COEXISTENCE) |
68c0bdff | 729 | lp->coexistence = value_convert; |
ce7f6389 | 730 | else |
d101b958 | 731 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_COEXISTENCE); |
68c0bdff HG |
732 | } |
733 | ||
734 | #ifdef USE_WDS | |
d101b958 PS |
735 | else if (strcmp(key, PARM_NAME_RTS_THRESHOLD1) == 0) { |
736 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD1, value); | |
68c0bdff | 737 | |
9f648592 | 738 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 739 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 740 | lp->wds_port[0].rtsThreshold = value_convert; |
ce7f6389 | 741 | else |
d101b958 | 742 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD1); |
d101b958 PS |
743 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD2) == 0) { |
744 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD2, value); | |
68c0bdff | 745 | |
9f648592 | 746 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 747 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 748 | lp->wds_port[1].rtsThreshold = value_convert; |
ce7f6389 | 749 | else |
d101b958 | 750 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD2); |
d101b958 PS |
751 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD3) == 0) { |
752 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD3, value); | |
68c0bdff | 753 | |
9f648592 | 754 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 755 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 756 | lp->wds_port[2].rtsThreshold = value_convert; |
ce7f6389 | 757 | else |
d101b958 | 758 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD3); |
d101b958 PS |
759 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD4) == 0) { |
760 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD4, value); | |
68c0bdff | 761 | |
9f648592 | 762 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 763 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 764 | lp->wds_port[3].rtsThreshold = value_convert; |
ce7f6389 | 765 | else |
d101b958 | 766 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD4); |
d101b958 PS |
767 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD5) == 0) { |
768 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD5, value); | |
68c0bdff | 769 | |
9f648592 | 770 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 771 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 772 | lp->wds_port[4].rtsThreshold = value_convert; |
ce7f6389 | 773 | else |
d101b958 | 774 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD5); |
d101b958 PS |
775 | } else if (strcmp(key, PARM_NAME_RTS_THRESHOLD6) == 0) { |
776 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD6, value); | |
68c0bdff | 777 | |
9f648592 | 778 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 779 | if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD)) |
68c0bdff | 780 | lp->wds_port[5].rtsThreshold = value_convert; |
ce7f6389 | 781 | else |
d101b958 | 782 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD6); |
d101b958 PS |
783 | } else if (strcmp(key, PARM_NAME_TX_RATE1) == 0) { |
784 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE1, value); | |
68c0bdff | 785 | |
9f648592 | 786 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 787 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 788 | lp->wds_port[0].txRateCntl = value_convert; |
ce7f6389 | 789 | else |
d101b958 | 790 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE1); |
d101b958 PS |
791 | } else if (strcmp(key, PARM_NAME_TX_RATE2) == 0) { |
792 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE2, value); | |
68c0bdff | 793 | |
9f648592 | 794 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 795 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 796 | lp->wds_port[1].txRateCntl = value_convert; |
ce7f6389 | 797 | else |
d101b958 | 798 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE2); |
d101b958 PS |
799 | } else if (strcmp(key, PARM_NAME_TX_RATE3) == 0) { |
800 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE3, value); | |
68c0bdff | 801 | |
9f648592 | 802 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 803 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 804 | lp->wds_port[2].txRateCntl = value_convert; |
ce7f6389 | 805 | else |
d101b958 | 806 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE3); |
d101b958 PS |
807 | } else if (strcmp(key, PARM_NAME_TX_RATE4) == 0) { |
808 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE4, value); | |
68c0bdff | 809 | |
9f648592 | 810 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 811 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 812 | lp->wds_port[3].txRateCntl = value_convert; |
ce7f6389 | 813 | else |
d101b958 | 814 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE4); |
d101b958 PS |
815 | } else if (strcmp(key, PARM_NAME_TX_RATE5) == 0) { |
816 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE5, value); | |
68c0bdff | 817 | |
9f648592 | 818 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 819 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 820 | lp->wds_port[4].txRateCntl = value_convert; |
ce7f6389 | 821 | else |
d101b958 | 822 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE5); |
d101b958 PS |
823 | } else if (strcmp(key, PARM_NAME_TX_RATE6) == 0) { |
824 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE6, value); | |
68c0bdff | 825 | |
9f648592 | 826 | value_convert = simple_strtoul(value, NULL, 0); |
ce7f6389 | 827 | if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE)) |
68c0bdff | 828 | lp->wds_port[5].txRateCntl = value_convert; |
ce7f6389 | 829 | else |
d101b958 | 830 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE6); |
d101b958 PS |
831 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS1) == 0) { |
832 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS1, value); | |
68c0bdff | 833 | |
ce7f6389 | 834 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 835 | memcpy(lp->wds_port[0].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 836 | else |
d101b958 | 837 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS1); |
d101b958 PS |
838 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS2) == 0) { |
839 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS2, value); | |
68c0bdff | 840 | |
ce7f6389 | 841 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 842 | memcpy(lp->wds_port[1].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 843 | else |
d101b958 | 844 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS2); |
d101b958 PS |
845 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS3) == 0) { |
846 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS3, value); | |
68c0bdff | 847 | |
ce7f6389 | 848 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 849 | memcpy(lp->wds_port[2].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 850 | else |
d101b958 | 851 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS3); |
d101b958 PS |
852 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS4) == 0) { |
853 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS4, value); | |
68c0bdff | 854 | |
ce7f6389 | 855 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 856 | memcpy(lp->wds_port[3].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 857 | else |
d101b958 | 858 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS4); |
d101b958 PS |
859 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS5) == 0) { |
860 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS5, value); | |
68c0bdff | 861 | |
ce7f6389 | 862 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 863 | memcpy(lp->wds_port[4].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 864 | else |
d101b958 | 865 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS5); |
d101b958 PS |
866 | } else if (strcmp(key, PARM_NAME_WDS_ADDRESS6) == 0) { |
867 | DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS6, value); | |
68c0bdff | 868 | |
ce7f6389 | 869 | if (parse_mac_address(value, mac_value) == ETH_ALEN) |
d101b958 | 870 | memcpy(lp->wds_port[5].wdsAddress, mac_value, ETH_ALEN); |
ce7f6389 | 871 | else |
d101b958 | 872 | DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS6); |
68c0bdff HG |
873 | } |
874 | #endif /* USE_WDS */ | |
875 | } | |
876 | #endif /* (HCF_TYPE) & HCF_TYPE_AP */ | |
877 | ||
878 | return; | |
801de523 | 879 | } /* translate_option */ |
68c0bdff HG |
880 | /*============================================================================*/ |
881 | ||
882 | /******************************************************************************* | |
883 | * parse_mac_address() | |
884 | ******************************************************************************* | |
885 | * | |
886 | * DESCRIPTION: | |
887 | * | |
888 | * This function will parse a mac address string and convert it to a byte | |
889 | * array. | |
890 | * | |
891 | * PARAMETERS: | |
892 | * | |
893 | * value - the MAC address, represented as a string | |
894 | * byte_array - the MAC address, represented as a byte array of length | |
895 | * ETH_ALEN | |
896 | * | |
897 | * RETURNS: | |
898 | * | |
899 | * The number of bytes in the final MAC address, should equal to ETH_ALEN. | |
900 | * | |
901 | ******************************************************************************/ | |
d101b958 | 902 | int parse_mac_address(char *value, u_char *byte_array) |
68c0bdff HG |
903 | { |
904 | int value_offset = 0; | |
905 | int array_offset = 0; | |
906 | int field_offset = 0; | |
907 | char byte_field[3]; | |
908 | /*------------------------------------------------------------------------*/ | |
909 | ||
d101b958 | 910 | memset(byte_field, '\0', 3); |
68c0bdff | 911 | |
d101b958 | 912 | while (value[value_offset] != '\0') { |
68c0bdff | 913 | /* Skip over the colon chars seperating the bytes, if they exist */ |
d101b958 | 914 | if (value[value_offset] == ':') { |
68c0bdff HG |
915 | value_offset++; |
916 | continue; | |
917 | } | |
918 | ||
919 | byte_field[field_offset] = value[value_offset]; | |
920 | field_offset++; | |
921 | value_offset++; | |
922 | ||
923 | /* Once the byte_field is filled, convert it and store it */ | |
d101b958 | 924 | if (field_offset == 2) { |
68c0bdff | 925 | byte_field[field_offset] = '\0'; |
d101b958 | 926 | byte_array[array_offset] = simple_strtoul(byte_field, NULL, 16); |
68c0bdff HG |
927 | field_offset = 0; |
928 | array_offset++; | |
929 | } | |
930 | } | |
931 | ||
932 | /* Use the array_offset as a check; 6 bytes should be written to the | |
933 | byte_array */ | |
934 | return array_offset; | |
801de523 | 935 | } /* parse_mac_address */ |
68c0bdff HG |
936 | /*============================================================================*/ |
937 | ||
938 | /******************************************************************************* | |
939 | * ParseConfigLine() | |
940 | ******************************************************************************* | |
941 | * | |
942 | * DESCRIPTION: | |
943 | * | |
944 | * Parses a line from the configuration file into an L-val and an R-val, | |
945 | * representing a key/value pair. | |
946 | * | |
947 | * PARAMETERS: | |
948 | * | |
949 | * pszLine - the line from the config file to parse | |
950 | * ppszLVal - the resulting L-val (Key) | |
951 | * ppszRVal - the resulting R-val (Value) | |
952 | * | |
953 | * RETURNS: | |
954 | * | |
955 | * N/A | |
956 | * | |
957 | ******************************************************************************/ | |
d101b958 | 958 | void ParseConfigLine(char *pszLine, char **ppszLVal, char **ppszRVal) |
68c0bdff HG |
959 | { |
960 | int i; | |
961 | int size; | |
962 | /*------------------------------------------------------------------------*/ | |
963 | ||
d101b958 PS |
964 | DBG_FUNC("ParseConfigLine"); |
965 | DBG_ENTER(DbgInfo); | |
68c0bdff HG |
966 | |
967 | /* get a snapshot of our string size */ | |
d101b958 | 968 | size = strlen(pszLine); |
68c0bdff HG |
969 | *ppszLVal = NULL; |
970 | *ppszRVal = NULL; | |
971 | ||
d101b958 PS |
972 | if (pszLine[0] != '#' && /* skip the line if it is a comment */ |
973 | pszLine[0] != '\n' && /* if it's an empty UNIX line, do nothing */ | |
974 | !(pszLine[0] == '\r' && pszLine[1] == '\n') /* if it's an empty MS-DOS line, do nothing */ | |
975 | ) { | |
68c0bdff | 976 | /* advance past any whitespace, and assign the L-value */ |
d101b958 PS |
977 | for (i = 0; i < size; i++) { |
978 | if (pszLine[i] != ' ') { | |
68c0bdff HG |
979 | *ppszLVal = &pszLine[i]; |
980 | break; | |
981 | } | |
982 | } | |
983 | /* advance to the end of the l-value*/ | |
d101b958 PS |
984 | for (i++; i < size; i++) { |
985 | if (pszLine[i] == ' ' || pszLine[i] == '=') { | |
68c0bdff HG |
986 | pszLine[i] = '\0'; |
987 | break; | |
988 | } | |
989 | } | |
990 | /* make any whitespace and the equal sign a NULL character, and | |
991 | advance to the R-Value */ | |
d101b958 PS |
992 | for (i++; i < size; i++) { |
993 | if (pszLine[i] == ' ' || pszLine[i] == '=') { | |
68c0bdff HG |
994 | pszLine[i] = '\0'; |
995 | continue; | |
996 | } | |
997 | *ppszRVal = &pszLine[i]; | |
998 | break; | |
999 | } | |
1000 | /* make the line ending character(s) a NULL */ | |
d101b958 | 1001 | for (i++; i < size; i++) { |
ce7f6389 | 1002 | if (pszLine[i] == '\n') |
68c0bdff | 1003 | pszLine[i] = '\0'; |
ce7f6389 | 1004 | if ((pszLine[i] == '\r') && (pszLine[i+1] == '\n')) |
68c0bdff | 1005 | pszLine[i] = '\0'; |
68c0bdff HG |
1006 | } |
1007 | } | |
d101b958 | 1008 | DBG_LEAVE(DbgInfo); |
801de523 | 1009 | } /* ParseConfigLine */ |
68c0bdff HG |
1010 | /*============================================================================*/ |
1011 | ||
801de523 | 1012 | #endif /* USE_PROFILE */ |