1 : /*
2 : * checksum.h - ICMPv6 checksumming
3 : * $Id: checksum.h 1938 2007-02-22 20:55:28Z remi $
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. *
11 : * *
12 : * This program is distributed in the hope that it will be useful, *
13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 : * See the GNU General Public License for more details. *
16 : * *
17 : * You should have received a copy of the GNU General Public License *
18 : * along with this program; if not, you can get it from: *
19 : * http://www.gnu.org/copyleft/gpl.html *
20 : ***********************************************************************/
21 :
22 : #ifndef LIBTEREDO_TEREDO_CHECKSUM_H
23 : # define LIBTEREDO_TEREDO_CHECKSUM_H
24 :
25 : # include <sys/types.h>
26 : # include <netinet/in.h>
27 :
28 : /*
29 : * Computes an ICMPv6 over IPv6 packet checksum.
30 : * Jumbo datagrams not supported (but you don't care, do you?).
31 : */
32 : static inline uint16_t
33 : icmp6_checksum (const struct ip6_hdr *ip6, const struct icmp6_hdr *icmp6)
34 0 : {
35 0 : struct iovec iov = { (void *)icmp6, ntohs (ip6->ip6_plen) };
36 0 : return teredo_cksum (&ip6->ip6_src, &ip6->ip6_dst, IPPROTO_ICMPV6, &iov, 1);
37 : }
38 :
39 : #endif
40 :
|