diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index 5258016f2..bcd7e0d0c 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -553,10 +553,11 @@ unsigned short in_cksum(u16 *ptr,int nbytes) { } -/* For computing TCP/UDP checksums, see RFC 1071 and TCP/IP Illustrated - sections 3.2, 11.3, and 17.3. */ -unsigned short tcpudp_cksum(const struct in_addr *src, const struct in_addr *dst, - u8 proto, u16 len, const void *hstart){ +/* Calculate the Internet checksum of some given data concatentated with the + IPv4 pseudo-header. See RFC 1071 and TCP/IP Illustrated sections 3.2, 11.3, + and 17.3. */ +unsigned short ipv4_pseudoheader_cksum(const struct in_addr *src, + const struct in_addr *dst, u8 proto, u16 len, const void *hstart) { struct pseudo { struct in_addr src; struct in_addr dst; diff --git a/libnetutil/netutil.h b/libnetutil/netutil.h index c177aa05b..8b59d3e7b 100644 --- a/libnetutil/netutil.h +++ b/libnetutil/netutil.h @@ -183,10 +183,11 @@ int arp_cache_set(struct sockaddr_storage *ss, u8 *mac); /* Standard BSD internet checksum routine. */ unsigned short in_cksum(u16 *ptr, int nbytes); -/* For computing TCP/UDP checksums, see RFC 1071 and TCP/IP Illustrated - sections 3.2, 11.3, and 17.3.*/ -unsigned short tcpudp_cksum(const struct in_addr *src, const struct in_addr *dst, - u8 proto, u16 len, const void *hstart); +/* Calculate the Internet checksum of some given data concatentated with the + IPv4 pseudo-header. See RFC 1071 and TCP/IP Illustrated sections 3.2, 11.3, + and 17.3. */ +unsigned short ipv4_pseudoheader_cksum(const struct in_addr *src, + const struct in_addr *dst, u8 proto, u16 len, const void *hstart); void sethdrinclude(int sd); void set_ipoptions(int sd, void *opts, size_t optslen); diff --git a/osscan2.cc b/osscan2.cc index 245157d2a..607278879 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -2995,7 +2995,7 @@ int HostOsScan::send_closedudp_probe(HostOsScanStats *hss, udp->uh_ulen = htons(8 + datalen); /* OK, now we should be able to compute a valid checksum */ - realcheck = tcpudp_cksum(source, hss->target->v4hostip(), IPPROTO_UDP, + realcheck = ipv4_pseudoheader_cksum(source, hss->target->v4hostip(), IPPROTO_UDP, sizeof(struct udp_hdr) + datalen, (char *) udp); #if STUPID_SOLARIS_CHECKSUM_BUG udp->uh_sum = sizeof(struct udp_hdr) + datalen;