|
From: <sat...@us...> - 2010-03-11 15:10:11
|
Revision: 233
http://w-meter.svn.sourceforge.net/w-meter/?rev=233&view=rev
Author: sathakselva
Date: 2010-03-11 14:40:30 +0000 (Thu, 11 Mar 2010)
Log Message:
-----------
Source & Destination IP address processing added in data frames
Modified Paths:
--------------
frame_injection_g/trunk/src/data_dataframe_cpp.cpp
Modified: frame_injection_g/trunk/src/data_dataframe_cpp.cpp
===================================================================
--- frame_injection_g/trunk/src/data_dataframe_cpp.cpp 2010-03-11 13:59:43 UTC (rev 232)
+++ frame_injection_g/trunk/src/data_dataframe_cpp.cpp 2010-03-11 14:40:30 UTC (rev 233)
@@ -337,18 +337,30 @@
uint16_t temp_payload_size = lineedit_payload->text().length();
const char *str_payload = lineedit_payload->text();
- QString str_ipsource=lineedit_ip_source->text();
+ QString str_ipsource = lineedit_ip_source->text();
+ QString str_ipdest = lineedit_ip_dest->text();
unsigned long ip;
- uint16_t a,b,c,d;
+ uint8_t src_ip[4], dest_ip[4];
ip=inet_addr( str_ipsource );
- d=( ip>>24 )&0xff;
- c=( ip>>16 )&0xff;
- b=( ip>>8 )&0xff;
- a=ip&0xff;
- printf( "%2x\n%2x\n%2x\n%2x",a,b,c,d );
+ int run, shift = 24;
+
+ for (run = 3; run >=0; run--)
+ {
+ src_ip[run] = ( ip >> shift ) & 0xff;
+ shift -= 8;
+ }
+
+ printf("%02x %02x %02x %02x\n", src_ip[0], src_ip[1], src_ip[2], src_ip[3]);
+
+ ip=inet_addr( str_ipdest );
+ for (run = 3, shift = 24; run >=0; run--)
+ {
+ dest_ip[run] = ( ip >> shift ) & 0xff;
+ shift -= 8;
+ }
uint8_t llc_hdr[8] = {0xaa, 0xaa, 0x03,0x00,0x00,0x00,0x08,0x00};
//values initializing in a dynamic array
uint8_t control_header_arr1[] =
@@ -402,7 +414,7 @@
}
else
{
- /* Otherwise increase the memory size to append LLC header */
+ /* Otherwise increase the variable size to append LLC header */
int llc_hdr_len = sizeof(llc_hdr)/sizeof(llc_hdr[0]);
control_header_arr=( unsigned char* ) realloc( control_header_arr, (frame_len + llc_hdr_len) * ( sizeof( unsigned char ) ) );
if ( control_header_arr == NULL )
@@ -416,7 +428,9 @@
frame_len = frame_len + llc_hdr_len;
/* Add IP header
This part is very ugly. Need to modify */
- unsigned char ip_hdr[] = {0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0xb7, 0x44, 0xc0, 0xa8, 0x01, 0x0b, 0xc0, 0xa8, 0x01, 0x09};
+ unsigned char ip_hdr[] = {
+ 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0xb7, 0x44, src_ip[0], src_ip[1], src_ip[2], src_ip[3], dest_ip[0], dest_ip[1], dest_ip[2], dest_ip[3]
+ };
int ip_hdr_len = sizeof(ip_hdr)/sizeof(ip_hdr[0]);
@@ -458,7 +472,7 @@
unsigned char temp_char_arr[msdu_size];
for ( int i=0; i<msdu_size; i++ )
- temp_char_arr[i]='a';
+ temp_char_arr[i]='a';
uint16_t temp_sum = frame_len + msdu_size;
@@ -628,7 +642,6 @@
lineedit_msdu_size->setText( "0" );
}
-
void data_dataframe_cpp::save_in_txt( char *file )
{
FILE *fptr;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|