Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/SharedDependencies/Sources/libslirp/include/tftp.h
2 views
1
/* SPDX-License-Identifier: BSD-3-Clause */
2
/* tftp defines */
3
4
#ifndef SLIRP_TFTP_H
5
#define SLIRP_TFTP_H
6
7
#include "util.h"
8
9
#define TFTP_SESSIONS_MAX 20
10
11
#define TFTP_SERVER 69
12
13
#define TFTP_RRQ 1
14
#define TFTP_WRQ 2
15
#define TFTP_DATA 3
16
#define TFTP_ACK 4
17
#define TFTP_ERROR 5
18
#define TFTP_OACK 6
19
20
#define TFTP_FILENAME_MAX 512
21
#define TFTP_BLOCKSIZE_MAX 1428
22
23
SLIRP_PACKED_BEGIN
24
struct tftphdr {
25
struct udphdr udp;
26
uint16_t tp_op;
27
} SLIRP_PACKED_END;
28
29
SLIRP_PACKED_BEGIN
30
struct tftp_t {
31
struct tftphdr hdr;
32
union {
33
struct {
34
uint16_t tp_block_nr;
35
uint8_t tp_buf[TFTP_BLOCKSIZE_MAX];
36
} tp_data;
37
struct {
38
uint16_t tp_error_code;
39
uint8_t tp_msg[TFTP_BLOCKSIZE_MAX];
40
} tp_error;
41
char tp_buf[TFTP_BLOCKSIZE_MAX + 2];
42
} x;
43
} SLIRP_PACKED_END;
44
45
struct tftp_session {
46
Slirp *slirp;
47
char *filename;
48
int fd;
49
uint16_t block_size;
50
51
struct sockaddr_storage client_addr;
52
uint16_t client_port;
53
uint32_t block_nr;
54
55
int timestamp;
56
};
57
58
/* Process TFTP packet coming from the guest */
59
void tftp_input(struct sockaddr_storage *srcsas, struct mbuf *m);
60
61
/* Clear remaining sessions */
62
void tftp_cleanup(Slirp *slirp);
63
64
#endif
65
66