bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 1 | /* tftp defines */ |
Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 2 | #ifndef SLIRP_TFTP_H |
| 3 | #define SLIRP_TFTP_H 1 |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 4 | |
Bernhard Übelacker | 5f22b05 | 2014-06-21 15:26:05 +0200 | [diff] [blame] | 5 | #define TFTP_SESSIONS_MAX 20 |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 6 | |
| 7 | #define TFTP_SERVER 69 |
| 8 | |
| 9 | #define TFTP_RRQ 1 |
| 10 | #define TFTP_WRQ 2 |
| 11 | #define TFTP_DATA 3 |
| 12 | #define TFTP_ACK 4 |
| 13 | #define TFTP_ERROR 5 |
ths | 1f697db | 2007-02-20 00:07:50 +0000 | [diff] [blame] | 14 | #define TFTP_OACK 6 |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 15 | |
| 16 | #define TFTP_FILENAME_MAX 512 |
| 17 | |
| 18 | struct tftp_t { |
| 19 | struct ip ip; |
| 20 | struct udphdr udp; |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 21 | uint16_t tp_op; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 22 | union { |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 23 | struct { |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 24 | uint16_t tp_block_nr; |
| 25 | uint8_t tp_buf[512]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 26 | } tp_data; |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 27 | struct { |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 28 | uint16_t tp_error_code; |
| 29 | uint8_t tp_msg[512]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 30 | } tp_error; |
Stefan Weil | 89d2d3af | 2011-02-23 19:40:14 +0100 | [diff] [blame] | 31 | char tp_buf[512 + 2]; |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 32 | } x; |
| 33 | }; |
| 34 | |
Jan Kiszka | 460fec6 | 2009-06-24 14:42:31 +0200 | [diff] [blame] | 35 | struct tftp_session { |
| 36 | Slirp *slirp; |
| 37 | char *filename; |
Hervé Poussineau | 78be056 | 2012-09-10 20:52:25 +0200 | [diff] [blame] | 38 | int fd; |
Jan Kiszka | 460fec6 | 2009-06-24 14:42:31 +0200 | [diff] [blame] | 39 | |
| 40 | struct in_addr client_ip; |
Stefan Weil | b6dce92 | 2010-07-22 22:15:23 +0200 | [diff] [blame] | 41 | uint16_t client_port; |
Hervé Poussineau | 4aa401f | 2012-09-13 12:39:36 +0200 | [diff] [blame] | 42 | uint32_t block_nr; |
Jan Kiszka | 460fec6 | 2009-06-24 14:42:31 +0200 | [diff] [blame] | 43 | |
| 44 | int timestamp; |
| 45 | }; |
| 46 | |
bellard | c7f7464 | 2004-08-24 21:57:12 +0000 | [diff] [blame] | 47 | void tftp_input(struct mbuf *m); |
Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 48 | |
| 49 | #endif |