1 | *** NetServer.cpp Sun Jul 17 18:31:19 2011
|
---|
2 | --- NetServer.cpp.mine Sun Jul 17 18:29:36 2011
|
---|
3 | ***************
|
---|
4 | *** 1010,1016 ****
|
---|
5 | } else if (!strcasecmp(string, "wep")) {
|
---|
6 | network.authentication_mode = B_NETWORK_AUTHENTICATION_WEP;
|
---|
7 | network.key_mode = B_KEY_MODE_NONE;
|
---|
8 | ! network.cipher = network.group_cipher = B_NETWORK_CIPHER_WEP_40;
|
---|
9 | } else if (strcasecmp(string, "none") && strcasecmp(string, "open"))
|
---|
10 | fprintf(stderr, "%s: invalid authentication mode.\n", name);
|
---|
11 | }
|
---|
12 | --- 1010,1036 ----
|
---|
13 | } else if (!strcasecmp(string, "wep")) {
|
---|
14 | network.authentication_mode = B_NETWORK_AUTHENTICATION_WEP;
|
---|
15 | network.key_mode = B_KEY_MODE_NONE;
|
---|
16 | ! if (password)
|
---|
17 | ! {
|
---|
18 | ! switch (strlen(password))
|
---|
19 | ! {
|
---|
20 | ! case 5: //ascii
|
---|
21 | ! case 12: //hex
|
---|
22 | ! network.cipher = network.group_cipher =
|
---|
23 | ! B_NETWORK_CIPHER_WEP_40;
|
---|
24 | ! break;
|
---|
25 | ! case 13: //ascii
|
---|
26 | ! case 28: //hex
|
---|
27 | ! network.cipher = network.group_cipher =
|
---|
28 | ! B_NETWORK_CIPHER_WEP_104;
|
---|
29 | ! break;
|
---|
30 | ! default:
|
---|
31 | ! fprintf(stderr, "WEP key %s not 5 / 13 characters\n",
|
---|
32 | ! password);
|
---|
33 | ! return B_NOT_ALLOWED;
|
---|
34 | ! }
|
---|
35 | ! } else return B_NOT_ALLOWED;
|
---|
36 | !
|
---|
37 | } else if (strcasecmp(string, "none") && strcasecmp(string, "open"))
|
---|
38 | fprintf(stderr, "%s: invalid authentication mode.\n", name);
|
---|
39 | }
|
---|
40 | ***************
|
---|
41 | *** 1046,1070 ****
|
---|
42 | const char* buffer = password;
|
---|
43 |
|
---|
44 | // set key
|
---|
45 | ! for (int32 i = 0; i < 4; i++) {
|
---|
46 | char key[IEEE80211_KEYBUF_SIZE];
|
---|
47 | int32 keyLength = translate_wep_key(buffer, key);
|
---|
48 | ! status = set_80211(deviceName, IEEE80211_IOC_WEPKEY, key,
|
---|
49 | ! keyLength);
|
---|
50 | if (status != B_OK)
|
---|
51 | break;
|
---|
52 | }
|
---|
53 |
|
---|
54 | ! if (status == B_OK) {
|
---|
55 | ! status = set_80211(deviceName, IEEE80211_IOC_WEPKEY, NULL, 0,
|
---|
56 | ! 0);
|
---|
57 | ! }
|
---|
58 | !
|
---|
59 | ! if (status != B_OK) {
|
---|
60 | fprintf(stderr, "%s: setting WEP keys failed: %s\n", name,
|
---|
61 | strerror(status));
|
---|
62 | return status;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | return B_OK;
|
---|
67 | --- 1066,1102 ----
|
---|
68 | const char* buffer = password;
|
---|
69 |
|
---|
70 | // set key
|
---|
71 | ! for (int32 i = 0; i < 10; i++) {
|
---|
72 | char key[IEEE80211_KEYBUF_SIZE];
|
---|
73 | int32 keyLength = translate_wep_key(buffer, key);
|
---|
74 | ! status = set_80211(deviceName, IEEE80211_IOC_WEPKEY,
|
---|
75 | ! keyLength==0 ? NULL : key, keyLength, i);
|
---|
76 | if (status != B_OK)
|
---|
77 | break;
|
---|
78 | }
|
---|
79 |
|
---|
80 | ! if (status != B_OK && buffer[0]!='\0') {
|
---|
81 | fprintf(stderr, "%s: setting WEP keys failed: %s\n", name,
|
---|
82 | strerror(status));
|
---|
83 | return status;
|
---|
84 | }
|
---|
85 | +
|
---|
86 | + // use first key - ignore errors
|
---|
87 | + status = set_80211(deviceName, IEEE80211_IOC_WEPTXKEY, NULL, 0, 0);
|
---|
88 | + if (status != B_OK)
|
---|
89 | + {
|
---|
90 | + fprintf(stderr, "%s: Setting WEP key index to 0 failed\n",
|
---|
91 | + strerror(status));
|
---|
92 | + }
|
---|
93 | +
|
---|
94 | + // set authentication mode to shared - ignore errors
|
---|
95 | + status = set_80211(deviceName, IEEE80211_IOC_AUTHMODE, NULL, 0,
|
---|
96 | + IEEE80211_AUTH_SHARED);
|
---|
97 | + if (status != B_OK)
|
---|
98 | + {
|
---|
99 | + fprintf(stderr, "%s: Setting auth mode to shared failed\n",
|
---|
100 | + strerror(status));
|
---|
101 | + }
|
---|
102 | }
|
---|
103 |
|
---|
104 | return B_OK;
|
---|