1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
36
37
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ... */
#ifndef __TFTPSERVER_H_
#define __TFTPSERVER_H_
#include "lwip/mem.h"
#include "lwip/udp.h"
#define TFTP_OPCODE_LEN 2
#define TFTP_BLKNUM_LEN 2
#define TFTP_ERRCODE_LEN 2
#define TFTP_DATA_LEN_MAX 512
#define TFTP_DATA_PKT_HDR_LEN (TFTP_OPCODE_LEN + TFTP_BLKNUM_LEN)
#define TFTP_ERR_PKT_HDR_LEN (TFTP_OPCODE_LEN + TFTP_ERRCODE_LEN)
#define TFTP_ACK_PKT_LEN (TFTP_OPCODE_LEN + TFTP_BLKNUM_LEN)
#define TFTP_DATA_PKT_LEN_MAX (TFTP_DATA_PKT_HDR_LEN + TFTP_DATA_LEN_MAX)
8 defines
typedef enum {
TFTP_RRQ = 1,
TFTP_WRQ = 2,
TFTP_DATA = 3,
TFTP_ACK = 4,
TFTP_ERROR = 5
...} tftp_opcode;
typedef enum {
TFTP_ERR_NOTDEFINED,
TFTP_ERR_FILE_NOT_FOUND,
TFTP_ERR_ACCESS_VIOLATION,
TFTP_ERR_DISKFULL,
TFTP_ERR_ILLEGALOP,
TFTP_ERR_UKNOWN_TRANSFER_ID,
TFTP_ERR_FILE_ALREADY_EXISTS,
TFTP_ERR_NO_SUCH_USER,
...} tftp_errorcode;
void tftpd_init(void);
int tftp_process_write(struct udp_pcb *upcb2, const ip_addr_t *to, unsigned short to_port, char* FileName);
int tftp_process_read(struct udp_pcb *upcb2, const ip_addr_t *to, unsigned short to_port, char* FileName);
/* ... */
#endif