aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_tun_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-20 23:18:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-20 23:18:49 +0000
commit5e442d9cf826adb58d4595722c7dd7b2532096c9 (patch)
tree8102eea776e7a14294f89c7e8a9b009f488b3548 /src/include/gnunet_tun_lib.h
parentbd6dc9683d63356d34d0b0d1c3cea4c1b6d67769 (diff)
downloadgnunet-5e442d9cf826adb58d4595722c7dd7b2532096c9.tar.gz
gnunet-5e442d9cf826adb58d4595722c7dd7b2532096c9.zip
-adding ICMP support to TUN library
Diffstat (limited to 'src/include/gnunet_tun_lib.h')
-rw-r--r--src/include/gnunet_tun_lib.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h
index 5fddf70b2..01358299d 100644
--- a/src/include/gnunet_tun_lib.h
+++ b/src/include/gnunet_tun_lib.h
@@ -145,6 +145,63 @@ struct GNUNET_TUN_DnsHeader
145 uint16_t arcount GNUNET_PACKED; 145 uint16_t arcount GNUNET_PACKED;
146}; 146};
147 147
148#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
149#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
150#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
151#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5
152#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8
153#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9
154#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10
155#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11
156
157#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1
158#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2
159#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3
160#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4
161#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128
162#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129
163
164/**
165 * ICMP header.
166 */
167struct GNUNET_TUN_IcmpHeader {
168 uint8_t type;
169 uint8_t code;
170 uint16_t crc;
171
172 union {
173 /**
174 * ICMP Echo (request/reply)
175 */
176 struct {
177 uint16_t identifier;
178 uint16_t sequence_number;
179 } echo;
180
181 /**
182 * ICMP Destination Unreachable (RFC 1191)
183 */
184 struct ih_pmtu {
185 uint16_t empty;
186 uint16_t next_hop_mtu;
187 /* followed by original IP header + first 8 bytes of original IP datagram */
188 } destination_unreachable;
189
190 /**
191 * ICMP Redirect
192 */
193 struct in_addr redirect_gateway_address;
194
195 /**
196 * Placeholder.
197 */
198 int32_t present;
199
200 } quench;
201
202};
203
204
148GNUNET_NETWORK_STRUCT_END 205GNUNET_NETWORK_STRUCT_END
149 206
150 207
@@ -239,4 +296,17 @@ GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
239 uint16_t payload_length); 296 uint16_t payload_length);
240 297
241 298
299/**
300 * Calculate ICMP checksum.
301 *
302 * @param icmp IMCP header (initialized except for CRC)
303 * @param payload the ICMP payload
304 * @param payload_length number of bytes of ICMP payload
305 */
306void
307GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
308 const void *payload,
309 uint16_t payload_length);
310
311
242#endif 312#endif