diff options
author | 2018-07-06 04:49:21 +0000 | |
---|---|---|
committer | 2018-07-06 04:49:21 +0000 | |
commit | dd17d5ca93a73d902f95390a334735148a13e44e (patch) | |
tree | b02f35cc472c0af59dc8294149d5af61fdcd527d /usr.sbin/tcpdump/print-ip.c | |
parent | Split trap() into kerntrap() and usertrap(), with all the signal generation (diff) | |
download | wireguard-openbsd-dd17d5ca93a73d902f95390a334735148a13e44e.tar.xz wireguard-openbsd-dd17d5ca93a73d902f95390a334735148a13e44e.zip |
move the ip checksumming code into in_cksum.c
this is part of a bigger change that refactors udp handling, but
works on hosts of both endians.
discussed at length with proctor@
ok sthen@
Diffstat (limited to 'usr.sbin/tcpdump/print-ip.c')
-rw-r--r-- | usr.sbin/tcpdump/print-ip.c | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index 475b79ee906..20bef72e9b3 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip.c,v 1.49 2018/02/10 10:00:32 dlg Exp $ */ +/* $OpenBSD: print-ip.c,v 1.50 2018/07/06 04:49:21 dlg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -312,40 +312,6 @@ trunc: } /* - * compute an IP header checksum. - * don't modifiy the packet. - */ -u_short -in_cksum(const u_short *addr, int len, int csum) -{ - int nleft = len; - const u_short *w = addr; - u_short answer; - int sum = csum; - - /* - * Our algorithm is simple, using a 32 bit accumulator (sum), - * we add sequential 16 bit words to it, and at the end, fold - * back all the carry bits from the top 16 bits into the lower - * 16 bits. - */ - while (nleft > 1) { - sum += *w++; - nleft -= 2; - } - if (nleft == 1) - sum += htons(*(u_char *)w<<8); - - /* - * add back carry outs from top 16 bits to low 16 bits - */ - sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ - sum += (sum >> 16); /* add carry */ - answer = ~sum; /* truncate to 16 bits */ - return (answer); -} - -/* * print an IP datagram. */ void |