|
From: <sat...@us...> - 2010-03-22 09:11:09
|
Revision: 246
http://w-meter.svn.sourceforge.net/w-meter/?rev=246&view=rev
Author: sathakselva
Date: 2010-03-22 09:11:00 +0000 (Mon, 22 Mar 2010)
Log Message:
-----------
Authentication frame cleanup
Modified Paths:
--------------
frame_injection_g/trunk/src/mgmt_asso_req_cpp.cpp
frame_injection_g/trunk/src/mgmt_authen_cpp.cpp
frame_injection_g/trunk/src/mgmt_authen_cpp.h
Modified: frame_injection_g/trunk/src/mgmt_asso_req_cpp.cpp
===================================================================
--- frame_injection_g/trunk/src/mgmt_asso_req_cpp.cpp 2010-03-20 06:22:46 UTC (rev 245)
+++ frame_injection_g/trunk/src/mgmt_asso_req_cpp.cpp 2010-03-22 09:11:00 UTC (rev 246)
@@ -88,7 +88,7 @@
lineedit_address1_5->setText (add1_5);
lineedit_address1_6->setText (add1_6);
- /* Set Transmitter Address */
+ /* Set Transmitter Address */
lineedit_address2_1->setText (add2_1);
lineedit_address2_2->setText (add2_2);
lineedit_address2_3->setText (add2_3);
@@ -96,7 +96,7 @@
lineedit_address2_5->setText (add2_5);
lineedit_address2_6->setText (add2_6);
- /* Set BSSID Address */
+ /* Set BSSID Address */
lineedit_address3_1->setText (add3_1);
lineedit_address3_2->setText (add3_2);
lineedit_address3_3->setText (add3_3);
@@ -108,7 +108,7 @@
lineedit_frag_no->setText (fragno);
lineedit_seq_no->setText (seqno);
- /* Set Capability Information */
+ /* Set Capability Information */
lineedit_cap_info_1->setText (capinfo1);
lineedit_cap_info_2->setText (capinfo2);
lineedit_cap_info_3->setText (capinfo3);
@@ -319,7 +319,7 @@
{
mac_80211 mac;
uint8_t *frame = msg;
- memset(frame, 0, sizeof (msg));
+ memset (frame, 0, sizeof (msg));
bool ok;
// QReg validator initialization
QRegExp rx ("[0-9A-Fa-f]{2}");
@@ -536,9 +536,9 @@
srate[index++] = * ( (unsigned char*) & hexrate) ;
}
srate_len = index;
- /*@erate: IEEE 802.11-2007 defines 12 data rates.
- 8 as supported rate and 4 as extended suported rate */
- uint8_t index1 = 0, erate[4], erate_id = 0X32, erate_len =0;
+ /*@erate: IEEE 802.11-2007 defines 12 data rates.
+ 8 as supported rate and 4 as extended suported rate */
+ uint8_t index1 = 0, erate[4], erate_id = 0X32, erate_len = 0;
if (checkbox_esrate_1->isChecked() == 1)
{
@@ -565,12 +565,12 @@
}
erate_len = index1;
- // copy frame control field
- memcpy (frame, &frame_ctrl, sizeof(frame_ctrl));
- frame += sizeof(frame_ctrl);
+ // copy frame control field
+ memcpy (frame, &frame_ctrl, sizeof (frame_ctrl));
+ frame += sizeof (frame_ctrl);
- memcpy (frame, &duration_char, sizeof(duration_char));
- frame += sizeof(duration_char);
+ memcpy (frame, &duration_char, sizeof (duration_char));
+ frame += sizeof (duration_char);
memcpy (frame, &addr1, MAC_ADDRESS_LEN);
frame += MAC_ADDRESS_LEN;
@@ -581,14 +581,14 @@
memcpy (frame, &addr3, MAC_ADDRESS_LEN);
frame += MAC_ADDRESS_LEN;
- memcpy (frame, &seq_ctrl_char, sizeof(seq_ctrl_char));
- frame += sizeof(seq_ctrl_char);
+ memcpy (frame, &seq_ctrl_char, sizeof (seq_ctrl_char));
+ frame += sizeof (seq_ctrl_char);
- memcpy (frame, &cap_info, sizeof(cap_info));
- frame += sizeof(cap_info);
+ memcpy (frame, &cap_info, sizeof (cap_info));
+ frame += sizeof (cap_info);
- memcpy (frame, &listen_intrvl_char, sizeof(listen_intrvl_char));
- frame += sizeof(listen_intrvl_char);
+ memcpy (frame, &listen_intrvl_char, sizeof (listen_intrvl_char));
+ frame += sizeof (listen_intrvl_char);
// append SSID
*frame++ = element_id;
@@ -599,9 +599,9 @@
frame += ssid_len;
}
- // Append supported rates
- if (srate_len > 0)
- {
+ // Append supported rates
+ if (srate_len > 0)
+ {
*frame++ = srate_id;
*frame++ = srate_len;
memcpy (frame, &srate, srate_len);
@@ -610,7 +610,7 @@
// append extended support rates
if (erate_len > 0)
- {
+ {
*frame++ = erate_id;
*frame++ = erate_len;
memcpy (frame, &erate, erate_len);
Modified: frame_injection_g/trunk/src/mgmt_authen_cpp.cpp
===================================================================
--- frame_injection_g/trunk/src/mgmt_authen_cpp.cpp 2010-03-20 06:22:46 UTC (rev 245)
+++ frame_injection_g/trunk/src/mgmt_authen_cpp.cpp 2010-03-22 09:11:00 UTC (rev 246)
@@ -34,118 +34,118 @@
#include <qfile.h>
#include "mac_80211.h"
-uint16_t global_auth_flag=0;
+uint16_t global_auth_flag = 0;
char default_auth_file[] = "default_auth";
-mgmt_authen_cpp::mgmt_authen_cpp( QWidget* parent, const char* name, WFlags fl )
- : mgmt_authen( parent,name,fl )
+mgmt_authen_cpp::mgmt_authen_cpp (QWidget* parent, const char* name, WFlags fl)
+ : mgmt_authen (parent, name, fl)
{
- authen_run_button->setEnabled( 1 );
+ authen_run_button->setEnabled (1);
- char frame1[2], frame2[2], frame3[2], frame4[2], frame5[2], frame6[2], frame7[2], frame8[2], frame9[2], frame10[2], frame11[2], frame12[2], frame13[2], frame14[2], frame15[2], frame16[2], nav[6], add1_1[3], add1_2[3], add1_3[3], add1_4[3], add1_5[3], add1_6[3], add2_1[3], add2_2[3], add2_3[3], add2_4[3], add2_5[3], add2_6[3], add3_1[3], add3_2[3], add3_3[3], add3_4[3], add3_5[3], add3_6[3], fragno[3], seqno[5], auth_algores[3],auth_seqnores[3], stat_cod[6], chall_txt[129];
- int auth_algorithm,auth_seq_no,status_code ;
+ char frame1[2], frame2[2], frame3[2], frame4[2], frame5[2], frame6[2], frame7[2], frame8[2], frame9[2], frame10[2], frame11[2], frame12[2], frame13[2], frame14[2], frame15[2], frame16[2], nav[6], add1_1[3], add1_2[3], add1_3[3], add1_4[3], add1_5[3], add1_6[3], add2_1[3], add2_2[3], add2_3[3], add2_4[3], add2_5[3], add2_6[3], add3_1[3], add3_2[3], add3_3[3], add3_4[3], add3_5[3], add3_6[3], fragno[3], seqno[5], auth_algores[3], auth_seqnores[3], stat_cod[6], chall_txt[129];
+ int auth_algorithm, auth_seq_no, status_code ;
- FILE *file1;
- file1=fopen( default_auth_file,"r" );
- if ( file1==NULL )
- {
- KMessageBox::error( this,"Unable to open file. Loading initial values." );
- reset_auth_frame();
- }
- else
- {
- /* Reading from template files for filling default values */
- while ( fscanf( file1,"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %d %s %d %s %d %s %s ", &frame1[0],&frame2[0],&frame3[0],&frame4[0],&frame5[0],&frame6[0],&frame7[0],&frame8[0],&frame9[0],&frame10[0],&frame11[0],&frame12[0],&frame13[0],&frame14[0],&frame15[0],&frame16[0],&nav[0],&add1_1[0],&add1_2[0],&add1_3[0],&add1_4[0],&add1_5[0],&add1_6[0],&add2_1[0],&add2_2[0],&add2_3[0],&add2_4[0],&add2_5[0],&add2_6[0],&add3_1[0],&add3_2[0],&add3_3[0],&add3_4[0],&add3_5[0],&add3_6[0],&fragno[0],&seqno[0],&auth_algorithm,&auth_algores[0],&auth_seq_no,&auth_seqnores[0],&status_code,&stat_cod[0],&chall_txt[0] )!=EOF )
- {
+ FILE *file1;
+ file1 = fopen (default_auth_file, "r");
+ if (file1 == NULL)
+ {
+ KMessageBox::error (this, "Unable to open file. Loading initial values.");
+ reset_auth_frame();
+ }
+ else
+ {
+ /* Reading from template files for filling default values */
+ while (fscanf (file1, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %d %s %d %s %d %s %s ", &frame1[0], &frame2[0], &frame3[0], &frame4[0], &frame5[0], &frame6[0], &frame7[0], &frame8[0], &frame9[0], &frame10[0], &frame11[0], &frame12[0], &frame13[0], &frame14[0], &frame15[0], &frame16[0], &nav[0], &add1_1[0], &add1_2[0], &add1_3[0], &add1_4[0], &add1_5[0], &add1_6[0], &add2_1[0], &add2_2[0], &add2_3[0], &add2_4[0], &add2_5[0], &add2_6[0], &add3_1[0], &add3_2[0], &add3_3[0], &add3_4[0], &add3_5[0], &add3_6[0], &fragno[0], &seqno[0], &auth_algorithm, &auth_algores[0], &auth_seq_no, &auth_seqnores[0], &status_code, &stat_cod[0], &chall_txt[0]) != EOF)
+ {
- /* Loading Frame Header details */
- lineedit_frame_1->setText( frame1 );
- lineedit_frame_2->setText( frame2 );
- lineedit_frame_3->setText( frame3 );
- lineedit_frame_4->setText( frame4 );
- lineedit_frame_5->setText( frame5 );
- lineedit_frame_6->setText( frame6 );
- lineedit_frame_7->setText( frame7 );
- lineedit_frame_8->setText( frame8 );
- lineedit_frame_9->setText( frame9 );
- lineedit_frame_10->setText( frame10 );
- lineedit_frame_11->setText( frame11 );
- lineedit_frame_12->setText( frame12 );
- lineedit_frame_13->setText( frame13 );
- lineedit_frame_14->setText( frame14 );
- lineedit_frame_15->setText( frame15 );
- lineedit_frame_16->setText( frame16 );
+ /* Set Frame control fields */
+ lineedit_frame_1->setText (frame1);
+ lineedit_frame_2->setText (frame2);
+ lineedit_frame_3->setText (frame3);
+ lineedit_frame_4->setText (frame4);
+ lineedit_frame_5->setText (frame5);
+ lineedit_frame_6->setText (frame6);
+ lineedit_frame_7->setText (frame7);
+ lineedit_frame_8->setText (frame8);
+ lineedit_frame_9->setText (frame9);
+ lineedit_frame_10->setText (frame10);
+ lineedit_frame_11->setText (frame11);
+ lineedit_frame_12->setText (frame12);
+ lineedit_frame_13->setText (frame13);
+ lineedit_frame_14->setText (frame14);
+ lineedit_frame_15->setText (frame15);
+ lineedit_frame_16->setText (frame16);
- lineedit_NAV->setText( nav );
+ lineedit_NAV->setText (nav);
- /* Loading Address Values */
- lineedit_address1_1->setText( add1_1 );
- lineedit_address1_2->setText( add1_2 );
- lineedit_address1_3->setText( add1_3 );
- lineedit_address1_4->setText( add1_4 );
- lineedit_address1_5->setText( add1_5 );
- lineedit_address1_6->setText( add1_6 );
- lineedit_address2_1->setText( add2_1 );
- lineedit_address2_2->setText( add2_2 );
- lineedit_address2_3->setText( add2_3 );
- lineedit_address2_4->setText( add2_4 );
- lineedit_address2_5->setText( add2_5 );
- lineedit_address2_6->setText( add2_6 );
- lineedit_address3_1->setText( add3_1 );
- lineedit_address3_2->setText( add3_2 );
- lineedit_address3_3->setText( add3_3 );
- lineedit_address3_4->setText( add3_4 );
- lineedit_address3_5->setText( add3_5 );
- lineedit_address3_6->setText( add3_6 );
+ /* Set Addresses */
+ lineedit_address1_1->setText (add1_1);
+ lineedit_address1_2->setText (add1_2);
+ lineedit_address1_3->setText (add1_3);
+ lineedit_address1_4->setText (add1_4);
+ lineedit_address1_5->setText (add1_5);
+ lineedit_address1_6->setText (add1_6);
+ lineedit_address2_1->setText (add2_1);
+ lineedit_address2_2->setText (add2_2);
+ lineedit_address2_3->setText (add2_3);
+ lineedit_address2_4->setText (add2_4);
+ lineedit_address2_5->setText (add2_5);
+ lineedit_address2_6->setText (add2_6);
+ lineedit_address3_1->setText (add3_1);
+ lineedit_address3_2->setText (add3_2);
+ lineedit_address3_3->setText (add3_3);
+ lineedit_address3_4->setText (add3_4);
+ lineedit_address3_5->setText (add3_5);
+ lineedit_address3_6->setText (add3_6);
- /* Loading fragment number, sequence number and athentication information */
- lineedit_frag_no->setText( fragno );
- lineedit_seq_no->setText( seqno );
+ /* Loading fragment number, sequence number and athentication information */
+ lineedit_frag_no->setText (fragno);
+ lineedit_seq_no->setText (seqno);
- /* determining algorithm for authentication */
- combobox_auth_algo->setCurrentItem( auth_algorithm );
- combobox_authen_seqno->setCurrentItem( auth_seq_no );
- /* Status Code Processing */
- if ( status_code==-1 )
- combobox_status_code->setEnabled( 0 );
- else
- combobox_status_code->setCurrentItem( status_code );
+ /* determining algorithm for authentication */
+ combobox_auth_algo->setCurrentItem (auth_algorithm);
+ combobox_authen_seqno->setCurrentItem (auth_seq_no);
+ /* Status Code Processing */
+ if (status_code == -1)
+ combobox_status_code->setEnabled (0);
+ else
+ combobox_status_code->setCurrentItem (status_code);
- if (( atoi( auth_algores ) )==0 )
- {
- lineedit_res_AAlgo->setText( "" );
- lineedit_res_AAlgo->setEnabled( 0 );
- }
- else
- lineedit_res_AAlgo->setText( auth_algores );
- if (( atoi( auth_seqnores ) )==0 )
- {
- lineedit_res_ASN->setText( "" );
- lineedit_res_ASN->setEnabled( 0 );
- }
- else
- lineedit_res_ASN->setText( auth_seqnores );
+ if ( (atoi (auth_algores)) == 0)
+ {
+ lineedit_res_AAlgo->setText ("");
+ lineedit_res_AAlgo->setEnabled (0);
+ }
+ else
+ lineedit_res_AAlgo->setText (auth_algores);
+ if ( (atoi (auth_seqnores)) == 0)
+ {
+ lineedit_res_ASN->setText ("");
+ lineedit_res_ASN->setEnabled (0);
+ }
+ else
+ lineedit_res_ASN->setText (auth_seqnores);
- if (( atoi( stat_cod ) )==0 )
- {
- lineedit_status_code->setText( "" );
- lineedit_status_code->setEnabled( 0 );
- }
- else
- lineedit_status_code->setText( stat_cod );
+ if ( (atoi (stat_cod)) == 0)
+ {
+ lineedit_status_code->setText ("");
+ lineedit_status_code->setEnabled (0);
+ }
+ else
+ lineedit_status_code->setText (stat_cod);
- if (( atoi( chall_txt ) )==0 )
- {
- challenge_text->setText( "" );
- challenge_text->setEnabled( 0 );
- }
- else
- challenge_text->setText( chall_txt );
- }
- fclose( file1 );
- }
+ if ( (atoi (chall_txt)) == 0)
+ {
+ challenge_text->setText ("");
+ challenge_text->setEnabled (0);
+ }
+ else
+ challenge_text->setText (chall_txt);
+ }
+ fclose (file1);
+ }
}
mgmt_authen_cpp::~mgmt_authen_cpp()
@@ -154,815 +154,716 @@
/*Event Invoked after changing items in combobox_status_code */
-
void mgmt_authen_cpp::auth_status_code_click()
{
- if ( combobox_status_code->currentText()=="Reserved (2-9)" || combobox_status_code->currentText()=="Reserved (27–31)" ||
- combobox_status_code->currentText()=="Reserved (36)" ||
- combobox_status_code->currentText()=="Reserved (52–65535)" )
- {
- lineedit_status_code->setEnabled( 1 );
- }
- else
- {
- lineedit_status_code->setEnabled( 0 );
- }
+ if (combobox_status_code->currentText() == "Reserved (2-9)" || combobox_status_code->currentText() == "Reserved (27–31)" ||
+ combobox_status_code->currentText() == "Reserved (36)" ||
+ combobox_status_code->currentText() == "Reserved (52–65535)")
+ {
+ lineedit_status_code->setEnabled (1);
+ }
+ else
+ {
+ lineedit_status_code->setEnabled (0);
+ }
}
/* Event Invoked after changing items in combobox_auth_seqno */
void mgmt_authen_cpp::auth_seqno_select()
{
- if ( combobox_authen_seqno->currentText()=="1" && combobox_auth_algo->currentText()=="Open" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_authen_seqno->currentText()=="1" && combobox_auth_algo->currentText()=="Shared" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_authen_seqno->currentText()=="3" && combobox_auth_algo->currentText()=="Shared" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 1 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="2" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 1 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Open" && combobox_authen_seqno->currentText()=="4" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="4" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
- else
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
- if ( combobox_authen_seqno->currentText()=="Reserved" )
- lineedit_res_ASN->setEnabled( 1 );
- else
- lineedit_res_ASN->setEnabled( 0 );
+ if (combobox_authen_seqno->currentText() == "1" && combobox_auth_algo->currentText() == "Open")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (0);
+ }
+ else
+ if (combobox_authen_seqno->currentText() == "1" && combobox_auth_algo->currentText() == "Shared")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (0);
+ }
+ else
+ if (combobox_authen_seqno->currentText() == "3" && combobox_auth_algo->currentText() == "Shared")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (1);
+ }
+ else
+ if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "2")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (1);
+ }
+ else
+ if (combobox_auth_algo->currentText() == "Open" && combobox_authen_seqno->currentText() == "4")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
+ else
+ if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "4")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
+ else
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
+ if (combobox_authen_seqno->currentText() == "Reserved")
+ lineedit_res_ASN->setEnabled (1);
+ else
+ lineedit_res_ASN->setEnabled (0);
}
/* Event Invoked after changing items in combobox_auth_algo */
void mgmt_authen_cpp::auth_algo_select()
{
- if ( combobox_auth_algo->currentText()=="Open" && combobox_authen_seqno->currentText()=="1" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="1" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="3" )
- {
- combobox_status_code->setEnabled( 0 );
- challenge_text->setEnabled( 1 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="2" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 1 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Open" && combobox_authen_seqno->currentText()=="4" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
- else
- if ( combobox_auth_algo->currentText()=="Shared" && combobox_authen_seqno->currentText()=="4" )
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
- else
- {
- combobox_status_code->setEnabled( 1 );
- challenge_text->setEnabled( 0 );
- }
+ if (combobox_auth_algo->currentText() == "Open" && combobox_authen_seqno->currentText() == "1")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (0);
+ }
+ else if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "1")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (0);
+ }
+ else if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "3")
+ {
+ combobox_status_code->setEnabled (0);
+ challenge_text->setEnabled (1);
+ }
+ else if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "2")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (1);
+ }
+ else if (combobox_auth_algo->currentText() == "Open" && combobox_authen_seqno->currentText() == "4")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
+ else if (combobox_auth_algo->currentText() == "Shared" && combobox_authen_seqno->currentText() == "4")
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
+ else
+ {
+ combobox_status_code->setEnabled (1);
+ challenge_text->setEnabled (0);
+ }
- if ( combobox_auth_algo->currentText()=="Reserved" )
- lineedit_res_AAlgo->setEnabled( 1 );
- else
- lineedit_res_AAlgo->setEnabled( 0 );
+ if (combobox_auth_algo->currentText() == "Reserved")
+ lineedit_res_AAlgo->setEnabled (1);
+ else
+ lineedit_res_AAlgo->setEnabled (0);
}
/* Event Invoked after pressing Main_win button */
void mgmt_authen_cpp::auth_main_window()
{
- authen_run_button->setEnabled( 1 );
- close();
+ authen_run_button->setEnabled (1);
+ close();
}
/* Event Invoked after pressing Clear button */
void mgmt_authen_cpp::auth_clear_click()
{
- reset_auth_frame();
- authen_run_button->setEnabled( 1 );
+ reset_auth_frame();
+ authen_run_button->setEnabled (1);
}
/* Event Invoked after pressing Run button */
void mgmt_authen_cpp::auth_run_click()
{
- global_auth_flag=1;
- func_auth_hex_convertion();
+ global_auth_flag = 1;
+ func_auth_hex_convertion();
}
/* Function for saving drafted frames with testid */
void mgmt_authen_cpp::auth_save_click()
{
- if ( lineedit_testid->text()!="" )
- {
- global_auth_flag=3;
- func_auth_hex_convertion();
- lineedit_testid->clear();
- }
- else
- QMessageBox::critical( this, tr( "Error" ), tr( "Test ID is empty" ) );
+ if (lineedit_testid->text() != "")
+ {
+ global_auth_flag = 3;
+ func_auth_hex_convertion();
+ lineedit_testid->clear();
+ }
+ else
+ QMessageBox::critical (this, tr ("Error"), tr ("Test ID is empty"));
}
/*Function for taking frame values and making it default */
void mgmt_authen_cpp::auth_default_click()
{
- global_auth_flag=2;
- func_auth_hex_convertion();
+ global_auth_flag = 2;
+ func_auth_hex_convertion();
}
void mgmt_authen_cpp::func_auth_hex_convertion()
{
- mac_80211 mac;
- bool ok;
- /*Qvalidator initialization */
- QRegExp rx( "[0-9A-Fa-f]{2}" );
- QRegExpValidator v( rx, this );
+ mac_80211 mac;
+ uint8_t *frame = msg;
+ memset (frame, 0, sizeof (msg));
+ bool ok;
+ /*Qvalidator initialization */
+ QRegExp rx ("[0-9A-Fa-f]{2}");
+ QRegExpValidator v (rx, this);
- lineedit_address1_1->setValidator( &v );
- lineedit_address1_2->setValidator( &v );
- lineedit_address1_3->setValidator( &v );
- lineedit_address1_4->setValidator( &v );
- lineedit_address1_5->setValidator( &v );
- lineedit_address1_6->setValidator( &v );
- lineedit_address2_1->setValidator( &v );
- lineedit_address2_2->setValidator( &v );
- lineedit_address2_3->setValidator( &v );
- lineedit_address2_4->setValidator( &v );
- lineedit_address2_5->setValidator( &v );
- lineedit_address2_6->setValidator( &v );
- lineedit_address3_1->setValidator( &v );
- lineedit_address3_2->setValidator( &v );
- lineedit_address3_3->setValidator( &v );
- lineedit_address3_4->setValidator( &v );
- lineedit_address3_5->setValidator( &v );
- lineedit_address3_6->setValidator( &v );
- // address fields values to local variable
- QString add1_1=lineedit_address1_1->text();
- QString add1_2=lineedit_address1_2->text();
- QString add1_3=lineedit_address1_3->text();
- QString add1_4=lineedit_address1_4->text();
- QString add1_5=lineedit_address1_5->text();
- QString add1_6=lineedit_address1_6->text();
- QString add2_1=lineedit_address2_1->text();
- QString add2_2=lineedit_address2_2->text();
- QString add2_3=lineedit_address2_3->text();
- QString add2_4=lineedit_address2_4->text();
- QString add2_5=lineedit_address2_5->text();
- QString add2_6=lineedit_address2_6->text();
- QString add3_1=lineedit_address3_1->text();
- QString add3_2=lineedit_address3_2->text();
- QString add3_3=lineedit_address3_3->text();
- QString add3_4=lineedit_address3_4->text();
- QString add3_5=lineedit_address3_5->text();
- QString add3_6=lineedit_address3_6->text();
+ lineedit_address1_1->setValidator (&v);
+ lineedit_address1_2->setValidator (&v);
+ lineedit_address1_3->setValidator (&v);
+ lineedit_address1_4->setValidator (&v);
+ lineedit_address1_5->setValidator (&v);
+ lineedit_address1_6->setValidator (&v);
+ lineedit_address2_1->setValidator (&v);
+ lineedit_address2_2->setValidator (&v);
+ lineedit_address2_3->setValidator (&v);
+ lineedit_address2_4->setValidator (&v);
+ lineedit_address2_5->setValidator (&v);
+ lineedit_address2_6->setValidator (&v);
+ lineedit_address3_1->setValidator (&v);
+ lineedit_address3_2->setValidator (&v);
+ lineedit_address3_3->setValidator (&v);
+ lineedit_address3_4->setValidator (&v);
+ lineedit_address3_5->setValidator (&v);
+ lineedit_address3_6->setValidator (&v);
+ // address fields values to local variable
+ QString add1_1 = lineedit_address1_1->text();
+ QString add1_2 = lineedit_address1_2->text();
+ QString add1_3 = lineedit_address1_3->text();
+ QString add1_4 = lineedit_address1_4->text();
+ QString add1_5 = lineedit_address1_5->text();
+ QString add1_6 = lineedit_address1_6->text();
+ QString add2_1 = lineedit_address2_1->text();
+ QString add2_2 = lineedit_address2_2->text();
+ QString add2_3 = lineedit_address2_3->text();
+ QString add2_4 = lineedit_address2_4->text();
+ QString add2_5 = lineedit_address2_5->text();
+ QString add2_6 = lineedit_address2_6->text();
+ QString add3_1 = lineedit_address3_1->text();
+ QString add3_2 = lineedit_address3_2->text();
+ QString add3_3 = lineedit_address3_3->text();
+ QString add3_4 = lineedit_address3_4->text();
+ QString add3_5 = lineedit_address3_5->text();
+ QString add3_6 = lineedit_address3_6->text();
- int pos=0;
- /* validating fields */
- if (( v.validate( add1_1, pos ) !=0 ) &&
- ( v.validate( add1_2, pos ) !=0 ) &&
- ( v.validate( add1_3, pos ) !=0 ) &&
- ( v.validate( add1_4, pos ) !=0 ) &&
- ( v.validate( add1_5, pos ) !=0 ) &&
- ( v.validate( add1_6, pos ) !=0 ) &&
- ( v.validate( add2_1, pos ) !=0 ) &&
- ( v.validate( add2_2, pos ) !=0 ) &&
- ( v.validate( add2_3, pos ) !=0 ) &&
- ( v.validate( add2_4, pos ) !=0 ) &&
- ( v.validate( add2_5, pos ) !=0 ) &&
- ( v.validate( add2_6, pos ) !=0 ) &&
- ( v.validate( add3_1, pos ) !=0 ) &&
- ( v.validate( add3_2, pos ) !=0 ) &&
- ( v.validate( add3_3, pos ) !=0 ) &&
- ( v.validate( add3_4, pos ) !=0 ) &&
- ( v.validate( add3_5, pos ) !=0 ) &&
- ( v.validate( add3_6, pos ) !=0 ) )
- {
+ int pos = 0;
+ /* validating fields */
+ if ( (v.validate (add1_1, pos) != 0) &&
+ (v.validate (add1_2, pos) != 0) &&
+ (v.validate (add1_3, pos) != 0) &&
+ (v.validate (add1_4, pos) != 0) &&
+ (v.validate (add1_5, pos) != 0) &&
+ (v.validate (add1_6, pos) != 0) &&
+ (v.validate (add2_1, pos) != 0) &&
+ (v.validate (add2_2, pos) != 0) &&
+ (v.validate (add2_3, pos) != 0) &&
+ (v.validate (add2_4, pos) != 0) &&
+ (v.validate (add2_5, pos) != 0) &&
+ (v.validate (add2_6, pos) != 0) &&
+ (v.validate (add3_1, pos) != 0) &&
+ (v.validate (add3_2, pos) != 0) &&
+ (v.validate (add3_3, pos) != 0) &&
+ (v.validate (add3_4, pos) != 0) &&
+ (v.validate (add3_5, pos) != 0) &&
+ (v.validate (add3_6, pos) != 0))
+ {
- /* validating frame control field values */
+ /* validating frame control field values */
- if ( lineedit_frame_1->text().toInt()<=1 && lineedit_frame_1->text()!="" && lineedit_frame_2->text().toInt()<=1 && lineedit_frame_2->text()!="" && lineedit_frame_3->text().toInt()<=1 && lineedit_frame_3->text()!="" && lineedit_frame_4->text().toInt()<=1 && lineedit_frame_4->text()!="" && lineedit_frame_5->text().toInt()<=1 && lineedit_frame_5->text()!="" && lineedit_frame_6->text().toInt()<=1 && lineedit_frame_6->text()!="" && lineedit_frame_7->text().toInt()<=1 && lineedit_frame_7->text()!="" && lineedit_frame_8->text().toInt()<=1 && lineedit_frame_8->text()!="" && lineedit_frame_9->text().toInt()<=1 && lineedit_frame_9->text()!="" && lineedit_frame_10->text().toInt()<=1 && lineedit_frame_10->text()!="" && lineedit_frame_11->text().toInt()<=1 && lineedit_frame_11->text()!="" && lineedit_frame_12->text().toInt()<=1 && lineedit_frame_12->text()!="" && lineedit_frame_13->text().toInt()<=1 && lineedit_frame_13->text()!="" && lineedit_frame_14->text().toInt()<=1 && lineedit_frame_14->text()!="" && lineedit_frame_15->text().toInt()<=1 && lineedit_frame_15->text()!="" && lineedit_frame_16->text().toInt()<=1 && lineedit_frame_16->text()!="" )
- {
- /* validating address fields to not have empty space */
+ if (lineedit_frame_1->text().toInt() <= 1 && lineedit_frame_1->text() != "" && lineedit_frame_2->text().toInt() <= 1 && lineedit_frame_2->text() != "" && lineedit_frame_3->text().toInt() <= 1 && lineedit_frame_3->text() != "" && lineedit_frame_4->text().toInt() <= 1 && lineedit_frame_4->text() != "" && lineedit_frame_5->text().toInt() <= 1 && lineedit_frame_5->text() != "" && lineedit_frame_6->text().toInt() <= 1 && lineedit_frame_6->text() != "" && lineedit_frame_7->text().toInt() <= 1 && lineedit_frame_7->text() != "" && lineedit_frame_8->text().toInt() <= 1 && lineedit_frame_8->text() != "" && lineedit_frame_9->text().toInt() <= 1 && lineedit_frame_9->text() != "" && lineedit_frame_10->text().toInt() <= 1 && lineedit_frame_10->text() != "" && lineedit_frame_11->text().toInt() <= 1 && lineedit_frame_11->text() != "" && lineedit_frame_12->text().toInt() <= 1 && lineedit_frame_12->text() != "" && lineedit_frame_13->text().toInt() <= 1 && lineedit_frame_13->text() != "" && lineedit_frame_14->text().toInt() <= 1 && lineedit_frame_14->text() != "" && lineedit_frame_15->text().toInt() <= 1 && lineedit_frame_15->text() != "" && lineedit_frame_16->text().toInt() <= 1 && lineedit_frame_16->text() != "")
+ {
+ /* validating address fields to not have empty space */
- if ( lineedit_address1_1->text()!="" && lineedit_address1_2->text()!="" && lineedit_address1_3->text()!="" && lineedit_address1_4->text()!="" && lineedit_address1_5->text()!="" && lineedit_address1_6->text()!="" && lineedit_address2_1->text()!="" && lineedit_address2_2->text()!="" && lineedit_address2_3->text()!="" && lineedit_address2_4->text()!="" && lineedit_address2_5->text()!="" && lineedit_address2_6->text()!="" && lineedit_address3_1->text()!="" && lineedit_address3_2->text()!="" && lineedit_address3_3->text()!="" && lineedit_address3_4->text()!="" && lineedit_address3_5->text()!="" && lineedit_address3_6->text()!="" )
- {
- uint16_t frag_no=lineedit_frag_no->text().toInt();
- uint16_t seq_no=lineedit_seq_no->text().toInt();
- uint16_t duration_id = lineedit_NAV->text().toInt();
+ if (lineedit_address1_1->text() != "" && lineedit_address1_2->text() != "" && lineedit_address1_3->text() != "" && lineedit_address1_4->text() != "" && lineedit_address1_5->text() != "" && lineedit_address1_6->text() != "" && lineedit_address2_1->text() != "" && lineedit_address2_2->text() != "" && lineedit_address2_3->text() != "" && lineedit_address2_4->text() != "" && lineedit_address2_5->text() != "" && lineedit_address2_6->text() != "" && lineedit_address3_1->text() != "" && lineedit_address3_2->text() != "" && lineedit_address3_3->text() != "" && lineedit_address3_4->text() != "" && lineedit_address3_5->text() != "" && lineedit_address3_6->text() != "")
+ {
+ uint16_t frag_no = lineedit_frag_no->text().toInt();
+ uint16_t seq_no = lineedit_seq_no->text().toInt();
+ uint16_t duration_id = lineedit_NAV->text().toInt();
- /* validating NAV */
- if ( duration_id<65535 && lineedit_NAV->text()!="" )
- {
- /* validating freq_no */
- if ( frag_no<16 && lineedit_frag_no->text()!="" )
- {
- /* validating seq_no */
- if ( seq_no<4096 && lineedit_seq_no->text()!="" )
- {
- uint16_t status_code = lineedit_status_code->text().toInt(), i;
- uint8_t frame_ctrl0 = 0x00, frame_ctrl1 = 0x00, duration_char[2];
- /* Form Frame control */
- frame_ctrl0 = mac.bits_to_byte( lineedit_frame_1->text(), lineedit_frame_2->text(), lineedit_frame_3->text(), lineedit_frame_4->text(), lineedit_frame_5->text(), lineedit_frame_6->text(), lineedit_frame_7->text(), lineedit_frame_8->text() );
+ /* validating NAV */
+ if (duration_id < 65535 && lineedit_NAV->text() != "")
+ {
+ /* validating freq_no */
+ if (frag_no < 16 && lineedit_frag_no->text() != "")
+ {
+ /* validating seq_no */
+ if (seq_no < 4096 && lineedit_seq_no->text() != "")
+ {
+ uint16_t i, status_code = lineedit_status_code->text().toInt();
+ uint8_t frame_ctrl[2], duration_char[2], addr1[6], addr2[6], addr3[6];
+ /* Form Frame control */
+ frame_ctrl[0] = mac.bits_to_byte (lineedit_frame_1->text(), lineedit_frame_2->text(), lineedit_frame_3->text(), lineedit_frame_4->text(), lineedit_frame_5->text(), lineedit_frame_6->text(), lineedit_frame_7->text(), lineedit_frame_8->text());
- /* Form Frame control (flags) */
- frame_ctrl1 = mac.bits_to_byte( lineedit_frame_9->text(), lineedit_frame_10->text(), lineedit_frame_11->text(), lineedit_frame_12->text(), lineedit_frame_13->text(), lineedit_frame_14->text(), lineedit_frame_15->text(), lineedit_frame_16->text() );
+ /* Form Frame control (flags) */
+ frame_ctrl[1] = mac.bits_to_byte (lineedit_frame_9->text(), lineedit_frame_10->text(), lineedit_frame_11->text(), lineedit_frame_12->text(), lineedit_frame_13->text(), lineedit_frame_14->text(), lineedit_frame_15->text(), lineedit_frame_16->text());
- for ( i=0;i<2;i++ )
- duration_char[i] = * ((( char* ) &duration_id ) +i );
+ for (i = 0;i < 2;i++)
+ duration_char[i] = * ( ( (unsigned char*) & duration_id) + i);
- uint8_t addr1_1 = ( unsigned char ) lineedit_address1_1->text().toInt( &ok ,16 );
- uint8_t addr1_2 = ( unsigned char ) lineedit_address1_2->text().toInt( &ok ,16 );
- uint8_t addr1_3 = ( unsigned char ) lineedit_address1_3->text().toInt( &ok ,16 );
- uint8_t addr1_4 = ( unsigned char ) lineedit_address1_4->text().toInt( &ok ,16 );
- uint8_t addr1_5 = ( unsigned char ) lineedit_address1_5->text().toInt( &ok ,16 );
- uint8_t addr1_6 = ( unsigned char ) lineedit_address1_6->text().toInt( &ok ,16 );
- uint8_t addr2_1 = ( unsigned char ) lineedit_address2_1->text().toInt( &ok ,16 );
- uint8_t addr2_2 = ( unsigned char ) lineedit_address2_2->text().toInt( &ok ,16 );
- uint8_t addr2_3 = ( unsigned char ) lineedit_address2_3->text().toInt( &ok ,16 );
- uint8_t addr2_4 = ( unsigned char ) lineedit_address2_4->text().toInt( &ok ,16 );
- uint8_t addr2_5 = ( unsigned char ) lineedit_address2_5->text().toInt( &ok ,16 );
- uint8_t addr2_6 = ( unsigned char ) lineedit_address2_6->text().toInt( &ok ,16 );
- uint8_t addr3_1 = ( unsigned char ) lineedit_address2_1->text().toInt( &ok ,16 );
- uint8_t addr3_2 = ( unsigned char ) lineedit_address2_2->text().toInt( &ok ,16 );
- uint8_t addr3_3 = ( unsigned char ) lineedit_address2_3->text().toInt( &ok ,16 );
- uint8_t addr3_4 = ( unsigned char ) lineedit_address2_4->text().toInt( &ok ,16 );
- uint8_t addr3_5 = ( unsigned char ) lineedit_address2_5->text().toInt( &ok ,16 );
- uint8_t addr3_6 = ( unsigned char ) lineedit_address2_6->text().toInt( &ok ,16 );
+ /* adress fields initializing to local variable */
+ addr1[0] = (unsigned char) lineedit_address1_1->text().toInt (&ok , 16);
+ addr1[1] = (unsigned char) lineedit_address1_2->text().toInt (&ok , 16);
+ addr1[2] = (unsigned char) lineedit_address1_3->text().toInt (&ok , 16);
+ addr1[3] = (unsigned char) lineedit_address1_4->text().toInt (&ok , 16);
+ addr1[4] = (unsigned char) lineedit_address1_5->text().toInt (&ok , 16);
+ addr1[5] = (unsigned char) lineedit_address1_6->text().toInt (&ok , 16);
+ addr2[0] = (unsigned char) lineedit_address2_1->text().toInt (&ok , 16);
+ addr2[1] = (unsigned char) lineedit_address2_2->text().toInt (&ok , 16);
+ addr2[2] = (unsigned char) lineedit_address2_3->text().toInt (&ok , 16);
+ addr2[3] = (unsigned char) lineedit_address2_4->text().toInt (&ok , 16);
+ addr2[4] = (unsigned char) lineedit_address2_5->text().toInt (&ok , 16);
+ addr2[5] = (unsigned char) lineedit_address2_6->text().toInt (&ok , 16);
+ addr3[0] = (unsigned char) lineedit_address3_1->text().toInt (&ok , 16);
+ addr3[1] = (unsigned char) lineedit_address3_2->text().toInt (&ok , 16);
+ addr3[2] = (unsigned char) lineedit_address3_3->text().toInt (&ok , 16);
+ addr3[3] = (unsigned char) lineedit_address3_4->text().toInt (&ok , 16);
+ addr3[4] = (unsigned char) lineedit_address3_5->text().toInt (&ok , 16);
+ addr3[5] = (unsigned char) lineedit_address3_6->text().toInt (&ok , 16);
+ /* fraq_no , seq_no to 2 bytes char array */
+ uint16_t seq_ctrl_int = 0X00;
+ uint8_t seq_ctrl_char[2];
- /* fraq_no , seq_no to 2 bytes char array */
- uint16_t seq_ctrl_int=0X00;
- uint8_t seq_ctrl_char[2];
+ seq_ctrl_int = seq_ctrl_int | seq_no;
+ seq_ctrl_int = seq_ctrl_int << 4;
+ seq_ctrl_int = seq_ctrl_int | frag_no;
- seq_ctrl_int=seq_ctrl_int | seq_no;
- seq_ctrl_int=seq_ctrl_int << 4;
- seq_ctrl_int=seq_ctrl_int | frag_no;
+ for (i = 0;i < 2;i++)
+ seq_ctrl_char[i] = * ( ( (unsigned char*) & seq_ctrl_int) + i);
- for ( i=0;i<2;i++ )
- seq_ctrl_char[i] = * ((( unsigned char* ) &seq_ctrl_int ) +i );
+ /* authentication algorithm operation */
+ uint8_t auth_algo_char[2];
+ uint16_t auth_algo;
- /* authentication algorithm operation */
- uint8_t tmp_auth_algo_char[2];
- uint16_t temp_auth_algo;
+ if (combobox_auth_algo->currentItem() == 2)
+ auth_algo = lineedit_res_AAlgo->text().toInt();
+ else
+ auth_algo = combobox_auth_algo->currentItem();
- if ( combobox_auth_algo->currentItem()==2 )
- temp_auth_algo=lineedit_res_AAlgo->text().toInt();
- else
- temp_auth_algo=combobox_auth_algo->currentItem();
+ for (i = 0;i < 2;i++)
+ auth_algo_char[i] = * ( ( (char*) & auth_algo) + i);
- for ( i=0;i<2;i++ )
- tmp_auth_algo_char[i] = * ((( char* ) &temp_auth_algo ) +i );
+ /* authentication sequence no operation */
+ uint8_t auth_seqno_char[2];
+ uint16_t auth_seq_no;
- /* authentication sequence no operation */
- uint8_t tmp_auth_seqno_char[2];
- uint16_t temp_auth_seqno;
+ if (combobox_authen_seqno->currentText() == "Reserved")
+ auth_seq_no = lineedit_res_ASN->text().toInt();
+ else
+ auth_seq_no = combobox_authen_seqno->currentText().toInt();
- if ( combobox_authen_seqno->currentText()=="Reserved" )
- temp_auth_seqno=lineedit_res_ASN->text().toInt();
- else
- temp_auth_seqno=combobox_authen_seqno->currentText().toInt();
+ for (i = 0;i < 2;i++)
+ auth_seqno_char[i] = * ( ( (unsigned char*) & auth_seq_no) + i);
- for ( i=0;i<2;i++ )
- tmp_auth_seqno_char[i] = * ((( char* ) &temp_auth_seqno ) +i );
+ /* status code operation */
+ uint16_t temp_status_code = mac.get_status_code (combobox_status_code->currentItem(), status_code);
- /* status code operation */
- uint16_t temp_status_code = mac.get_status_code( combobox_status_code->currentItem(), status_code );
+ uint8_t status_code_char[2];
+ for (i = 0;i < 2;i++)
+ status_code_char[i] = * ( ( (unsigned char*) & temp_status_code) + i);
- uint8_t temp_status_code_char[2];
- for ( i=0;i<2;i++ )
- temp_status_code_char[i] = *((( char* )&temp_status_code )+i );
+ int temp_challenge = challenge_text->text().length();
+ const char *str_challenge = challenge_text->text();
- int temp_challenge = challenge_text->text().length();
- const char *str_challenge=challenge_text->text();
+ memcpy (frame, &frame_ctrl, sizeof (frame_ctrl));
+ frame += sizeof (frame_ctrl);
- /* initializing dynamic char array */
- unsigned char control_header_arr1[] =
- {
- frame_ctrl0,
- frame_ctrl1,
- duration_char[0],
- duration_char[1],
- addr1_1,
- addr1_2,
- addr1_3,
- addr1_4,
- addr1_5,
- addr1_6,
- addr2_1,
- addr2_2,
- addr2_3,
- addr2_4,
- addr2_5,
- addr2_6,
- addr3_1,
- addr3_2,
- addr3_3,
- addr3_4,
- addr3_5,
- addr3_6,
- seq_ctrl_char[0],
- seq_ctrl_char[1],
- tmp_auth_algo_char[0],
- tmp_auth_algo_char[1],
- tmp_auth_seqno_char[0],
- tmp_auth_seqno_char[1]
- };
+ memcpy (frame, &duration_char, sizeof (duration_char));
+ frame += sizeof (duration_char);
- if ( combobox_status_code->isEnabled()==1 && challenge_text->isEnabled()==1 )
- {
- int size_ctrl_hdr_arr1= sizeof( control_header_arr1 );
- unsigned char *control_header_arr;
+ memcpy (frame, &addr1, MAC_ADDRESS_LEN);
+ frame += MAC_ADDRESS_LEN;
- control_header_arr=( unsigned char* ) malloc( size_ctrl_hdr_arr1* ( sizeof( unsigned char ) ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
+ memcpy (frame, &addr2, MAC_ADDRESS_LEN);
+ frame += MAC_ADDRESS_LEN;
- for ( i =0;i < size_ctrl_hdr_arr1; i++ )
- control_header_arr[i]=control_header_arr1[i];
+ memcpy (frame, &addr3, MAC_ADDRESS_LEN);
+ frame += MAC_ADDRESS_LEN;
- int temp_sum=size_ctrl_hdr_arr1+2;
- control_header_arr= ( unsigned char* ) realloc( control_header_arr, temp_sum * sizeof( unsigned char ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
+ memcpy (frame, &seq_ctrl_char, sizeof (seq_ctrl_char));
+ frame += sizeof (seq_ctrl_char);
- control_header_arr[size_ctrl_hdr_arr1]=temp_status_code_char[0];
- control_header_arr[size_ctrl_hdr_arr1+1]=temp_status_code_char[1];
+ memcpy (frame, &auth_algo_char, sizeof (auth_algo_char));
+ frame += sizeof (auth_algo_char);
- int temp_sum1=temp_sum+temp_challenge;
+ memcpy (frame, &auth_seqno_char, sizeof (auth_seqno_char));
+ frame += sizeof (auth_seqno_char);
- control_header_arr= ( unsigned char* ) realloc( control_header_arr, temp_sum1 * sizeof( unsigned char ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
+ int frame_len;
+ if (combobox_status_code->isEnabled() == 1 && challenge_text->isEnabled() == 1)
+ {
+ memcpy (frame, &status_code_char, sizeof (status_code_char));
+ frame += sizeof (status_code_char);
- for ( int r=0;r<temp_challenge;r++ )
- control_header_arr[temp_sum+r]=str_challenge[r];
+ memcpy (frame, str_challenge, sizeof (temp_challenge));
+ frame += sizeof (temp_challenge);
- if ( lineedit_status_code->isEnabled()==1 )
- {
- if ((( status_code>1 && status_code<10 ) || ( status_code>26 && status_code<32 ) || ( status_code==36 ) || ( status_code>51 && status_code<65536 ) ) && lineedit_status_code->text()!="" )
- {
- func_auth_call( control_header_arr,temp_sum1 );
- }
- else
- {
- KMessageBox::error( this,"invalid status code" );
- lineedit_status_code->setText( "" );
- }
- }
- else
- {
- func_auth_call( control_header_arr,temp_sum1 );
- }
- }
- else
- if ( combobox_status_code->isEnabled()==0 && challenge_text->isEnabled()==0 )
- {
- int size_ctrl_hdr_arr1= sizeof( control_header_arr1 );
- unsigned char *control_header_arr;
+ frame_len = frame - &msg[0];
+ if (lineedit_status_code->isEnabled() == 1)
+ {
+ if ( ( (status_code > 1 && status_code < 10) || (status_code > 26 && status_code < 32) || (status_code == 36) || (status_code > 51 && status_code < 65536)) && lineedit_status_code->text() != "")
+ {
+ func_auth_call (msg, frame_len);
+ }
+ else
+ {
+ KMessageBox::error (this, "invalid status code");
+ lineedit_status_code->setText ("");
+ }
+ }
+ else
+ func_auth_call (msg , frame_len);
+ }
+ else if (combobox_status_code->isEnabled() == 0 && challenge_text->isEnabled() == 0)
+ {
+ frame_len = frame - &msg[0];
- control_header_arr=( unsigned char* ) malloc( size_ctrl_hdr_arr1* ( sizeof( unsigned char ) ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
+ if (lineedit_status_code->isEnabled() == 1)
+ {
+ if ( ( ( (status_code > 1) && (status_code < 10)) || ( (status_code > 26) && (status_code < 32)) || (status_code == 36) || ( (status_code > 51) && (status_code < 65536))) && (lineedit_status_code->text() != ""))
+ func_auth_call (msg , frame_len);
+ else
+ {
+ KMessageBox::error (this, "invalid status code");
+ lineedit_status_code->setText ("");
+ }
+ }
+ else
+ func_auth_call (msg , frame_len);
+ }
+ else if (combobox_status_code->isEnabled() == 0 && challenge_text->isEnabled() == 1)
+ {
+ memcpy (frame, str_challenge, sizeof (temp_challenge));
+ frame += sizeof (temp_challenge);
+ frame_len = frame - &msg[0];
+ if (lineedit_status_code->isEnabled() == 1)
+ {
+ if ( ( (status_code > 1 && status_code < 10) || (status_code > 26 && status_code < 32) || (status_code == 36) || (status_code > 51 && status_code < 65536)) && lineedit_status_code->text() != "")
+ {
+ func_auth_call (msg, frame_len);
+ }
+ else
+ {
+ KMessageBox::error (this, "invalid status code");
+ lineedit_status_code->setText ("");
+ }
+ }
+ else
+ {
+ func_auth_call (msg, frame_len);
+ }
+ }
+ else if (challenge_text->isEnabled() == 0 && combobox_status_code->isEnabled() == 1)
+ {
+ memcpy (frame, &status_code_char, sizeof (status_code_char));
+ frame += sizeof (status_code_char);
- for ( int i =0;i < size_ctrl_hdr_arr1; i++ )
- control_header_arr[i]=control_header_arr1[i];
-
- if ( lineedit_status_code->isEnabled()==1 )
- {
- if (( ( (status_code>1) && (status_code<10) ) || ( (status_code>26) && (status_code<32) ) || ( status_code==36 ) || ( (status_code>51) && (status_code<65536) ) ) && (lineedit_status_code->text()!="") )
- func_auth_call( control_header_arr,size_ctrl_hdr_arr1 );
- else
- {
- KMessageBox::error( this,"invalid status code" );
- lineedit_status_code->setText( "" );
- }
- }
- else
- func_auth_call( control_header_arr,size_ctrl_hdr_arr1 );
- }
- else
- if ( combobox_status_code->isEnabled()==0 && challenge_text->isEnabled()==1 )
- {
- int size_ctrl_hdr_arr1= sizeof( control_header_arr1 );
- unsigned char *control_header_arr;
-
- control_header_arr=( unsigned char* ) malloc( size_ctrl_hdr_arr1* ( sizeof( unsigned char ) ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
-
- for ( i =0;i < size_ctrl_hdr_arr1; i++ )
- control_header_arr[i]=control_header_arr1[i];
-
- int temp_sum=size_ctrl_hdr_arr1+temp_challenge;
- control_header_arr= ( unsigned char* ) realloc( control_header_arr, temp_sum * sizeof( unsigned char ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
-
- for ( int r=0;r<temp_challenge;r++ )
- control_header_arr[size_ctrl_hdr_arr1+r]=str_challenge[r];
-
- if ( lineedit_status_code->isEnabled()==1 )
- {
- if ((( status_code>1 && status_code<10 ) || ( status_code>26 && status_code<32 ) || ( status_code==36 ) || ( status_code>51 && status_code<65536 ) ) && lineedit_status_code->text()!="" )
- {
- func_auth_call( control_header_arr,temp_sum );
- }
- else
- {
- KMessageBox::error( this,"invalid status code" );
- lineedit_status_code->setText( "" );
- }
- }
- else
- {
- func_auth_call( control_header_arr,temp_sum );
- }
- }
- else
- if ( challenge_text->isEnabled()==0 && combobox_status_code->isEnabled()==1 )
- {
- int size_ctrl_hdr_arr1= sizeof( control_header_arr1 );
- unsigned char *control_header_arr;
-
- control_header_arr=( unsigned char* ) malloc( size_ctrl_hdr_arr1* ( sizeof( unsigned char ) ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
-
- int i;
- for ( i =0;i < size_ctrl_hdr_arr1; i++ )
- control_header_arr[i]=control_header_arr1[i];
-
- int temp_sum=size_ctrl_hdr_arr1+2;
- control_header_arr= ( unsigned char* ) realloc( control_header_arr, temp_sum * sizeof( unsigned char ) );
- if ( control_header_arr == NULL )
- {
- printf( "Unable to allocate memory...\n" );
- exit( 1 );
- }
-
- control_header_arr[size_ctrl_hdr_arr1]=temp_status_code_char[0];
- control_header_arr[size_ctrl_hdr_arr1+1]=temp_status_code_char[1];
-
- if ( lineedit_status_code->isEnabled()==1 )
- {
- if ((( status_code>1 && status_code<10 ) || ( status_code>26 && status_code<32 ) || ( status_code==36 ) || ( status_code>51 && status_code<65536 ) ) && lineedit_status_code->text()!="" )
- {
- func_auth_call( control_header_arr,temp_sum );
- }
- else
- {
- KMessageBox::error( this,"invalid status code" );
- lineedit_status_code->setText( "" );
- }
- }
- else
- {
- func_auth_call( control_header_arr,temp_sum );
- }
- }
- }
- else
- {
- KMessageBox::error( this,"sequence number should be in the range 0 and 4095" );
- lineedit_seq_no->setText( "" );
- }
- }
- else
- {
- KMessageBox::error( this,"Fragment number should be in the range 0 and 15" );
- lineedit_frag_no->setText( "" );
- }
- }
- else
- KMessageBox::error( this,"NAV should be less than 65535" );
- }
- else
- KMessageBox::error( this,"Address field empty" );
- }
- else
- KMessageBox::error( this,"Check the frame control field" );
- }
- else
- KMessageBox::error( this,"Hexa decimal values only allowed in address field" );
+ frame_len = frame - &msg[0];
+ if (lineedit_status_code->isEnabled() == 1)
+ {
+ if ( ( (status_code > 1 && status_code < 10) || (status_code > 26 && status_code < 32) || (status_code == 36) || (status_code > 51 && status_code < 65536)) && lineedit_status_code->text() != "")
+ {
+ func_auth_call (msg , frame_len);
+ }
+ else
+ {
+ KMessageBox::error (this, "invalid status code");
+ lineedit_status_code->setText ("");
+ }
+ }
+ else
+ {
+ func_auth_call (msg , frame_len);
+ }
+ }
+ }
+ else
+ {
+ KMessageBox::error (this, "sequence number should be in the range 0 and 4095");
+ lineedit_seq_no->setText ("");
+ }
+ }
+ else
+ {
+ KMessageBox::error (this, "Fragment number should be in the range 0 and 15");
+ lineedit_frag_no->setText ("");
+ }
+ }
+ else
+ KMessageBox::error (this, "NAV should be less than 65535");
+ }
+ else
+ KMessageBox::error (this, "Address field empty");
+ }
+ else
+ KMessageBox::error (this...
[truncated message content] |