#include <TFTP_Option.hpp>
Public Methods | |
| TFTP_Option () | |
| virtual | ~TFTP_Option () |
| void | ArgParser (int argc, char *argv[]) |
| void | ArgDetect (const char *s, char *o) |
| void | ConfigClient (char *opt) |
| void | TFTP_Option::ConfigServer (char *opt) |
| void | build_RRQ_WRQ_TemplatePacket () |
| void | build_OptionPacket () |
| __inline void | setFileName (const char *fname) |
| const char * | getFileName () |
| __inline void | setBlockSize (size_t bsize) |
| __inline void | requestedBlockSize (size_t bsize) |
| __inline size_t | getBlockSize () |
| __inline void | setPort (size_t portNo) |
| __inline void | setHostName (const char *host) |
| __inline void | setWindowSize (size_t wsize) |
| __inline void | requestedWindowSize (size_t wsize) |
| __inline size_t | getWindowSize () |
| __inline void | setFileSize (size_t fsize) |
| __inline void | requestedFileSize (size_t fsize) |
| __inline const char * | getFileSize () |
| __inline void | setMode (char *m) |
| __inline void | requestedMode (const char *m) |
| __inline const char * | getMode () |
| __inline void | setTimeOut (size_t t) |
| __inline void | requestedTimeOut (size_t t) |
| __inline const char * | getTimeOut () |
| __inline ULONG | getTimeOutValue () |
| __inline ULONG | getBlockSizeValue () |
| __inline ULONG | getWindowSizeValue () |
| void | openFile (char *mode="rb") |
| void | ServiceSelection () |
| void | createSocket () |
| void | showStr (const char *n, const char *s) |
| void | showVal (const char *n, size_t s) |
| void | showChar (const char *n, const char *s, size_t sz) |
| void | showOptions () |
| __inline int | isInitialized () |
| __inline int | isConnected () |
| __inline int | isWaitingForAck () |
| __inline int | isReading () |
| __inline int | isWriting () |
| __inline int | isEnding () |
| __inline int | hasError () |
| __inline int | isKilling () |
| __inline int | isRRQ_Valid () |
| __inline int | isWRQ_Valid () |
| __inline int | isDATA_Valid () |
| __inline int | isACK_Valid () |
| __inline int | isOACK_Valid () |
| __inline int | isServer () |
| __inline int | isClient () |
Public Attributes | |
| JFile * | myFile |
| UDP_Socket * | sender |
| DataFactory * | dataFactory |
| FileFactory * | fileFactory |
| char * | RRQ_WRQ_template |
| size_t | RRQ_WRQ_templateLength |
| char * | Option_template |
| size_t | Option_templateLength |
| RWLock | rwlock1_global |
| RWLock | rwlock2_file |
| RWLock | rwlock3_templates |
| enum TFTP_Status_t | state |
| enum TFTP_Type_t | pgmType |
| int | RW_command |
| bool | OACK_arg |
| RWLock | rwlock5_data_queue |
| DList_pPacket * | data_queue |
| RWLock | rwlock6_wait_queue |
| DList_pPacket * | waitingAck_queue |
| bool | Done |
| size_t | LastData |
| double | currentTime |
| size_t | windowsizeLeft |
| size_t | TopAck |
| TFTP_Timeout * | timeoutThread |
| TFTP_Sender * | sendFactory |
| double | debug |
| friend | TFTP_OptionSaved |
Private Attributes | |
| char * | fpath |
| char * | filename |
| char * | filesize |
| char * | timeout |
| char * | blocksize |
| char * | mode |
| char * | windowsize |
| USHORT | port |
| char * | hostname |
| size_t | hostnameLength |
| size_t | fpathLength |
| size_t | filenameLength |
| size_t | filesizeLength |
| size_t | blocksizeLength |
| size_t | windowsizeLength |
| size_t | timeoutLength |
| size_t | modeLength |
| char * | openedFile |
|
|
Definition at line 9 of file TFTP_Option.cpp. 00010 {
00011 rwlock1_global.write();
00012 fpath = new char[ FILEPATH_LENGTH ]; // 2 lines
00013 openedFile = new char[ FILEPATH_LENGTH ];
00014 filename = new char[ FILENAME_LENGTH ];
00015 hostname = new char[ HOSTNAME_LENGTH ];
00016
00017 filesize = new char[ FILESIZE_LENGTH ]; // < 100 TB
00018 windowsize = new char[ WINDOWSIZE_LENGTH ];
00019 blocksize = new char[ BLOCKSIZE_LENGTH ];
00020 timeout = new char[ TIMEOUT_LENGTH ];
00021 mode = new char[ MODE_LENGTH ];
00022
00023 pgmType = TFTP_Type_Undefined;
00024 state = TFTP_Uninitialized;
00025 OACK_arg = FALSE;
00026 myFile = NULL;
00027 sender = NULL;
00028 fileFactory = NULL;
00029 sendFactory = NULL;
00030 dataFactory = NULL;
00031 TopAck = 0;
00032 LastData = 0;
00033 RW_command = 0;
00034 Done = FALSE;
00035 waitingAck_queue = NULL;
00036 data_queue = NULL;
00037 debug = 0.0;
00038
00039 fpathLength = 0;
00040 filenameLength = 0;
00041 filesizeLength = 0;
00042 windowsizeLength = 2; // "1"
00043 blocksizeLength = 4; // "512"
00044 timeoutLength = 2; // "5"
00045 modeLength = 6; // "octet"
00046
00047 memset( fpath, 0, FILEPATH_LENGTH );
00048 memset( openedFile, 0, FILEPATH_LENGTH );
00049 memset( filename, 0, FILENAME_LENGTH );
00050 memset( hostname, 0, HOSTNAME_LENGTH );
00051 memset( filesize, 0, FILESIZE_LENGTH );
00052 memset( windowsize, 0, WINDOWSIZE_LENGTH );
00053 memset( blocksize, 0, BLOCKSIZE_LENGTH );
00054 memset( timeout, 0, TIMEOUT_LENGTH );
00055 memset( mode, 0, MODE_LENGTH );
00056
00057 port = DEFAULT_PORT;
00058
00059 char* temp;
00060
00061 temp = DEFAULT_BLOCKSIZE;
00062 memcpy( blocksize, temp, 4 );
00063
00064 temp = DEFAULT_WINDOWSIZE;
00065 memcpy( windowsize, temp, 4 );
00066
00067 temp = DEFAULT_TIMEOUT;
00068 memcpy( timeout, temp, 2 );
00069
00070 temp = DEFAULT_MODE;
00071 memcpy( mode, temp, 6 );
00072
00073 temp = DEFAULT_HOSTNAME;
00074 memcpy( hostname, temp, 20 );
00075
00076 rwlock1_global.releaseWrite();
00077
00078
00079 rwlock3_templates.write();
00080
00081 RRQ_WRQ_template = new char[ RRQ_WRQ_TEMPLATE_LENGTH ];
00082 Option_template = new char[ OPTION_TEMPLATE_LENGTH ];
00083
00084 RRQ_WRQ_templateLength = 6 + 2 + 2;
00085 Option_templateLength = 0;
00086
00087 memset( RRQ_WRQ_template, 0, RRQ_WRQ_TEMPLATE_LENGTH );
00088 memset( Option_template, 0, OPTION_TEMPLATE_LENGTH );
00089
00090 rwlock3_templates.releaseWrite();
00091 }
|
|
|
Definition at line 96 of file TFTP_Option.cpp. 00097 {
00098 #if 0
00099 rwlock1_global.write();
00100 if ( fpath != NULL ) delete [] fpath;
00101 if ( filename != NULL ) delete [] filename;
00102 if ( hostname != NULL ) delete [] hostname;
00103 if ( filesize != NULL ) delete [] filesize;
00104 if ( blocksize != NULL ) delete [] blocksize;
00105 if ( timeout != NULL ) delete [] timeout;
00106 if ( mode != NULL ) delete [] mode;
00107 rwlock1_global.releaseWrite();
00108 #endif
00109
00110 rwlock2_file.write();
00111 if ( myFile != NULL ) delete myFile;
00112 if ( sender != NULL ) delete sender;
00113 rwlock2_file.releaseWrite();
00114
00115 rwlock3_templates.write();
00116 if ( RRQ_WRQ_template != NULL ) delete [] RRQ_WRQ_template;
00117 if ( Option_template != NULL ) delete [] Option_template;
00118 rwlock3_templates.releaseWrite();
00119 }
|
|
||||||||||||
|
Definition at line 186 of file TFTP_Option.cpp. Referenced by ArgParser().
00187 {
00188 char* s2 = NULL;
00189 char* opt = o;
00190 size_t val = 0;
00191
00192 if ( s != NULL )
00193 {
00194 s2 = strlwr( s );
00195 }
00196
00197 if ( o != NULL )
00198 {
00199 opt = strlwr( o );
00200 val = atol( opt );
00201 printf("{%s}", o );
00202 }
00203
00204 printf("[%s]", s );
00205 fflush(stdout);
00206 if ( !strcmp( s2, "b" ) || !strcmp( s2, "blksize" ) \
00207 || !strcmp( s2, "blocksize" ) )
00208 {
00209 OACK_arg = TRUE; // This is an OACK extension
00210 setBlockSize( val );
00211 }
00212 else if ( !strcmp( s2, "f" ) || !strcmp( s2, "file" ) \
00213 || !strcmp( s2, "filename" ) )
00214 {
00215 setFileName( o );
00216 }
00217 else if ( !strcmp( s2, "put" ) || !strcmp( s2, "save" ) || \
00218 !strcmp( s2, "write" ) || !strcmp( s2, "upload" ) )
00219 {
00220 setFileName( o );
00221 RW_command = 2;
00222
00223 // Set Write bit and clear Read bit, if any.
00224 pgmType = (TFTP_Type_t)( ((int)pgmType & 0x0B) | 0x08 );
00225 }
00226 else if ( !strcmp( s2, "get" ) || !strcmp( s2, "load" ) || \
00227 !strcmp( s2, "read" ) || !strcmp( s2, "download" ) )
00228 {
00229 setFileName( o );
00230 RW_command = 1;
00231
00232 // Set Read bit and clear Write bit, if any.
00233 pgmType = (TFTP_Type_t)( ((int)pgmType & 0x07) | 0x04 );
00234
00235 }
00236 else if ( !strcmp( s2, "t" ) || !strcmp( s2, "timeout" ) )
00237 {
00238 OACK_arg = TRUE; // This is an OACK extension
00239 setTimeOut( val );
00240 }
00241 else if ( !strcmp( s2, "m" ) || !strcmp( s2, "mode" ) )
00242 {
00243 setMode( opt );
00244 }
00245 else if ( !strcmp( s2, "s" ) || !strcmp( s2, "fsize" ) \
00246 || !strcmp( s2, "filesize" ) )
00247 {
00248 OACK_arg = TRUE; // This is an OACK extension
00249 setFileSize( val );
00250 }
00251 else if ( !strcmp( s2, "w" ) || !strcmp( s2, "wsize" ) || \
00252 !strcmp( s2, "window" ) || !strcmp( s2, "windowsize" ) )
00253 {
00254 OACK_arg = TRUE; // This is an OACK extension
00255 setWindowSize( val );
00256 }
00257 else if ( !strcmp( s2, "h" ) || !strcmp( s2, "host" ) \
00258 || !strcmp( s2, "hostname" ) )
00259 {
00260 setHostName( o );
00261 }
00262 else if ( !strcmp( s2, "p" ) || !strcmp( s2, "port" ) )
00263 {
00264 setPort( val );
00265 }
00266 else if ( !strcmp( s2, "c" ) || !strcmp( s2, "client" ) \
00267 || !strcmp( s2, "open" ) )
00268 {
00269 ConfigClient( opt );
00270 }
00271 else if ( !strcmp( s2, "d" ) || !strcmp( s2, "deamon" ) || \
00272 !strcmp( s2, "srv" ) || !strcmp( s2, "server" ) )
00273 {
00274 ConfigServer( opt );
00275 }
00276 }
|
|
||||||||||||
|
Definition at line 125 of file TFTP_Option.cpp. 00126 {
00127 int i = 1;
00128 if (argc == 1)
00129 {
00130 char service;
00131 printf("Please tell me what kind of service you want. (S)erver or (C)lient?\n");
00132 cin>>service;
00133
00134 if (service == 'S' || service == 's')
00135 {
00136 ConfigServer( NULL );
00137 }
00138 else
00139 {
00140 //Configures the hostname and port of the client
00141 ConfigClient( NULL );
00142 }
00143
00144 }
00145
00146 for ( ; i < argc; i++)
00147 {
00148 // Does the first character is a - or /
00149 if ( argv[i][0] == '-' || argv[i][0] == '/' )
00150 {
00151 char* s = argv[i] + 1;
00152 printf("(%s)", s );
00153 fflush(stdout);
00154 // Do we give param x by space or =
00155 char* p = strchr (argv[i], '=');
00156 if ( p > 0 )
00157 {
00158 // We have to -arg=x or --arg=x
00159 if ( argv[i][1] == '-' ) s++;
00160 *p = '\0';
00161 ArgDetect( s, p+1 );
00162
00163 } else {
00164
00165 // We have to -arg x or --arg x
00166 if ( argv[i][1] == '-' ) s++;
00167
00168 char* opt = NULL;
00169 if ( (i+1) < argc ) opt = argv[i+1];
00170 fflush(stdout);
00171
00172 ArgDetect( s, opt );
00173 i++;
00174 }
00175 } else {
00176 printf("\nInvalid parameter: [%s]\n", argv[i] );
00177 }
00178 }
00179 }
|
|
|
Definition at line 310 of file TFTP_Option.cpp. Referenced by ArgDetect(), and ArgParser().
00311 {
00312
00313 short port = DEFAULT_PORT;
00314 if (opt != NULL)
00315 {
00316 //Look for :
00317 char* q = strchr( opt, ':' );
00318
00319 //If it's there the word after it is the port
00320 if ( q > 0 )
00321 {
00322 port = atol( q+1 );
00323 opt[ (int)(q-opt) ] = '\0';
00324 setPort( port );
00325 //And the hostname is right before.
00326 setHostName( opt);
00327 }
00328 }
00329 else
00330 {
00331 char hn[121];
00332 short pt;
00333 printf("Please enter hostname: \n");
00334 cin>>hn;
00335 printf("Please enter port: \n");
00336 cin>>pt;
00337 setPort (pt);
00338 setHostName(hn);
00339 }
00340
00341 // Set Client bit and clear Server bit, if any.
00342 pgmType = (TFTP_Type_t)( ((int)pgmType & 0xFE) | 0x02 );
00343 }
|
|
|
|
|
|
|
|
|
Definition at line 380 of file TFTP_Option.cpp. 00381 {
00382 size_t sz = 2;
00383 size_t pos = 0;
00384 char* txt_blksize = "blksize"; // 8
00385 char* txt_tsize = "tsize"; // 6
00386 char* txt_timeout = "timeout"; // 8
00387 char* txt_wsize = "window"; // 7
00388
00389 rwlock1_global.read();
00390
00391 if ( blocksize != NULL ) {
00392 sz += blocksizeLength + 8;
00393 }
00394
00395 if ( filesize != NULL ) {
00396 sz += filesizeLength + 6;
00397 }
00398
00399 if ( timeout != NULL ) {
00400 sz += timeoutLength + 8;
00401 }
00402
00403 if ( windowsize != NULL ) {
00404 sz += windowsizeLength + 7;
00405 }
00406
00407 rwlock3_templates.write();
00408
00409 memset( Option_template, 0, OPTION_TEMPLATE_LENGTH );
00410
00411 short oack_op = 6;
00412
00413 memcpy( Option_template, (char*)&oack_op, 2 );
00414
00415 pos = 2;
00416
00417 if ( blocksize != NULL )
00418 {
00419 memcpy( Option_template + pos, txt_blksize, 8 );
00420 Option_template[ pos + 8 - 1 ] = '\0';
00421
00422 memcpy( Option_template + pos + 8, blocksize, blocksizeLength );
00423 Option_template[ pos + 8 + blocksizeLength - 1 ] = '\0';
00424
00425 pos += blocksizeLength + 8;
00426 }
00427
00428 /*
00429 if ( filesize != NULL )
00430 { memset( blocksize, 0, blocksizeLength );
00431
00432 memcpy( Option_template + pos, txt_tsize, 6 );
00433 Option_template[ pos + 6 - 1 ] = '\0';
00434
00435 memcpy( Option_template + pos + 6, filesize, filesizeLength );
00436 Option_template[ pos + 6 + filesizeLength - 1 ] = '\0';
00437
00438 pos += filesizeLength + 6;
00439 }
00440 */
00441
00442 if ( timeout != NULL )
00443 {
00444 memcpy( Option_template + pos, txt_timeout, 8 );
00445 Option_template[ pos + 8 - 1 ] = '\0';
00446
00447 memcpy( Option_template + pos + 8, timeout, timeoutLength );
00448 Option_template[ pos + 8 + timeoutLength - 1 ] = '\0';
00449
00450 pos += timeoutLength + 8;
00451 }
00452
00453 if ( windowsize != NULL )
00454 {
00455 memcpy( Option_template + pos, txt_wsize, 7 );
00456 Option_template[ pos + 7 - 1 ] = '\0';
00457
00458 memcpy( Option_template + pos + 7, windowsize, windowsizeLength );
00459 Option_template[ pos + 7 + windowsizeLength - 1 ] = '\0';
00460
00461 pos += windowsizeLength + 7;
00462 }
00463
00464 Option_templateLength = sz;
00465
00466 rwlock1_global.releaseRead();
00467 rwlock3_templates.releaseWrite();
00468 }
|
|
|
Definition at line 351 of file TFTP_Option.cpp. 00352 {
00353 rwlock1_global.read();
00354 rwlock3_templates.write();
00355
00356 printf("I'm in = (\n");
00357 fflush( stdout );
00358
00359 showOptions();
00360 printf("\n);" );
00361 memset( RRQ_WRQ_template, 0, RRQ_WRQ_TEMPLATE_LENGTH );
00362
00363 short op = 1;
00364
00365 RRQ_WRQ_templateLength = filenameLength + modeLength + 2;
00366
00367 memcpy( RRQ_WRQ_template, (char*)&op, 2 );
00368 memcpy( RRQ_WRQ_template + 2, filename, filenameLength );
00369 memcpy( RRQ_WRQ_template + 2 + filenameLength, mode, modeLength );
00370
00371 rwlock1_global.releaseRead();
00372 rwlock3_templates.releaseWrite();
00373 }
|
|
|
Definition at line 988 of file TFTP_Option.cpp. 00989 {
00990 rwlock2_file.write();
00991 if ( sender != NULL ) {
00992 delete sender;
00993 }
00994
00995 if ( isServer() ) {
00996 sender = new UDP_SocketServer( port );
00997 } else
00998 if ( isClient() ) {
00999 sender = new UDP_SocketClient( hostname, port );
01000 } else {
01001 printf( "The program type, Server or Client, was not specified on the command line.\n");
01002 exit( 1 );
01003 }
01004 rwlock2_file.releaseWrite();
01005 }
|
|
|
Definition at line 536 of file TFTP_Option.cpp. 00537 {
00538 rwlock1_global.read();
00539 long sz = atol( blocksize );
00540 rwlock1_global.releaseRead();
00541 return (size_t)sz;
00542 }
|
|
|
Definition at line 766 of file TFTP_Option.cpp. 00767 {
00768 rwlock1_global.read();
00769 long val = atol( blocksize );
00770 rwlock1_global.releaseRead();
00771 return (ULONG)val;
00772 }
|
|
|
Definition at line 491 of file TFTP_Option.cpp. 00492 {
00493 rwlock1_global.read();
00494 char* temp = new char[ filenameLength ];
00495 memcpy( temp, filename, filenameLength );
00496 rwlock1_global.releaseRead();
00497 return (const char*)temp;
00498 }
|
|
|
Definition at line 646 of file TFTP_Option.cpp. 00647 {
00648 rwlock1_global.read();
00649 char* temp = new char[ filesizeLength ];
00650 memcpy( temp, filesize, filesizeLength );
00651 rwlock1_global.releaseRead();
00652 return (const char*)temp;
00653 }
|
|
|
Definition at line 698 of file TFTP_Option.cpp. 00699 {
00700 rwlock1_global.read();
00701 char* temp = new char[ modeLength ];
00702 memcpy( temp, mode, modeLength );
00703 rwlock1_global.releaseRead();
00704 return (const char*)temp;
00705 }
|
|
|
Definition at line 743 of file TFTP_Option.cpp. 00744 {
00745 rwlock1_global.read();
00746 char* temp = new char[ timeoutLength ];
00747 memcpy( temp, timeout, timeoutLength );
00748 rwlock1_global.releaseRead();
00749 return (const char*)temp;
00750 }
|
|
|
Definition at line 755 of file TFTP_Option.cpp. 00756 {
00757 rwlock1_global.read();
00758 long val = atol( timeout );
00759 rwlock1_global.releaseRead();
00760 return (ULONG)val;
00761 }
|
|
|
Definition at line 605 of file TFTP_Option.cpp. 00606 {
00607 rwlock1_global.read();
00608 long sz = atol( windowsize );
00609 rwlock1_global.releaseRead();
00610 return (size_t)sz;
00611 }
|
|
|
Definition at line 777 of file TFTP_Option.cpp. 00778 {
00779 rwlock1_global.read();
00780 long val = atol( windowsize );
00781 rwlock1_global.releaseRead();
00782 return (ULONG)val;
00783 }
|
|
|
Definition at line 891 of file TFTP_Option.cpp. 00892 {
00893 return (( (int)state & 0x40 ) == 0x40 );
00894 }
|
|
|
Definition at line 979 of file TFTP_Option.cpp. 00980 {
00981 return ( state == TFTP_Reading || state == TFTP_Writing \
00982 || state == TFTP_ReadingNotAck || state == TFTP_WritingNotAck );
00983 }
|
|
|
Definition at line 922 of file TFTP_Option.cpp. Referenced by createSocket(), isDATA_Valid(), isOACK_Valid(), and openFile().
00923 {
00924 return (( (int)pgmType & 0x02 ) == 0x02 );
00925 }
|
|
|
Definition at line 851 of file TFTP_Option.cpp. 00852 {
00853 return (( (int)state & 0x02 ) == 0x02 );
00854 }
|
|
|
Definition at line 954 of file TFTP_Option.cpp. 00955 {
00956 return ( ( state == TFTP_ReadingNotAck && isClient() ) || \
00957 ( state == TFTP_Reading && isClient() ) || \
00958 ( state == TFTP_Writing && isServer() ) );
00959 }
|
|
|
Definition at line 883 of file TFTP_Option.cpp. 00884 {
00885 return (( (int)state & 0x20 ) == 0x20 );
00886 }
|
|
|
Definition at line 843 of file TFTP_Option.cpp. 00844 {
00845 return (( (int)state & 0x01 ) == 0x01 );
00846 }
|
|
|
Definition at line 899 of file TFTP_Option.cpp. 00900 {
00901 return (( (int)state & 0x80 ) == 0x80 );
00902 }
|
|
|
Definition at line 967 of file TFTP_Option.cpp. 00968 {
00969 return ( (( state == TFTP_ReadingNotAck ) || \
00970 ( state == TFTP_WritingNotAck )) && isClient() );
00971 }
|
|
|
Definition at line 931 of file TFTP_Option.cpp. 00932 {
00933 return ( state == TFTP_Connected && isServer() );
00934 }
|
|
|
Definition at line 867 of file TFTP_Option.cpp. Referenced by openFile().
00868 {
00869 return (( (int)state & 0x08 ) == 0x08 );
00870 }
|
|
|
Definition at line 917 of file TFTP_Option.cpp. Referenced by createSocket(), isDATA_Valid(), isRRQ_Valid(), isWRQ_Valid(), and openFile().
00918 {
00919 return (( (int)pgmType & 0x01 ) == 0x01 );
00920 }
|
|
|
Definition at line 940 of file TFTP_Option.cpp. 00941 {
00942 return ( state == TFTP_Connected && isServer() );
00943 }
|
|
|
Definition at line 859 of file TFTP_Option.cpp. 00860 {
00861 return (( (int)state & 0x04 ) == 0x04 );
00862 }
|
|
|
Definition at line 875 of file TFTP_Option.cpp. Referenced by openFile().
00876 {
00877 return (( (int)state & 0x10 ) == 0x10 );
00878 }
|
|
|
Definition at line 789 of file TFTP_Option.cpp. 00790 {
00791 if ( !strcmp( openedFile, fpath ) ) return;
00792
00793 char* rw = rwmode;
00794
00795 if ( isClient() )
00796 {
00797 if ( isReading() ) rw = "wb";
00798 if ( isWriting() ) rw = "rb";
00799 } else if ( isServer() )
00800 {
00801 if ( isReading() ) rw = "rb";
00802 if ( isWriting() ) rw = "wb";
00803 }
00804
00805 rwlock1_global.read();
00806 rwlock2_file.write();
00807 if ( myFile != NULL ) delete myFile;
00808
00809 printf( "Building myFile for %s \n", rw );
00810 fflush( stdout );
00811
00812 memcpy( openedFile, fpath, FILEPATH_LENGTH );
00813 myFile = new JFile( fpath, rw, (size_t)atol( blocksize ) );
00814
00815 memset( filename, 0, FILENAME_LENGTH );
00816
00817 myFile->getFileName( filename );
00818 filenameLength = strlen( filename ) + 1;
00819 rwlock1_global.releaseRead();
00820 rwlock2_file.releaseWrite();
00821 }
|
|
|
Definition at line 525 of file TFTP_Option.cpp. 00526 {
00527 if ( blocksize == NULL ) return; // Rejected.
00528 if ( bsize < 8 || bsize > 65464 ) return; // Rejected.
00529
00530 setBlockSize( bsize );
00531 }
|
|
|
Definition at line 638 of file TFTP_Option.cpp. 00639 {
00640 setFileSize( fsize );
00641 }
|
|
|
Definition at line 689 of file TFTP_Option.cpp. 00690 {
00691 if ( *m == 'o' ) return;
00692 SendNotDefinedError( "The requested mode is not supported." );
00693 }
|
|
|
Definition at line 732 of file TFTP_Option.cpp. 00733 {
00734 if ( timeout == NULL ) return; // Rejected.
00735 if ( t < 1 || t > 255 ) return; // Rejected.
00736
00737 setTimeOut( t );
00738 }
|
|
|
Definition at line 594 of file TFTP_Option.cpp. 00595 {
00596 if ( windowsize == NULL ) return; // Rejected.
00597 if ( wsize < 1 || wsize > 65464 ) return; // Rejected.
00598
00599 setWindowSize( wsize );
00600 }
|
|
|
Definition at line 503 of file TFTP_Option.cpp. Referenced by ArgDetect(), and requestedBlockSize().
00504 {
00505 rwlock1_global.write();
00506
00507 char* temp = DEFAULT_BLOCKSIZE;
00508 memset( blocksize, 0, BLOCKSIZE_LENGTH );
00509
00510 if ( bsize >= 8 && bsize <= 65464 )
00511 {
00512 blocksize = ulltostr( bsize, blocksize + BLOCKSIZE_LENGTH );
00513 blocksizeLength = strlen( blocksize ) + 1;
00514 } else {
00515 blocksizeLength = strlen( temp ) + 1;
00516 memcpy( blocksize, temp, blocksizeLength );
00517 }
00518
00519 rwlock1_global.releaseWrite();
00520 }
|
|
|
Definition at line 473 of file TFTP_Option.cpp. Referenced by ArgDetect().
00474 {
00475 rwlock1_global.write();
00476
00477 fpathLength = strlen( fname ) + 1;
00478
00479 memset( fpath, 0, FILENAME_LENGTH );
00480 memset( filename, 0, FILENAME_LENGTH );
00481
00482 filenameLength = fpathLength;
00483 memcpy( fpath, fname, fpathLength );
00484 memcpy( filename, fname, fpathLength );
00485 rwlock1_global.releaseWrite();
00486 }
|
|
|
Definition at line 616 of file TFTP_Option.cpp. Referenced by ArgDetect(), and requestedFileSize().
00617 {
00618 rwlock1_global.write();
00619 char* temp = "0";
00620
00621 memset( filesize, 0, FILESIZE_LENGTH );
00622
00623 if ( fsize > 0 )
00624 {
00625 filesize = ulltostr( fsize, filesize + FILESIZE_LENGTH );
00626 filesizeLength = strlen( filesize ) + 1;
00627 } else {
00628 filesizeLength = strlen( temp ) + 1;
00629 memcpy( filesize, temp, filesizeLength );
00630 }
00631
00632 rwlock1_global.releaseWrite();
00633 }
|
|
|
Definition at line 560 of file TFTP_Option.cpp. Referenced by ArgDetect(), and ConfigClient().
00561 {
00562 rwlock1_global.write();
00563 hostnameLength = strlen( host ) + 1;
00564 memset( hostname, 0, HOSTNAME_LENGTH );
00565 memcpy( hostname, host, hostnameLength );
00566 rwlock1_global.releaseWrite();
00567 }
|
|
|
Definition at line 658 of file TFTP_Option.cpp. Referenced by ArgDetect().
00659 {
00660 if ( *m == 'o' ) { // octet
00661 if ( *mode != 'o' )
00662 {
00663 rwlock1_global.write();
00664 char* temp = DEFAULT_MODE;
00665 modeLength = 6;
00666 memcpy( mode, temp, 6 );
00667 rwlock1_global.releaseWrite();
00668 }
00669 } else if ( *m == 'n' ) { // NetAscii
00670
00671 printf( "NetASCII TFTP Mode NOT SUPPORTED! \n" );
00672 exit( 2 );
00673
00674 } else if ( *m == 'm' ) { // Mail
00675
00676 printf( "Mail TFTP Mode NOT SUPPORTED! \n" );
00677 exit( 2 );
00678
00679 } else {
00680
00681 printf( "Unknown TFTP Mode\n" );
00682 exit( 2 );
00683 }
00684 }
|
|
|
Definition at line 547 of file TFTP_Option.cpp. Referenced by ArgDetect(), and ConfigClient().
00548 {
00549 rwlock1_global.write();
00550 if ( portNo >= 0 && portNo <= 65535 )
00551 {
00552 port = portNo;
00553 }
00554 rwlock1_global.releaseWrite();
00555 }
|
|
|
Definition at line 710 of file TFTP_Option.cpp. Referenced by ArgDetect(), and requestedTimeOut().
00711 {
00712 rwlock1_global.write();
00713 char* temp = "5";
00714
00715 memset( timeout, 0, TIMEOUT_LENGTH );
00716
00717 if ( t >= 1 && t <= 255 )
00718 {
00719 timeout = ulltostr( t, timeout + TIMEOUT_LENGTH );
00720 timeoutLength = strlen( timeout ) + 1;
00721 } else {
00722 timeoutLength = strlen( temp ) + 1;
00723 memcpy( timeout, temp, timeoutLength );
00724 }
00725
00726 rwlock1_global.releaseWrite();
00727 }
|
|
|
Definition at line 572 of file TFTP_Option.cpp. Referenced by ArgDetect(), and requestedWindowSize().
00573 {
00574 rwlock1_global.write();
00575 char* temp = DEFAULT_WINDOWSIZE;
00576
00577 memset( windowsize, 0, WINDOWSIZE_LENGTH );
00578
00579 if ( wsize >= 1 && wsize <= 65464 )
00580 {
00581 windowsize = ulltostr( wsize, windowsize + WINDOWSIZE_LENGTH );
00582 windowsizeLength = strlen( windowsize ) + 1;
00583 } else {
00584 windowsizeLength = strlen( temp ) + 1;
00585 memcpy( windowsize, temp, windowsizeLength );
00586 }
00587
00588 rwlock1_global.releaseWrite();
00589 }
|
|
||||||||||||||||
|
Definition at line 1024 of file TFTP_Option.cpp. Referenced by showOptions().
|
|
|
Definition at line 1034 of file TFTP_Option.cpp. Referenced by build_RRQ_WRQ_TemplatePacket().
01035 {
01036 showStr( "fpath", fpath); // Full path "/home/fred/test.txt"
01037 showStr( "filename", filename); // Only the filename "test.txt"
01038 showStr( "filesize", filesize);
01039 showStr( "timeout", timeout);
01040 showStr( "blocksize", blocksize);
01041 showStr( "mode", mode);
01042 showStr( "windowsize", windowsize);
01043
01044 short port;
01045 showStr( "hostname", hostname);
01046 showVal( "hostnameLength ", hostnameLength);
01047
01048 showVal("fpathLength ", fpathLength);
01049 showVal("filenameLength ", filenameLength);
01050
01051 showVal("filesizeLength ", filesizeLength);
01052 showVal("blocksizeLength ", blocksizeLength);
01053 showVal("windowsizeLength ", windowsizeLength);
01054 showVal("timeoutLength ", timeoutLength);
01055 showVal("modeLength ", modeLength);
01056
01057 showChar( "RRQ_WRQ_template", RRQ_WRQ_template, RRQ_WRQ_templateLength );
01058 showVal( "RRQ_WRQ_templateLength ", RRQ_WRQ_templateLength);
01059
01060 showChar( "Option_template", Option_template, Option_templateLength );
01061 showVal( "Option_templateLength ", Option_templateLength);
01062
01063 showVal( "state", (int)state );
01064 showVal( "pgmType", (int)pgmType );
01065
01066 showVal( "OCAK_arg", OACK_arg );
01067 showVal( "Done", Done );
01068
01069 showVal("LastData ", LastData);
01070
01071 printf( "CurrentTime[%d]\n", currentTime);
01072 showVal("windowsizeLeft ", windowsizeLeft);
01073
01074 showVal("TopAck ", TopAck);
01075 }
|
|
||||||||||||
|
Definition at line 1009 of file TFTP_Option.cpp. Referenced by showOptions().
|
|
||||||||||||
|
Definition at line 1019 of file TFTP_Option.cpp. Referenced by showOptions().
01020 {
01021 printf( "%s[%u]\n", n, s );
01022 }
|
|
|
Definition at line 233 of file TFTP_Option.hpp. |
|
|
Definition at line 234 of file TFTP_Option.hpp. |
|
|
Definition at line 225 of file TFTP_Option.hpp. |
|
|
Definition at line 214 of file TFTP_Option.hpp. |
|
|
Definition at line 215 of file TFTP_Option.hpp. |
|
|
Definition at line 211 of file TFTP_Option.hpp. |
|
|
Definition at line 212 of file TFTP_Option.hpp. |
|
|
Definition at line 224 of file TFTP_Option.hpp. |
|
|
Definition at line 246 of file TFTP_Option.hpp. |
|
|
Definition at line 239 of file TFTP_Option.hpp. |
|
|
Definition at line 186 of file TFTP_Option.hpp. |
|
|
Definition at line 197 of file TFTP_Option.hpp. |
|
|
Definition at line 236 of file TFTP_Option.hpp. |
|
|
Definition at line 208 of file TFTP_Option.hpp. |
|
|
Definition at line 228 of file TFTP_Option.hpp. |
|
|
Definition at line 244 of file TFTP_Option.hpp. |
|
|
Definition at line 209 of file TFTP_Option.hpp. |
|
|
Definition at line 183 of file TFTP_Option.hpp. |
|
|
Definition at line 195 of file TFTP_Option.hpp. |
|
|
Definition at line 184 of file TFTP_Option.hpp. |
|
|
Definition at line 196 of file TFTP_Option.hpp. |
|
|
Definition at line 182 of file TFTP_Option.hpp. |
|
|
Definition at line 194 of file TFTP_Option.hpp. |
|
|
Definition at line 191 of file TFTP_Option.hpp. |
|
|
Definition at line 192 of file TFTP_Option.hpp. |
|
|
Definition at line 187 of file TFTP_Option.hpp. |
|
|
Definition at line 200 of file TFTP_Option.hpp. |
|
|
Definition at line 206 of file TFTP_Option.hpp. |
|
|
Definition at line 202 of file TFTP_Option.hpp. |
|
|
Definition at line 222 of file TFTP_Option.hpp. |
|
|
Definition at line 190 of file TFTP_Option.hpp. |
|
|
Definition at line 217 of file TFTP_Option.hpp. |
|
|
Definition at line 218 of file TFTP_Option.hpp. |
|
|
Definition at line 219 of file TFTP_Option.hpp. |
|
|
Definition at line 227 of file TFTP_Option.hpp. |
|
|
Definition at line 230 of file TFTP_Option.hpp. |
|
|
Definition at line 242 of file TFTP_Option.hpp. |
|
|
Definition at line 207 of file TFTP_Option.hpp. |
|
|
Definition at line 221 of file TFTP_Option.hpp. |
|
|
Definition at line 185 of file TFTP_Option.hpp. |
|
|
Definition at line 199 of file TFTP_Option.hpp. |
|
|
Definition at line 241 of file TFTP_Option.hpp. |
|
|
Definition at line 231 of file TFTP_Option.hpp. |
|
|
Definition at line 188 of file TFTP_Option.hpp. |
|
|
Definition at line 237 of file TFTP_Option.hpp. |
|
|
Definition at line 198 of file TFTP_Option.hpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001