forked from pandax381/microps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudp.h
50 lines (38 loc) · 970 Bytes
/
udp.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef UDP_H
#define UDP_H
#include <stddef.h>
#include <stdint.h>
#include "platform.h"
#include "ip.h"
#include "ip6.h"
#define UDP_PCB_SIZE 16
#define UDP_PCB_STATE_FREE 0
#define UDP_PCB_STATE_OPEN 1
#define UDP_PCB_STATE_CLOSING 2
/* see https://tools.ietf.org/html/rfc6335 */
#define UDP_SOURCE_PORT_MIN 49152
#define UDP_SOURCE_PORT_MAX 65535
struct udp_hdr {
uint16_t src;
uint16_t dst;
uint16_t len;
uint16_t sum;
};
/* udp.c */
extern void
udp_dump(const uint8_t *data, size_t len);
extern ssize_t
udp_output(struct ip_endpoint *src, struct ip_endpoint *dst, const uint8_t *buf, size_t len);
extern int
udp_init(void);
extern int
udp_open(void);
extern int
udp_bind(int index, struct ip_endpoint *local);
extern ssize_t
udp_sendto(int id, uint8_t *buf, size_t len, struct ip_endpoint *foreign);
extern ssize_t
udp_recvfrom(int id, uint8_t *buf, size_t size, struct ip_endpoint *foreign);
extern int
udp_close(int id);
#endif