1/* tftp defines */ 2 3#ifndef SLIRP_TFTP_H 4#define SLIRP_TFTP_H 5 6#define TFTP_SESSIONS_MAX 20 7 8#define TFTP_SERVER 69 9 10#define TFTP_RRQ 1 11#define TFTP_WRQ 2 12#define TFTP_DATA 3 13#define TFTP_ACK 4 14#define TFTP_ERROR 5 15#define TFTP_OACK 6 16 17#define TFTP_FILENAME_MAX 512 18#define TFTP_BLOCKSIZE_MAX 1428 19 20struct tftp_t { 21 struct udphdr udp; 22 uint16_t tp_op; 23 union { 24 struct { 25 uint16_t tp_block_nr; 26 uint8_t tp_buf[TFTP_BLOCKSIZE_MAX]; 27 } tp_data; 28 struct { 29 uint16_t tp_error_code; 30 uint8_t tp_msg[TFTP_BLOCKSIZE_MAX]; 31 } tp_error; 32 char tp_buf[TFTP_BLOCKSIZE_MAX + 2]; 33 } x; 34} __attribute__((packed)); 35 36struct tftp_session { 37 Slirp *slirp; 38 char *filename; 39 int fd; 40 uint16_t block_size; 41 42 struct sockaddr_storage client_addr; 43 uint16_t client_port; 44 uint32_t block_nr; 45 46 int timestamp; 47}; 48 49void tftp_input(struct sockaddr_storage *srcsas, struct mbuf *m); 50 51#endif 52