diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-17 18:59:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-17 18:59:02 +0000 |
commit | 4d899684274d4d5d0ce68c897acafc3d6d5ea3ab (patch) | |
tree | 832befd0132651af352e30cbb15f71783077aa28 /src/include/gnunet_tun_lib.h | |
parent | 6a665489add525880f1f609271dace270c868786 (diff) | |
download | gnunet-4d899684274d4d5d0ce68c897acafc3d6d5ea3ab.tar.gz gnunet-4d899684274d4d5d0ce68c897acafc3d6d5ea3ab.zip |
-rename header
Diffstat (limited to 'src/include/gnunet_tun_lib.h')
-rw-r--r-- | src/include/gnunet_tun_lib.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h new file mode 100644 index 000000000..ca521db3b --- /dev/null +++ b/src/include/gnunet_tun_lib.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010, 2011, 2012 Christian Grothoff | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_tun_lib.h | ||
23 | * @brief standard TCP/IP network structs and IP checksum calculations for TUN interaction | ||
24 | * @author Philipp Toelke | ||
25 | * @author Christian Grothoff | ||
26 | * | ||
27 | * TODO: | ||
28 | * - currently does not follow our naming conventions | ||
29 | */ | ||
30 | #ifndef TCPIP_TUN_H | ||
31 | #define TCPIP_TUN_H | ||
32 | |||
33 | #include "platform.h" | ||
34 | #include "gnunet_util_lib.h" | ||
35 | |||
36 | |||
37 | /* see http://www.iana.org/assignments/ethernet-numbers */ | ||
38 | #ifndef ETH_P_IPV4 | ||
39 | #define ETH_P_IPV4 0x0800 | ||
40 | #endif | ||
41 | |||
42 | #ifndef ETH_P_IPV6 | ||
43 | #define ETH_P_IPV6 0x86DD | ||
44 | #endif | ||
45 | |||
46 | |||
47 | GNUNET_NETWORK_STRUCT_BEGIN | ||
48 | /** | ||
49 | * Header from Linux TUN interface. | ||
50 | */ | ||
51 | struct tun_header | ||
52 | { | ||
53 | /** | ||
54 | * Some flags (unused). | ||
55 | */ | ||
56 | uint16_t flags; | ||
57 | |||
58 | /** | ||
59 | * Here we get an ETH_P_-number. | ||
60 | */ | ||
61 | uint16_t proto; | ||
62 | }; | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Standard IPv4 header. | ||
67 | */ | ||
68 | struct ip4_header | ||
69 | { | ||
70 | unsigned header_length:4 GNUNET_PACKED; | ||
71 | unsigned version:4 GNUNET_PACKED; | ||
72 | uint8_t diff_serv; | ||
73 | uint16_t total_length GNUNET_PACKED; | ||
74 | uint16_t identification GNUNET_PACKED; | ||
75 | unsigned flags:3 GNUNET_PACKED; | ||
76 | unsigned fragmentation_offset:13 GNUNET_PACKED; | ||
77 | uint8_t ttl; | ||
78 | uint8_t protocol; | ||
79 | uint16_t checksum GNUNET_PACKED; | ||
80 | struct in_addr source_address GNUNET_PACKED; | ||
81 | struct in_addr destination_address GNUNET_PACKED; | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * Standard IPv6 header. | ||
86 | */ | ||
87 | struct ip6_header | ||
88 | { | ||
89 | unsigned traffic_class_h:4 GNUNET_PACKED; | ||
90 | unsigned version:4 GNUNET_PACKED; | ||
91 | unsigned traffic_class_l:4 GNUNET_PACKED; | ||
92 | unsigned flow_label:20 GNUNET_PACKED; | ||
93 | uint16_t payload_length GNUNET_PACKED; | ||
94 | uint8_t next_header; | ||
95 | uint8_t hop_limit; | ||
96 | struct in6_addr source_address GNUNET_PACKED; | ||
97 | struct in6_addr destination_address GNUNET_PACKED; | ||
98 | }; | ||
99 | |||
100 | #define TCP_FLAG_SYN 2 | ||
101 | |||
102 | /** | ||
103 | * TCP packet header (FIXME: rename!) | ||
104 | */ | ||
105 | struct tcp_packet | ||
106 | { | ||
107 | unsigned spt:16 GNUNET_PACKED; | ||
108 | unsigned dpt:16 GNUNET_PACKED; | ||
109 | unsigned seq:32 GNUNET_PACKED; | ||
110 | unsigned ack:32 GNUNET_PACKED; | ||
111 | unsigned off:4 GNUNET_PACKED; | ||
112 | unsigned rsv:4 GNUNET_PACKED; | ||
113 | unsigned flg:8 GNUNET_PACKED; | ||
114 | unsigned wsz:16 GNUNET_PACKED; | ||
115 | unsigned crc:16 GNUNET_PACKED; | ||
116 | unsigned urg:16 GNUNET_PACKED; | ||
117 | }; | ||
118 | |||
119 | /** | ||
120 | * UDP packet header (FIXME: rename!) | ||
121 | */ | ||
122 | struct udp_packet | ||
123 | { | ||
124 | uint16_t spt GNUNET_PACKED; | ||
125 | uint16_t dpt GNUNET_PACKED; | ||
126 | uint16_t len GNUNET_PACKED; | ||
127 | uint16_t crc GNUNET_PACKED; | ||
128 | }; | ||
129 | |||
130 | /** | ||
131 | * DNS header. | ||
132 | */ | ||
133 | struct dns_header | ||
134 | { | ||
135 | uint16_t id GNUNET_PACKED; | ||
136 | uint16_t flags GNUNET_PACKED; | ||
137 | uint16_t qdcount GNUNET_PACKED; | ||
138 | uint16_t ancount GNUNET_PACKED; | ||
139 | uint16_t nscount GNUNET_PACKED; | ||
140 | uint16_t arcount GNUNET_PACKED; | ||
141 | }; | ||
142 | GNUNET_NETWORK_STRUCT_END | ||
143 | |||
144 | |||
145 | |||
146 | |||
147 | |||
148 | |||
149 | |||
150 | |||
151 | #endif | ||