#include <TFTP.hpp>
Public Methods | |
TFTP (int argc, char *argv[]) | |
virtual __inline | ~TFTP () |
void | read () |
void | write () |
void | server () |
Private Methods | |
TFTP (const TFTP &) | |
const TFTP & | operator= (const TFTP &) |
void | sendPacket (siz1e_t begin, size_t length) |
void | sendRRQ_WRQ (char opcode, char *filename) void sendRR(int frameNo) |
void | sendErr () |
Private Attributes | |
Buffer * | buffer |
UCHAR | windowSize |
ULONG | blockSize |
char * | filename |
int | Opt |
Packet * | pkt |
|
Definition at line 9 of file TFTP.cpp. 00010 { 00011 parser = NULL; 00012 option.ArgParser( argc, argv ); 00013 option.createSocket(); 00014 00015 add_TFTP_ErrorHandlers(); 00016 parser = new TFTP_Parser(); 00017 option.sendFactory = new TFTP_Sender(); 00018 option.dataFactory = new DataFactory(); 00019 option.fileFactory = new FileFactory(); 00020 option.data_queue = new DList_pPacket(); 00021 option.waitingAck_queue = new DList_pPacket(); 00022 option.timeoutThread = new TFTP_Timeout(); 00023 00024 switch( option.pgmType ) 00025 { 00026 case TFTP_Server: server(); break; 00027 00028 case TFTP_Client: // Shell or prompt a R/W request 00029 if ( option.RW_command == 1 ) { read(); break; } 00030 if ( option.RW_command == 2 ) { write(); break; } 00031 option.RW_command = 0; 00032 00033 #ifndef SHELL 00034 char rw; 00035 char f[161]; 00036 cout << "\n\nDo you want to (R)ead or (W)rite a file ? "; 00037 cin >> rw; 00038 cout << "\n\nEnter the name of the file: "; 00039 cin >> f; 00040 cout << "\n\nInitializing...\n"; 00041 option.setFileName( f ); 00042 00043 if ( rw == 'r' || rw == 'R' || rw == 'd' || rw == 'D' ) { 00044 read(); break; 00045 } else { 00046 write(); break; 00047 } 00048 #else 00049 TFTP_client_shell(); 00050 #endif 00051 00052 break; 00053 00054 case TFTP_ClientRead: read(); TFTP_client_shell(); break; 00055 case TFTP_ClientWrite: write(); TFTP_client_shell(); break; 00056 00057 default: 00058 cout << "\n\nError: Client/Server not specified. \n"; 00059 exit( 1 ); 00060 } 00061 } |
|
|
|
|
|
|
|
Definition at line 67 of file TFTP.cpp. Referenced by TFTP().
00067 { 00068 printf("Reading\n"); 00069 option.state = TFTP_Connected; 00070 option.setMode( "octet" ); 00071 option.build_OptionPacket(); 00072 option.build_RRQ_WRQ_TemplatePacket(); 00073 option.openFile( "wb" ); 00074 00075 option.showOptions(); 00076 00077 option.timeoutThread->start(); 00078 TFTP_Packet pkt; 00079 //I'm just going to try to send a read request and send an ack back. 00080 pkt.sendRRQ(); 00081 option.state = TFTP_Reading; 00082 option.showOptions(); 00083 } |
|
|
|
Definition at line 349 of file TFTP_design.hpp. 00349 { 00350 char* pkt = new char[ blockSize ]; 00351 char* pos = buffer.getPtr(); 00352 memcpy( pkt, pos+begin, length ); 00353 sender.send( pkt, length ); 00354 } |
|
|
|
Definition at line 101 of file TFTP.cpp. Referenced by TFTP().
00101 { 00102 printf("Server\n"); 00103 option.state = TFTP_Connected; 00104 option.build_OptionPacket(); 00105 00106 option.showOptions(); 00107 00108 option.timeoutThread->start(); 00109 00110 //First receive request. 00111 //Send Ack 00112 } |
|
Definition at line 85 of file TFTP.cpp. Referenced by TFTP().
00085 { 00086 printf("Writing\n"); 00087 option.state = TFTP_Connected; 00088 option.build_OptionPacket(); 00089 option.build_RRQ_WRQ_TemplatePacket(); 00090 option.openFile( "rb" ); 00091 option.showOptions(); 00092 00093 option.timeoutThread->start(); 00094 TFTP_Packet pkt; 00095 //I'm just going to try to send a read request and send an ack back. 00096 pkt.sendWRQ(); 00097 option.state = TFTP_Writing; 00098 option.showOptions(); 00099 } |
|
Definition at line 308 of file TFTP_design.hpp. |
|
Definition at line 306 of file TFTP_design.hpp. |
|
Definition at line 304 of file TFTP_design.hpp. |
|
Definition at line 307 of file TFTP_design.hpp. |
|
Definition at line 310 of file TFTP_design.hpp. |
|
Definition at line 305 of file TFTP_design.hpp. |