aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-vpn-packet.h
blob: 835ffb8a3627647228566f81aa43323fc40d4c01 (plain) (blame)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#ifndef _GNTUN_PACKET_H_
#define _GNTUN_PACKET_H_

#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_dnsparser_lib.h"

GNUNET_NETWORK_STRUCT_BEGIN

// Headers
struct pkt_tun
{
  unsigned flags:16 GNUNET_PACKED;
  unsigned type:16 GNUNET_PACKED;
};

struct ip6_hdr
{
  unsigned tclass_h:4 GNUNET_PACKED;
  unsigned version:4 GNUNET_PACKED;
  unsigned tclass_l:4 GNUNET_PACKED;
  unsigned flowlbl:20 GNUNET_PACKED;
  unsigned paylgth:16 GNUNET_PACKED;
  unsigned nxthdr:8 GNUNET_PACKED;
  unsigned hoplmt:8 GNUNET_PACKED;
  struct in6_addr sadr;
  struct in6_addr dadr;
};

struct ip_hdr
{
  unsigned hdr_lngth:4 GNUNET_PACKED;
  unsigned version:4 GNUNET_PACKED;

  unsigned diff_serv:8 GNUNET_PACKED;
  unsigned tot_lngth:16 GNUNET_PACKED;

  unsigned ident:16 GNUNET_PACKED;
  unsigned flags:3 GNUNET_PACKED;
  unsigned frag_off:13 GNUNET_PACKED;

  unsigned ttl:8 GNUNET_PACKED;
  unsigned proto:8 GNUNET_PACKED;
  unsigned chks:16 GNUNET_PACKED;

  struct in_addr sadr GNUNET_PACKED;
  struct in_addr dadr GNUNET_PACKED;
};

#define TCP_FLAG_SYN 2

struct tcp_pkt
{
  unsigned spt:16 GNUNET_PACKED;
  unsigned dpt:16 GNUNET_PACKED;
  unsigned seq:32 GNUNET_PACKED;
  unsigned ack:32 GNUNET_PACKED;
  unsigned off:4 GNUNET_PACKED;
  unsigned rsv:4 GNUNET_PACKED;
  unsigned flg:8 GNUNET_PACKED;
  unsigned wsz:16 GNUNET_PACKED;
  unsigned crc:16 GNUNET_PACKED;
  unsigned urg:16 GNUNET_PACKED;
};

struct udp_pkt
{
  unsigned spt:16 GNUNET_PACKED;
  unsigned dpt:16 GNUNET_PACKED;
  unsigned len:16 GNUNET_PACKED;
  unsigned crc:16 GNUNET_PACKED;
};

struct icmp_hdr
{
  unsigned type:8 GNUNET_PACKED;
  unsigned code:8 GNUNET_PACKED;
  unsigned chks:16 GNUNET_PACKED;
};
GNUNET_NETWORK_STRUCT_END


struct udp_dns
{
  struct udp_pkt udp_hdr;
  struct dns_pkt data;
};

GNUNET_NETWORK_STRUCT_BEGIN

// Complete Packets
struct tun_pkt
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
};

struct ip6_pkt
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip6_hdr ip6_hdr;
  unsigned char data[1];
};

struct ip6_tcp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip6_hdr ip6_hdr;
  struct tcp_pkt tcp_hdr;
  unsigned char data[1];
};

struct ip6_icmp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip6_hdr ip6_hdr;
  struct icmp_hdr icmp_hdr;
};

struct ip6_udp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip6_hdr ip6_hdr;
  struct udp_pkt udp_hdr;
  unsigned char data[1];
};

struct ip6_udp_dns
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip6_hdr ip6_hdr;
  struct udp_dns udp_dns;
};

struct ip_pkt
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip_hdr ip_hdr;
  unsigned char data[1];
};

struct ip_udp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip_hdr ip_hdr;
  struct udp_pkt udp_hdr;
  unsigned char data[1];
};

struct ip_udp_dns
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip_hdr ip_hdr;
  struct udp_dns udp_dns;
};

struct ip_tcp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip_hdr ip_hdr;
  struct tcp_pkt tcp_hdr;
  unsigned char data[1];
};

struct ip_icmp
{
  struct GNUNET_MessageHeader shdr;
  struct pkt_tun tun;
  struct ip_hdr ip_hdr;
  struct icmp_hdr icmp_hdr;
};
GNUNET_NETWORK_STRUCT_END

#endif