-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmud.h
104 lines (88 loc) · 2.25 KB
/
mud.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include <stddef.h>
#include <inttypes.h>
#include <sys/socket.h>
#define MUD_PATH_MAX (32U)
#define MUD_PUBKEY_SIZE (32U)
struct mud;
enum mud_state {
MUD_EMPTY = 0,
MUD_DOWN,
MUD_BACKUP,
MUD_UP,
};
struct mud_stat {
uint64_t val;
uint64_t var;
int setup;
};
struct mud_conf {
uint64_t keepalive;
uint64_t timetolerance;
uint64_t kxtimeout;
int tc;
};
struct mud_path {
enum mud_state state;
struct sockaddr_storage local_addr, addr, r_addr;
struct mud_stat rtt;
struct {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t rate;
uint64_t loss;
} tx, rx;
struct {
struct {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t acc;
uint64_t acc_time;
} tx, rx;
uint64_t time;
uint64_t sent;
uint64_t set;
} msg;
struct {
size_t min;
size_t max;
size_t probe;
size_t last;
size_t ok;
} mtu;
struct {
uint64_t tx_max_rate;
uint64_t rx_max_rate;
uint64_t beat;
unsigned char fixed_rate;
unsigned char loss_limit;
} conf;
uint64_t idle;
unsigned char ok;
};
struct mud_bad {
struct {
struct sockaddr_storage addr;
uint64_t time;
uint64_t count;
} decrypt, difftime, keyx;
};
struct mud *mud_create (struct sockaddr *, int master);
void mud_delete (struct mud *);
int mud_update (struct mud *);
int mud_send_wait (struct mud *);
int mud_get_fd (struct mud *);
size_t mud_get_mtu (struct mud *);
int mud_get_bad (struct mud *, struct mud_bad *);
int mud_set_key (struct mud *, unsigned char *, size_t);
int mud_get_key (struct mud *, unsigned char *, size_t *);
int mud_set_aes (struct mud *);
int mud_set_conf (struct mud *, struct mud_conf *);
int mud_set_state (struct mud *, struct sockaddr *, struct sockaddr *,
enum mud_state, unsigned long, unsigned long,
unsigned long, unsigned char, unsigned char);
int mud_recv (struct mud *, void *, size_t);
int mud_send (struct mud *, const void *, size_t);
struct mud_path *mud_get_paths(struct mud *, unsigned *);