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