iPXE
tftp.h
Go to the documentation of this file.
1 #ifndef _IPXE_TFTP_H
2 #define _IPXE_TFTP_H
3 
4 /** @file
5  *
6  * TFTP protocol
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 
14 #define TFTP_PORT 69 /**< Default TFTP server port */
15 #define TFTP_DEFAULT_BLKSIZE 512 /**< Default TFTP data block size */
16 #define TFTP_MAX_BLKSIZE 1432
17 
18 #define TFTP_RRQ 1 /**< Read request opcode */
19 #define TFTP_WRQ 2 /**< Write request opcode */
20 #define TFTP_DATA 3 /**< Data block opcode */
21 #define TFTP_ACK 4 /**< Data block acknowledgement opcode */
22 #define TFTP_ERROR 5 /**< Error opcode */
23 #define TFTP_OACK 6 /**< Options acknowledgement opcode */
24 
25 #define TFTP_ERR_FILE_NOT_FOUND 1 /**< File not found */
26 #define TFTP_ERR_ACCESS_DENIED 2 /**< Access violation */
27 #define TFTP_ERR_DISK_FULL 3 /**< Disk full or allocation exceeded */
28 #define TFTP_ERR_ILLEGAL_OP 4 /**< Illegal TFTP operation */
29 #define TFTP_ERR_UNKNOWN_TID 5 /**< Unknown transfer ID */
30 #define TFTP_ERR_FILE_EXISTS 6 /**< File already exists */
31 #define TFTP_ERR_UNKNOWN_USER 7 /**< No such user */
32 #define TFTP_ERR_BAD_OPTS 8 /**< Option negotiation failed */
33 
34 #define MTFTP_PORT 1759 /**< Default MTFTP server port */
35 
36 /** A TFTP read request (RRQ) packet */
37 struct tftp_rrq {
39  char data[0];
40 } __attribute__ (( packed ));
41 
42 /** A TFTP data (DATA) packet */
43 struct tftp_data {
47 } __attribute__ (( packed ));
48 
49 /** A TFTP acknowledgement (ACK) packet */
50 struct tftp_ack {
53 } __attribute__ (( packed ));
54 
55 /** A TFTP error (ERROR) packet */
56 struct tftp_error {
59  char errmsg[0];
60 } __attribute__ (( packed ));
61 
62 /** A TFTP options acknowledgement (OACK) packet */
63 struct tftp_oack {
65  char data[0];
66 } __attribute__ (( packed ));
67 
68 /** The common header of all TFTP packets */
69 struct tftp_common {
71 } __attribute__ (( packed ));
72 
73 /** A union encapsulating all TFTP packet types */
74 union tftp_any {
76  struct tftp_rrq rrq;
77  struct tftp_data data;
78  struct tftp_ack ack;
79  struct tftp_error error;
80  struct tftp_oack oack;
81 };
82 
83 #endif /* _IPXE_TFTP_H */
unsigned short uint16_t
Definition: stdint.h:11
A TFTP options acknowledgement (OACK) packet.
Definition: tftp.h:63
uint16_t opcode
Definition: tftp.h:51
uint16_t block
Definition: tftp.h:52
struct tftp_rrq rrq
Definition: tftp.h:76
struct tftp_common common
Definition: tftp.h:75
A TFTP data (DATA) packet.
Definition: tftp.h:43
uint16_t opcode
Definition: tftp.h:70
uint16_t block
Definition: tftp.h:45
uint8_t data[0]
Definition: tftp.h:46
uint16_t errcode
Definition: tftp.h:58
uint16_t opcode
Definition: tftp.h:38
uint16_t opcode
Definition: tftp.h:64
unsigned char uint8_t
Definition: stdint.h:10
char data[0]
Definition: tftp.h:65
The common header of all TFTP packets.
Definition: tftp.h:69
char data[0]
Definition: tftp.h:39
A TFTP read request (RRQ) packet.
Definition: tftp.h:37
uint16_t opcode
Definition: tftp.h:57
char errmsg[0]
Definition: tftp.h:59
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct tftp_oack oack
Definition: tftp.h:80
struct tftp_ack ack
Definition: tftp.h:78
struct tftp_error error
Definition: tftp.h:79
A union encapsulating all TFTP packet types.
Definition: tftp.h:74
struct tftp_data data
Definition: tftp.h:77
union tftp_any __attribute__
uint16_t opcode
Definition: tftp.h:44
A TFTP acknowledgement (ACK) packet.
Definition: tftp.h:50
A TFTP error (ERROR) packet.
Definition: tftp.h:56