2004-08-25 05:57:12 +08:00
|
|
|
/* tftp defines */
|
2012-12-06 19:15:58 +08:00
|
|
|
#ifndef SLIRP_TFTP_H
|
|
|
|
#define SLIRP_TFTP_H 1
|
2004-08-25 05:57:12 +08:00
|
|
|
|
2014-06-21 21:26:05 +08:00
|
|
|
#define TFTP_SESSIONS_MAX 20
|
2004-08-25 05:57:12 +08:00
|
|
|
|
|
|
|
#define TFTP_SERVER 69
|
|
|
|
|
|
|
|
#define TFTP_RRQ 1
|
|
|
|
#define TFTP_WRQ 2
|
|
|
|
#define TFTP_DATA 3
|
|
|
|
#define TFTP_ACK 4
|
|
|
|
#define TFTP_ERROR 5
|
2007-02-20 08:07:50 +08:00
|
|
|
#define TFTP_OACK 6
|
2004-08-25 05:57:12 +08:00
|
|
|
|
|
|
|
#define TFTP_FILENAME_MAX 512
|
|
|
|
|
|
|
|
struct tftp_t {
|
|
|
|
struct ip ip;
|
|
|
|
struct udphdr udp;
|
2010-07-23 04:15:23 +08:00
|
|
|
uint16_t tp_op;
|
2004-08-25 05:57:12 +08:00
|
|
|
union {
|
2007-09-17 05:08:06 +08:00
|
|
|
struct {
|
2010-07-23 04:15:23 +08:00
|
|
|
uint16_t tp_block_nr;
|
|
|
|
uint8_t tp_buf[512];
|
2004-08-25 05:57:12 +08:00
|
|
|
} tp_data;
|
2007-09-17 05:08:06 +08:00
|
|
|
struct {
|
2010-07-23 04:15:23 +08:00
|
|
|
uint16_t tp_error_code;
|
|
|
|
uint8_t tp_msg[512];
|
2004-08-25 05:57:12 +08:00
|
|
|
} tp_error;
|
2011-02-24 02:40:14 +08:00
|
|
|
char tp_buf[512 + 2];
|
2004-08-25 05:57:12 +08:00
|
|
|
} x;
|
|
|
|
};
|
|
|
|
|
2009-06-24 20:42:31 +08:00
|
|
|
struct tftp_session {
|
|
|
|
Slirp *slirp;
|
|
|
|
char *filename;
|
2012-09-11 02:52:25 +08:00
|
|
|
int fd;
|
2009-06-24 20:42:31 +08:00
|
|
|
|
|
|
|
struct in_addr client_ip;
|
2010-07-23 04:15:23 +08:00
|
|
|
uint16_t client_port;
|
2012-09-13 18:39:36 +08:00
|
|
|
uint32_t block_nr;
|
2009-06-24 20:42:31 +08:00
|
|
|
|
|
|
|
int timestamp;
|
|
|
|
};
|
|
|
|
|
2004-08-25 05:57:12 +08:00
|
|
|
void tftp_input(struct mbuf *m);
|
2012-12-06 19:15:58 +08:00
|
|
|
|
|
|
|
#endif
|