aboutsummaryrefslogtreecommitdiff
path: root/src/tun
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/tun
parentbd6dc9683d63356d34d0b0d1c3cea4c1b6d67769 (diff)
downloadgnunet-5e442d9cf826adb58d4595722c7dd7b2532096c9.tar.gz
gnunet-5e442d9cf826adb58d4595722c7dd7b2532096c9.zip
-adding ICMP support to TUN library
Diffstat (limited to 'src/tun')
-rw-r--r--src/tun/tun.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tun/tun.c b/src/tun/tun.c
index 009fdd952..4c2ddf07a 100644
--- a/src/tun/tun.c
+++ b/src/tun/tun.c
@@ -242,4 +242,27 @@ GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
242} 242}
243 243
244 244
245/**
246 * Calculate ICMP checksum.
247 *
248 * @param icmp IMCP header (initialized except for CRC)
249 * @param payload the ICMP payload
250 * @param payload_length number of bytes of ICMP payload
251 */
252void
253GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
254 const void *payload,
255 uint16_t payload_length)
256{
257 uint32_t sum;
258
259 icmp->crc = 0;
260 sum = GNUNET_CRYPTO_crc16_step (0,
261 icmp,
262 sizeof (struct GNUNET_TUN_IcmpHeader));
263 sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
264 icmp->crc = GNUNET_CRYPTO_crc16_finish (sum);
265}
266
267
245/* end of tun.c */ 268/* end of tun.c */