00001 #ifndef _GPXE_TFTP_H 00002 #define _GPXE_TFTP_H 00003 00004 /** @file 00005 * 00006 * TFTP protocol 00007 * 00008 */ 00009 00010 FILE_LICENCE ( GPL2_OR_LATER ); 00011 00012 #include <stdint.h> 00013 00014 #define TFTP_PORT 69 /**< Default TFTP server port */ 00015 #define TFTP_DEFAULT_BLKSIZE 512 /**< Default TFTP data block size */ 00016 #define TFTP_MAX_BLKSIZE 1432 00017 00018 #define TFTP_RRQ 1 /**< Read request opcode */ 00019 #define TFTP_WRQ 2 /**< Write request opcode */ 00020 #define TFTP_DATA 3 /**< Data block opcode */ 00021 #define TFTP_ACK 4 /**< Data block acknowledgement opcode */ 00022 #define TFTP_ERROR 5 /**< Error opcode */ 00023 #define TFTP_OACK 6 /**< Options acknowledgement opcode */ 00024 00025 #define TFTP_ERR_FILE_NOT_FOUND 1 /**< File not found */ 00026 #define TFTP_ERR_ACCESS_DENIED 2 /**< Access violation */ 00027 #define TFTP_ERR_DISK_FULL 3 /**< Disk full or allocation exceeded */ 00028 #define TFTP_ERR_ILLEGAL_OP 4 /**< Illegal TFTP operation */ 00029 #define TFTP_ERR_UNKNOWN_TID 5 /**< Unknown transfer ID */ 00030 #define TFTP_ERR_FILE_EXISTS 6 /**< File already exists */ 00031 #define TFTP_ERR_UNKNOWN_USER 7 /**< No such user */ 00032 #define TFTP_ERR_BAD_OPTS 8 /**< Option negotiation failed */ 00033 00034 #define MTFTP_PORT 1759 /**< Default MTFTP server port */ 00035 00036 /** A TFTP read request (RRQ) packet */ 00037 struct tftp_rrq { 00038 uint16_t opcode; 00039 char data[0]; 00040 } __attribute__ (( packed )); 00041 00042 /** A TFTP data (DATA) packet */ 00043 struct tftp_data { 00044 uint16_t opcode; 00045 uint16_t block; 00046 uint8_t data[0]; 00047 } __attribute__ (( packed )); 00048 00049 /** A TFTP acknowledgement (ACK) packet */ 00050 struct tftp_ack { 00051 uint16_t opcode; 00052 uint16_t block; 00053 } __attribute__ (( packed )); 00054 00055 /** A TFTP error (ERROR) packet */ 00056 struct tftp_error { 00057 uint16_t opcode; 00058 uint16_t errcode; 00059 char errmsg[0]; 00060 } __attribute__ (( packed )); 00061 00062 /** A TFTP options acknowledgement (OACK) packet */ 00063 struct tftp_oack { 00064 uint16_t opcode; 00065 char data[0]; 00066 } __attribute__ (( packed )); 00067 00068 /** The common header of all TFTP packets */ 00069 struct tftp_common { 00070 uint16_t opcode; 00071 } __attribute__ (( packed )); 00072 00073 /** A union encapsulating all TFTP packet types */ 00074 union tftp_any { 00075 struct tftp_common common; 00076 struct tftp_rrq rrq; 00077 struct tftp_data data; 00078 struct tftp_ack ack; 00079 struct tftp_error error; 00080 struct tftp_oack oack; 00081 }; 00082 00083 extern void tftp_set_request_blksize ( unsigned int blksize ); 00084 00085 #endif /* _GPXE_TFTP_H */
1.5.7.1