summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/sstp/proxy_prot.h
blob: bada8aa383dd8e70cc870860a58dff53335c0185 (plain)
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
#ifndef PROXY_PROT_H
#define PROXY_PROT_H

#include <stdint.h>
#include <string.h>
#include <netinet/in.h>

#define PROXY_SIG		{ 'P', 'R', 'O', 'X', 'Y' }
#define PROXY_MINLEN		8
#define PROXY_TCP4		"TCP4"
#define PROXY_TCP6		"TCP6"
#define PROXY_UNKNOWN		"UNKNOWN"

#define PROXY2_SIG		{ 0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, 0x54, 0x0a }
#define PROXY2_MINLEN		16
#define PROXY2_LOCAL		0
#define PROXY2_PROXY		1
#define PROXY2_AF_UNSPEC	0
#define PROXY2_AF_INET		1
#define PROXY2_AF_INET6		2
#define PROXY2_AF_UNIX		3
#define PROXY2_UNSPEC		0
#define PROXY2_STREAM		1
#define PROXY2_DGRAM		2

struct proxy_hdr {
	char line[108];
} __attribute__((packed));

struct proxy2_ipv4 {
	struct in_addr src_addr;
	struct in_addr dst_addr;
	uint16_t src_port;
	uint16_t dst_port;
} __attribute__((packed));

struct proxy2_ipv6 {
	struct in6_addr src_addr;
	struct in6_addr dst_addr;
	uint16_t src_port;
	uint16_t dst_port;
} __attribute__((packed));

struct proxy2_unix {
	char src_addr[108];
	char dst_addr[108];
} __attribute__((packed));

union proxy2_addr {
	struct proxy2_ipv4 ipv4_addr;
	struct proxy2_ipv6 ipv6_addr;
	struct proxy2_unix unix_addr;
};

struct proxy2_hdr {
	uint8_t sig[12];	/* hex 0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A */
	uint8_t ver_cmd;	/* protocol version and command */
	uint8_t fam;		/* protocol family and address */
	uint16_t len;		/* number of following bytes part of the header */
	union proxy2_addr __addr[0];
#define ipv4_addr __addr[0].ipv4_addr
#define ipv6_addr __addr[0].ipv6_addr
#define unix_addr __addr[0].unix_addr
} __attribute__((packed));

struct BUG_bad_sizeof_proxy_hdr {
	uint8_t proxy_hdr[sizeof(struct proxy_hdr) < PROXY_MINLEN ? -1 : 0 ];
};

struct BUG_bad_sizeof_proxy2_hdr {
	uint8_t proxy2_hdr[sizeof(struct proxy2_hdr) != PROXY2_MINLEN ? -1 : 0 ];
};

#endif