2 This file is part of GNUnet.
3 (C) 2010, 2011, 2012 Christian Grothoff
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.
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.
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.
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
28 * - currently does not follow our naming conventions
34 #include "gnunet_util_lib.h"
37 /* see http://www.iana.org/assignments/ethernet-numbers */
39 #define ETH_P_IPV4 0x0800
43 #define ETH_P_IPV6 0x86DD
47 GNUNET_NETWORK_STRUCT_BEGIN
49 * Header from Linux TUN interface.
54 * Some flags (unused).
59 * Here we get an ETH_P_-number.
66 * Standard IPv4 header.
70 unsigned header_length:4 GNUNET_PACKED;
71 unsigned version:4 GNUNET_PACKED;
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;
79 uint16_t checksum GNUNET_PACKED;
80 struct in_addr source_address GNUNET_PACKED;
81 struct in_addr destination_address GNUNET_PACKED;
85 * Standard IPv6 header.
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;
96 struct in6_addr source_address GNUNET_PACKED;
97 struct in6_addr destination_address GNUNET_PACKED;
100 #define TCP_FLAG_SYN 2
103 * TCP packet header (FIXME: rename!)
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;
120 * UDP packet header (FIXME: rename!)
124 uint16_t spt GNUNET_PACKED;
125 uint16_t dpt GNUNET_PACKED;
126 uint16_t len GNUNET_PACKED;
127 uint16_t crc GNUNET_PACKED;
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;
142 GNUNET_NETWORK_STRUCT_END