2004-08-24 23:57:12 +02:00
|
|
|
/* tftp defines */
|
2016-06-29 15:29:06 +02:00
|
|
|
|
2012-12-06 12:15:58 +01:00
|
|
|
#ifndef SLIRP_TFTP_H
|
2016-06-29 15:29:06 +02:00
|
|
|
#define SLIRP_TFTP_H
|
2004-08-24 23:57:12 +02:00
|
|
|
|
2014-06-21 15:26:05 +02:00
|
|
|
#define TFTP_SESSIONS_MAX 20
|
2004-08-24 23:57:12 +02: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 01:07:50 +01:00
|
|
|
#define TFTP_OACK 6
|
2004-08-24 23:57:12 +02:00
|
|
|
|
|
|
|
#define TFTP_FILENAME_MAX 512
|
2016-11-21 20:45:49 +01:00
|
|
|
#define TFTP_BLOCKSIZE_MAX 1428
|
2004-08-24 23:57:12 +02:00
|
|
|
|
|
|
|
struct tftp_t {
|
|
|
|
struct udphdr udp;
|
2010-07-22 22:15:23 +02:00
|
|
|
uint16_t tp_op;
|
2004-08-24 23:57:12 +02:00
|
|
|
union {
|
2007-09-16 23:08:06 +02:00
|
|
|
struct {
|
2010-07-22 22:15:23 +02:00
|
|
|
uint16_t tp_block_nr;
|
2016-11-21 20:45:49 +01:00
|
|
|
uint8_t tp_buf[TFTP_BLOCKSIZE_MAX];
|
2004-08-24 23:57:12 +02:00
|
|
|
} tp_data;
|
2007-09-16 23:08:06 +02:00
|
|
|
struct {
|
2010-07-22 22:15:23 +02:00
|
|
|
uint16_t tp_error_code;
|
2016-11-21 20:45:49 +01:00
|
|
|
uint8_t tp_msg[TFTP_BLOCKSIZE_MAX];
|
2004-08-24 23:57:12 +02:00
|
|
|
} tp_error;
|
2016-11-21 20:45:49 +01:00
|
|
|
char tp_buf[TFTP_BLOCKSIZE_MAX + 2];
|
2004-08-24 23:57:12 +02:00
|
|
|
} x;
|
2016-03-15 10:31:23 +01:00
|
|
|
} __attribute__((packed));
|
2004-08-24 23:57:12 +02:00
|
|
|
|
2009-06-24 14:42:31 +02:00
|
|
|
struct tftp_session {
|
|
|
|
Slirp *slirp;
|
|
|
|
char *filename;
|
2012-09-10 20:52:25 +02:00
|
|
|
int fd;
|
2016-11-21 20:45:49 +01:00
|
|
|
uint16_t block_size;
|
2009-06-24 14:42:31 +02:00
|
|
|
|
2016-03-15 10:31:23 +01:00
|
|
|
struct sockaddr_storage client_addr;
|
2010-07-22 22:15:23 +02:00
|
|
|
uint16_t client_port;
|
2012-09-13 12:39:36 +02:00
|
|
|
uint32_t block_nr;
|
2009-06-24 14:42:31 +02:00
|
|
|
|
|
|
|
int timestamp;
|
|
|
|
};
|
|
|
|
|
2016-03-15 10:31:23 +01:00
|
|
|
void tftp_input(struct sockaddr_storage *srcsas, struct mbuf *m);
|
2012-12-06 12:15:58 +01:00
|
|
|
|
|
|
|
#endif
|