12 #define TFTP_PORT 69 /**< Default TFTP server port */
13 #define TFTP_DEFAULT_BLKSIZE 512
14 #define TFTP_MAX_BLKSIZE 1432 /* 512 */
23 #define TFTP_ERR_FILE_NOT_FOUND 1 /**< File not found */
24 #define TFTP_ERR_ACCESS_DENIED 2 /**< Access violation */
25 #define TFTP_ERR_DISK_FULL 3 /**< Disk full or allocation exceeded */
26 #define TFTP_ERR_ILLEGAL_OP 4 /**< Illegal TFTP operation */
27 #define TFTP_ERR_UNKNOWN_TID 5 /**< Unknown transfer ID */
28 #define TFTP_ERR_FILE_EXISTS 6 /**< File already exists */
29 #define TFTP_ERR_UNKNOWN_USER 7 /**< No such user */
30 #define TFTP_ERR_BAD_OPTS 8 /**< Option negotiation failed */
32 /** A TFTP request (RRQ) packet */
37 char data[TFTP_DEFAULT_BLKSIZE];
40 /** A TFTP data (DATA) packet */
46 uint8_t data[TFTP_MAX_BLKSIZE];
49 /** A TFTP acknowledgement (ACK) packet */
57 /** A TFTP error (ERROR) packet */
63 char errmsg[TFTP_DEFAULT_BLKSIZE];
66 /** A TFTP options acknowledgement (OACK) packet */
71 uint8_t data[TFTP_DEFAULT_BLKSIZE];
74 /** The common header of all TFTP packets */
81 /** A union encapsulating all TFTP packet types */
83 struct tftp_common common;
85 struct tftp_data data;
87 struct tftp_error error;
88 struct tftp_oack oack;
94 * This data structure holds the state for an ongoing TFTP transfer.
97 /** TFTP server address
99 * This is the IP address and UDP port from which data packets
100 * will be sent, and to which ACK packets should be sent.
102 struct sockaddr_in server;
105 * This is the UDP port from which the open request will be
106 * sent, and to which any unicast data packets will be sent.
109 /** TFTP multicast address
111 * This is the IP address and UDP port to which multicast data
112 * packets, if any, will be sent.
114 struct sockaddr_in multicast;
117 * This will be true if the client is the master client for a
118 * multicast protocol (i.e. MTFTP or TFTM). (It will always
119 * be true for a non-multicast protocol, i.e. plain old TFTP).
124 * This is the "blksize" option negotiated with the TFTP
125 * server. (If the TFTP server does not support TFTP options,
126 * this will default to 512).
128 unsigned int blksize;
131 * This is the value returned in the "tsize" option from the
132 * TFTP server. If the TFTP server does not support the
133 * "tsize" option, this value will be zero.
136 /** Last received block
138 * The block number of the most recent block received from the
139 * TFTP server. Note that the first data block is block 1; a
140 * value of 0 indicates that no data blocks have yet been
143 * For multicast TFTP protocols, where the blocks may not be
144 * received in strict order, the meaning of this field changes
145 * slightly, to "first missing block minus one". For example,
146 * suppose that we have received blocks 1, 2, 4 and 5; this
147 * field would then have the value 2, since the first missing
148 * block is block 3. If the blocks do arrive in strict order,
149 * this definition is exactly equivalent to "most recently
157 struct tftpreq_info_t {
158 struct sockaddr_in *server;
160 unsigned short blksize;
163 struct tftpblk_info_t {
170 #define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)