1 /**
2 * @file checksum.h
3 * @brief ICMPv6 checksumming
4 */
5
6 /***********************************************************************
7 * Copyright © 2004-2007 Rémi Denis-Courmont. *
8 * This program is free software; you can redistribute and/or modify *
9 * it under the terms of the GNU General Public License as published *
10 * by the Free Software Foundation; version 2 of the license, or (at *
11 * your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
16 * See the GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, you can get it from: *
20 * http://www.gnu.org/copyleft/gpl.html *
21 ***********************************************************************/
22
23 #ifndef LIBTEREDO_TEREDO_CHECKSUM_H
24 # define LIBTEREDO_TEREDO_CHECKSUM_H
25
26 # include <sys/types.h>
27 # include <netinet/in.h>
28
29 /**
30 * Computes an ICMPv6 over IPv6 packet checksum.
31 * Jumbo datagrams not supported (but you don't care, do you?).
32 */
33 static inline uint16_t
icmp6_checksum(const struct ip6_hdr * ip6,const struct icmp6_hdr * icmp6)34 icmp6_checksum (const struct ip6_hdr *ip6, const struct icmp6_hdr *icmp6)
35 {
36 struct iovec iov = { (void *)icmp6, ntohs (ip6->ip6_plen) };
37 return teredo_cksum (&ip6->ip6_src, &ip6->ip6_dst, IPPROTO_ICMPV6, &iov, 1);
38 }
39
40 #endif
41
42