#include <TFTP_Parser.hpp>
Public Methods | |
TFTP_Parser () | |
virtual | ~TFTP_Parser () |
void | parseOptions (char *str, size_t length, size_t offset) |
char * | scanParam (char *str, size_t *len) |
void | getParams (char *str, size_t offset) |
int | select (int i) |
void | RRQ_driver (char *rawPacket, int sz) |
void | WRQ_driver (char *rawPacket, int sz) |
int | TestTimeout (short blockNo) |
void | DATA_driver (char *rawPacket, int sz) |
void | ACK_driver (char *rawPacket, int sz) |
void | ERROR_driver (char *rawPacket, int sz) |
void | OACK_driver (char *rawPacket, int sz) |
void | opcodeDispatcher (char *rawPacket, int sz) |
Private Attributes | |
bool | OACK_arg |
int | blocksizeDefault |
int | windowsizeDefault |
int | timeoutDefault |
size_t | expectedBlockSize |
TFTP_ParserCallback * | opTable |
char * | array [12] |
size_t | array_sz |
|
Definition at line 16 of file TFTP_Parser.cpp. 00017 { 00018 OACK_arg = FALSE; 00019 array_sz = 0; 00020 expectedBlockSize = option.getBlockSizeValue(); 00021 00022 blocksizeDefault = 1; 00023 windowsizeDefault = 1; 00024 timeoutDefault = 1; 00025 00026 opTable = new TFTP_ParserCallback[6]; 00027 00028 opTable[0] = &TFTP_Parser::RRQ_driver; 00029 opTable[1] = &TFTP_Parser::WRQ_driver; 00030 opTable[2] = &TFTP_Parser::DATA_driver; 00031 opTable[3] = &TFTP_Parser::ACK_driver; 00032 opTable[4] = &TFTP_Parser::ERROR_driver; 00033 opTable[5] = &TFTP_Parser::OACK_driver; 00034 } |
|
Definition at line 36 of file TFTP_Parser.cpp. 00037 { 00038 if ( opTable != NULL ) delete[] opTable; 00039 } |
|
Definition at line 259 of file TFTP_Parser.hpp. |
|
Definition at line 215 of file TFTP_Parser.hpp. |
|
Definition at line 333 of file TFTP_Parser.hpp. |
|
Definition at line 343 of file TFTP_Parser.hpp. |
|
Definition at line 51 of file TFTP_Parser.hpp. |
|
Definition at line 181 of file TFTP_Parser.hpp. |
|
Definition at line 127 of file TFTP_Parser.hpp. |
|
Definition at line 93 of file TFTP_Parser.cpp. Referenced by parseOptions().
00094 { 00095 size_t l = 1; 00096 char* f = str + offset; 00097 char* p = f; 00098 char* q = p; 00099 00100 int k = 0; 00101 while( l != 0 ) 00102 { 00103 // q = scanParam( p, &l ); 00104 l = strlen( p ); 00105 q = p + l + 1; 00106 array[ k ] = new char[ l ]; 00107 memcpy( array[ k ], p, l ); 00108 k++; 00109 p = q; 00110 } 00111 array_sz = k - 1; 00112 } |
|
Definition at line 400 of file TFTP_Parser.hpp. |
|
Definition at line 41 of file TFTP_Parser.cpp. 00042 { 00043 // CORRUPTION OF THE STACK, PATCH THE STRING BY BACKUPing! 00044 char* tmp = new char[ length ]; 00045 memcpy( tmp, str, length ); 00046 delete [] str; 00047 00048 array_sz = 0; 00049 00050 blocksizeDefault = 1; 00051 windowsizeDefault = 1; 00052 timeoutDefault = 1; 00053 00054 getParams( tmp, offset ); 00055 00056 printf( "%d", array_sz ); 00057 fflush( stdout ); 00058 for( int i = 0; i < array_sz; i++ ) { 00059 safePrint( array[i] ); 00060 printf( "\t%d-%d\n", i, array_sz ); 00061 fflush( stdout ); 00062 i += select( i ); 00063 } 00064 00065 // If not defined, set TFTP default options. 00066 if ( blocksizeDefault ) { 00067 option.setBlockSize( atol( DEFAULT_BLOCKSIZE ) ); 00068 } 00069 00070 if ( windowsizeDefault ) { 00071 option.setWindowSize( atol( DEFAULT_WINDOWSIZE ) ); 00072 } 00073 00074 if ( timeoutDefault ) { 00075 option.setTimeOut( atol( DEFAULT_TIMEOUT ) ); 00076 } 00077 00078 expectedBlockSize = option.getBlockSizeValue(); 00079 00080 str = new char[ length ]; 00081 memcpy( str, tmp, length ); 00082 } |
|
Definition at line 84 of file TFTP_Parser.cpp. |
|
Definition at line 116 of file TFTP_Parser.cpp. Referenced by parseOptions().
00117 { 00118 char* s2 = array[i]; 00119 00120 if ( s2 != NULL ) s2 = strlwr( s2 ); 00121 00122 char* opt = NULL; 00123 00124 if ( (i+1) <= array_sz ) { 00125 opt = strlwr( array[i+1] ); 00126 } 00127 00128 if ( !strcmp( s2, "blksize" ) || !strcmp( s2, "blocksize" ) ) 00129 { 00130 long bsize = atol( opt ); 00131 printf("BlockSize[%d]", bsize ); 00132 fflush( stdout ); 00133 // OACK_arg = TRUE; 00134 option.requestedBlockSize( bsize ); 00135 blocksizeDefault = 0; 00136 return 1; 00137 } else 00138 if ( !strcmp( s2, "timeout" ) ) 00139 { 00140 size_t t = atol( opt ); 00141 printf("Timeout[%d]", t ); 00142 fflush( stdout ); 00143 // OACK_arg = TRUE; 00144 option.requestedTimeOut( t ); 00145 timeoutDefault = 0; 00146 return 1; 00147 } else 00148 if ( !strcmp( s2, "tsize" ) ) 00149 { 00150 size_t sz = atol( opt ); 00151 printf("FileSize[%d]", sz ); 00152 fflush( stdout ); 00153 // OACK_arg = TRUE; 00154 option.requestedFileSize( sz ); 00155 return 1; 00156 } else 00157 if ( !strcmp( s2, "wsize" ) || !strcmp( s2, "windowsize" ) \ 00158 || !strcmp( s2, "window" ) ) 00159 { 00160 long wsize = atol( opt ); 00161 printf("WindowSize[%d]", wsize ); 00162 fflush( stdout ); 00163 // OACK_arg = TRUE; 00164 option.requestedWindowSize( wsize ); 00165 windowsizeDefault = 0; 00166 return 1; 00167 } 00168 00169 if ( i == 0 ) { 00170 printf("Filename[%s]\n", array[i] ); 00171 fflush( stdout ); 00172 option.setFileName( array[i] ); 00173 return 0; 00174 } 00175 00176 if ( i == 1 ) { 00177 printf("Mode[%s]\n", array[i] ); 00178 fflush( stdout ); 00179 option.requestedMode( array[i] ); 00180 return 0; 00181 } 00182 00183 return 0; 00184 } |
|
Definition at line 444 of file TFTP_Parser.hpp. |
|
Definition at line 454 of file TFTP_Parser.hpp. |
|
Definition at line 455 of file TFTP_Parser.hpp. |
|
Definition at line 446 of file TFTP_Parser.hpp. |
|
Definition at line 450 of file TFTP_Parser.hpp. |
|
Definition at line 452 of file TFTP_Parser.hpp. |
|
Definition at line 448 of file TFTP_Parser.hpp. |
|
Definition at line 447 of file TFTP_Parser.hpp. |