2014-03-02 11:42:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// $Id$
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-02-16 17:31:53 +04:00
|
|
|
/* tftp defines */
|
2014-02-19 00:34:14 +04:00
|
|
|
#ifndef SLIRP_TFTP_H
|
|
|
|
#define SLIRP_TFTP_H 1
|
2014-02-16 17:31:53 +04:00
|
|
|
|
|
|
|
#define TFTP_SESSIONS_MAX 3
|
|
|
|
|
|
|
|
#define TFTP_SERVER 69
|
|
|
|
|
2014-03-28 01:09:09 +04:00
|
|
|
#define TFTP_BUFFER_SIZE 1024
|
2014-02-16 17:31:53 +04:00
|
|
|
|
|
|
|
struct tftp_t {
|
|
|
|
struct ip ip;
|
|
|
|
struct udphdr udp;
|
|
|
|
uint16_t tp_op;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16_t tp_block_nr;
|
2014-03-28 01:09:09 +04:00
|
|
|
uint8_t tp_buf[TFTP_BUFFER_SIZE];
|
2014-02-16 17:31:53 +04:00
|
|
|
} tp_data;
|
|
|
|
struct {
|
|
|
|
uint16_t tp_error_code;
|
2014-03-28 01:09:09 +04:00
|
|
|
uint8_t tp_msg[TFTP_BUFFER_SIZE];
|
2014-02-16 17:31:53 +04:00
|
|
|
} tp_error;
|
2014-03-28 01:09:09 +04:00
|
|
|
char tp_buf[TFTP_BUFFER_SIZE + 2];
|
2014-02-16 17:31:53 +04:00
|
|
|
} x;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tftp_session {
|
|
|
|
Slirp *slirp;
|
|
|
|
char *filename;
|
2014-02-19 00:34:14 +04:00
|
|
|
int fd;
|
2014-02-16 17:31:53 +04:00
|
|
|
|
|
|
|
struct in_addr client_ip;
|
|
|
|
uint16_t client_port;
|
2014-02-19 00:34:14 +04:00
|
|
|
uint32_t block_nr;
|
2014-03-28 01:09:09 +04:00
|
|
|
bx_bool write;
|
|
|
|
unsigned options;
|
|
|
|
size_t tsize_val;
|
|
|
|
unsigned blksize_val;
|
|
|
|
unsigned timeout_val;
|
2014-02-16 17:31:53 +04:00
|
|
|
|
|
|
|
int timestamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
void tftp_input(struct mbuf *m);
|
2014-02-19 00:34:14 +04:00
|
|
|
|
|
|
|
#endif
|