MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Utility / raconfigui.cpp
blobe280b35aa246294b913fb9b43c2c2c233199aaca
1 #include "raconfigui.h"
2 #include "addprofiledlg.h"
3 #include "authsecudlg.h"
4 #include "hiddenssiddlg.h"
5 #include "rt_tool.h"
6 #include "configapi.h"
8 #include <qvariant.h>
9 #include <qapplication.h>
10 #include <qbuttongroup.h>
11 #include <qcheckbox.h>
12 #include <qcombobox.h>
13 #include <qheader.h>
14 #include <qlabel.h>
15 #include <qlineedit.h>
16 #include <qlistview.h>
17 #include <qprogressbar.h>
18 #include <qpushbutton.h>
19 #include <qtabwidget.h>
20 #include <qwidget.h>
21 #include <qmime.h>
22 #include <qdragobject.h>
23 #include <qlayout.h>
24 #include <qtooltip.h>
25 #include <qwhatsthis.h>
26 #include <qimage.h>
27 #include <qpixmap.h>
28 #include <qmessagebox.h>
29 #include <unistd.h>
30 #include <errno.h>
32 PAIR_CHANNEL_FREQ_ENTRY ChannelFreqTable[] =
34 // channel Frequency
35 {1, 2412000},
36 {2, 2417000},
37 {3, 2422000},
38 {4, 2427000},
39 {5, 2432000},
40 {6, 2437000},
41 {7, 2442000},
42 {8, 2447000},
43 {9, 2452000},
44 {10, 2457000},
45 {11, 2462000},
46 {12, 2467000},
47 {13, 2472000},
48 {14, 2484000},
49 {34, 5170000},
50 {36, 5180000},
51 {38, 5190000},
52 {40, 5200000},
53 {42, 5210000},
54 {44, 5220000},
55 {46, 5230000},
56 {48, 5240000},
57 {52, 5260000},
58 {56, 5280000},
59 {60, 5300000},
60 {64, 5320000},
61 {100, 5500000},
62 {104, 5520000},
63 {108, 5540000},
64 {112, 5560000},
65 {116, 5580000},
66 {120, 5600000},
67 {124, 5620000},
68 {128, 5640000},
69 {132, 5660000},
70 {136, 5680000},
71 {140, 5700000},
72 {149, 5745000},
73 {153, 5765000},
74 {157, 5785000},
75 {161, 5805000},
78 int G_nChanFreqCount = sizeof (ChannelFreqTable) / sizeof(PAIR_CHANNEL_FREQ_ENTRY);
80 const char *strAryNetworkType[]=
82 "Ad Hoc",
83 "Infrastructure",
84 "Automatic"
87 const char *strAryEncryption[]=
89 "WEP",
90 "Not Use",
91 "",
92 "",
93 "TKIP",
94 "",
95 "AES",
99 const char *strAryAuthenType[]=
101 "OPEN",
102 "SHARED"
104 "WPA",
105 "WPAPSK",
106 "WPA-None"
110 extern UINT G_nCountryRegion;
111 bool G_bRadio = TRUE;
112 extern bool G_bUserAdmin;
113 extern bool G_bSupportAMode;
114 RT_802_11_PHY_MODE G_enumWirelessMode = PHY_11BG_MIXED; // Default use BG_Mixed
117 static QPixmap uic_load_pixmap_RaConfigForm( const QString &name )
119 const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( name );
120 if ( !m )
121 return QPixmap();
122 QPixmap pix;
123 QImageDrag::decode( m, pix );
124 return pix;
127 * Constructs a RaConfigForm which is a child of 'parent', with the
128 * name 'name' and widget flags set to 'f'.
130 RaConfigForm::RaConfigForm( int socket_id, const char *device_name, QWidget* parent, const char* name)
131 : QWidget( parent, name)
133 if ( !name )
134 setName( "RaConfigForm" );
135 resize( 600, 480 );
136 setMinimumSize( 600, 480 );
137 setMaximumSize( 600, 480 );
138 setCaption("Configuration Utility - RT2500");
139 setIcon( uic_load_pixmap_RaConfigForm( "RaConfig2500.xpm" ) );
140 setPaletteBackgroundColor( QColor( 222, 222, 222 ) );
141 qApp->setStyle("Windows");
143 TabWidgetRaConfig = new QTabWidget( this, "TabWidgetRaConfig" );
144 TabWidgetRaConfig->setGeometry( QRect( 10, 10, 580, 460 ) );
145 setPaletteBackgroundColor( QColor( 222, 222, 222 ) );
146 TabWidgetRaConfig->setPaletteBackgroundColor( QColor( 222, 222, 222 ) );
147 //===============================================================================
148 //Profile Page
149 //===============================================================================
150 ProfilePage_tab = new QWidget( TabWidgetRaConfig, "ProfilePage_tab" );
152 Profile_ButtonGroup = new QButtonGroup( ProfilePage_tab, "Profile_ButtonGroup" );
153 Profile_ButtonGroup->setGeometry( QRect( 10, 10, 550, 410 ) );
154 Profile_ButtonGroup->setTitle("Profile List");
156 Profile_ListView = new QListView( Profile_ButtonGroup, "Profile_ListView" );
157 Profile_ListView->addColumn("Profile");
158 Profile_ListView->addColumn("SSID");
159 Profile_ListView->addColumn("Channel");
160 Profile_ListView->addColumn("Authentication");
161 Profile_ListView->addColumn("Encryption");
162 Profile_ListView->addColumn("Network Type");
163 Profile_ListView->setSelectionMode( QListView::Single );
164 Profile_ListView->setAllColumnsShowFocus( TRUE );
165 Profile_ListView->setGeometry( QRect( 8, 20, 530, 350 ) );
167 Profile_PushButton_Add = new QPushButton( Profile_ButtonGroup, "Profile_PushButton_Add" );
168 Profile_PushButton_Add->setGeometry( QRect( 8, 375, 120, 30 ) );
169 Profile_PushButton_Add->setText("&ADD");
171 Profile_PushButton_Delete = new QPushButton( Profile_ButtonGroup, "Profile_PushButton_Delete" );
172 Profile_PushButton_Delete->setGeometry( QRect( 145, 375, 120, 30 ) );
173 Profile_PushButton_Delete->setText("&DELETE");
174 Profile_PushButton_Delete->setEnabled(FALSE);
176 Profile_PushButton_Edit = new QPushButton( Profile_ButtonGroup, "Profile_PushButton_Edit" );
177 Profile_PushButton_Edit->setGeometry( QRect( 282, 375, 120, 30 ) );
178 Profile_PushButton_Edit->setText("&EDIT");
179 Profile_PushButton_Edit->setEnabled(FALSE);
181 Profile_PushButton_Activate = new QPushButton( Profile_ButtonGroup, "Profile_PushButton_Activate" );
182 Profile_PushButton_Activate->setGeometry( QRect( 419, 375, 120, 30 ) );
183 Profile_PushButton_Activate->setText("A&CTIVATE");
184 Profile_PushButton_Activate->setEnabled(FALSE);
186 TabWidgetRaConfig->insertTab( ProfilePage_tab,"Profile");
187 //===============================================================================
188 //LinkStatus Page
189 //===============================================================================
190 LinkStatusPage_tab = new QWidget( TabWidgetRaConfig, "LinkStatusPage_tab" );
192 LinkStatus_TextLabel1 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel1" );
193 LinkStatus_TextLabel1->setGeometry( QRect( 50, 20, 110, 30 ) );
194 LinkStatus_TextLabel1->setText("Status:");
196 LinkStatus_TextLabel_Status = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_Status" );
197 LinkStatus_TextLabel_Status->setGeometry( QRect( 230, 20, 300, 30 ) );
198 LinkStatus_TextLabel_Status->setFrameShape( QLabel::LineEditPanel );
199 LinkStatus_TextLabel_Status->setFrameShadow( QLabel::Sunken );
201 LinkStatus_TextLabel2 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel2" );
202 LinkStatus_TextLabel2->setGeometry( QRect( 50, 65, 120, 30 ) );
203 LinkStatus_TextLabel2->setText("Current Channel:");
205 LinkStatus_TextLabel_Channel = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_Channel" );
206 LinkStatus_TextLabel_Channel->setGeometry( QRect( 230, 65, 300, 30 ) );
207 LinkStatus_TextLabel_Channel->setFrameShape( QLabel::LineEditPanel );
208 LinkStatus_TextLabel_Channel->setFrameShadow( QLabel::Sunken );
210 LinkStatus_TextLabel3 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel3" );
211 LinkStatus_TextLabel3->setGeometry( QRect( 50, 110, 130, 30 ) );
212 LinkStatus_TextLabel3->setText("Current Tx Rate:");
214 LinkStatus_TextLabel_TxRate = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_TxRate" );
215 LinkStatus_TextLabel_TxRate->setGeometry( QRect( 230, 110, 300, 30 ) );
216 LinkStatus_TextLabel_TxRate->setFrameShape( QLabel::LineEditPanel );
217 LinkStatus_TextLabel_TxRate->setFrameShadow( QLabel::Sunken );
218 LinkStatus_TextLabel_TxRate->setText("");
220 LinkStatus_TextLabel4 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel4" );
221 LinkStatus_TextLabel4->setGeometry( QRect( 50, 155, 150, 30 ) );
222 LinkStatus_TextLabel4->setText("Throughput (KBits/sec):");
224 LinkStatus_TextLabel5 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel5" );
225 LinkStatus_TextLabel5->setGeometry( QRect( 230, 155, 50, 30 ) );
226 LinkStatus_TextLabel5->setText("TX");
228 LinkStatus_TextLabel_TxThrougput = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_TxThrougput" );
229 LinkStatus_TextLabel_TxThrougput->setGeometry( QRect( 300, 155, 70, 30 ) );
230 LinkStatus_TextLabel_TxThrougput->setFrameShape( QLabel::LineEditPanel );
231 LinkStatus_TextLabel_TxThrougput->setFrameShadow( QLabel::Sunken );
232 LinkStatus_TextLabel_TxThrougput->setText("");
234 LinkStatus_TextLabel6 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel6" );
235 LinkStatus_TextLabel6->setGeometry( QRect( 390, 155, 50, 30 ) );
236 LinkStatus_TextLabel6->setText("RX");
238 LinkStatus_TextLabel_RxThroughput = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_RxThroughput" );
239 LinkStatus_TextLabel_RxThroughput->setGeometry( QRect( 460, 155, 70, 30 ) );
240 LinkStatus_TextLabel_RxThroughput->setFrameShape( QLabel::LineEditPanel );
241 LinkStatus_TextLabel_RxThroughput->setFrameShadow( QLabel::Sunken );
242 LinkStatus_TextLabel_RxThroughput->setText("");
244 LinkStatus_TextLabel7 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel7" );
245 LinkStatus_TextLabel7->setGeometry( QRect( 50, 230, 120, 30 ) );
246 LinkStatus_TextLabel7->setText("Link Quality:");
248 LinkStatus_TextLabel_Link = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_Link" );
249 LinkStatus_TextLabel_Link->setGeometry( QRect( 230, 200, 80, 20 ) );
250 LinkStatus_TextLabel_Link->setText("");
252 LinkStatus_ProgressBar_Link = new QProgressBar( LinkStatusPage_tab, "LinkStatus_ProgressBar_Link" );
253 LinkStatus_ProgressBar_Link->setGeometry( QRect( 230, 230, 300, 30 ) );
255 LinkStatus_TextLabel8 = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel8" );
256 LinkStatus_TextLabel8->setGeometry( QRect( 50, 305, 131, 31 ) );
257 LinkStatus_TextLabel8->setText("Signal Strength:");
259 LinkStatus_TextLabel_Signal = new QLabel( LinkStatusPage_tab, "LinkStatus_TextLabel_Signal" );
260 LinkStatus_TextLabel_Signal->setGeometry( QRect( 230, 275, 80, 20 ) );
261 LinkStatus_TextLabel_Signal->setText("");
263 LinkStatus_CheckBox_dbm = new QCheckBox( LinkStatusPage_tab, "LinkStatus_CheckBox_dbm" );
264 LinkStatus_CheckBox_dbm->setGeometry( QRect( 325, 275, 110, 20 ) );
265 LinkStatus_CheckBox_dbm->setText("dBm format");
267 LinkStatus_ProgressBar_Signal = new QProgressBar( LinkStatusPage_tab, "LinkStatus_ProgressBar_Signal" );
268 LinkStatus_ProgressBar_Signal->setGeometry( QRect( 230, 305, 300, 30 ) );
270 TabWidgetRaConfig->insertTab( LinkStatusPage_tab,"Link Status");
271 //===============================================================================
272 //Site Survey Page
273 //===============================================================================
274 SiteSurveyPage_tab = new QWidget( TabWidgetRaConfig, "SiteSurveyPage_tab" );
276 SiteSurvey_ButtonGroup = new QButtonGroup( SiteSurveyPage_tab, "SiteSurvey_ButtonGroup" );
277 SiteSurvey_ButtonGroup->setGeometry( QRect( 10, 10, 550, 410 ) );
278 SiteSurvey_ButtonGroup->setTitle("");
280 SiteSurvey_ListView = new QListView( SiteSurvey_ButtonGroup, "SiteSurvey_ListView" );
281 SiteSurvey_ListView->addColumn("SSID");
282 SiteSurvey_ListView->addColumn("BSSID");
283 SiteSurvey_ListView->addColumn("Signal");
284 SiteSurvey_ListView->addColumn("Channel");
285 SiteSurvey_ListView->addColumn("Encryption");
286 SiteSurvey_ListView->addColumn("Authentication");
287 SiteSurvey_ListView->addColumn("Network Type");
288 SiteSurvey_ListView->setSelectionMode( QListView::Single );
289 SiteSurvey_ListView->setAllColumnsShowFocus( TRUE );
290 SiteSurvey_ListView->setGeometry( QRect( 8, 20, 530, 350 ) );
292 SiteSurvey_LineEdit_Status = new QLineEdit( SiteSurvey_ButtonGroup, "SiteSurvey_LineEdit_Status" );
293 SiteSurvey_LineEdit_Status->setEnabled( FALSE );
294 SiteSurvey_LineEdit_Status->setGeometry( QRect( 8, 375, 220, 30 ) );
296 SiteSurvey_PushButton_Rescan = new QPushButton( SiteSurvey_ButtonGroup, "SiteSurvey_PushButton_Rescan" );
297 SiteSurvey_PushButton_Rescan->setGeometry( QRect( 232, 375, 100, 30 ) );
298 SiteSurvey_PushButton_Rescan->setText("&RESCAN");
300 SiteSurvey_PushButton_Connect = new QPushButton( SiteSurvey_ButtonGroup, "SiteSurvey_PushButton_Connect" );
301 SiteSurvey_PushButton_Connect->setGeometry( QRect( 336, 375, 100, 30 ) );
302 SiteSurvey_PushButton_Connect->setText("&CONNECT");
303 SiteSurvey_PushButton_Connect->setEnabled( FALSE );
305 SiteSurvey_PushButton_AddProfile = new QPushButton( SiteSurvey_ButtonGroup, "SiteSurvey_PushButton_AddProfile" );
306 SiteSurvey_PushButton_AddProfile->setGeometry( QRect( 440, 375, 100, 30 ) );
307 SiteSurvey_PushButton_AddProfile->setText("&ADD PROFILE");
308 SiteSurvey_PushButton_AddProfile->setEnabled( FALSE );
310 TabWidgetRaConfig->insertTab( SiteSurveyPage_tab,"Site Survey");
311 //===============================================================================
312 //Statistics Page
313 //===============================================================================
314 StatisticsPage_tab = new QWidget( TabWidgetRaConfig, "StatisticsPage_tab" );
316 Statistics_ButtonGroup_Tx = new QButtonGroup( StatisticsPage_tab, "Statistics_ButtonGroup_Tx" );
317 Statistics_ButtonGroup_Tx->setGeometry( QRect( 10, 10, 549, 210 ) );
318 Statistics_ButtonGroup_Tx->setTitle("Transmit Statistics");
320 Statistics_TextLabel1 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel1" );
321 Statistics_TextLabel1->setGeometry( QRect( 10, 20, 151, 30 ) );
322 Statistics_TextLabel1->setText("Frames Transmitted Successfully");
324 Statistics_TextLabel2 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel2" );
325 Statistics_TextLabel2->setGeometry( QRect( 380, 20, 30, 30 ) );
326 Statistics_TextLabel2->setText("=");
328 Statistics_TextLabel_TxSuccess = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_TxSuccess" );
329 Statistics_TextLabel_TxSuccess->setGeometry( QRect( 420, 20, 100, 30 ) );
330 Statistics_TextLabel_TxSuccess->setText("0");
331 Statistics_TextLabel_TxSuccess->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
333 Statistics_TextLabel3 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel3" );
334 Statistics_TextLabel3->setGeometry( QRect( 10, 50, 218, 30 ) );
335 Statistics_TextLabel3->setText("Frames Transmitted Successfully Without Retry");
337 Statistics_TextLabel4 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel4" );
338 Statistics_TextLabel4->setGeometry( QRect( 380, 50, 30, 30 ) );
339 Statistics_TextLabel4->setText("=");
341 Statistics_TextLabel_TxWithoutRetry = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_TxWithoutRetry" );
342 Statistics_TextLabel_TxWithoutRetry->setGeometry( QRect( 420, 50, 100, 28 ) );
343 Statistics_TextLabel_TxWithoutRetry->setText("0");
344 Statistics_TextLabel_TxWithoutRetry->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
346 Statistics_TextLabel5 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel5" );
347 Statistics_TextLabel5->setGeometry( QRect( 10, 80, 219, 30 ) );
348 Statistics_TextLabel5->setText("Frames Transmitted Successfully After Retry(s)");
350 Statistics_TextLabel6 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel6" );
351 Statistics_TextLabel6->setGeometry( QRect( 380, 80, 30, 30 ) );
352 Statistics_TextLabel6->setText("=");
354 Statistics_TextLabel_TxAfterRetry = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_TxAfterRetry" );
355 Statistics_TextLabel_TxAfterRetry->setGeometry( QRect( 420, 80, 100, 30 ) );
356 Statistics_TextLabel_TxAfterRetry->setText("0");
357 Statistics_TextLabel_TxAfterRetry->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
359 Statistics_TextLabel7 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel7" );
360 Statistics_TextLabel7->setGeometry( QRect( 10, 110, 207, 30 ) );
361 Statistics_TextLabel7->setText("Frames Fail To Receive ACK After All Retries");
363 Statistics_TextLabel8 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel8" );
364 Statistics_TextLabel8->setGeometry( QRect( 380, 110, 30, 30 ) );
365 Statistics_TextLabel8->setText("=");
367 Statistics_TextLabel_TxFailACK = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_TxFailACK" );
368 Statistics_TextLabel_TxFailACK->setGeometry( QRect( 420, 110, 100, 30 ) );
369 Statistics_TextLabel_TxFailACK->setText("0");
370 Statistics_TextLabel_TxFailACK->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
372 Statistics_TextLabel9 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel9" );
373 Statistics_TextLabel9->setGeometry( QRect( 10, 140, 172, 30 ) );
374 Statistics_TextLabel9->setText("RTS Frames Sucessfully Receive CTS");
376 Statistics_TextLabel10 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel10" );
377 Statistics_TextLabel10->setGeometry( QRect( 380, 140, 30, 30 ) );
378 Statistics_TextLabel10->setText("=");
380 Statistics_TextLabel_RTSSuccess = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_RTSSuccess" );
381 Statistics_TextLabel_RTSSuccess->setGeometry( QRect( 420, 140, 100, 30 ) );
382 Statistics_TextLabel_RTSSuccess->setText("0");
383 Statistics_TextLabel_RTSSuccess->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
385 Statistics_TextLabel11 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel11" );
386 Statistics_TextLabel11->setGeometry( QRect( 10, 170, 151, 30 ) );
387 Statistics_TextLabel11->setText("RTS Frames Fail To Receive CTS");
389 Statistics_TextLabel12 = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel12" );
390 Statistics_TextLabel12->setGeometry( QRect( 380, 170, 30, 30 ) );
391 Statistics_TextLabel12->setText("=");
393 Statistics_TextLabel_RTSFail = new QLabel( Statistics_ButtonGroup_Tx, "Statistics_TextLabel_RTSFail" );
394 Statistics_TextLabel_RTSFail->setGeometry( QRect( 420, 170, 100, 30 ) );
395 Statistics_TextLabel_RTSFail->setText("0");
396 Statistics_TextLabel_RTSFail->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
398 Statistics_ButtonGroup_Rx = new QButtonGroup( StatisticsPage_tab, "Statistics_ButtonGroup_Rx" );
399 Statistics_ButtonGroup_Rx->setGeometry( QRect( 10, 228, 549, 150 ) );
400 Statistics_ButtonGroup_Rx->setTitle("Receive Statistics");
402 Statistics_TextLabel13 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel13" );
403 Statistics_TextLabel13->setGeometry( QRect( 10, 20, 138, 30 ) );
404 Statistics_TextLabel13->setText("Frames Received Successfully");
406 Statistics_TextLabel14 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel14" );
407 Statistics_TextLabel14->setGeometry( QRect( 380, 20, 30, 30 ) );
408 Statistics_TextLabel14->setText("=");
410 Statistics_TextLabel_RxSuccess = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel_RxSuccess" );
411 Statistics_TextLabel_RxSuccess->setGeometry( QRect( 420, 20, 100, 30 ) );
412 Statistics_TextLabel_RxSuccess->setText("0");
413 Statistics_TextLabel_RxSuccess->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
415 Statistics_TextLabel15 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel15" );
416 Statistics_TextLabel15->setGeometry( QRect( 10, 50, 158, 30 ) );
417 Statistics_TextLabel15->setText("Frames Received With CRC Error");
419 Statistics_TextLabel16 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel16" );
420 Statistics_TextLabel16->setGeometry( QRect( 380, 50, 30, 30 ) );
421 Statistics_TextLabel16->setText("=");
423 Statistics_TextLabel_RxCRC = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel_RxCRC" );
424 Statistics_TextLabel_RxCRC->setGeometry( QRect( 420, 50, 100, 30 ) );
425 Statistics_TextLabel_RxCRC->setText("0");
426 Statistics_TextLabel_RxCRC->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
428 Statistics_TextLabel17 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel17" );
429 Statistics_TextLabel17->setGeometry( QRect( 10, 80, 195, 30 ) );
430 Statistics_TextLabel17->setText("Frames Dropped Due To Out-of-Resource");
432 Statistics_TextLabel18 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel18" );
433 Statistics_TextLabel18->setGeometry( QRect( 380, 80, 30, 30 ) );
434 Statistics_TextLabel18->setText("=");
436 Statistics_TextLabel_RxDrop = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel_RxDrop" );
437 Statistics_TextLabel_RxDrop->setGeometry( QRect( 420, 80, 100, 30 ) );
438 Statistics_TextLabel_RxDrop->setText("0");
439 Statistics_TextLabel_RxDrop->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
441 Statistics_TextLabel19 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel19" );
442 Statistics_TextLabel19->setGeometry( QRect( 10, 110, 125, 30 ) );
443 Statistics_TextLabel19->setText("Duplicate Frames Received");
445 Statistics_TextLabel20 = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel20" );
446 Statistics_TextLabel20->setGeometry( QRect( 380, 110, 30, 30 ) );
447 Statistics_TextLabel20->setText("=");
449 Statistics_TextLabel_Duplicate = new QLabel( Statistics_ButtonGroup_Rx, "Statistics_TextLabel_Duplicate" );
450 Statistics_TextLabel_Duplicate->setGeometry( QRect( 420, 110, 100, 30 ) );
451 Statistics_TextLabel_Duplicate->setText("0");
452 Statistics_TextLabel_Duplicate->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
454 Statistics_PushButton_Reset = new QPushButton( StatisticsPage_tab, "Statistics_PushButton_Reset" );
455 Statistics_PushButton_Reset->setGeometry( QRect( 428, 388, 130, 30 ) );
456 Statistics_PushButton_Reset->setText("&RESET COUNTERS");
458 TabWidgetRaConfig->insertTab( StatisticsPage_tab, "Statistics");
459 //===============================================================================
460 //Advance Page
461 //===============================================================================
462 AdvancePage_tab = new QWidget( TabWidgetRaConfig, "AdvancePage_tab" );
464 Advance_TextLabel1 = new QLabel( AdvancePage_tab, "Advance_TextLabel1" );
465 Advance_TextLabel1->setGeometry( QRect( 30, 20, 110, 30 ) );
466 Advance_TextLabel1->setText("Wireless Mode");
468 Advance_ComboBox_Mode = new QComboBox( FALSE, AdvancePage_tab, "Advance_ComboBox_Mode" );
469 Advance_ComboBox_Mode->insertItem("802.11 B/G mixed mode");
470 Advance_ComboBox_Mode->insertItem("802.11 B only");
471 Advance_ComboBox_Mode->setGeometry( QRect( 160, 18, 201, 31 ) );
473 Advance_CheckBox_TxBurst = new QCheckBox( AdvancePage_tab, "Advance_CheckBox_TxBurst" );
474 Advance_CheckBox_TxBurst->setGeometry( QRect( 30, 70, 200, 30 ) );
475 Advance_CheckBox_TxBurst->setText("Enable TX Burst");
477 Advance_CheckBox_AdhocOfdm = new QCheckBox( AdvancePage_tab, "Advance_CheckBox_AdhocOfdm" );
478 Advance_CheckBox_AdhocOfdm->setGeometry( QRect( 30, 110, 200, 30 ) );
479 Advance_CheckBox_AdhocOfdm->setText("Ad Hoc mode use OFDM rate");
481 Advance_CheckBox_ShortSlot = new QCheckBox( AdvancePage_tab, "Advance_CheckBox_ShortSlot" );
482 Advance_CheckBox_ShortSlot->setEnabled( FALSE );
483 Advance_CheckBox_ShortSlot->setGeometry( QRect( 30, 150, 200, 30 ) );
484 Advance_CheckBox_ShortSlot->setText("Use Short Slot Time when applicable");
486 Advance_CheckBox_TurboRate = new QCheckBox( AdvancePage_tab, "Advance_CheckBox_TurboRate" );
487 Advance_CheckBox_TurboRate->setEnabled( FALSE );
488 Advance_CheckBox_TurboRate->setGeometry( QRect( 30, 190, 200, 30 ) );
489 Advance_CheckBox_TurboRate->setText("Use Turbo rate (72/100Mbps) when applicable");
491 Advance_TextLabel2 = new QLabel( AdvancePage_tab, "Advance_TextLabel2" );
492 Advance_TextLabel2->setGeometry( QRect( 300, 70, 120, 30 ) );
493 Advance_TextLabel2->setText("11B/G Protection");
495 Advance_ComboBox_BGProtection = new QComboBox( FALSE, AdvancePage_tab, "Advance_ComboBox_BGProtection" );
496 Advance_ComboBox_BGProtection->insertItem("Auto");
497 Advance_ComboBox_BGProtection->insertItem("On");
498 Advance_ComboBox_BGProtection->insertItem("Off");
499 Advance_ComboBox_BGProtection->setEnabled( TRUE );
500 Advance_ComboBox_BGProtection->setGeometry( QRect( 430, 70, 120, 30 ) );
502 Advance_TextLabel3 = new QLabel( AdvancePage_tab, "Advance_TextLabel3" );
503 Advance_TextLabel3->setGeometry( QRect( 300, 110, 120, 30 ) );
504 Advance_TextLabel3->setText("TX Rate");
506 Advance_ComboBox_TxRate = new QComboBox( FALSE, AdvancePage_tab, "Advance_ComboBox_TxRate" );
507 Advance_ComboBox_TxRate->insertItem("Auto");
508 Advance_ComboBox_TxRate->insertItem("1 Mbps");
509 Advance_ComboBox_TxRate->insertItem("2 Mbps");
510 Advance_ComboBox_TxRate->insertItem("5.5 Mbps");
511 Advance_ComboBox_TxRate->insertItem("11 Mbps");
512 Advance_ComboBox_TxRate->insertItem("6 Mbps");
513 Advance_ComboBox_TxRate->insertItem("9 Mbps");
514 Advance_ComboBox_TxRate->insertItem("12 Mbps");
515 Advance_ComboBox_TxRate->insertItem("18 Mbps");
516 Advance_ComboBox_TxRate->insertItem("24 Mbps");
517 Advance_ComboBox_TxRate->insertItem("36 Mbps");
518 Advance_ComboBox_TxRate->insertItem("48 Mbps");
519 Advance_ComboBox_TxRate->insertItem("54 Mbps");
520 Advance_ComboBox_TxRate->setGeometry( QRect( 430, 110, 120, 30 ) );
522 Advance_TextLabel_Radio = new QLabel( AdvancePage_tab, "Advance_TextLabel_Radio" );
523 Advance_TextLabel_Radio->setGeometry( QRect( 45, 380, 30, 30 ) );
524 Advance_TextLabel_Radio->setText("");
525 Advance_TextLabel_Radio->setPixmap( uic_load_pixmap_RaConfigForm( "radioon.png" ) );
527 Advance_PushButton_Radio = new QPushButton( AdvancePage_tab, "Advance_PushButton_Radio" );
528 Advance_PushButton_Radio->setGeometry( QRect( 80, 380, 120, 30 ) );
529 Advance_PushButton_Radio->setText("&RADIO OFF");
531 Advance_PushButton_Apply = new QPushButton( AdvancePage_tab, "Advance_PushButton_Apply" );
532 Advance_PushButton_Apply->setGeometry( QRect( 420, 380, 120, 30 ) );
533 Advance_PushButton_Apply->setText("&APPLY");
535 TabWidgetRaConfig->insertTab( AdvancePage_tab, "Advance");
536 //===============================================================================
537 //About Page
538 //===============================================================================
539 AboutPage_tab = new QWidget( TabWidgetRaConfig, "AboutPage_tab" );
541 About_TextLabel_Logo = new QLabel( AboutPage_tab, "About_TextLabel_Logo" );
542 About_TextLabel_Logo->setGeometry( QRect( 30, 30, 161, 91 ) );
543 About_TextLabel_Logo->setText("");
544 About_TextLabel_Logo->setPixmap( uic_load_pixmap_RaConfigForm( "rtlogo.png" ) );
546 About_ButtonGroupUI = new QButtonGroup( AboutPage_tab, "About_ButtonGroupUI" );
547 About_ButtonGroupUI->setGeometry( QRect( 30, 140, 510, 60 ) );
548 About_ButtonGroupUI->setTitle("Configuration Utility - Rt2500");
550 About_TextLabel1 = new QLabel( About_ButtonGroupUI, "About_TextLabel1" );
551 About_TextLabel1->setGeometry( QRect( 20, 20, 80, 30 ) );
552 About_TextLabel1->setText("Version:");
554 About_TextLabel_UIVersion = new QLabel( About_ButtonGroupUI, "About_TextLabel_UIVersion" );
555 About_TextLabel_UIVersion->setGeometry( QRect( 110, 20, 100, 30 ) );
556 About_TextLabel_UIVersion->setText(CONFIGURATION_UI_VERSION);
558 About_TextLabel2 = new QLabel( About_ButtonGroupUI, "About_TextLabel2" );
559 About_TextLabel2->setGeometry( QRect( 280, 20, 80, 30 ) );
560 About_TextLabel2->setText("Date:");
562 About_TextLabel_UIDate = new QLabel( About_ButtonGroupUI, "About_TextLabel_UIDate" );
563 About_TextLabel_UIDate->setGeometry( QRect( 370, 20, 100, 30 ) );
564 About_TextLabel_UIDate->setText(CONFIGURATION_UI_DATE);
566 About_ButtonGroupNIC = new QButtonGroup( AboutPage_tab, "About_ButtonGroupNIC" );
567 About_ButtonGroupNIC->setGeometry( QRect( 30, 230, 510, 60 ) );
568 About_ButtonGroupNIC->setTitle("NIC Driver");
570 About_TextLabel3 = new QLabel( About_ButtonGroupNIC, "About_TextLabel3" );
571 About_TextLabel3->setGeometry( QRect( 20, 20, 80, 30 ) );
572 About_TextLabel3->setText("Version:");
574 About_TextLabel_NICVersion = new QLabel( About_ButtonGroupNIC, "About_TextLabel_NICVersion" );
575 About_TextLabel_NICVersion->setGeometry( QRect( 110, 20, 100, 30 ) );
577 About_TextLabel4 = new QLabel( About_ButtonGroupNIC, "About_TextLabel4" );
578 About_TextLabel4->setGeometry( QRect( 280, 20, 80, 30 ) );
579 About_TextLabel4->setText("Date:");
581 About_TextLabel_NICDate = new QLabel( About_ButtonGroupNIC, "About_TextLabel_NICDate" );
582 About_TextLabel_NICDate->setGeometry( QRect( 370, 20, 100, 30 ) );
584 About_ButtonGroupMAC = new QButtonGroup( AboutPage_tab, "About_ButtonGroupMAC" );
585 About_ButtonGroupMAC->setGeometry( QRect( 30, 320, 510, 60 ) );
586 About_ButtonGroupMAC->setTitle("Mac Address");
588 About_TextLabel5 = new QLabel( About_ButtonGroupMAC, "About_TextLabel5" );
589 About_TextLabel5->setGeometry( QRect( 20, 20, 130, 30 ) );
590 About_TextLabel5->setText("Phy_Address:");
592 About_TextLabel_PhyAddress = new QLabel( About_ButtonGroupMAC, "About_TextLabel_PhyAddress" );
593 About_TextLabel_PhyAddress->setGeometry( QRect( 170, 20, 170, 30 ) );
594 About_TextLabel_PhyAddress->setText("");
596 TabWidgetRaConfig->insertTab( AboutPage_tab,"About");
598 TabWidgetRaConfig->showPage(SiteSurveyPage_tab); //Site survey.
600 connect( TabWidgetRaConfig, SIGNAL( currentChanged(QWidget*) ), this, SLOT( OnPageChanged() ) );
601 connect( Profile_PushButton_Add, SIGNAL( clicked() ), this, SLOT( Profile_OnAddProfile() ) );
602 connect( Profile_PushButton_Delete, SIGNAL( clicked() ), this, SLOT( Profile_OnDeleteProfile() ) );
603 connect( Profile_PushButton_Edit, SIGNAL( clicked() ), this, SLOT( Profile_OnEditProfile() ) );
604 connect( Profile_PushButton_Activate, SIGNAL( clicked() ), this, SLOT( Profile_OnActiveProfile() ) );
605 connect( Profile_ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( Profile_OnEditProfile() ) );
606 connect( SiteSurvey_PushButton_Rescan, SIGNAL( clicked() ), this, SLOT( SiteSurvey_OnRescan() ) );
607 connect( SiteSurvey_PushButton_Connect, SIGNAL( clicked() ), this, SLOT( SiteSurvey_OnConnect() ) );
608 connect( SiteSurvey_PushButton_AddProfile, SIGNAL( clicked() ), this, SLOT( SiteSurvey_OnAddToProfile() ) );
609 connect( SiteSurvey_ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( SiteSurvey_OnConnect() ) );
610 connect( SiteSurvey_ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( SiteSurvey_OnSelectChange() ) );
611 connect( Statistics_PushButton_Reset, SIGNAL( clicked() ), this, SLOT( Statistics_OnResetCounters() ) );
612 connect( Advance_PushButton_Radio, SIGNAL( clicked() ), this, SLOT( Advance_OnRadio() ) );
613 connect( Advance_PushButton_Apply, SIGNAL( clicked() ), this, SLOT( Advance_OnApply() ) );
614 connect( Advance_PushButton_Apply, SIGNAL( clicked() ), this, SLOT( Advance_OnApply() ) );
615 connect( Advance_ComboBox_Mode, SIGNAL( activated(int) ), this, SLOT( Advance_OnSelchangeWirelessMode(int) ) );
618 m_nSocketId = socket_id;
619 m_strDeviceName = (char *)malloc(strlen(device_name)+1);
620 if(m_strDeviceName)
621 strcpy(m_strDeviceName, device_name);
623 timerId_Alive = startTimer(2000); //check device driver per 2 seconds.
624 timerId_ConnectStatus = -1;
625 timerId_LinkStatus = -1;
626 timerId_Statistic = -1;
627 timerId_UpdateProfileStatus = -1;
629 m_pBssidList = (PNDIS_802_11_BSSID_LIST_EX) malloc(65536); //64k
630 m_pProfileSetting = NULL;
631 m_bSetSsid = FALSE;
632 m_bSetBssid = FALSE;
633 m_bRescan = FALSE;
634 m_nTimerCount = 0;
635 m_lTxCount = 0;
636 m_lRxCount = 0;
637 m_lChannelQuality = 0;
638 m_WirelessMode = PHY_11BG_MIXED;
639 m_bTXBurst = FALSE;
640 m_nBGProtection = 0;
641 m_bShortSlot = FALSE;
642 m_bTurboRate = FALSE;
643 m_bAdhocOfdm = FALSE;
644 m_nTXRate = 0;
645 m_nSigQua=0;
646 m_bUpdateSiteSurveyPage = TRUE;
647 m_bUpdateProfilePage = TRUE;
648 m_bUpdateLinkSatusPage = TRUE;
650 memset(&m_BssidSet, 0x00, sizeof(m_BssidSet));
651 memset(&m_SsidSet, 0x00, sizeof(m_SsidSet));
653 Profile_ReadProfileFromFile();
655 if (!G_bUserAdmin)
657 Profile_PushButton_Add->setEnabled(FALSE);
658 Profile_PushButton_Delete->setEnabled(FALSE);
659 Profile_PushButton_Edit->setEnabled(FALSE);
660 Profile_PushButton_Activate->setEnabled(FALSE);
662 Advance_ComboBox_Mode->setEnabled( FALSE );
663 Advance_CheckBox_TxBurst->setEnabled( FALSE );
664 Advance_CheckBox_ShortSlot->setEnabled( FALSE );
665 Advance_CheckBox_TurboRate->setEnabled( FALSE );
666 Advance_ComboBox_BGProtection->setEnabled( FALSE );
667 Advance_ComboBox_TxRate->setEnabled( FALSE );
668 Advance_PushButton_Radio->setEnabled( FALSE );
669 Advance_PushButton_Apply->setEnabled( FALSE );
672 ULONG RadioStatus;
674 OidQueryInformation(RT_OID_802_11_RADIO, m_nSocketId, m_strDeviceName, &RadioStatus, sizeof(RadioStatus));
675 if (RadioStatus)
676 G_bRadio = TRUE;
677 else
678 G_bRadio = FALSE;
682 * Destroys the object and frees any allocated resources
684 RaConfigForm::~RaConfigForm()
686 // no need to delete child widgets, Qt does it all for us
689 void RaConfigForm::OnPageChanged()
691 killTimer(timerId_LinkStatus);
692 timerId_LinkStatus = -1;
693 killTimer(timerId_ConnectStatus);
694 timerId_ConnectStatus = -1;
695 killTimer(timerId_Statistic);
696 timerId_Statistic = -1;
697 killTimer(timerId_UpdateProfileStatus);
698 timerId_UpdateProfileStatus = -1;
700 switch(TabWidgetRaConfig->currentPageIndex())
702 case 0: //Profile Page
703 Profile_OnActive();
704 break;
705 case 1: //Link Status page
706 LinkStatus_OnActive();
707 break;
708 case 2: //Site Survey page
709 SiteSurvey_OnActive();
710 break;
711 case 3: //Statistics page
712 Statistics_OnActive();
713 break;
714 case 4: //Advance page
715 Advance_OnActive();
716 break;
717 case 5: //About page
718 About_OnActive();
719 break;
724 void RaConfigForm::timerEvent(QTimerEvent* e)
726 NDIS_802_11_MAC_ADDRESS CurrentAddress;
728 if (e->timerId() == timerId_Alive)
730 if(OidQueryInformation(OID_802_3_CURRENT_ADDRESS, m_nSocketId, m_strDeviceName, &CurrentAddress, sizeof(CurrentAddress)) == -1 &&
731 errno == ENODEV) //No such device from errno.h
733 killTimers();
734 close();
737 else if (e->timerId() == timerId_ConnectStatus)
739 SiteSurvey_ProbeConnectStatus();
740 SiteSurvey_ButtonShowHide();
742 else if (e->timerId() == timerId_LinkStatus)
743 LinkStatus_UpdateStatus();
744 else if (e->timerId() == timerId_Statistic)
745 Statistics_OnTimer();
746 else if (e->timerId() == timerId_UpdateProfileStatus)
747 Profile_UpdateProfileStatus();
750 void RaConfigForm::Profile_ReadProfileFromFile()
752 QListViewItem *Item;
753 PRT_PROFILE_SETTING nowProfileSetting=NULL;
754 PRT_PROFILE_SETTING lastProfileSetting=NULL;
755 RT_PROFILE_SETTING tmpProfileSetting;
756 NDIS_802_11_SSID SsidQuery;
757 NDIS_MEDIA_STATE ConnectStatus;
758 FILE *cfgProfileId;
759 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
760 char cfgProfile[512];
761 char tempstr[255];
763 memset(m_strActiveProfileID, 0x00, 32+1);
764 getkeystring("Default", "ProfileID", m_strActiveProfileID, 32, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
766 sprintf(cfgProfile, "%s/%s", RT2500_SYSTEM_PATH, RT2500_UI_PROFILE);
767 lastProfileSetting = NULL;
768 if ((cfgProfileId = fopen(cfgProfile, "rb")) != NULL)
770 while (fread((void *)&tmpProfileSetting, sizeof(RT_PROFILE_SETTING), (unsigned) 1, cfgProfileId) != 0)
772 if (tmpProfileSetting.ProfileDataType != RT2500_UI_TYPE)
773 break; //not for RT2500 Utility
775 if (( nowProfileSetting = (PRT_PROFILE_SETTING) malloc(sizeof(RT_PROFILE_SETTING))) == NULL)
776 break;
778 memcpy(nowProfileSetting, (void *)&tmpProfileSetting, sizeof(RT_PROFILE_SETTING));
779 nowProfileSetting->Next=lastProfileSetting;
780 lastProfileSetting = nowProfileSetting;
782 Item = new QListViewItem(Profile_ListView);
783 if (strcmp(m_strActiveProfileID, (const char *)nowProfileSetting->Profile) == 0)
785 if (OidQueryInformation(OID_GEN_MEDIA_CONNECT_STATUS, m_nSocketId, m_strDeviceName, &ConnectStatus, sizeof(ConnectStatus)) >= 0)
787 if(ConnectStatus == NdisMediaStateConnected && G_bRadio)
789 memset(&SsidQuery, 0x00, sizeof(SsidQuery));
790 OidQueryInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SsidQuery, sizeof(SsidQuery));
792 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
793 memcpy(strSSID, SsidQuery.Ssid, SsidQuery.SsidLength);
795 if (strcmp(strSSID, (const char *)nowProfileSetting->SSID) == 0)
796 Item->setPixmap(0, uic_load_pixmap_RaConfigForm("check16.xpm"));
797 else
798 Item->setPixmap(0, uic_load_pixmap_RaConfigForm("noactive16.xpm"));
800 else
801 Item->setPixmap(0, uic_load_pixmap_RaConfigForm("noactive16.xpm"));
803 else
804 Item->setPixmap(0, uic_load_pixmap_RaConfigForm("noactive16.xpm"));
806 else
808 Item->setPixmap(0, uic_load_pixmap_RaConfigForm("uncheck16.xpm"));
811 Item->setText(0, (const char *)nowProfileSetting->Profile);
812 Item->setText(1, (const char *)nowProfileSetting->SSID);
814 if(nowProfileSetting->Channel != 0)
816 sprintf(tempstr, "%d", nowProfileSetting->Channel);
817 Item->setText(2, tempstr);
819 else
820 Item->setText(2, "Auto");
822 if (nowProfileSetting->Authentication == Ndis802_11AuthModeOpen)
823 Item->setText(3, "OPEN");
824 else if (nowProfileSetting->Authentication == Ndis802_11AuthModeShared)
825 Item->setText(3, "SHARED");
826 else if (nowProfileSetting->Authentication == Ndis802_11AuthModeWPAPSK)
827 Item->setText(3, "WPAPSK");
828 else if (nowProfileSetting->Authentication == Ndis802_11AuthModeWPANone)
829 Item->setText(3, "WPA-None");
830 else if (nowProfileSetting->Authentication == Ndis802_11AuthModeWPA)
831 Item->setText(3, "WPA");
832 else
833 Item->setText(3, "unknown");
835 if (nowProfileSetting->Encryption == Ndis802_11WEPEnabled)
836 Item->setText(4,"WEP");
837 else if (nowProfileSetting->Encryption == Ndis802_11WEPDisabled)
838 Item->setText(4,"NONE");
839 else if (nowProfileSetting->Encryption == Ndis802_11Encryption2Enabled)
840 Item->setText(4,"TKIP");
841 else if (nowProfileSetting->Encryption == Ndis802_11Encryption3Enabled)
842 Item->setText(4,"AES");
843 else
844 Item->setText(4,"unknown");
846 Item->setText(5, strAryNetworkType[nowProfileSetting->NetworkType]);
848 fclose(cfgProfileId);
849 m_pProfileSetting = lastProfileSetting;
852 if (G_bUserAdmin)
854 if (Profile_ListView->childCount() > 0)
856 Profile_PushButton_Delete->setEnabled(TRUE);
857 Profile_PushButton_Edit->setEnabled(TRUE);
858 Profile_PushButton_Activate->setEnabled(TRUE);
863 void RaConfigForm::Profile_UpdateProfileStatus()
865 QListViewItem *ListItem = NULL;
866 NDIS_MEDIA_STATE ConnectStatus = NdisMediaStateDisconnected;
867 NDIS_802_11_SSID SsidQuery;
868 NDIS_802_11_WEP_STATUS ProEncryp = Ndis802_11WEPDisabled, Encryp = Ndis802_11WEPDisabled;
869 NDIS_802_11_AUTHENTICATION_MODE ProAuthenType = Ndis802_11AuthModeOpen, AuthenType = Ndis802_11AuthModeOpen;
870 NDIS_802_11_NETWORK_INFRASTRUCTURE ProNetType = Ndis802_11Infrastructure, NetType = Ndis802_11Infrastructure;
871 QString qstr;
872 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
873 int nItem;
874 int i;
876 if (OidQueryInformation(OID_GEN_MEDIA_CONNECT_STATUS, m_nSocketId, m_strDeviceName, &ConnectStatus, sizeof(ConnectStatus)) < 0)
877 ConnectStatus = NdisMediaStateDisconnected;
879 memset(&SsidQuery, 0x00, sizeof(SsidQuery));
880 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
882 if (ConnectStatus == NdisMediaStateConnected)
884 if (OidQueryInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SsidQuery, sizeof(SsidQuery)) >=0 )
886 memcpy(strSSID, SsidQuery.Ssid, SsidQuery.SsidLength);
890 OidQueryInformation(OID_802_11_WEP_STATUS, m_nSocketId, m_strDeviceName, &Encryp, sizeof(Encryp));
891 OidQueryInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &AuthenType, sizeof(AuthenType));
892 OidQueryInformation(OID_802_11_INFRASTRUCTURE_MODE, m_nSocketId, m_strDeviceName, &NetType, sizeof(NetType));
894 nItem = Profile_ListView->childCount();
895 ListItem = Profile_ListView->firstChild();
896 for (i = 0; i < nItem; i++)
898 qstr = ListItem->text(0);
899 if (qstr.compare(m_strActiveProfileID) == 0)
901 qstr = ListItem->text(5);
902 if (qstr.compare("Infrastructure") == 0)
903 ProNetType = Ndis802_11Infrastructure;
904 else
905 ProNetType = Ndis802_11IBSS;
907 qstr = ListItem->text(3);
908 if (qstr.compare("OPEN") == 0)
909 ProAuthenType = Ndis802_11AuthModeOpen;
910 else if (qstr.compare("SHARED") == 0)
911 ProAuthenType = Ndis802_11AuthModeShared;
912 else if (qstr.compare("WPAPSK") == 0)
913 ProAuthenType = Ndis802_11AuthModeWPAPSK;
914 else if (qstr.compare("WPA-None") == 0)
915 ProAuthenType = Ndis802_11AuthModeWPANone;
916 else if (qstr.compare("WPA") == 0)
917 ProAuthenType = Ndis802_11AuthModeWPA;
919 qstr = ListItem->text(4);
920 if (qstr.compare("WEP") == 0)
921 ProEncryp = Ndis802_11WEPEnabled;
922 else if (qstr.compare("NONE") == 0)
923 ProEncryp = Ndis802_11WEPDisabled;
924 else if (qstr.compare("TKIP") == 0)
925 ProEncryp = Ndis802_11Encryption2Enabled;
926 else if (qstr.compare("AES") == 0)
927 ProEncryp = Ndis802_11Encryption3Enabled;
929 qstr = ListItem->text(1);
930 if ( ((qstr.isEmpty()) || (qstr.compare(strSSID) == 0)) && (ConnectStatus == NdisMediaStateConnected) &&
931 (ProNetType == NetType) && (ProAuthenType == AuthenType) && (ProEncryp == Encryp))
932 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("check16.xpm"));
933 else
934 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("noactive16.xpm"));
936 else
937 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("uncheck16.xpm"));
939 ListItem = ListItem->itemBelow();
942 if (m_bUpdateSiteSurveyPage)
944 m_bUpdateSiteSurveyPage = FALSE;
945 SiteSurvey_ProbeConnectStatus();
948 if (m_bUpdateLinkSatusPage)
950 m_bUpdateLinkSatusPage = FALSE;
951 LinkStatus_UpdateStatus();
956 void RaConfigForm::Profile_WriteProfileToFile()
958 FILE *WriteProfileId;
959 PRT_PROFILE_SETTING ptr=NULL;
960 char cfgProfile[512];
961 char cmdString[256];
963 if (getuid() == 0)
965 sprintf(cfgProfile, "%s/%s", RT2500_SYSTEM_PATH, RT2500_UI_PROFILE);
966 sprintf(cmdString, " if [ ! -d %s ] ; then mkdir -p %s ; fi ", RT2500_SYSTEM_PATH, RT2500_SYSTEM_PATH);
967 system(cmdString);
969 if (m_pProfileSetting != NULL)
971 if ((WriteProfileId = fopen(cfgProfile, "wb")) != NULL)
973 ptr = m_pProfileSetting;
974 while (ptr != NULL)
976 ptr->ProfileDataType = RT2500_UI_TYPE;
977 fwrite(ptr, sizeof(RT_PROFILE_SETTING), 1, WriteProfileId);
978 ptr = ptr->Next;
980 fclose(WriteProfileId);
983 else
985 sprintf(cmdString, "rm -f %s", cfgProfile);
986 system(cmdString);
991 void RaConfigForm::Profile_WriteConfigToRegistryAndSetOid()
993 QListViewItem *Item;
994 QString qstr;
995 PRT_PROFILE_SETTING ptr=NULL;
996 RT_802_11_PHY_MODE enumWirelessMode;
997 RT_802_11_STA_CONFIG configStation;
998 RT_802_11_STA_CONFIG configOldStation;
999 NDIS_802_11_NETWORK_INFRASTRUCTURE enumNetworkType;
1000 RT_802_11_PREAMBLE enumPreamType;
1001 NDIS_802_11_RTS_THRESHOLD lRtsThre;
1002 NDIS_802_11_FRAGMENTATION_THRESHOLD lFragThre;
1003 NDIS_802_11_AUTHENTICATION_MODE enumAuthenType;
1004 NDIS_802_11_WEP_STATUS enumEncryp;
1005 NDIS_802_11_CONFIGURATION Configuration;
1006 NDIS_802_11_POWER_MODE enumPSMode;
1007 NDIS_802_11_SSID SSID;
1008 NDIS_802_11_REMOVE_KEY removeKey;
1009 PNDIS_802_11_KEY pKey = NULL;
1010 NDIS_802_11_RATES aryRates;
1011 ULONG nKeyLen;
1012 ULONG lBufLen;
1013 ULONG lFreq = 0;
1014 UCHAR keyMaterial[40];
1015 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
1016 char strtmp[255];
1017 int i;
1018 bool bSetSSID = FALSE;
1019 bool bIsFound = FALSE;
1021 Item = Profile_ListView->currentItem();
1022 qstr = Item->text(0);
1023 ptr = m_pProfileSetting;
1024 while (ptr)
1026 if (qstr.compare((const char *)ptr->Profile) == 0)
1028 bIsFound = TRUE;
1029 break;
1031 ptr = ptr->Next;
1034 if (bIsFound)
1036 writekeystring("Default", "ProfileID", (char *)ptr->Profile, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1037 strcpy(m_strActiveProfileID, (const char *)ptr->Profile);
1039 //Write to Registry
1040 //SSID
1041 writekeystring("Default", "SSID", (char *)ptr->SSID, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1043 if(!G_bSupportAMode && G_enumWirelessMode >= PHY_11A)
1044 G_enumWirelessMode = PHY_11BG_MIXED;
1046 // SetOidInformation
1047 OidQueryInformation(RT_OID_802_11_PHY_MODE, m_nSocketId, m_strDeviceName, &enumWirelessMode, sizeof(enumWirelessMode));
1048 if(enumWirelessMode != G_enumWirelessMode)
1049 OidSetInformation(RT_OID_802_11_PHY_MODE, m_nSocketId, m_strDeviceName, &G_enumWirelessMode, sizeof(G_enumWirelessMode));
1051 //Get AdhocOfdm mode
1052 if (getkeystring("Default", "AdhocOfdm", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1054 if (atoi(strtmp) != 0)
1055 m_bAdhocOfdm = TRUE;
1056 else
1057 m_bAdhocOfdm = FALSE;
1059 else
1060 m_bAdhocOfdm = FALSE;
1062 // Get TXBurst value
1063 if (getkeystring("Default", "TXBurst", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1065 if (atoi(strtmp) != 0)
1066 m_bTXBurst = TRUE;
1067 else
1068 m_bTXBurst = FALSE;
1070 else
1071 m_bTXBurst = FALSE;
1073 //Get TurboRate value
1074 if (getkeystring("Default", "TurboRate", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1076 if (atoi(strtmp) != 0)
1077 m_bTurboRate = TRUE;
1078 else
1079 m_bTurboRate = FALSE;
1081 else
1082 m_bTurboRate = FALSE;
1084 // Get ShortSlot value
1085 if (getkeystring("Default", "ShortSlot", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1087 if (atoi(strtmp) != 0)
1088 m_bShortSlot = TRUE;
1089 else
1090 m_bShortSlot = FALSE;
1092 else
1093 m_bShortSlot = FALSE;
1095 // Get BGProtection value
1096 if (getkeystring("Default", "BGProtection", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1098 m_nBGProtection = atoi(strtmp);
1100 if ((m_nBGProtection < 0) || (m_nBGProtection >= 3))
1101 m_nBGProtection = 0;
1103 m_nBGProtection = 0;
1105 // Get TXRate value
1106 if (getkeystring("Default", "TxRate", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
1108 m_nTXRate = atoi(strtmp);
1111 OidQueryInformation(RT_OID_802_11_STA_CONFIG, m_nSocketId, m_strDeviceName, &configOldStation, sizeof(configOldStation));
1112 configStation.EnableTurboRate = m_bTurboRate;
1113 configStation.EnableTxBurst = m_bTXBurst;
1114 configStation.UseBGProtection = m_nBGProtection;
1115 configStation.UseShortSlotTime = m_bShortSlot;
1116 configStation.UseOfdmRatesIn11gAdhoc = m_bAdhocOfdm;
1117 if(memcmp(&configOldStation, &configStation, sizeof(RT_802_11_STA_CONFIG)) != 0)
1118 OidSetInformation(RT_OID_802_11_STA_CONFIG, m_nSocketId, m_strDeviceName, &configStation, sizeof(configStation));
1120 memset(aryRates, 0x00, sizeof(NDIS_802_11_RATES));
1121 if (m_WirelessMode == PHY_11A)
1123 switch (m_nTXRate)
1125 case 0:
1126 aryRates[0] = 0x6c; // 54Mbps
1127 aryRates[1] = 0x60; // 48Mbps
1128 aryRates[2] = 0x48; // 36Mbps
1129 aryRates[3] = 0x30; // 24Mbps
1130 aryRates[4] = 0x24; // 18M
1131 aryRates[5] = 0x18; // 12M
1132 aryRates[6] = 0x12; // 9M
1133 aryRates[7] = 0x0c; // 6M
1134 break;
1135 case 1:
1136 aryRates[0] = 0x0c; // 6M
1137 break;
1138 case 2:
1139 aryRates[0] = 0x12; // 9M
1140 break;
1141 case 3:
1142 aryRates[0] = 0x18; // 12M
1143 break;
1144 case 4:
1145 aryRates[0] = 0x24; // 18M
1146 break;
1147 case 5:
1148 aryRates[0] = 0x30; // 24M
1149 break;
1150 case 6:
1151 aryRates[0] = 0x48; // 36M
1152 break;
1153 case 7:
1154 aryRates[0] = 0x60; // 48M
1155 break;
1156 case 8:
1157 aryRates[0] = 0x6c; // 54M
1158 break;
1161 else if ((m_WirelessMode == PHY_11BG_MIXED) || (m_WirelessMode == PHY_11B) ||
1162 (m_WirelessMode == PHY_11ABG_MIXED))
1164 switch(m_nTXRate)
1166 case 0:
1167 switch(m_WirelessMode)
1169 case PHY_11BG_MIXED: // B/G Mixed
1170 case PHY_11ABG_MIXED: // A/B/G Mixed
1171 aryRates[0] = 0x6c; // 54Mbps
1172 aryRates[1] = 0x60; // 48Mbps
1173 aryRates[2] = 0x48; // 36Mbps
1174 aryRates[3] = 0x30; // 24Mbps
1175 aryRates[4] = 0x16; // 11Mbps
1176 aryRates[5] = 0x0b; // 5.5Mbps
1177 aryRates[6] = 0x04; // 2Mbps
1178 aryRates[7] = 0x02; // 1Mbps
1179 break;
1180 case PHY_11B: // B Only
1181 aryRates[0] = 0x16; // 11Mbps
1182 aryRates[1] = 0x0b; // 5.5Mbps
1183 aryRates[2] = 0x04; // 2Mbps
1184 aryRates[3] = 0x02; // 1Mbps
1185 break;
1186 case PHY_11A:
1187 break; //Not be call, for avoid warning.
1189 break;
1190 case 1:
1191 aryRates[0] = 0x02; // 1M
1192 break;
1193 case 2:
1194 aryRates[0] = 0x04; // 2M
1195 break;
1196 case 3:
1197 aryRates[0] = 0x0b; // 5.5M
1198 break;
1199 case 4:
1200 aryRates[0] = 0x16; // 11M
1201 break;
1202 case 5:
1203 aryRates[0] = 0x0c; // 6M
1204 break;
1205 case 6:
1206 aryRates[0] = 0x12; // 9M
1207 break;
1208 case 7:
1209 aryRates[0] = 0x18; // 12M
1210 break;
1211 case 8:
1212 aryRates[0] = 0x24; // 18M
1213 break;
1214 case 9:
1215 aryRates[0] = 0x30; // 24M
1216 break;
1217 case 10:
1218 aryRates[0] = 0x48; // 36M
1219 break;
1220 case 11:
1221 aryRates[0] = 0x60; // 48M
1222 break;
1223 case 12:
1224 aryRates[0] = 0x6c; // 54M
1225 break;
1228 OidSetInformation(OID_802_11_DESIRED_RATES, m_nSocketId, m_strDeviceName, &aryRates, sizeof(NDIS_802_11_RATES));
1230 OidQueryInformation(OID_802_11_INFRASTRUCTURE_MODE, m_nSocketId, m_strDeviceName, &enumNetworkType, sizeof(enumNetworkType));
1231 if (ptr->NetworkType != enumNetworkType)
1233 bSetSSID = TRUE;
1234 OidSetInformation(OID_802_11_INFRASTRUCTURE_MODE, m_nSocketId, m_strDeviceName, &ptr->NetworkType, sizeof(ptr->NetworkType));
1236 //Write to Registry
1237 if (ptr->NetworkType == Ndis802_11IBSS)
1238 writekeystring("Default", "NetworkType", "Adhoc", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1239 else
1240 writekeystring("Default", "NetworkType", "Infra", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1242 OidQueryInformation(RT_OID_802_11_PREAMBLE, m_nSocketId, m_strDeviceName, &enumPreamType, sizeof(enumPreamType));
1243 if (ptr->PreamType != enumPreamType)
1244 OidSetInformation(RT_OID_802_11_PREAMBLE, m_nSocketId, m_strDeviceName, &ptr->PreamType, sizeof(ptr->PreamType));
1246 //Write to Registry
1247 switch (ptr->PreamType)
1249 case Rt802_11PreambleLong:
1250 writekeystring("Default", "PreambleType", "Long", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1251 break;
1252 case Rt802_11PreambleShort:
1253 writekeystring("Default", "PreambleType", "Short", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1254 break;
1255 case Rt802_11PreambleAuto:
1256 default:
1257 writekeystring("Default", "PreambleType", "Auto", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1258 break;
1261 OidQueryInformation(OID_802_11_RTS_THRESHOLD, m_nSocketId, m_strDeviceName, &lRtsThre, sizeof(lRtsThre));
1262 if (ptr->RTS != lRtsThre)
1263 OidSetInformation(OID_802_11_RTS_THRESHOLD, m_nSocketId, m_strDeviceName, &ptr->RTS, sizeof(ptr->RTS));
1265 //Write to Registry
1266 sprintf(strtmp, "%ld", ptr->RTS);
1267 writekeystring("Default", "RTSThreshold", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1269 OidQueryInformation(OID_802_11_FRAGMENTATION_THRESHOLD, m_nSocketId, m_strDeviceName, &lFragThre, sizeof(lFragThre));
1270 if (ptr->Fragment != lFragThre)
1271 OidSetInformation(OID_802_11_FRAGMENTATION_THRESHOLD, m_nSocketId, m_strDeviceName, &ptr->Fragment, sizeof(ptr->Fragment));
1273 //Write to Registry
1274 sprintf(strtmp, "%ld", ptr->Fragment);
1275 writekeystring("Default", "FragThreshold", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1277 OidQueryInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &enumAuthenType, sizeof(enumAuthenType));
1278 if (ptr->Authentication != enumAuthenType)
1280 bSetSSID = TRUE;
1281 OidSetInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &ptr->Authentication, sizeof(ptr->Authentication));
1284 //Write to Registry
1285 switch (ptr->Authentication)
1287 case Ndis802_11AuthModeShared:
1288 writekeystring("Default", "AuthMode", "SHARED", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1289 break;
1290 case Ndis802_11AuthModeWPA:
1291 writekeystring("Default", "AuthMode", "WPA", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1292 break;
1293 case Ndis802_11AuthModeWPAPSK:
1294 writekeystring("Default", "AuthMode", "WPAPSK", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1295 break;
1296 case Ndis802_11AuthModeWPANone:
1297 writekeystring("Default", "AuthMode", "WPA-None", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1298 break;
1299 case Ndis802_11AuthModeOpen:
1300 default:
1301 writekeystring("Default", "AuthMode", "OPEN", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1302 break;
1305 OidQueryInformation(OID_802_11_WEP_STATUS, m_nSocketId, m_strDeviceName, &enumEncryp, sizeof(enumEncryp));
1306 if ( ptr->Encryption != enumEncryp)
1308 bSetSSID = TRUE;
1309 OidSetInformation(OID_802_11_WEP_STATUS, m_nSocketId, m_strDeviceName, &ptr->Encryption, sizeof(ptr->Encryption));
1312 switch (ptr->Encryption)
1314 case Ndis802_11WEPEnabled:
1315 writekeystring("Default", "EncrypType", "WEP", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1316 break;
1317 case Ndis802_11Encryption2Enabled:
1318 writekeystring("Default", "EncrypType", "TKIP", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1319 break;
1320 case Ndis802_11Encryption3Enabled:
1321 writekeystring("Default", "EncrypType", "AES", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1322 break;
1323 case Ndis802_11WEPDisabled:
1324 default:
1325 writekeystring("Default", "EncrypType", "NONE", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1326 break;
1329 if (ptr->Encryption == Ndis802_11WEPEnabled)
1331 sprintf(strtmp, "%d", ptr->KeyDefaultId + 1);
1332 writekeystring("Default", "DefaultKeyID", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1333 //Key1
1334 if (ptr->Key1Type == 0) //hex
1335 writekeystring("Default", "Key1Type", "0", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1336 else
1337 writekeystring("Default", "Key1Type", "1", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1338 writekeystring("Default", "Key1Str", ptr->Key1, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1339 //Key2
1340 if (ptr->Key2Type == 0) //hex
1341 writekeystring("Default", "Key2Type", "0", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1342 else
1343 writekeystring("Default", "Key2Type", "1", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1344 writekeystring("Default", "Key2Str", ptr->Key2, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1345 //Key3
1346 if (ptr->Key3Type == 0) //hex
1347 writekeystring("Default", "Key3Type", "0", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1348 else
1349 writekeystring("Default", "Key3Type", "1", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1350 writekeystring("Default", "Key3Str", ptr->Key2, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1351 //Key4
1352 if (ptr->Key4Type == 0) //hex
1353 writekeystring("Default", "Key4Type", "0", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1354 else
1355 writekeystring("Default", "Key4Type", "1", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1356 writekeystring("Default", "Key4Str", ptr->Key4, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1358 //----------------------------------------------------------//
1359 //Key 1
1360 //----------------------------------------------------------//
1361 nKeyLen = strlen(ptr->Key1);
1362 if(nKeyLen == 0)
1364 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
1365 removeKey.KeyIndex = 0;
1366 for(int i = 0; i < 6; i++)
1367 removeKey.BSSID[i] = 0xff;
1368 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
1370 else
1372 if(nKeyLen == 10)
1373 nKeyLen = 5;
1374 else if(nKeyLen == 26)
1375 nKeyLen = 13;
1377 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
1378 // Allocate Resource
1379 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
1380 pKey->Length = lBufLen;
1381 pKey->KeyLength = nKeyLen;
1382 pKey->KeyIndex = 0;
1383 if(ptr->KeyDefaultId == 0)
1384 pKey->KeyIndex |= 0x80000000;
1385 for(i = 0; i < 6; i++)
1386 pKey->BSSID[i] = 0xff;
1388 if(strlen(ptr->Key1) == 5)
1389 memcpy(pKey->KeyMaterial, ptr->Key1, 5);
1390 else if(strlen(ptr->Key1) == 10)
1391 AtoH(ptr->Key1, pKey->KeyMaterial, 5);
1392 else if(strlen(ptr->Key1) == 13)
1393 memcpy(pKey->KeyMaterial, ptr->Key1, 13);
1394 else if(strlen(ptr->Key1) == 26)
1395 AtoH(ptr->Key1, pKey->KeyMaterial, 13);
1397 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
1398 free(pKey);
1400 //----------------------------------------------------------//
1401 //Key 2
1402 //----------------------------------------------------------//
1403 nKeyLen = strlen(ptr->Key2);
1404 if(nKeyLen == 0)
1406 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
1407 removeKey.KeyIndex = 1;
1408 for(int i = 0; i < 6; i++)
1409 removeKey.BSSID[i] = 0xff;
1410 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
1412 else
1414 if(nKeyLen == 10)
1415 nKeyLen = 5;
1416 else if(nKeyLen == 26)
1417 nKeyLen = 13;
1419 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
1420 // Allocate Resource
1421 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
1422 pKey->Length = lBufLen;
1423 pKey->KeyLength = nKeyLen;
1424 pKey->KeyIndex = 1;
1425 if(ptr->KeyDefaultId == 1)
1426 pKey->KeyIndex |= 0x80000000;
1427 for(i = 0; i < 6; i++)
1428 pKey->BSSID[i] = 0xff;
1430 if(strlen(ptr->Key2) == 5)
1431 memcpy(pKey->KeyMaterial, ptr->Key2, 5);
1432 else if(strlen(ptr->Key2) == 10)
1433 AtoH(ptr->Key2, pKey->KeyMaterial, 5);
1434 else if(strlen(ptr->Key2) == 13)
1435 memcpy(pKey->KeyMaterial, ptr->Key2, 13);
1436 else if(strlen(ptr->Key2) == 26)
1437 AtoH(ptr->Key2, pKey->KeyMaterial, 13);
1439 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
1440 free(pKey);
1442 //----------------------------------------------------------//
1443 //Key 3
1444 //----------------------------------------------------------//
1445 nKeyLen = strlen(ptr->Key3);
1446 if(nKeyLen == 0)
1448 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
1449 removeKey.KeyIndex = 2;
1450 for(int i = 0; i < 6; i++)
1451 removeKey.BSSID[i] = 0xff;
1452 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
1454 else
1456 if(nKeyLen == 10)
1457 nKeyLen = 5;
1458 else if(nKeyLen == 26)
1459 nKeyLen = 13;
1461 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
1462 // Allocate Resource
1463 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
1464 pKey->Length = lBufLen;
1465 pKey->KeyLength = nKeyLen;
1466 pKey->KeyIndex = 2;
1467 if(ptr->KeyDefaultId == 2)
1468 pKey->KeyIndex |= 0x80000000;
1469 for(i = 0; i < 6; i++)
1470 pKey->BSSID[i] = 0xff;
1472 if(strlen(ptr->Key3) == 5)
1473 memcpy(pKey->KeyMaterial, ptr->Key3, 5);
1474 else if(strlen(ptr->Key3) == 10)
1475 AtoH(ptr->Key3, pKey->KeyMaterial, 5);
1476 else if(strlen(ptr->Key3) == 13)
1477 memcpy(pKey->KeyMaterial, ptr->Key3, 13);
1478 else if(strlen(ptr->Key3) == 26)
1479 AtoH(ptr->Key3, pKey->KeyMaterial, 13);
1481 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
1482 free(pKey);
1484 //----------------------------------------------------------//
1485 //Key 4
1486 //----------------------------------------------------------//
1487 nKeyLen = strlen(ptr->Key4);
1488 if(nKeyLen == 0)
1490 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
1491 removeKey.KeyIndex = 3;
1492 for(int i = 0; i < 6; i++)
1493 removeKey.BSSID[i] = 0xff;
1494 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
1496 else
1498 if(nKeyLen == 10)
1499 nKeyLen = 5;
1500 else if(nKeyLen == 26)
1501 nKeyLen = 13;
1503 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
1504 // Allocate Resource
1505 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
1506 pKey->Length = lBufLen;
1507 pKey->KeyLength = nKeyLen;
1508 pKey->KeyIndex = 3;
1509 if(ptr->KeyDefaultId == 3)
1510 pKey->KeyIndex |= 0x80000000;
1511 for(i = 0; i < 6; i++)
1512 pKey->BSSID[i] = 0xff;
1514 if(strlen(ptr->Key4) == 5)
1515 memcpy(pKey->KeyMaterial, ptr->Key4, 5);
1516 else if(strlen(ptr->Key4) == 10)
1517 AtoH(ptr->Key4, pKey->KeyMaterial, 5);
1518 else if(strlen(ptr->Key4) == 13)
1519 memcpy(pKey->KeyMaterial, ptr->Key3, 13);
1520 else if(strlen(ptr->Key4) == 26)
1521 AtoH(ptr->Key4, pKey->KeyMaterial, 13);
1523 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
1524 free(pKey);
1527 else if (ptr->Authentication == Ndis802_11AuthModeWPAPSK)
1529 writekeystring("Default", "WPAPSK", ptr->WpaPsk, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1531 nKeyLen = 32;
1532 lBufLen = (sizeof(NDIS_802_11_KEY) + nKeyLen - 1);
1533 // Allocate Resouce
1534 pKey = (PNDIS_802_11_KEY)malloc(lBufLen); // Don't use GMEM_ZEROINIT to get random key
1535 pKey->Length = lBufLen;
1536 pKey->KeyLength = nKeyLen;
1537 pKey->KeyIndex = 0x80000000;
1539 PasswordHash(ptr->WpaPsk, ptr->SSID, ptr->SsidLen, keyMaterial);
1540 memcpy(pKey->KeyMaterial, keyMaterial, 32);
1542 OidSetInformation(RT_OID_802_11_ADD_WPA, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
1544 free(pKey);
1547 if (ptr->NetworkType == Ndis802_11IBSS)
1549 OidQueryInformation(OID_802_11_CONFIGURATION, m_nSocketId, m_strDeviceName, &Configuration, sizeof(Configuration));
1550 for(i = 0; i < G_nChanFreqCount; i++)
1552 if(ptr->Channel == ChannelFreqTable[i].lChannel)
1554 lFreq = ChannelFreqTable[i].lFreq;
1555 break;
1559 if(lFreq != Configuration.DSConfig)
1561 bSetSSID = TRUE;
1562 Configuration.DSConfig = lFreq;
1564 OidSetInformation(OID_802_11_CONFIGURATION, m_nSocketId, m_strDeviceName, &Configuration, sizeof(Configuration));
1566 //Write to Registry
1567 //Channel
1568 sprintf(strtmp, "%d", ptr->Channel);
1569 writekeystring("Default", "Channel", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1570 //Power Save Mode
1571 writekeystring("Default", "PSMode", "", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1573 else
1574 { //Infra
1575 OidQueryInformation(OID_802_11_POWER_MODE, m_nSocketId, m_strDeviceName, &enumPSMode, sizeof(enumPSMode));
1576 if (ptr->PSmode != enumPSMode)
1577 OidSetInformation(OID_802_11_POWER_MODE, m_nSocketId, m_strDeviceName, &ptr->PSmode, sizeof(ptr->PSmode));
1579 writekeystring("Default", "Channel", "0", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1581 //Power Save Mode
1582 switch (ptr->PSmode)
1584 case Ndis802_11PowerModeMAX_PSP:
1585 writekeystring("Default", "PSMode", "MAX_PSP", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1586 break;
1587 case Ndis802_11PowerModeFast_PSP:
1588 writekeystring("Default", "PSMode", "Fast_PSP", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1589 break;
1590 case Ndis802_11PowerModeCAM:
1591 default:
1592 writekeystring("Default", "PSMode", "CAM", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1596 OidQueryInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SSID, sizeof(SSID));
1597 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
1598 memcpy(strSSID, SSID.Ssid, SSID.SsidLength);
1600 if (bSetSSID || (strcmp((const char *)ptr->SSID, strSSID) != 0))
1602 memset(&SSID, 0x00, sizeof(NDIS_802_11_SSID));
1603 SSID.SsidLength = ptr->SsidLen;
1604 memcpy(SSID.Ssid, (const void *)ptr->SSID, ptr->SsidLen);
1606 OidSetInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SSID, sizeof(SSID));
1612 void RaConfigForm::Profile_OnAddProfile()
1615 AddProfileDlg *pAddProfileDlg;
1617 killTimer(timerId_UpdateProfileStatus);
1618 timerId_UpdateProfileStatus = -1;
1620 pAddProfileDlg = new AddProfileDlg(m_nSocketId, m_strDeviceName, this, "AddProfile", PROFILE_ADD, Profile_ListView, &m_pProfileSetting, NULL, TRUE);
1621 pAddProfileDlg->exec();
1623 if (pAddProfileDlg->IsOk())
1625 Profile_WriteProfileToFile();
1627 if (Profile_ListView->childCount() == 0 )
1629 Profile_PushButton_Delete->setEnabled(FALSE);
1630 Profile_PushButton_Edit->setEnabled(FALSE);
1631 Profile_PushButton_Activate->setEnabled(FALSE);
1633 else
1635 Profile_PushButton_Delete->setEnabled(TRUE);
1636 Profile_PushButton_Edit->setEnabled(TRUE);
1637 Profile_PushButton_Activate->setEnabled(TRUE);
1640 delete pAddProfileDlg;
1641 timerId_UpdateProfileStatus = startTimer(2000);
1644 void RaConfigForm::Profile_OnDeleteProfile()
1646 QListViewItem *Item;
1647 QString qstr;
1648 PRT_PROFILE_SETTING ptr;
1649 PRT_PROFILE_SETTING previous;
1650 int answer = 0;
1652 killTimer(timerId_UpdateProfileStatus);
1653 timerId_UpdateProfileStatus = -1;
1655 Item = Profile_ListView->currentItem();
1656 if (Item == NULL)
1658 timerId_UpdateProfileStatus = startTimer(2000);
1659 return ; //No one selected!
1662 qstr=Item->text(0);
1663 if (qstrcmp(qstr.data(), m_strActiveProfileID) == 0)
1665 answer = QMessageBox::warning(this, "Warning", "The profile which you want to delete is in active!",
1666 "&Yes", "&No", QString::null, 1, 1 );
1667 if ( answer == 0 )
1668 { //Yes
1669 memset(m_strActiveProfileID, 0x00, 32+1);
1670 writekeystring("Default", "ProfileID", "", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1671 writekeystring("Default", "SSID", "", RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
1673 else
1675 timerId_UpdateProfileStatus = startTimer(2000);
1676 return; //do nothing.
1680 ptr = m_pProfileSetting;
1681 previous = ptr;
1682 while (ptr!=NULL)
1684 if (qstr.compare((const char *)ptr->Profile) == 0)
1686 if (ptr == m_pProfileSetting)
1688 m_pProfileSetting = m_pProfileSetting->Next;
1689 free (ptr);
1691 else
1693 previous->Next = ptr->Next;
1694 free(ptr);
1696 Profile_ListView->takeItem(Item);
1697 break;
1699 else
1700 previous = ptr;
1701 ptr = ptr->Next;
1704 Profile_WriteProfileToFile();
1706 if (G_bUserAdmin)
1708 if (Profile_ListView->childCount() == 0 )
1710 Profile_PushButton_Delete->setEnabled(FALSE);
1711 Profile_PushButton_Edit->setEnabled(FALSE);
1712 Profile_PushButton_Activate->setEnabled(FALSE);
1714 else
1716 Profile_PushButton_Delete->setEnabled(TRUE);
1717 Profile_PushButton_Edit->setEnabled(TRUE);
1718 Profile_PushButton_Activate->setEnabled(TRUE);
1721 timerId_UpdateProfileStatus = startTimer(2000);
1724 void RaConfigForm::Profile_OnEditProfile()
1726 AddProfileDlg *pAddProfileDlg;
1727 QListViewItem *Item;
1728 QString qstr;
1729 bool bChangeProfileName = FALSE;
1731 if (!G_bUserAdmin)
1733 QMessageBox::information(this, "Information", "You do not have supper user's privilege!");
1734 return;
1737 Item = Profile_ListView->currentItem();
1738 if (Item == NULL)
1740 QMessageBox::warning(this, "Warning", "Please select profile first.!");
1741 return;
1744 killTimer(timerId_UpdateProfileStatus);
1745 timerId_UpdateProfileStatus = -1;
1747 qstr=Item->text(0);
1748 if (strcmp(qstr.data(), m_strActiveProfileID) == 0)
1749 bChangeProfileName = TRUE;
1751 pAddProfileDlg = new AddProfileDlg(m_nSocketId, m_strDeviceName, this, "AddProfile", PROFILE_EDIT, Profile_ListView, &m_pProfileSetting, NULL, TRUE);
1752 pAddProfileDlg->exec();
1754 if (pAddProfileDlg->IsOk())
1756 Profile_WriteProfileToFile();
1758 if (Profile_ListView->childCount() == 0 )
1760 Profile_PushButton_Delete->setEnabled(FALSE);
1761 Profile_PushButton_Edit->setEnabled(FALSE);
1762 Profile_PushButton_Activate->setEnabled(FALSE);
1764 else
1766 Profile_PushButton_Delete->setEnabled(TRUE);
1767 Profile_PushButton_Edit->setEnabled(TRUE);
1768 Profile_PushButton_Activate->setEnabled(TRUE);
1771 if (bChangeProfileName)
1773 Profile_WriteConfigToRegistryAndSetOid();
1774 killTimer(timerId_UpdateProfileStatus);
1775 timerId_UpdateProfileStatus = -1;
1776 timerId_UpdateProfileStatus = startTimer(2000);
1777 m_bUpdateSiteSurveyPage = TRUE;
1778 m_bUpdateLinkSatusPage = TRUE;
1782 delete pAddProfileDlg;
1783 timerId_UpdateProfileStatus = startTimer(2000);
1786 void RaConfigForm::Profile_OnActive()
1788 killTimer(timerId_UpdateProfileStatus);
1789 // Stop SiteSurvey Autoreconnect
1790 m_bSetBssid = FALSE;
1791 m_bSetSsid = FALSE;
1792 timerId_UpdateProfileStatus = -1;
1793 timerId_UpdateProfileStatus = startTimer(2000);
1796 void RaConfigForm::Profile_OnActiveProfile()
1798 QListViewItem *Item;
1800 Item = Profile_ListView->currentItem();
1801 if (Item == NULL)
1803 QMessageBox::warning(this, "Warning", "Please select profile first.!");
1804 return;
1807 Profile_WriteConfigToRegistryAndSetOid();
1809 killTimer(timerId_UpdateProfileStatus);
1810 timerId_UpdateProfileStatus = -1;
1811 timerId_UpdateProfileStatus = startTimer(2000);
1812 m_bUpdateSiteSurveyPage = TRUE;
1813 m_bUpdateLinkSatusPage = TRUE;
1816 void RaConfigForm::SiteSurvey_OnActive()
1818 m_bRescan = TRUE;
1819 SiteSurvey_ProbeConnectStatus();
1820 timerId_ConnectStatus = startTimer(2000);
1823 void RaConfigForm::SiteSurvey_ProbeConnectStatus()
1825 NDIS_MEDIA_STATE ConnectStatus = NdisMediaStateDisconnected;
1826 NDIS_802_11_SSID SsidQuery;
1827 NDIS_802_11_MAC_ADDRESS BssidQuery;
1828 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
1829 char msg[255];
1831 if (m_bRescan)
1833 SiteSurvey_RescanTimerFunc();
1834 m_bRescan = FALSE;
1837 if (OidQueryInformation(OID_GEN_MEDIA_CONNECT_STATUS, m_nSocketId, m_strDeviceName, &ConnectStatus, sizeof(ConnectStatus)) >= 0)
1839 if(ConnectStatus == NdisMediaStateConnected && G_bRadio)
1841 m_nTimerCount = 0;
1842 m_bRescan = TRUE;
1844 memset(&SsidQuery, 0x00, sizeof(SsidQuery));
1845 OidQueryInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SsidQuery, sizeof(SsidQuery));
1847 if (SsidQuery.SsidLength == 0)
1849 memset(&BssidQuery, 0x00, sizeof(BssidQuery));
1850 OidQueryInformation(OID_802_11_BSSID, m_nSocketId, m_strDeviceName, &BssidQuery, sizeof(BssidQuery));
1851 sprintf(msg, "Connected <--> [%02X:%02X:%02X:%02X:%02X:%02X]",
1852 BssidQuery[0], BssidQuery[1], BssidQuery[2],
1853 BssidQuery[3], BssidQuery[4], BssidQuery[5]);
1855 else
1857 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
1858 memcpy(strSSID, SsidQuery.Ssid, SsidQuery.SsidLength);
1859 sprintf(msg, "Connected <--> %s", strSSID);
1862 SiteSurvey_LineEdit_Status->setText(msg);
1864 else
1866 if (G_bRadio)
1868 if (m_nTimerCount == 1)
1869 m_bRescan = TRUE;
1870 if ((m_nTimerCount % 30) == 0)
1871 OidSetInformation(OID_802_11_BSSID_LIST_SCAN, m_nSocketId, m_strDeviceName, 0, 0);
1872 else
1874 SiteSurvey_LineEdit_Status->setText("Disconnected");
1875 // if Site Survey connect failed then try reconnect
1876 if (m_bSetSsid)
1877 OidSetInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &m_SsidSet, sizeof(m_SsidSet));
1878 else if (m_bSetBssid)
1880 OidSetInformation(OID_802_11_BSSID, m_nSocketId, m_strDeviceName, &m_BssidSet, sizeof(m_BssidSet));
1881 if(m_nTimerCount >= 5)
1883 m_bSetBssid = FALSE;
1884 m_bSetSsid = TRUE;
1888 m_nTimerCount++;
1890 else
1891 SiteSurvey_LineEdit_Status->setText("Radio Status <--> OFF");
1894 else
1895 SiteSurvey_LineEdit_Status->setText("Disconnected");
1898 SiteSurvey_UpdateConnectStatus(ConnectStatus);
1901 void RaConfigForm::SiteSurvey_OnRescan()
1903 killTimer(timerId_ConnectStatus);
1904 timerId_ConnectStatus = -1;
1906 SiteSurvey_LineEdit_Status->setText("Rescanning");
1908 SiteSurvey_PushButton_Rescan->setEnabled(FALSE);
1909 SiteSurvey_PushButton_Connect->setEnabled(FALSE);
1910 SiteSurvey_PushButton_AddProfile->setEnabled(FALSE);
1912 OidSetInformation(OID_802_11_BSSID_LIST_SCAN, m_nSocketId, m_strDeviceName, 0, 0);
1913 timerId_ConnectStatus = startTimer(2000);
1914 m_bRescan = TRUE;
1917 void RaConfigForm::SiteSurvey_RescanTimerFunc()
1919 QListViewItem *ListItem;
1920 PNDIS_WLAN_BSSID_EX pBssid;
1921 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
1922 QString qstrBssid;
1923 QString qstrRSSI;
1924 QString qstrChannel;
1925 ULONG lBufLen = 65536; // 64K
1926 ULONG i;
1927 UINT nSigQua;
1928 int nChannel;
1929 int j;
1931 SiteSurvey_ListView->clear();
1933 if (OidQueryInformation(OID_802_11_BSSID_LIST, m_nSocketId, m_strDeviceName, m_pBssidList, lBufLen) < 0)
1934 { //failed
1935 memset(m_pBssidList, 0x00, lBufLen);
1936 return;
1939 pBssid = (PNDIS_WLAN_BSSID_EX) m_pBssidList->Bssid;
1940 for (i = 0; i < m_pBssidList->NumberOfItems; i++)
1942 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
1943 memcpy(strSSID, pBssid->Ssid.Ssid, pBssid->Ssid.SsidLength);
1945 qstrBssid.sprintf("%02X-%02X-%02X-%02X-%02X-%02X",
1946 pBssid->MacAddress[0], pBssid->MacAddress[1], pBssid->MacAddress[2],
1947 pBssid->MacAddress[3], pBssid->MacAddress[4], pBssid->MacAddress[5]);
1949 nSigQua = ConvertRssiToSignalQuality(pBssid->Rssi);
1951 qstrRSSI.sprintf("%d%%", nSigQua);
1953 nChannel = -1;
1955 for(j = 0; j < G_nChanFreqCount; j++)
1957 if(pBssid->Configuration.DSConfig == ChannelFreqTable[j].lFreq)
1959 nChannel = ChannelFreqTable[j].lChannel;
1960 break;
1964 if(nChannel == -1)
1965 continue;
1967 qstrChannel.sprintf("%u", nChannel);
1969 // Insert the item, select every other item.
1970 ListItem=new QListViewItem(SiteSurvey_ListView);
1971 // Set subitem 0
1972 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("uncheck16.xpm"));
1973 ListItem->setText(0, strSSID);
1974 // Set subitem 1
1975 ListItem->setText(1, qstrBssid);
1976 // Set subitem 2
1977 ListItem->setText(2, qstrRSSI);
1978 // Set subitem 3
1979 ListItem->setText(3, qstrChannel);
1980 // Set subitem 4
1981 if (pBssid->Privacy)
1982 ListItem->setText(4, strAryEncryption[0]);
1983 else
1984 ListItem->setText(4, strAryEncryption[1]);
1985 // Set subitem 5
1986 ListItem->setText(5, "Unknown");
1987 // Set subitem 6
1988 ListItem->setText(6, strAryNetworkType[pBssid->InfrastructureMode]);
1990 // work with NDIS_WLAN_BSSID_EX
1991 if ((pBssid->Length > sizeof(NDIS_WLAN_BSSID)) && (pBssid->IELength > sizeof(NDIS_802_11_FIXED_IEs)))
1993 ULONG lIELoc = 0;
1994 PNDIS_802_11_FIXED_IEs pFixIE = (PNDIS_802_11_FIXED_IEs)pBssid->IEs;
1995 PNDIS_802_11_VARIABLE_IEs pVarIE = (PNDIS_802_11_VARIABLE_IEs)((char*)pFixIE + sizeof(NDIS_802_11_FIXED_IEs));
1996 lIELoc += sizeof(NDIS_802_11_FIXED_IEs);
1997 while (pBssid->IELength > (lIELoc + sizeof(NDIS_802_11_VARIABLE_IEs)))
1999 if ((pVarIE->ElementID == 221) && (pVarIE->Length >= 16))
2001 ULONG* pOUI = (ULONG*)((char*)pVarIE + 2);
2002 if(*pOUI != WPA_OUI_TYPE)
2003 break;
2004 ULONG* plGroupKey;
2005 WORD* pdPairKeyCount;
2006 ULONG* plAuthenKey;
2007 WORD* pdAuthenKeyCount;
2008 plGroupKey = (ULONG*)((char*)pVarIE + 8);
2010 ULONG lGroupKey = *plGroupKey & 0x00ffffff;
2011 if (lGroupKey == WPA_OUI)
2013 lGroupKey = (*plGroupKey & 0xff000000) >> 0x18;
2014 if (lGroupKey == 2)
2015 ListItem->setText(4, "TKIP");
2016 else if (lGroupKey == 3)
2017 ListItem->setText(4, "AES-WRAP");
2018 else if (lGroupKey == 4)
2019 ListItem->setText(4, "AES-CCMP");
2021 else
2022 break;
2024 pdPairKeyCount = (WORD*)((char*)plGroupKey + 4);
2025 pdAuthenKeyCount = (WORD*)((char*)pdPairKeyCount + 2 + 4 * (*pdPairKeyCount));
2026 if (*pdAuthenKeyCount > 0)
2028 plAuthenKey = (ULONG*)((char*)pdAuthenKeyCount + 2);
2030 ULONG lAuthenKey = *plAuthenKey & 0x00ffffff;
2031 if (lAuthenKey == WPA_OUI)
2033 lAuthenKey = (*plAuthenKey & 0xff000000) >> 0x18;
2034 if (lAuthenKey == 1)
2035 ListItem->setText(5, "WPA");
2036 else if (lAuthenKey == 2)
2038 if (pBssid->InfrastructureMode)
2039 ListItem->setText(5, "WPAPSK");
2040 else
2041 ListItem->setText(5, "WPA-None");
2045 break;
2047 lIELoc += pVarIE->Length;
2048 pVarIE = (PNDIS_802_11_VARIABLE_IEs)((char*)pVarIE + pVarIE->Length);
2050 if(pVarIE->Length <= 0)
2051 break;
2054 pBssid = (PNDIS_WLAN_BSSID_EX)((char *)pBssid + pBssid->Length);
2058 bool RaConfigForm::SiteSurvey_ResetOidValue(NDIS_802_11_NETWORK_INFRASTRUCTURE enumInfrastructureMode)
2060 RT_802_11_PREAMBLE enumPreamType = Rt802_11PreambleAuto;
2061 NDIS_802_11_RTS_THRESHOLD lRtsThre = MAX_RTS_THRESHOLD;
2062 NDIS_802_11_FRAGMENTATION_THRESHOLD lFragThre = 0;
2063 NDIS_802_11_TX_POWER_LEVEL lTransPower = MAX_TX_POWER_LEVEL;
2064 NDIS_802_11_POWER_MODE enumPSMode = Ndis802_11PowerModeCAM;
2066 OidSetInformation(RT_OID_802_11_PREAMBLE, m_nSocketId, m_strDeviceName, &enumPreamType, sizeof(enumPreamType));
2068 OidSetInformation(OID_802_11_TX_POWER_LEVEL, m_nSocketId, m_strDeviceName, &lTransPower, sizeof(lTransPower));
2070 OidSetInformation(OID_802_11_RTS_THRESHOLD, m_nSocketId, m_strDeviceName, &lRtsThre, sizeof(lRtsThre));
2072 OidSetInformation(OID_802_11_FRAGMENTATION_THRESHOLD, m_nSocketId, m_strDeviceName, &lFragThre, sizeof(lFragThre));
2074 if (enumInfrastructureMode == Ndis802_11Infrastructure)
2076 OidSetInformation(OID_802_11_POWER_MODE, m_nSocketId, m_strDeviceName, &enumPSMode, sizeof(enumPSMode));
2078 else if (enumInfrastructureMode == Ndis802_11IBSS)
2080 ; //do nothing
2083 return TRUE;
2086 void RaConfigForm::SiteSurvey_UpdateConnectStatus(NDIS_MEDIA_STATE ConnectStatus)
2088 QListViewItem *ListItem;
2089 QString qstrBssid;
2090 NDIS_802_11_MAC_ADDRESS BssidQuery;
2091 NDIS_802_11_MAC_ADDRESS Bssid;
2092 int nItem;
2093 int i,j;
2096 memset(&BssidQuery, 0x00, sizeof(BssidQuery));
2097 OidQueryInformation(OID_802_11_BSSID, m_nSocketId, m_strDeviceName, &BssidQuery, sizeof(BssidQuery));
2099 nItem = SiteSurvey_ListView->childCount();
2100 ListItem = SiteSurvey_ListView->firstChild();
2101 for (i = 0; i < nItem; i++)
2103 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("uncheck16.xpm"));
2104 if(ConnectStatus == NdisMediaStateConnected && G_bRadio)
2106 qstrBssid = ListItem->text(1);
2107 j = 0;
2108 while ( ( j = qstrBssid.find( '-', j ) ) != -1 )
2109 qstrBssid.remove( j ,1 );
2111 AtoH((char *)qstrBssid.data(), Bssid, 6);
2112 if(memcmp(BssidQuery, Bssid, 6) == 0)
2114 ListItem->setPixmap(0, uic_load_pixmap_RaConfigForm("handshak16.xpm"));
2115 m_bRescan = FALSE;
2118 ListItem = ListItem->itemBelow();
2121 if (m_bUpdateProfilePage)
2123 m_bUpdateProfilePage = FALSE;
2124 Profile_UpdateProfileStatus();
2127 if (m_bUpdateLinkSatusPage)
2129 m_bUpdateLinkSatusPage = FALSE;
2130 LinkStatus_UpdateStatus();
2135 void RaConfigForm::SiteSurvey_OnConnect()
2137 QListViewItem *CurSelItem;
2138 PNDIS_WLAN_BSSID_EX pBssid;
2139 NDIS_802_11_MAC_ADDRESS CurBssid;
2140 NDIS_802_11_AUTHENTICATION_MODE AuthenticationMode = Ndis802_11AuthModeOpen;
2141 NDIS_802_11_ENCRYPTION_STATUS EncryptType = Ndis802_11WEPDisabled;
2142 NDIS_802_11_AUTHENTICATION_MODE EncryStatus;
2143 NDIS_802_11_REMOVE_KEY removeKey;
2144 PNDIS_802_11_KEY pKey = NULL;
2145 QString qstrAuthen;
2146 QString qstrEncrypt;
2147 QString qstrBssid;
2148 QString strPsk;
2149 QString strKey;
2150 ULONG index;
2151 ULONG nKeyLen;
2152 ULONG lBufLen;
2153 UCHAR keyMaterial[40];
2154 int i = 0;
2155 bool bfound = FALSE;
2156 bool bHiddenSsid = FALSE;
2158 if (!G_bUserAdmin)
2160 QMessageBox::information(this, "Information", "You do not have supper user's privilege!");
2161 return;
2164 CurSelItem = SiteSurvey_ListView->selectedItem();
2165 if(!CurSelItem)
2167 QMessageBox::warning(this, "Warning", "No selected Item!");
2168 return;
2171 if (!m_pBssidList)
2172 return;
2174 // Not support WPA yet
2175 EncryStatus = SiteSurvey_GetEncryStatus();
2176 if (EncryStatus == Ndis802_11AuthModeWPA)
2177 return;
2179 killTimer(timerId_ConnectStatus);
2180 timerId_ConnectStatus = -1;
2182 qstrBssid = CurSelItem->text(1);
2183 while ( ( i = qstrBssid.find( '-', i ) ) != -1 )
2184 qstrBssid.remove( i ,1 );
2186 AtoH((char *)qstrBssid.data(), CurBssid, 6);
2188 pBssid = (PNDIS_WLAN_BSSID_EX)m_pBssidList->Bssid;
2189 //for (i = 0; i < m_nCurSelItem; i++)
2190 for (index = 0; index < m_pBssidList->NumberOfItems; index++)
2192 if(memcmp(pBssid->MacAddress, CurBssid, 6) == 0)
2194 bfound = TRUE;
2195 break;
2197 pBssid = (PNDIS_WLAN_BSSID_EX)((char *)pBssid + pBssid->Length);
2200 if (!bfound)
2201 return;
2203 if (pBssid->Ssid.SsidLength == 0)
2205 HiddenSsidDlg *pHiddendlg = new HiddenSsidDlg(this, "HiddenSsid", TRUE);
2206 QString qstrSsid;
2208 pHiddendlg->exec();
2209 if (pHiddendlg->IsClickOk())
2211 bHiddenSsid = TRUE;
2212 qstrSsid = pHiddendlg->GetSsidString();
2213 m_SsidSet.SsidLength = qstrSsid.length();
2214 memcpy(m_SsidSet.Ssid, qstrSsid.data(), m_SsidSet.SsidLength);
2216 else
2217 return;
2220 // Reset all configuration value
2221 SiteSurvey_ResetOidValue(pBssid->InfrastructureMode);
2223 // Set Infrastructure Mode
2224 OidSetInformation(OID_802_11_INFRASTRUCTURE_MODE, m_nSocketId, m_strDeviceName, &pBssid->InfrastructureMode, sizeof(pBssid->InfrastructureMode));
2226 // Set Wep Status
2227 if (pBssid->Privacy)
2229 AuthSecuDlg *pAuthSecuDlg = new AuthSecuDlg(this, "AuthSecuDlg", TRUE);
2231 qstrAuthen = CurSelItem->text(5);
2232 qstrEncrypt = CurSelItem->text(4);
2234 if (qstrAuthen.compare("Unknown") == 0)
2236 if (qstrEncrypt.compare("WEP") == 0)
2238 EncryptType = Ndis802_11WEPEnabled;
2239 AuthenticationMode = Ndis802_11AuthModeOpen;
2242 else if (qstrAuthen.compare("WPAPSK") == 0)
2244 AuthenticationMode = Ndis802_11AuthModeWPAPSK;
2245 if (qstrEncrypt.compare("TKIP") == 0)
2246 EncryptType = Ndis802_11Encryption2Enabled;
2247 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2248 EncryptType = Ndis802_11Encryption3Enabled;
2249 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2250 EncryptType = Ndis802_11Encryption3Enabled;
2252 else if (qstrAuthen.compare("WPA-None") == 0)
2254 AuthenticationMode = Ndis802_11AuthModeWPANone;
2255 if (qstrEncrypt.compare("TKIP") == 0)
2256 EncryptType = Ndis802_11Encryption2Enabled;
2257 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2258 EncryptType = Ndis802_11Encryption3Enabled;
2259 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2260 EncryptType = Ndis802_11Encryption3Enabled;
2262 else if (qstrAuthen.compare("WPA") == 0)
2264 AuthenticationMode = Ndis802_11AuthModeWPA;
2265 if (qstrEncrypt.compare("TKIP") == 0)
2266 EncryptType = Ndis802_11Encryption2Enabled;
2267 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2268 EncryptType = Ndis802_11Encryption3Enabled;
2269 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2270 EncryptType = Ndis802_11Encryption3Enabled;
2273 pAuthSecuDlg->Security_SetAuthModeAndEncryType(AuthenticationMode, EncryptType);
2274 pAuthSecuDlg->exec();
2276 if (pAuthSecuDlg->Security_IsClickOk() == FALSE)
2277 return; //Do nothing
2279 AuthenticationMode = pAuthSecuDlg->Security_GetAuthticationMode();
2280 EncryptType = pAuthSecuDlg->Security_GetEncryptType();
2282 if ( AuthenticationMode >= Ndis802_11AuthModeAutoSwitch)
2284 nKeyLen = 32;
2285 lBufLen = (sizeof(NDIS_802_11_KEY) + nKeyLen - 1);
2286 // Allocate Resouce
2287 pKey = (PNDIS_802_11_KEY)malloc(lBufLen); // Don't use GMEM_ZEROINIT to get random key
2288 pKey->Length = lBufLen;
2289 pKey->KeyLength = nKeyLen;
2290 pKey->KeyIndex = 0x80000000;
2292 strPsk = pAuthSecuDlg->Security_GetPSKString();
2294 if (bHiddenSsid)
2295 PasswordHash((char *)strPsk.data(), m_SsidSet.Ssid, m_SsidSet.SsidLength, keyMaterial);
2296 else
2297 PasswordHash((char *)strPsk.data(), pBssid->Ssid.Ssid, pBssid->Ssid.SsidLength, keyMaterial);
2299 memcpy(pKey->KeyMaterial, keyMaterial, 32);
2301 // Set Authentication Mode
2302 if(pBssid->InfrastructureMode == Ndis802_11Infrastructure)
2303 AuthenticationMode = Ndis802_11AuthModeWPAPSK;
2304 else
2305 AuthenticationMode = Ndis802_11AuthModeWPANone;
2307 OidSetInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &AuthenticationMode, sizeof(AuthenticationMode));
2309 OidSetInformation(OID_802_11_ENCRYPTION_STATUS, m_nSocketId, m_strDeviceName, &EncryptType, sizeof(EncryptType));
2310 // Add Key
2311 OidSetInformation(RT_OID_802_11_ADD_WPA, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
2313 // Free Resouce
2314 free(pKey);
2316 else if ((AuthenticationMode == Ndis802_11AuthModeShared) || (EncryptType == Ndis802_11WEPEnabled))
2318 // Set Authentication Mode
2319 OidSetInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &AuthenticationMode, sizeof(AuthenticationMode));
2321 // Set Encryption Status
2322 OidSetInformation(OID_802_11_ENCRYPTION_STATUS, m_nSocketId, m_strDeviceName, &EncryptType, sizeof(EncryptType));
2324 //----------------------------------------------------------//
2325 //Key 1
2326 //----------------------------------------------------------//
2327 strKey = pAuthSecuDlg->Security_GetWepKeyString(0);
2328 nKeyLen = strKey.length();
2329 if(nKeyLen == 0)
2331 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
2332 removeKey.KeyIndex = 0;
2333 for(i = 0; i < 6; i++)
2334 removeKey.BSSID[i] = 0xff;
2335 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
2337 else
2339 if(nKeyLen == 10)
2340 nKeyLen = 5;
2341 else if(nKeyLen == 26)
2342 nKeyLen = 13;
2344 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
2345 // Allocate Resource
2346 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
2347 pKey->Length = lBufLen;
2348 pKey->KeyLength = nKeyLen;
2349 pKey->KeyIndex = 0;
2350 if(pAuthSecuDlg->Security_GetDefaultKeyId() == 0)
2351 pKey->KeyIndex |= 0x80000000;
2352 for(i = 0; i < 6; i++)
2353 pKey->BSSID[i] = 0xff;
2355 if(strKey.length() == 5)
2356 memcpy(pKey->KeyMaterial, strKey.data(), 5);
2357 else if(strKey.length() == 10)
2358 AtoH((char *)strKey.data(), pKey->KeyMaterial, 5);
2359 else if(strKey.length() == 13)
2360 memcpy(pKey->KeyMaterial, strKey.data(), 13);
2361 else if(strKey.length() == 26)
2362 AtoH((char *)strKey.data(), pKey->KeyMaterial, 13);
2364 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
2365 free(pKey);
2367 //----------------------------------------------------------//
2368 //Key 2
2369 //----------------------------------------------------------//
2370 strKey = pAuthSecuDlg->Security_GetWepKeyString(1);
2371 nKeyLen = strKey.length();
2372 if(nKeyLen == 0)
2374 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
2375 removeKey.KeyIndex = 1;
2376 for(i = 0; i < 6; i++)
2377 removeKey.BSSID[i] = 0xff;
2378 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
2380 else
2382 if(nKeyLen == 10)
2383 nKeyLen = 5;
2384 else if(nKeyLen == 26)
2385 nKeyLen = 13;
2387 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
2388 // Allocate Resource
2389 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
2390 pKey->Length = lBufLen;
2391 pKey->KeyLength = nKeyLen;
2392 pKey->KeyIndex = 1;
2393 if(pAuthSecuDlg->Security_GetDefaultKeyId() == 1)
2394 pKey->KeyIndex |= 0x80000000;
2395 for(i = 0; i < 6; i++)
2396 pKey->BSSID[i] = 0xff;
2398 if(strKey.length() == 5)
2399 memcpy(pKey->KeyMaterial, strKey.data(), 5);
2400 else if(strKey.length() == 10)
2401 AtoH((char *)strKey.data(), pKey->KeyMaterial, 5);
2402 else if(strKey.length() == 13)
2403 memcpy(pKey->KeyMaterial, strKey.data(), 13);
2404 else if(strKey.length() == 26)
2405 AtoH((char *)strKey.data(), pKey->KeyMaterial, 13);
2407 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
2408 free(pKey);
2410 //----------------------------------------------------------//
2411 //Key 3
2412 //----------------------------------------------------------//
2413 strKey = pAuthSecuDlg->Security_GetWepKeyString(2);
2414 nKeyLen = strKey.length();
2415 if(nKeyLen == 0)
2417 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
2418 removeKey.KeyIndex = 2;
2419 for(i = 0; i < 6; i++)
2420 removeKey.BSSID[i] = 0xff;
2421 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
2423 else
2425 if(nKeyLen == 10)
2426 nKeyLen = 5;
2427 else if(nKeyLen == 26)
2428 nKeyLen = 13;
2430 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
2431 // Allocate Resource
2432 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
2433 pKey->Length = lBufLen;
2434 pKey->KeyLength = nKeyLen;
2435 pKey->KeyIndex = 2;
2436 if(pAuthSecuDlg->Security_GetDefaultKeyId() == 2)
2437 pKey->KeyIndex |= 0x80000000;
2438 for(i = 0; i < 6; i++)
2439 pKey->BSSID[i] = 0xff;
2441 if(strKey.length() == 5)
2442 memcpy(pKey->KeyMaterial, strKey.data(), 5);
2443 else if(strKey.length() == 10)
2444 AtoH((char *)strKey.data(), pKey->KeyMaterial, 5);
2445 else if(strKey.length() == 13)
2446 memcpy(pKey->KeyMaterial, strKey.data(), 13);
2447 else if(strKey.length() == 26)
2448 AtoH((char *)strKey.data(), pKey->KeyMaterial, 13);
2450 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
2451 free(pKey);
2453 //----------------------------------------------------------//
2454 //Key 4
2455 //----------------------------------------------------------//
2456 strKey = pAuthSecuDlg->Security_GetWepKeyString(3);
2457 nKeyLen = strKey.length();
2458 if(nKeyLen == 0)
2460 removeKey.Length = sizeof(NDIS_802_11_REMOVE_KEY);
2461 removeKey.KeyIndex = 3;
2462 for(i = 0; i < 6; i++)
2463 removeKey.BSSID[i] = 0xff;
2464 OidSetInformation(OID_802_11_REMOVE_KEY, m_nSocketId, m_strDeviceName, &removeKey, removeKey.Length);
2466 else
2468 if(nKeyLen == 10)
2469 nKeyLen = 5;
2470 else if(nKeyLen == 26)
2471 nKeyLen = 13;
2473 lBufLen = sizeof(NDIS_802_11_KEY) + nKeyLen - 1;
2474 // Allocate Resource
2475 pKey = (PNDIS_802_11_KEY)malloc(lBufLen);
2476 pKey->Length = lBufLen;
2477 pKey->KeyLength = nKeyLen;
2478 pKey->KeyIndex = 3;
2479 if(pAuthSecuDlg->Security_GetDefaultKeyId() == 3)
2480 pKey->KeyIndex |= 0x80000000;
2481 for(i = 0; i < 6; i++)
2482 pKey->BSSID[i] = 0xff;
2484 if(strKey.length() == 5)
2485 memcpy(pKey->KeyMaterial, strKey.data(), 5);
2486 else if(strKey.length() == 10)
2487 AtoH((char *)strKey.data(), pKey->KeyMaterial, 5);
2488 else if(strKey.length() == 13)
2489 memcpy(pKey->KeyMaterial, strKey.data(), 13);
2490 else if(strKey.length() == 26)
2491 AtoH((char *)strKey.data(), pKey->KeyMaterial, 13);
2493 OidSetInformation(OID_802_11_ADD_KEY, m_nSocketId, m_strDeviceName, pKey, pKey->Length);
2494 free(pKey);
2497 else
2499 // Set Authentication Mode
2500 OidSetInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &AuthenticationMode, sizeof(AuthenticationMode));
2502 // Set Encryption Status
2503 OidSetInformation(OID_802_11_ENCRYPTION_STATUS, m_nSocketId, m_strDeviceName, &EncryptType, sizeof(EncryptType));
2506 else
2508 // Set Authentication Mode
2509 OidSetInformation(OID_802_11_AUTHENTICATION_MODE, m_nSocketId, m_strDeviceName, &AuthenticationMode, sizeof(AuthenticationMode));
2511 // Set Encryption Status
2512 OidSetInformation(OID_802_11_ENCRYPTION_STATUS, m_nSocketId, m_strDeviceName, &EncryptType, sizeof(EncryptType));
2515 SiteSurvey_LineEdit_Status->setText("Connecting");
2518 if (!bHiddenSsid)
2519 memcpy(&m_SsidSet, &pBssid->Ssid, sizeof(NDIS_802_11_SSID)); // Prepare SSID for retry after retry 5 times BSSID
2521 if ((pBssid->InfrastructureMode == Ndis802_11IBSS) || bHiddenSsid) // Ad hoc use SSID
2523 // Set SSID
2524 OidSetInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &m_SsidSet, sizeof(m_SsidSet));
2525 m_bSetSsid = TRUE;
2526 m_bSetBssid = FALSE;
2528 else
2530 memcpy(m_BssidSet, pBssid->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS));
2531 // Set BSSID
2532 OidSetInformation(OID_802_11_BSSID, m_nSocketId, m_strDeviceName, m_BssidSet, sizeof(NDIS_802_11_MAC_ADDRESS));
2533 m_bSetBssid = TRUE;
2534 m_bSetSsid = FALSE;
2537 m_bUpdateProfilePage = TRUE;
2538 m_bUpdateLinkSatusPage = TRUE;
2539 timerId_ConnectStatus = startTimer(2000);
2542 void RaConfigForm::SiteSurvey_ButtonShowHide()
2544 NDIS_802_11_AUTHENTICATION_MODE EncrypType;
2546 if (G_bRadio)
2547 SiteSurvey_PushButton_Rescan->setEnabled( TRUE );
2548 else
2549 SiteSurvey_PushButton_Rescan->setEnabled( FALSE );
2551 EncrypType = SiteSurvey_GetEncryStatus();
2552 if ((!G_bRadio) || (SiteSurvey_ListView->childCount() <= 0) ||
2553 (EncrypType == Ndis802_11AuthModeAutoSwitch) ||
2554 (EncrypType == Ndis802_11AuthModeWPA) ||
2555 (EncrypType == Ndis802_11AuthModeWPANone) ||
2556 (EncrypType == Ndis802_11AuthModeMax))
2558 SiteSurvey_PushButton_Connect->setEnabled( FALSE );
2559 SiteSurvey_PushButton_AddProfile->setEnabled( FALSE );
2561 else
2563 if(G_bUserAdmin)
2565 SiteSurvey_PushButton_Connect->setEnabled( TRUE );
2566 SiteSurvey_PushButton_AddProfile->setEnabled( TRUE );
2568 else
2570 SiteSurvey_PushButton_Connect->setEnabled( FALSE );
2571 SiteSurvey_PushButton_AddProfile->setEnabled( FALSE );
2577 NDIS_802_11_AUTHENTICATION_MODE RaConfigForm::SiteSurvey_GetEncryStatus()
2579 QListViewItem *selectedItem;
2580 QString qstrAuthenMode;
2581 QString qstrEncrypType;
2582 NDIS_802_11_AUTHENTICATION_MODE status = Ndis802_11AuthModeWPANone;
2584 selectedItem = SiteSurvey_ListView->selectedItem();
2585 if (!selectedItem)
2586 return (status);
2588 qstrAuthenMode = selectedItem->text(5);
2589 qstrEncrypType = selectedItem->text(4);
2590 if (qstrAuthenMode.compare("Unknown") == 0)
2592 if (qstrEncrypType.compare("WEP") == 0)
2593 status = Ndis802_11AuthModeOpen;
2594 else if (qstrEncrypType.compare("Not Use") == 0)
2595 status = Ndis802_11AuthModeOpen;
2597 else if (qstrAuthenMode.compare("Shared Key") == 0)
2598 status = Ndis802_11AuthModeShared;
2599 else if (qstrAuthenMode.compare("WPA") == 0)
2600 status = Ndis802_11AuthModeWPA;
2601 else if (qstrAuthenMode.compare("WPAPSK") == 0)
2602 status = Ndis802_11AuthModeWPAPSK;
2603 else if (qstrAuthenMode.compare("WPA-None") == 0)
2604 status = Ndis802_11AuthModeWPANone;
2605 else
2606 status = Ndis802_11AuthModeMax;
2608 return (status);
2611 void RaConfigForm::SiteSurvey_OnAddToProfile()
2613 AddProfileDlg *pAddProfileDlg;
2614 QListViewItem *selectedItem;
2615 PNDIS_WLAN_BSSID_EX pBssid;
2616 NDIS_802_11_MAC_ADDRESS CurBssid;
2617 NDIS_802_11_AUTHENTICATION_MODE AuthenticationMode = Ndis802_11AuthModeOpen;
2618 NDIS_802_11_ENCRYPTION_STATUS EncryptType = Ndis802_11WEPDisabled;
2619 QString qstrSsid;
2620 QString qstrBssid;
2621 QString qstrAuthen;
2622 QString qstrEncrypt;
2623 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
2624 ULONG index;
2625 int nChannel;
2626 int i = 0;
2627 bool bfound = FALSE;
2628 bool bHiddenSsid = FALSE;
2630 if (!G_bUserAdmin)
2631 return;
2633 selectedItem = SiteSurvey_ListView->selectedItem();
2634 if (!selectedItem)
2636 QMessageBox::warning(this, "Warning", "No selected Item!");
2637 return;
2640 if (!m_pBssidList)
2641 return;
2643 qstrBssid = selectedItem->text(1);
2644 while ( ( i = qstrBssid.find( '-', i ) ) != -1 )
2645 qstrBssid.remove( i ,1 );
2647 AtoH((char *)qstrBssid.data(), CurBssid, 6);
2649 pBssid = (PNDIS_WLAN_BSSID_EX) m_pBssidList->Bssid;
2650 for (index = 0; index < m_pBssidList->NumberOfItems; index++)
2652 if (memcmp(pBssid->MacAddress, CurBssid, 6) == 0)
2654 bfound = TRUE;
2655 break;
2657 pBssid = (PNDIS_WLAN_BSSID_EX)((char *)pBssid + pBssid->Length);
2660 if (!bfound)
2661 return;
2663 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
2664 memcpy(strSSID, pBssid->Ssid.Ssid, pBssid->Ssid.SsidLength);
2666 nChannel = -1;
2668 for (i = 0; i < G_nChanFreqCount; i++)
2670 if (pBssid->Configuration.DSConfig == ChannelFreqTable[i].lFreq)
2672 nChannel = ChannelFreqTable[i].lChannel;
2673 break;
2677 if(nChannel == -1)
2678 return;
2680 qstrAuthen = selectedItem->text(5);
2681 qstrEncrypt = selectedItem->text(4);
2683 if (qstrAuthen.compare("Unknown") == 0)
2685 if (qstrEncrypt.compare("WEP") == 0)
2687 EncryptType = Ndis802_11WEPEnabled;
2688 AuthenticationMode = Ndis802_11AuthModeOpen;
2691 else if (qstrAuthen.compare("WPAPSK") == 0)
2693 AuthenticationMode = Ndis802_11AuthModeWPAPSK;
2694 if (qstrEncrypt.compare("TKIP") == 0)
2695 EncryptType = Ndis802_11Encryption2Enabled;
2696 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2697 EncryptType = Ndis802_11Encryption3Enabled;
2698 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2699 EncryptType = Ndis802_11Encryption3Enabled;
2701 else if (qstrAuthen.compare("WPA-None") == 0)
2703 AuthenticationMode = Ndis802_11AuthModeWPANone;
2704 if (qstrEncrypt.compare("TKIP") == 0)
2705 EncryptType = Ndis802_11Encryption2Enabled;
2706 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2707 EncryptType = Ndis802_11Encryption3Enabled;
2708 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2709 EncryptType = Ndis802_11Encryption3Enabled;
2711 else if (qstrAuthen.compare("WPA") == 0)
2713 AuthenticationMode = Ndis802_11AuthModeWPA;
2714 if (qstrEncrypt.compare("TKIP") == 0)
2715 EncryptType = Ndis802_11Encryption2Enabled;
2716 else if (qstrEncrypt.compare("AES-WRAP") == 0)
2717 EncryptType = Ndis802_11Encryption3Enabled;
2718 else if (qstrEncrypt.compare("AES-CCMP") == 0)
2719 EncryptType = Ndis802_11Encryption3Enabled;
2722 if (pBssid->Ssid.SsidLength == 0)
2724 HiddenSsidDlg *pHiddendlg = new HiddenSsidDlg(this, "HiddenSsid", TRUE);
2726 pHiddendlg->exec();
2727 if (pHiddendlg->IsClickOk())
2729 qstrSsid = pHiddendlg->GetSsidString();
2730 bHiddenSsid = TRUE;
2732 else
2733 return;
2736 pAddProfileDlg = new AddProfileDlg(m_nSocketId, m_strDeviceName, this, "AddProfile", PROFILE_ADD, Profile_ListView, &m_pProfileSetting, &CurBssid, TRUE);
2737 if (bHiddenSsid)
2738 pAddProfileDlg->Config_SetCurrentSSID(qstrSsid);
2739 pAddProfileDlg->Security_SetAuthModeAndEncryType(pBssid->InfrastructureMode, AuthenticationMode, EncryptType);
2740 pAddProfileDlg->exec();
2742 if (pAddProfileDlg->IsOk())
2744 Profile_WriteProfileToFile();
2746 if (Profile_ListView->childCount() == 0 )
2748 Profile_PushButton_Delete->setEnabled(FALSE);
2749 Profile_PushButton_Edit->setEnabled(FALSE);
2750 Profile_PushButton_Activate->setEnabled(FALSE);
2752 else
2754 Profile_PushButton_Delete->setEnabled(TRUE);
2755 Profile_PushButton_Edit->setEnabled(TRUE);
2756 Profile_PushButton_Activate->setEnabled(TRUE);
2759 TabWidgetRaConfig->setCurrentPage(0);
2761 delete pAddProfileDlg;
2764 void RaConfigForm::LinkStatus_OnActive()
2766 RT_802_11_LINK_STATUS LinkStatus;
2768 if (OidQueryInformation(RT_OID_802_11_LINK_STATUS, m_nSocketId, m_strDeviceName, &LinkStatus, sizeof(&LinkStatus)) >= 0)
2770 m_lTxCount = LinkStatus.TxByteCount;
2771 m_lRxCount = LinkStatus.RxByteCount;
2774 timerId_LinkStatus = startTimer(2000);
2777 void RaConfigForm::LinkStatus_UpdateStatus()
2779 NDIS_MEDIA_STATE ConnectStatus = NdisMediaStateDisconnected;
2780 NDIS_802_11_SSID SSID;
2781 NDIS_802_11_MAC_ADDRESS Bssid;
2782 NDIS_802_11_CONFIGURATION Configuration;
2783 RT_802_11_LINK_STATUS LinkStatus;
2784 NDIS_802_11_RSSI RSSI;
2785 QString qstrStatus;
2786 QString qstrChannel;
2787 QString qstrTxRate;
2788 QString qstrTxThrougput;
2789 QString qstrRxThrougput;
2790 QString qstrLinkQuality;
2791 QString qstrSignalQuality;
2792 char strSSID[NDIS_802_11_LENGTH_SSID + 1];
2793 unsigned int nSigQua;
2794 int nChannel = -1;
2795 int i;
2797 OidQueryInformation(OID_GEN_MEDIA_CONNECT_STATUS, m_nSocketId, m_strDeviceName, &ConnectStatus, sizeof(ConnectStatus));
2799 if (ConnectStatus == NdisMediaStateConnected)
2801 memset(&SSID, 0x00, sizeof(SSID));
2802 OidQueryInformation(OID_802_11_SSID, m_nSocketId, m_strDeviceName, &SSID, sizeof(SSID));
2804 memset(&Bssid, 0x00, sizeof(Bssid));
2805 OidQueryInformation(OID_802_11_BSSID, m_nSocketId, m_strDeviceName, &Bssid, sizeof(Bssid));
2807 memset(strSSID, 0x00, NDIS_802_11_LENGTH_SSID + 1);
2808 memcpy(strSSID, SSID.Ssid, SSID.SsidLength);
2810 qstrStatus.sprintf("%s <--> %02X-%02X-%02X-%02X-%02X-%02X", strSSID, Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5] );
2811 LinkStatus_TextLabel_Status->setText(qstrStatus);
2813 else
2815 if (G_bRadio)
2816 qstrStatus.sprintf("Disconnected");
2817 else
2818 qstrStatus.sprintf("Radio Status <--> OFF");
2820 LinkStatus_TextLabel_Status->setText(qstrStatus);
2821 LinkStatus_TextLabel_Channel->setText("");
2822 LinkStatus_TextLabel_TxRate->setText("");
2823 LinkStatus_TextLabel_TxThrougput->setText("");
2824 LinkStatus_TextLabel_RxThroughput->setText("");
2825 LinkStatus_TextLabel_Link->setText("");
2826 LinkStatus_TextLabel_Signal->setText("");
2827 LinkStatus_ProgressBar_Link->setProgress(0);
2828 LinkStatus_ProgressBar_Signal->setProgress(0);
2830 return;
2833 // Current Channel
2834 memset(&Configuration, 0x00, sizeof(Configuration));
2835 OidQueryInformation(OID_802_11_CONFIGURATION, m_nSocketId, m_strDeviceName, &Configuration, sizeof(Configuration));
2837 for (i = 0; i < G_nChanFreqCount; i++)
2839 if (Configuration.DSConfig == ChannelFreqTable[i].lFreq)
2841 nChannel = ChannelFreqTable[i].lChannel;
2842 break;
2846 if (nChannel != -1)
2848 qstrChannel.sprintf("%u <--> %ld KHz", nChannel, Configuration.DSConfig);
2849 LinkStatus_TextLabel_Channel->setText(qstrChannel);
2852 memset(&LinkStatus, 0x00, sizeof(LinkStatus));
2853 if (OidQueryInformation(RT_OID_802_11_LINK_STATUS, m_nSocketId, m_strDeviceName, &LinkStatus, sizeof(LinkStatus)) >= 0)
2855 // Current Tx Rate LinkStatus.CurrTxRate / 2(secs)
2856 if ((LinkStatus.CurrTxRate % 2) == 0)
2857 qstrTxRate.sprintf("%ld Mbps", LinkStatus.CurrTxRate / 2);
2858 else
2859 qstrTxRate.sprintf("%.1f Mbps", double(LinkStatus.CurrTxRate) / 2 );
2861 LinkStatus_TextLabel_TxRate->setText(qstrTxRate);
2862 // Tx Throughput (KBits/sec) (LinkStatus.TxByteCount - m_lTxCount) * 8(bits) /1000 / 2(secs)
2863 qstrTxThrougput.sprintf("%.1f", (double)(LinkStatus.TxByteCount - m_lTxCount) / 250);
2864 LinkStatus_TextLabel_TxThrougput->setText(qstrTxThrougput);
2865 m_lTxCount = LinkStatus.TxByteCount;
2867 // Rx Throughput (KBits/sec) (LinkStatus.RxByteCount - m_lRxCount) * 8(bits) /1000 / 2(secs)
2868 qstrRxThrougput.sprintf("%.1f", (double)(LinkStatus.RxByteCount - m_lRxCount) / 250);
2869 LinkStatus_TextLabel_RxThroughput->setText(qstrRxThrougput);
2870 m_lRxCount = LinkStatus.RxByteCount;
2872 // Link Quality
2873 LinkStatus.ChannelQuality = (ULONG)(LinkStatus.ChannelQuality * 1.2 + 10);
2874 if (LinkStatus.ChannelQuality > 100)
2875 LinkStatus.ChannelQuality = 100;
2877 if (m_lChannelQuality != 0)
2878 LinkStatus.ChannelQuality = (ULONG)((m_lChannelQuality + LinkStatus.ChannelQuality) / 2.0 + 0.5);
2880 m_lChannelQuality = LinkStatus.ChannelQuality;
2882 if (LinkStatus.ChannelQuality > 70)
2883 qstrLinkQuality.sprintf("Good %ld%%", LinkStatus.ChannelQuality);
2884 else if(LinkStatus.ChannelQuality > 40)
2885 qstrLinkQuality.sprintf("Normal %ld%%", LinkStatus.ChannelQuality);
2886 else
2887 qstrLinkQuality.sprintf("Weak %ld%%", LinkStatus.ChannelQuality);
2889 LinkStatus_TextLabel_Link->setText(qstrLinkQuality);
2890 LinkStatus_ProgressBar_Link->setProgress(LinkStatus.ChannelQuality);
2894 // Signal Strength
2895 memset(&RSSI, 0x00, sizeof(RSSI));
2896 if (OidQueryInformation(OID_802_11_RSSI, m_nSocketId, m_strDeviceName, &RSSI, sizeof(RSSI)) >= 0)
2898 // Use convert formula to getSignal Quality
2899 nSigQua = ConvertRssiToSignalQuality(RSSI);
2901 if (m_nSigQua !=0)
2902 nSigQua = (unsigned int)((m_nSigQua + nSigQua) / 2.0 + 0.5);
2904 m_nSigQua = nSigQua;
2906 if (nSigQua > 70)
2908 if (LinkStatus_CheckBox_dbm->isChecked())
2909 qstrSignalQuality.sprintf("Good %ld dBm", RSSI);
2910 else
2911 qstrSignalQuality.sprintf("Good %d%%", nSigQua);
2913 else if (nSigQua > 40)
2915 if (LinkStatus_CheckBox_dbm->isChecked())
2916 qstrSignalQuality.sprintf("Normal %ld dBm", RSSI);
2917 else
2918 qstrSignalQuality.sprintf("Normal %d%%", nSigQua);
2920 else
2922 if (LinkStatus_CheckBox_dbm->isChecked())
2923 qstrSignalQuality.sprintf("Weak %ld dBm", RSSI);
2924 else
2925 qstrSignalQuality.sprintf("Weak %d%%", nSigQua);
2928 LinkStatus_TextLabel_Signal->setText(qstrSignalQuality);
2929 LinkStatus_ProgressBar_Signal->setProgress(nSigQua);
2933 void RaConfigForm::Statistics_OnActive()
2935 timerId_Statistic = startTimer(2000);
2938 void RaConfigForm::Statistics_OnTimer()
2940 NDIS_802_11_STATISTICS Statistics;
2941 ULONG lRcvOk = 0;
2942 ULONG lRcvNoBuf = 0;
2943 char tmp[255];
2945 // Transmit Section
2946 memset(&Statistics, 0x00, sizeof(Statistics));
2947 if (OidQueryInformation(OID_802_11_STATISTICS, m_nSocketId, m_strDeviceName, &Statistics, sizeof(Statistics)) >= 0)
2949 // Frames Transmitted Successfully
2950 sprintf(tmp, "%8lld", Statistics.TransmittedFragmentCount);
2951 Statistics_TextLabel_TxSuccess->setText(tmp);
2953 // Frames Transmitted Successfully After Retry(s)
2954 sprintf(tmp, "%8lld", Statistics.RetryCount);
2955 Statistics_TextLabel_TxAfterRetry->setText(tmp);
2957 // Frames Transmitted Successfully Without Retry(s)
2958 sprintf(tmp, "%8lld", Statistics.TransmittedFragmentCount - Statistics.RetryCount);
2959 Statistics_TextLabel_TxWithoutRetry->setText(tmp);
2961 // Frames Fail To Receive ACK After All Retries
2962 sprintf(tmp, "%8lld", Statistics.FailedCount);
2963 Statistics_TextLabel_TxFailACK->setText(tmp);
2965 // RTS Frames Successfully Receive CTS
2966 sprintf(tmp, "%8lld", Statistics.RTSSuccessCount);
2967 Statistics_TextLabel_RTSSuccess->setText(tmp);
2969 // RTS Frames Fail To Receive CTS
2970 sprintf(tmp, "%8lld", Statistics.RTSFailureCount);
2971 Statistics_TextLabel_RTSFail->setText(tmp);
2973 // Frames Received With CRC Error
2974 sprintf(tmp, "%8lld", Statistics.FCSErrorCount);
2975 Statistics_TextLabel_RxCRC->setText(tmp);
2977 // Duplicate Frames Received
2978 sprintf(tmp, "%8lld", Statistics.FrameDuplicateCount);
2979 Statistics_TextLabel_Duplicate->setText(tmp);
2982 // Frames Received Successfully
2983 if (OidQueryInformation(OID_GEN_RCV_OK, m_nSocketId, m_strDeviceName, &lRcvOk, sizeof(lRcvOk)) >= 0)
2985 sprintf(tmp, "%ld", lRcvOk);
2986 Statistics_TextLabel_RxSuccess->setText(tmp);
2989 // Frames Dropped Due To Out-of-Resource
2990 if (OidQueryInformation(OID_GEN_RCV_NO_BUFFER, m_nSocketId, m_strDeviceName, &lRcvNoBuf, sizeof(lRcvNoBuf)) >= 0)
2992 sprintf(tmp, "%ld", lRcvNoBuf);
2993 Statistics_TextLabel_RxDrop->setText(tmp);
2997 void RaConfigForm::Statistics_OnResetCounters()
2999 Statistics_TextLabel_TxSuccess->setText(0);
3000 Statistics_TextLabel_TxAfterRetry->setText(0);
3001 Statistics_TextLabel_TxWithoutRetry->setText(0);
3002 Statistics_TextLabel_TxFailACK->setText(0);
3003 Statistics_TextLabel_RTSSuccess->setText(0);
3004 Statistics_TextLabel_RTSFail->setText(0);
3005 Statistics_TextLabel_RxCRC->setText(0);
3006 Statistics_TextLabel_Duplicate->setText(0);
3007 Statistics_TextLabel_RxSuccess->setText(0);
3008 Statistics_TextLabel_RxDrop->setText(0);
3010 OidSetInformation(RT_OID_802_11_RESET_COUNTERS, m_nSocketId, m_strDeviceName, 0, 0);
3013 void RaConfigForm::Advance_OnActive()
3015 if(G_bSupportAMode)
3017 Advance_ComboBox_Mode->insertItem("802.11 A only");
3018 Advance_ComboBox_Mode->insertItem("802.11 A/B/G mixed mode");
3021 if(G_bRadio)
3023 Advance_PushButton_Radio->setText("RADIO OFF");
3024 Advance_TextLabel_Radio->setPixmap( uic_load_pixmap_RaConfigForm( "radioon.png" ) );
3026 else
3028 Advance_PushButton_Radio->setText("RADIO ON");
3029 Advance_TextLabel_Radio->setPixmap( uic_load_pixmap_RaConfigForm( "radiooff.png" ) );
3032 Advance_ReadConfigFromRegistry();
3033 Advance_OnSelchangeWirelessMode( Advance_ComboBox_Mode->currentItem());
3036 void RaConfigForm::Advance_ReadConfigFromRegistry()
3038 char strtmp[255];
3039 unsigned int nWirelessMode;
3041 if (getkeystring("Default", "WirelessMode", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3043 nWirelessMode = atoi(strtmp);
3045 if (G_bSupportAMode)
3047 if ( nWirelessMode > PHY_11ABG_MIXED )
3048 m_WirelessMode = PHY_11ABG_MIXED;
3049 else
3050 m_WirelessMode = (RT_802_11_PHY_MODE) nWirelessMode;
3052 else
3054 if (nWirelessMode >= PHY_11A )
3055 m_WirelessMode = PHY_11BG_MIXED;
3056 else
3057 m_WirelessMode = (RT_802_11_PHY_MODE) nWirelessMode;
3060 Advance_ComboBox_Mode->setCurrentItem( (int)m_WirelessMode);
3063 if (getkeystring("Default", "AdhocOfdm", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3065 if (atoi(strtmp) != 0)
3066 m_bAdhocOfdm = TRUE;
3067 else
3068 m_bAdhocOfdm = FALSE;
3070 Advance_CheckBox_AdhocOfdm->setChecked(m_bAdhocOfdm);
3073 if (getkeystring("Default", "TXBurst", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3075 if (atoi(strtmp) != 0)
3076 m_bTXBurst = TRUE;
3077 else
3078 m_bTXBurst = FALSE;
3080 Advance_CheckBox_TxBurst->setChecked(m_bTXBurst);
3083 if (getkeystring("Default", "TurboRate", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3085 if (atoi(strtmp) != 0)
3086 m_bTurboRate = TRUE;
3087 else
3088 m_bTurboRate = FALSE;
3090 Advance_CheckBox_TurboRate->setChecked(m_bTurboRate);
3093 if (getkeystring("Default", "ShortSlot", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3095 if (atoi(strtmp) != 0)
3096 m_bShortSlot = TRUE;
3097 else
3098 m_bShortSlot = FALSE;
3100 Advance_CheckBox_ShortSlot->setChecked(m_bShortSlot);
3103 if (getkeystring("Default", "BGProtection", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3105 m_nBGProtection = atoi(strtmp);
3107 if ((m_nBGProtection < 0) || (m_nBGProtection >= 3))
3108 m_nBGProtection = 0;
3110 Advance_ComboBox_BGProtection->setCurrentItem(m_nBGProtection);
3113 if (getkeystring("Default", "TxRate", strtmp, 255, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA) == TRUE)
3115 m_nTXRate = atoi(strtmp);
3117 Advance_ComboBox_TxRate->setCurrentItem(m_nTXRate);
3122 void RaConfigForm::Advance_OnSelchangeWirelessMode(int index)
3124 Advance_ComboBox_TxRate->clear();
3126 if (index == 0)
3127 m_WirelessMode = PHY_11BG_MIXED;
3128 else
3129 m_WirelessMode = PHY_11B;
3131 switch(m_WirelessMode)
3133 case PHY_11B: // B only
3134 Advance_ComboBox_TxRate->insertItem("Auto");
3135 Advance_ComboBox_TxRate->insertItem("1 Mbps");
3136 Advance_ComboBox_TxRate->insertItem("2 Mbps");
3137 Advance_ComboBox_TxRate->insertItem("5.5 Mbps");
3138 Advance_ComboBox_TxRate->insertItem("11 Mbps");
3139 Advance_ComboBox_BGProtection->setEnabled(FALSE);
3141 m_nBGProtection = 0;
3142 if(m_nTXRate > 4)
3143 m_nTXRate = 0;
3144 break;
3145 case PHY_11A: // A Only
3146 Advance_ComboBox_TxRate->insertItem("Auto");
3147 Advance_ComboBox_TxRate->insertItem("6 Mbps");
3148 Advance_ComboBox_TxRate->insertItem("9 Mbps");
3149 Advance_ComboBox_TxRate->insertItem("12 Mbps");
3150 Advance_ComboBox_TxRate->insertItem("18 Mbps");
3151 Advance_ComboBox_TxRate->insertItem("24 Mbps");
3152 Advance_ComboBox_TxRate->insertItem("36 Mbps");
3153 Advance_ComboBox_TxRate->insertItem("48 Mbps");
3154 Advance_ComboBox_TxRate->insertItem("54 Mbps");
3155 Advance_ComboBox_BGProtection->setEnabled(FALSE);
3157 m_nBGProtection = 0;
3158 if(m_nTXRate > 8)
3159 m_nTXRate = 0;
3160 break;
3161 case PHY_11BG_MIXED: // B/G Mixed
3162 case PHY_11ABG_MIXED: // A/B/G Mixed
3163 default:
3164 Advance_ComboBox_TxRate->insertItem("Auto");
3165 Advance_ComboBox_TxRate->insertItem("1 Mbps");
3166 Advance_ComboBox_TxRate->insertItem("2 Mbps");
3167 Advance_ComboBox_TxRate->insertItem("5.5 Mbps");
3168 Advance_ComboBox_TxRate->insertItem("11 Mbps");
3169 Advance_ComboBox_TxRate->insertItem("6 Mbps");
3170 Advance_ComboBox_TxRate->insertItem("9 Mbps");
3171 Advance_ComboBox_TxRate->insertItem("12 Mbps");
3172 Advance_ComboBox_TxRate->insertItem("18 Mbps");
3173 Advance_ComboBox_TxRate->insertItem("24 Mbps");
3174 Advance_ComboBox_TxRate->insertItem("36 Mbps");
3175 Advance_ComboBox_TxRate->insertItem("48 Mbps");
3176 Advance_ComboBox_TxRate->insertItem("54 Mbps");
3177 // Advance_ComboBox_TxRate->insertItem("72 Mbps");
3178 // Advance_ComboBox_TxRate->insertItem("100 Mbps");
3180 if (G_bUserAdmin)
3181 Advance_ComboBox_BGProtection->setEnabled(TRUE);
3183 if(m_nTXRate > 12)
3184 m_nTXRate = 0;
3185 break;
3188 Advance_ComboBox_TxRate->setCurrentItem(m_nTXRate);
3191 void RaConfigForm::Advance_OnRadio()
3193 char strtmp[255];
3195 G_bRadio = !G_bRadio;
3197 if (OidSetInformation(RT_OID_802_11_RADIO, m_nSocketId, m_strDeviceName, &G_bRadio, sizeof(G_bRadio)) >= 0)
3198 { //Set success
3199 if (G_bRadio)
3201 Advance_PushButton_Radio->setText("RADIO OFF");
3202 Advance_TextLabel_Radio->setPixmap( uic_load_pixmap_RaConfigForm( "radioon.png" ) );
3204 else
3206 Advance_PushButton_Radio->setText("RADIO ON");
3207 Advance_TextLabel_Radio->setPixmap( uic_load_pixmap_RaConfigForm( "radiooff.png" ) );
3210 if (G_bUserAdmin)
3212 sprintf(strtmp, "%d", G_bRadio);
3213 writekeystring("Default", "Radio", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3216 else
3217 { //Set failed
3218 G_bRadio = !G_bRadio;
3221 OidSetInformation(OID_802_11_BSSID_LIST_SCAN, m_nSocketId, m_strDeviceName, 0, 0);
3222 LinkStatus_UpdateStatus();
3223 Profile_UpdateProfileStatus();
3224 SiteSurvey_ProbeConnectStatus();
3228 void RaConfigForm::Advance_OnApply()
3230 RT_802_11_PHY_MODE enumWirelessMode;
3231 RT_802_11_STA_CONFIG configStation;
3232 RT_802_11_STA_CONFIG configOldStation;
3233 NDIS_802_11_RATES aryRates;
3234 char strtmp[255];
3236 m_nTXRate = Advance_ComboBox_TxRate->currentItem();
3238 if (!G_bSupportAMode && (m_WirelessMode >= PHY_11A))
3239 m_WirelessMode = PHY_11BG_MIXED;
3241 G_enumWirelessMode = (RT_802_11_PHY_MODE)m_WirelessMode;
3242 if ((m_WirelessMode == PHY_11B) || (m_WirelessMode == PHY_11A))
3243 m_nBGProtection = 0;
3244 if (((m_WirelessMode == PHY_11B) && (m_nTXRate > 4)) || ((m_WirelessMode == PHY_11A) && (m_nTXRate > 8)))
3245 m_nTXRate = 0;
3247 m_bAdhocOfdm = Advance_CheckBox_AdhocOfdm->isChecked();
3248 m_bTurboRate = Advance_CheckBox_TurboRate->isChecked();
3249 m_bTXBurst = Advance_CheckBox_TxBurst->isChecked();
3250 m_bShortSlot = Advance_CheckBox_ShortSlot->isChecked();
3251 switch (Advance_ComboBox_BGProtection->currentItem())
3253 case 1://1-always ON
3254 m_nBGProtection = 1;
3255 break;
3256 case 2://2-always OFF
3257 m_nBGProtection = 2;
3258 break;
3259 case 0:// 0-AUTO
3260 default:
3261 m_nBGProtection = 0;
3262 break;
3265 if (G_bUserAdmin)
3267 // Set Wireless Mode value
3268 sprintf(strtmp, "%d", m_WirelessMode);
3269 writekeystring("Default", "WirelessMode", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3271 //Set AdhocOfdm
3272 sprintf(strtmp, "%d", m_bAdhocOfdm);
3273 writekeystring("Default", "AdhocOfdm", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3275 // Set TXBurst value
3276 sprintf(strtmp, "%d", m_bTXBurst);
3277 writekeystring("Default", "TXBurst", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3279 // Set TurboRate value
3280 sprintf(strtmp, "%d", m_bTurboRate);
3281 writekeystring("Default", "TurboRate", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3283 // Set BGProtection value
3284 sprintf(strtmp, "%d", m_nBGProtection);
3285 writekeystring("Default", "BGProtection", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3287 // Set ShortSlot value
3288 sprintf(strtmp, "%d", m_bShortSlot);
3289 writekeystring("Default", "ShortSlot", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3291 // Set TXRate value
3292 sprintf(strtmp, "%d", m_nTXRate);
3293 writekeystring("Default", "TxRate", strtmp, RT2500_SYSTEM_PATH, RT2500_SYSTEM_DATA);
3296 // SetOidInformation
3297 OidQueryInformation(RT_OID_802_11_PHY_MODE, m_nSocketId, m_strDeviceName, &enumWirelessMode, sizeof(enumWirelessMode));
3298 if(enumWirelessMode != G_enumWirelessMode)
3299 OidSetInformation(RT_OID_802_11_PHY_MODE, m_nSocketId, m_strDeviceName, &G_enumWirelessMode, sizeof(G_enumWirelessMode));
3301 OidQueryInformation(RT_OID_802_11_STA_CONFIG, m_nSocketId, m_strDeviceName, &configOldStation, sizeof(configOldStation));
3303 configStation.EnableTurboRate = m_bTurboRate;
3304 configStation.EnableTxBurst = m_bTXBurst;
3305 configStation.UseBGProtection = m_nBGProtection;
3306 configStation.UseShortSlotTime = m_bShortSlot;
3307 configStation.UseOfdmRatesIn11gAdhoc = m_bAdhocOfdm;
3309 if(memcmp(&configOldStation, &configStation, sizeof(RT_802_11_STA_CONFIG)) != 0)
3310 OidSetInformation(RT_OID_802_11_STA_CONFIG, m_nSocketId, m_strDeviceName, &configStation, sizeof(configStation));
3312 memset(aryRates, 0x00, sizeof(NDIS_802_11_RATES));
3313 if (m_WirelessMode == PHY_11A)
3315 switch (m_nTXRate)
3317 case 0:
3318 aryRates[0] = 0x6c; // 54Mbps
3319 aryRates[1] = 0x60; // 48Mbps
3320 aryRates[2] = 0x48; // 36Mbps
3321 aryRates[3] = 0x30; // 24Mbps
3322 aryRates[4] = 0x24; // 18M
3323 aryRates[5] = 0x18; // 12M
3324 aryRates[6] = 0x12; // 9M
3325 aryRates[7] = 0x0c; // 6M
3326 break;
3327 case 1:
3328 aryRates[0] = 0x0c; // 6M
3329 break;
3330 case 2:
3331 aryRates[0] = 0x12; // 9M
3332 break;
3333 case 3:
3334 aryRates[0] = 0x18; // 12M
3335 break;
3336 case 4:
3337 aryRates[0] = 0x24; // 18M
3338 break;
3339 case 5:
3340 aryRates[0] = 0x30; // 24M
3341 break;
3342 case 6:
3343 aryRates[0] = 0x48; // 36M
3344 break;
3345 case 7:
3346 aryRates[0] = 0x60; // 48M
3347 break;
3348 case 8:
3349 aryRates[0] = 0x6c; // 54M
3350 break;
3353 else if ((m_WirelessMode == PHY_11BG_MIXED) || (m_WirelessMode == PHY_11B) ||
3354 (m_WirelessMode == PHY_11ABG_MIXED))
3356 switch(m_nTXRate)
3358 case 0:
3359 switch(m_WirelessMode)
3361 case PHY_11BG_MIXED: // B/G Mixed
3362 case PHY_11ABG_MIXED: // A/B/G Mixed
3363 aryRates[0] = 0x6c; // 54Mbps
3364 aryRates[1] = 0x60; // 48Mbps
3365 aryRates[2] = 0x48; // 36Mbps
3366 aryRates[3] = 0x30; // 24Mbps
3367 aryRates[4] = 0x16; // 11Mbps
3368 aryRates[5] = 0x0b; // 5.5Mbps
3369 aryRates[6] = 0x04; // 2Mbps
3370 aryRates[7] = 0x02; // 1Mbps
3371 break;
3372 case PHY_11B: // B Only
3373 aryRates[0] = 0x16; // 11Mbps
3374 aryRates[1] = 0x0b; // 5.5Mbps
3375 aryRates[2] = 0x04; // 2Mbps
3376 aryRates[3] = 0x02; // 1Mbps
3377 break;
3378 case PHY_11A:
3379 break; //Not be call, for avoid warning.
3381 break;
3382 case 1:
3383 aryRates[0] = 0x02; // 1M
3384 break;
3385 case 2:
3386 aryRates[0] = 0x04; // 2M
3387 break;
3388 case 3:
3389 aryRates[0] = 0x0b; // 5.5M
3390 break;
3391 case 4:
3392 aryRates[0] = 0x16; // 11M
3393 break;
3394 case 5:
3395 aryRates[0] = 0x0c; // 6M
3396 break;
3397 case 6:
3398 aryRates[0] = 0x12; // 9M
3399 break;
3400 case 7:
3401 aryRates[0] = 0x18; // 12M
3402 break;
3403 case 8:
3404 aryRates[0] = 0x24; // 18M
3405 break;
3406 case 9:
3407 aryRates[0] = 0x30; // 24M
3408 break;
3409 case 10:
3410 aryRates[0] = 0x48; // 36M
3411 break;
3412 case 11:
3413 aryRates[0] = 0x60; // 48M
3414 break;
3415 case 12:
3416 aryRates[0] = 0x6c; // 54M
3417 break;
3420 OidSetInformation(OID_802_11_DESIRED_RATES, m_nSocketId, m_strDeviceName, &aryRates, sizeof(NDIS_802_11_RATES));
3423 void RaConfigForm::About_OnActive()
3425 NDIS_802_11_MAC_ADDRESS CurrentAddress;
3426 RT_VERSION_INFO DriverVersionInfo;
3427 char tmp[40];
3430 if( OidQueryInformation(OID_802_3_CURRENT_ADDRESS, m_nSocketId, m_strDeviceName, &CurrentAddress, sizeof(CurrentAddress)) >= 0)
3432 sprintf(tmp, "%02X-%02X-%02X-%02X-%02X-%02X", CurrentAddress[0], CurrentAddress[1],
3433 CurrentAddress[2], CurrentAddress[3], CurrentAddress[4], CurrentAddress[5]);
3435 else
3437 sprintf(tmp, "");
3439 About_TextLabel_PhyAddress->setText( (const char *)tmp );
3441 if (OidQueryInformation(RT_OID_VERSION_INFO, m_nSocketId, m_strDeviceName, &DriverVersionInfo, sizeof(DriverVersionInfo)) >= 0)
3443 sprintf(tmp, "%d.%d.%d.%d", DriverVersionInfo.DriverVersionW, DriverVersionInfo.DriverVersionX, DriverVersionInfo.DriverVersionY, DriverVersionInfo.DriverVersionZ);
3444 About_TextLabel_NICVersion->setText(tmp);
3445 sprintf(tmp, "%04d-%02d-%02d", DriverVersionInfo.DriverBuildYear, DriverVersionInfo.DriverBuildMonth, DriverVersionInfo.DriverBuildDay);
3446 About_TextLabel_NICDate->setText(tmp);
3450 void RaConfigForm::SiteSurvey_OnSelectChange()
3452 SiteSurvey_ButtonShowHide();