Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Net/TFTP/TFTP_header.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__TFTP_header_hpp__
00002 #define __J2K__TFTP_header_hpp__
00003 
00004 #include <j2k/Fred/Standard.hpp>
00005 
00006 // Forward declaration
00007 class TFTP_Option;
00008 class TFTP_OptionSaved;
00009 class TFTP_Sender;
00010 class TFTP_Packet;
00011 class TFTP_Parser;
00012 class TFTP_Timeout;
00013 class DataFactory; 
00014 class FileFactory; 
00015 
00016 class UDP_Socket;
00017 class UDP_SocketServer;
00018 class UDP_SocketClient;
00019 
00020 // Global TFTP object declaration
00021 extern TFTP_Option        option;
00022 extern TFTP_OptionSaved   savedOptions;
00023 
00024 
00025 #define Opt_None       0x00
00026 #define Opt_BlockSize  0x01
00027 #define Opt_Timeout    0x02
00028 #define Opt_FileSize   0x04
00029 
00030 /* 
00031 pkt.setBlockSize( 2048 );
00032 pkt.setTimeout( 1 );
00033 pkt.SendRRQ( "fred.h", "mode", Opt_BlkSize | Opt_TimeOut );
00034 */
00035 
00036 
00037 __J2K__EXTERN_C
00038 
00039 // List of all OpCode accepted by TFTP.
00040 enum OpCode_t
00041 {
00042   RRQ   = 1,
00043   WRQ   = 2,
00044   DATA  = 3,
00045   ACK   = 4,
00046   ERROR = 5,
00047   OACK  = 6
00048 };   
00049 
00050 // Union to change back and forth
00051 // between short and char[2]
00052 union short_char2_t
00053 {
00054   short  v;
00055   char   s[2];
00056 };
00057 
00058 struct StringData_t {
00059   char*  data;
00060   size_t length;
00061 };
00062 
00063 StringData_t tftp_error_msg[8] = {
00064 /* 0 */  { "Not defined.",         12 },
00065 /* 1 */  { "File not found.",      15 },
00066 /* 2 */  { "Access violation.",    17 },
00067 /* 3 */  { "Disk full or allocation exceeded.", 33 },
00068 /* 4 */  { "Illegal operation.",   18 },
00069 /* 5 */  { "Unknown transfer ID.", 20 },
00070 /* 6 */  { "File already exist.",  19 },
00071 /* 7 */  { "No such user.",        13 }
00072 };
00073 
00074 const char* TFTP_errmsg[ 8 ] = {
00075 /* 0 */  "Not defined.",
00076 /* 1 */  "File not found.",
00077 /* 2 */  "Access violation.",
00078 /* 3 */  "Disk full or allocation exceeded.",
00079 /* 4 */  "Illegal TFTP operation.",
00080 /* 5 */  "Unknown transfer ID.",
00081 /* 6 */  "File already exist.",
00082 /* 7 */  "No such user.",
00083 }; 
00084      
00085 enum TFTP_errcode_t {
00086   TFTP_NotDefined       = 0,
00087   TFTP_FileNotFound     = 1,
00088   TFTP_AccessViolation  = 2,
00089   TFTP_DiskFull         = 3,   
00090   TFTP_IllegalOp        = 4,
00091   TFTP_FileAlreadyExist = 5,
00092   TFTP_NoSuchUser       = 6   // only use for mail (Not supported)
00093 };
00094 
00095 /************************************************************************** 
00096  ************************************************************************** 
00097  ***   bit 0 Init                                                       *** 
00098  ***   bit 1 Connected                                                  *** 
00099  ***   bit 2 Ack for RRQ/WRQ                                            *** 
00100  ***   bit 3 Reading                                                    *** 
00101  ***   bit 4 Writing                                                    *** 
00102  ***   bit 5 End of Read/Write                                          *** 
00103  ***   bit 6 Error                                                      *** 
00104  ***   bit 7 Finished, program exit signal                              *** 
00105  ************************************************************************** 
00106  ***   Disconnect means that we are not connected and that              *** 
00107  ***   all the variables in TFTP_Option are still initialized.          *** 
00108  ************************************************************************** 
00109  **************************************************************************/
00110 enum TFTP_Status_t
00111 {
00112   TFTP_Uninitialized    = 0x00,  // %0000,0000
00113   TFTP_Disconnected     = 0x01,  // %0000,0001
00114   TFTP_Connected        = 0x03,  // %0000,0011
00115   TFTP_ReadingNotAck    = 0x0B,  // %0000,1011
00116   TFTP_WritingNotAck    = 0x13,  // %0001,0011
00117   TFTP_Reading          = 0x0F,  // %0000,1111
00118   TFTP_Writing          = 0x17,  // %0001,0111
00119   TFTP_EndofReadNotAck  = 0x2B,  // %0010,1011
00120   TFTP_EndofWriteNotAck = 0x33,  // %0011,0011
00121   TFTP_EndofRead        = 0x2F,  // %0010,1111
00122   TFTP_EndofWrite       = 0x37,  // %0011,0111
00123   TFTP_Error            = 0x43,  // %0100,0011 
00124   TFTP_Finished         = 0x81   // %1000,0001
00125 };
00126 
00127 /**************************************************************************
00128  ************************************************************************** 
00129  ***   bit 0 Server                                                     *** 
00130  ***   bit 1 Client                                                     *** 
00131  ***   bit 2 Reading Command Line request                               *** 
00132  ***   bit 3 Writing Command Line request                               *** 
00133  ************************************************************************** 
00134  **************************************************************************/
00135 enum TFTP_Type_t
00136 {
00137   TFTP_Type_Undefined = 0x00,  // %0000
00138   TFTP_Server         = 0x01,  // %0001
00139   TFTP_ServerRead     = 0x05,  // %0101
00140   TFTP_ServerWrite    = 0x09,  // %1001
00141 
00142   TFTP_Client         = 0x02,  // %0010
00143   TFTP_ClientRead     = 0x06,  // %0110
00144   TFTP_ClientWrite    = 0x0A,  // %1010
00145 };
00146 
00147 __J2K__END_C
00148 
00149 #endif

Generated on Sun Oct 14 18:46:34 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001