[sundance] Add reset completion check
[gpxe.git] / src / include / gpxe / tftp.h
blob0177a95af4e9b3a6fdb69c94cc6063e6bfdf61b4
1 #ifndef _GPXE_TFTP_H
2 #define _GPXE_TFTP_H
4 /** @file
6 * TFTP protocol
8 */
10 #include <stdint.h>
12 #define TFTP_PORT 69 /**< Default TFTP server port */
13 #define TFTP_DEFAULT_BLKSIZE 512 /**< Default TFTP data block size */
14 #define TFTP_MAX_BLKSIZE 1432
16 #define TFTP_RRQ 1 /**< Read request opcode */
17 #define TFTP_WRQ 2 /**< Write request opcode */
18 #define TFTP_DATA 3 /**< Data block opcode */
19 #define TFTP_ACK 4 /**< Data block acknowledgement opcode */
20 #define TFTP_ERROR 5 /**< Error opcode */
21 #define TFTP_OACK 6 /**< Options acknowledgement opcode */
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 #define MTFTP_PORT 1759 /**< Default MTFTP server port */
34 /** A TFTP read request (RRQ) packet */
35 struct tftp_rrq {
36 uint16_t opcode;
37 char data[0];
38 } __attribute__ (( packed ));
40 /** A TFTP data (DATA) packet */
41 struct tftp_data {
42 uint16_t opcode;
43 uint16_t block;
44 uint8_t data[0];
45 } __attribute__ (( packed ));
47 /** A TFTP acknowledgement (ACK) packet */
48 struct tftp_ack {
49 uint16_t opcode;
50 uint16_t block;
51 } __attribute__ (( packed ));
53 /** A TFTP error (ERROR) packet */
54 struct tftp_error {
55 uint16_t opcode;
56 uint16_t errcode;
57 char errmsg[0];
58 } __attribute__ (( packed ));
60 /** A TFTP options acknowledgement (OACK) packet */
61 struct tftp_oack {
62 uint16_t opcode;
63 char data[0];
64 } __attribute__ (( packed ));
66 /** The common header of all TFTP packets */
67 struct tftp_common {
68 uint16_t opcode;
69 } __attribute__ (( packed ));
71 /** A union encapsulating all TFTP packet types */
72 union tftp_any {
73 struct tftp_common common;
74 struct tftp_rrq rrq;
75 struct tftp_data data;
76 struct tftp_ack ack;
77 struct tftp_error error;
78 struct tftp_oack oack;
81 extern void tftp_set_request_blksize ( unsigned int blksize );
83 #endif /* _GPXE_TFTP_H */