#include <TFTP_Packet.hpp>
Public Methods | |
TFTP_Packet () | |
__inline void | setOpCode (enum OpCode_t op) |
__inline short | getOpCode () |
void | create_RRQ_WRQ () |
__inline void | sendRRQ () |
__inline void | sendWRQ () |
void | createData (short blockNo, char *data, size_t sz) |
__inline void | createData (const char *rawData, size_t sz) |
__inline void | sendData (short blockNo, char *data, size_t sz) |
__inline void | send () |
void | createAck (short blockNo) |
void | sendAck (short blockNo) |
void | createError (enum TFTP_errcode_t e, const char *errmsg="") |
__inline void | sendError (enum TFTP_errcode_t e, const char *errmsg="") |
__inline char * | getErrorMsg () |
void | createOAck () |
__inline void | sendOAck () |
__inline double | getTimeStamp () |
__inline void | setTimeStamp (double t) |
__inline double | getID () |
__inline char * | getData () |
short | getBlockNo () |
__inline size_t | getpktLength () |
Public Attributes | |
char * | pkt |
size_t | pktLength |
char * | errorMsg |
double | timestamp |
short | resent |
Private Attributes | |
short | opCode |
short | block |
short | err |
|
Definition at line 7 of file TFTP_Packet.cpp. |
|
Definition at line 96 of file TFTP_Packet.cpp. Referenced by sendAck().
00097 { 00098 opCode = 4; 00099 block = blockNo; 00100 00101 pktLength = 2 + 2; 00102 pkt = new char[ pktLength ]; 00103 00104 memcpy( pkt, (char*)&opCode, 2 ); 00105 memcpy( pkt + 2, (char*)&block, 2 ); 00106 } |
|
Definition at line 73 of file TFTP_Packet.cpp. 00074 { 00075 if ( pkt == NULL ) pkt = new char[ sz + 1 ]; 00076 pktLength = sz; 00077 memcpy( pkt, rawData, sz ); 00078 } |
|
Definition at line 58 of file TFTP_Packet.cpp. Referenced by DATA_driver(), DataFactory::createDataPacket(), DataFactory::dummyPacket(), and sendData().
00059 { 00060 opCode = 3; 00061 block = blockNo; 00062 00063 pktLength = 2 + 2 + sz; 00064 pkt = new char[ pktLength ]; 00065 00066 memcpy( pkt, (char*)&opCode, 2 ); 00067 memcpy( pkt + 2, (char*)&block, 2 ); 00068 if ( sz > 0 ) { 00069 memcpy( pkt + 4, data, sz ); 00070 } 00071 } |
|
Definition at line 114 of file TFTP_Packet.cpp. Referenced by sendError().
00115 { 00116 opCode = 5; 00117 err = (short)e; 00118 00119 if ( errorMsg != NULL ) delete [] errorMsg; 00120 errorMsg = new char[ 200 ]; 00121 00122 memset( errorMsg, 0, 200 ); 00123 00124 const char* s = TFTP_errmsg[ opCode ]; 00125 size_t len2 = strlen( s ); 00126 00127 size_t len = strlen( errmsg ); 00128 memcpy( errorMsg, errmsg, len ); 00129 errorMsg[ len ] = '\n'; 00130 memcpy( errorMsg+len+1, s, len2 ); 00131 00132 size_t sz = len + len2 + 1; 00133 errorMsg[ sz ] = '\0'; 00134 00135 pktLength = 2 + 2 + sz; 00136 pkt = new char[ pktLength ]; 00137 00138 memcpy( pkt, (char*)&opCode, 2 ); 00139 memcpy( pkt + 2, (char*)&err, 2 ); 00140 memcpy( pkt + 4, (char*)errorMsg, sz ); 00141 } |
|
Definition at line 154 of file TFTP_Packet.cpp. Referenced by sendOAck().
00155 { 00156 opCode = 6; 00157 00158 option.rwlock3_templates.read(); 00159 00160 size_t opt = option.Option_templateLength - 2; 00161 00162 pktLength = opt + 2; 00163 pkt = new char[ pktLength ]; 00164 00165 00166 // Copy the option, if they exist. 00167 if ( opt > 0 ) { 00168 memcpy( pkt, option.Option_template + 2, opt ); 00169 } 00170 00171 memcpy( pkt, (char*)&opCode, 2 ); 00172 00173 option.rwlock3_templates.releaseRead(); 00174 } |
|
Definition at line 20 of file TFTP_Packet.cpp. Referenced by sendRRQ(), and sendWRQ().
00021 { 00022 option.rwlock3_templates.read(); 00023 00024 long opt = option.Option_templateLength - 2; 00025 size_t sz = option.RRQ_WRQ_templateLength; 00026 00027 if ( opt <= 0 ) opt = 0; 00028 pktLength = sz + opt; 00029 pkt = new char[ pktLength ]; 00030 00031 memcpy( pkt, option.RRQ_WRQ_template, sz ); // Copy the RRQ Template 00032 memcpy( pkt, (char*)&opCode, 2 ); // Overwrite the opcode part 00033 00034 00035 // Copy the option, if they exist. 00036 if ( opt > 0 ) { 00037 memcpy( pkt + sz, option.Option_template + 2, opt ); 00038 } 00039 00040 option.rwlock3_templates.releaseRead(); 00041 } |
|
Definition at line 199 of file TFTP_Packet.cpp. Referenced by FileFactory::validPacket().
00199 { 00200 short val; 00201 memcpy( (char*)(&val), (pkt+2), 2 ); 00202 00203 return val; 00204 } |
|
Definition at line 195 of file TFTP_Packet.cpp. Referenced by FileFactory::validPacket().
00195 { 00196 return (char*)( pkt + 4 ); 00197 } |
|
Definition at line 149 of file TFTP_Packet.cpp. 00150 { 00151 return errorMsg; 00152 } |
|
Definition at line 187 of file TFTP_Packet.cpp. 00187 { 00188 return block; 00189 } |
|
Definition at line 16 of file TFTP_Packet.cpp. 00016 { 00017 return opCode; 00018 } |
|
Definition at line 183 of file TFTP_Packet.cpp. 00183 { 00184 return timestamp; 00185 } |
|
Definition at line 206 of file TFTP_Packet.cpp. Referenced by FileFactory::validPacket().
00206 { 00207 return pktLength; 00208 } |
|
Definition at line 91 of file TFTP_Packet.cpp. Referenced by TFTP_Sender::sendData(), and TFTP_Timeout::timedRun().
00091 { 00092 printf( "Sending Data: %d, %u", pkt, pktLength ); 00093 option.sender->send( pkt, pktLength ); 00094 } |
|
Definition at line 108 of file TFTP_Packet.cpp. Referenced by DATA_driver(), OACK_driver(), and WRQ_driver().
00109 { 00110 createAck( blockNo ); 00111 option.sender->send( pkt, pktLength ); 00112 } |
|
Definition at line 80 of file TFTP_Packet.cpp. 00081 { 00082 if ( sz > 0 ) { 00083 createData( blockNo, data, sz ); 00084 pktLength = 4 + sz; 00085 } else { 00086 pktLength = 4; 00087 } 00088 option.sender->send( pkt, pktLength ); 00089 } |
|
Definition at line 143 of file TFTP_Packet.cpp. Referenced by TFTP_AccessViolationErrorHandler(), TFTP_DiskFullErrorHandler(), TFTP_FileAlreadyExistErrorHandler(), TFTP_FileNotFoundErrorHandler(), TFTP_IllegalOpErrorHandler(), TFTP_NoSuchUserErrorHandler(), and TFTP_NotDefinedErrorHandler().
00144 { 00145 createError( e, errmsg ); 00146 option.sender->send( pkt, pktLength ); 00147 } |
|
Definition at line 176 of file TFTP_Packet.cpp. Referenced by RRQ_driver(), and WRQ_driver().
00177 { 00178 createOAck(); 00179 option.sender->send(pkt,pktLength); 00180 } |
|
Definition at line 43 of file TFTP_Packet.cpp. Referenced by TFTP::read().
00044 { 00045 opCode = 1; 00046 create_RRQ_WRQ(); 00047 option.sender->send( pkt, pktLength ); 00048 } |
|
Definition at line 50 of file TFTP_Packet.cpp. Referenced by TFTP::write().
00051 { 00052 opCode = 2; 00053 create_RRQ_WRQ(); 00054 option.sender->send( pkt, pktLength ); 00055 } |
|
Definition at line 11 of file TFTP_Packet.cpp. 00011 { 00012 opCode = (short)op; 00013 } |
|
Definition at line 191 of file TFTP_Packet.cpp. Referenced by TFTP_Sender::sendData(), and TFTP_Timeout::timedRun().
00191 { 00192 timestamp = ceil( t ); 00193 } |
|
Definition at line 52 of file TFTP_Packet.hpp. |
|
Definition at line 53 of file TFTP_Packet.hpp. |
|
Definition at line 59 of file TFTP_Packet.hpp. |
|
Definition at line 51 of file TFTP_Packet.hpp. |
|
Definition at line 56 of file TFTP_Packet.hpp. |
|
Definition at line 57 of file TFTP_Packet.hpp. |
|
Definition at line 63 of file TFTP_Packet.hpp. Referenced by TFTP_Sender::sendData(), and TFTP_Timeout::timedRun().
|
|
Definition at line 60 of file TFTP_Packet.hpp. |