bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 1 | /* tftp defines */ |
| 2 | |
| 3 | #define TFTP_SESSIONS_MAX 3 |
| 4 | |
| 5 | #define TFTP_SERVER 69 |
| 6 | |
| 7 | #define TFTP_RRQ 1 |
| 8 | #define TFTP_WRQ 2 |
| 9 | #define TFTP_DATA 3 |
| 10 | #define TFTP_ACK 4 |
| 11 | #define TFTP_ERROR 5 |
ths | 1f697db | 2007-02-20 00:07:50 +0000 | [diff] [blame] | 12 | #define TFTP_OACK 6 |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 13 | |
| 14 | #define TFTP_FILENAME_MAX 512 |
| 15 | |
| 16 | struct tftp_t { |
| 17 | struct ip ip; |
| 18 | struct udphdr udp; |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 19 | uint16_t tp_op; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 20 | union { |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 21 | struct { |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 22 | uint16_t tp_block_nr; |
| 23 | uint8_t tp_buf[512]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 24 | } tp_data; |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 25 | struct { |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 26 | uint16_t tp_error_code; |
| 27 | uint8_t tp_msg[512]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 28 | } tp_error; |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 29 | uint8_t tp_buf[512 + 2]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 30 | } x; |
| 31 | }; |
| 32 | |
Jan Kiszka | 460fec6 | 2009-06-24 14:42:31 +0200 | [diff] [blame] | 33 | struct tftp_session { |
| 34 | Slirp *slirp; |
| 35 | char *filename; |
| 36 | |
| 37 | struct in_addr client_ip; |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 38 | uint16_t client_port; |
Jan Kiszka | 460fec6 | 2009-06-24 14:42:31 +0200 | [diff] [blame] | 39 | |
| 40 | int timestamp; |
| 41 | }; |
| 42 | |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 43 | void tftp_input(struct mbuf *m); |