*** From dhcp-server -- To unsubscribe, see the end of this message. ***
I've come up with my own change to the checksum code based on the BSD
checksum code. My reasoning is that the current code is a bit more
complicated than it needs to be. Can you try this patch out and let
me know if it also solves your problem?
Thanks!
_MelloN_
Index: packet.c
===================================================================
RCS file: /proj/src/isc/cvs-1/DHCP/common/packet.c,v
retrieving revision 1.24
diff -c -r1.24 packet.c
*** packet.c 1999/04/12 21:37:03 1.24
--- packet.c 1999/04/23 14:41:58
***************
*** 52,57 ****
--- 52,60 ----
log_debug ("sum = %x", sum);
#endif
sum += (u_int16_t) ntohs(*((u_int16_t *)(buf + i)));
+ /* Add carry. */
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
}
/* If there's a single byte left over, checksum it, too. Network
***************
*** 61,73 ****
log_debug ("sum = %x", sum);
#endif
sum += buf [i] << 8;
}
return sum;
}
! /* Fold the upper sixteen bits of the checksum down into the lower bits,
! complement the sum, and then put it into network byte order. */
u_int32_t wrapsum (sum)
u_int32_t sum;
--- 64,78 ----
log_debug ("sum = %x", sum);
#endif
sum += buf [i] << 8;
+ /* Add carry. */
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
}
return sum;
}
! /* Finish computing the checksum, and then put it into network byte order. */
u_int32_t wrapsum (sum)
u_int32_t sum;
***************
*** 76,93 ****
log_debug ("wrapsum (%x)", sum);
#endif
! while (sum > 0x10000) {
! sum = (sum >> 16) + (sum & 0xFFFF);
#ifdef DEBUG_CHECKSUM_VERBOSE
- log_debug ("sum = %x", sum);
- #endif
- sum += (sum >> 16);
- #ifdef DEBUG_CHECKSUM_VERBOSE
- log_debug ("sum = %x", sum);
- #endif
- }
- sum = sum ^ 0xFFFF;
- #ifdef DEBUG_CHECKSUM_VERBOSE
log_debug ("sum = %x", sum);
#endif
--- 81,88 ----
log_debug ("wrapsum (%x)", sum);
#endif
! sum = ~sum & 0xFFFF;
#ifdef DEBUG_CHECKSUM_VERBOSE
log_debug ("sum = %x", sum);
#endif
***************
*** 250,261 ****
return -1;
#endif /* USERLAND_FILTER */
- ++ip_packets_seen;
/* Check the IP header checksum - it should be zero. */
if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
++ip_packets_bad_checksum;
if (ip_packets_seen > 4 &&
! (++ip_packets_seen / ++ip_packets_bad_checksum) < 2) {
log_info ("%d bad IP checksums seen in %d packets",
ip_packets_bad_checksum, ip_packets_seen);
ip_packets_seen = ip_packets_bad_checksum = 0;
--- 245,256 ----
return -1;
#endif /* USERLAND_FILTER */
/* Check the IP header checksum - it should be zero. */
+ ++ip_packets_seen;
if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
++ip_packets_bad_checksum;
if (ip_packets_seen > 4 &&
! (ip_packets_seen / ip_packets_bad_checksum) < 2) {
log_info ("%d bad IP checksums seen in %d packets",
ip_packets_bad_checksum, ip_packets_seen);
ip_packets_seen = ip_packets_bad_checksum = 0;
***************
*** 279,285 ****
data = buf + bufix + ip_len + sizeof *udp;
len = ntohs (udp -> uh_ulen) - sizeof *udp;
++udp_packets_length_checked;
! if (len + data > buf + buflen) {
++udp_packets_length_overflow;
if (udp_packets_length_checked > 4 &&
(udp_packets_length_checked /
--- 274,280 ----
data = buf + bufix + ip_len + sizeof *udp;
len = ntohs (udp -> uh_ulen) - sizeof *udp;
++udp_packets_length_checked;
! if (len + data > buf + bufix + buflen) {
++udp_packets_length_overflow;
if (udp_packets_length_checked > 4 &&
(udp_packets_length_checked /
***************
*** 287,294 ****
log_info ("%d udp packets in %d too long - dropped",
udp_packets_length_overflow,
udp_packets_length_checked);
! udp_packets_length_overflow
! = udp_packets_length_checked = 0;
}
return -1;
}
--- 282,289 ----
log_info ("%d udp packets in %d too long - dropped",
udp_packets_length_overflow,
udp_packets_length_checked);
! udp_packets_length_overflow =
! udp_packets_length_checked = 0;
}
return -1;
}
***************
*** 310,319 ****
++udp_packets_seen;
if (usum && usum != sum) {
! ++udp_packets_bad_checksum;
if (udp_packets_seen > 4 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
! log_info ("%d bad udp checksums seen in %d packets",
udp_packets_bad_checksum, udp_packets_seen);
udp_packets_seen = udp_packets_bad_checksum = 0;
}
--- 305,314 ----
++udp_packets_seen;
if (usum && usum != sum) {
! udp_packets_bad_checksum++;
if (udp_packets_seen > 4 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
! log_info ("%d bad udp checksums in %d packets",
udp_packets_bad_checksum, udp_packets_seen);
udp_packets_seen = udp_packets_bad_checksum = 0;
}
------------------------------------------------------------------------------
To unsubscribe from this list, please visit http://www.fugue.com/dhcp/lists
If you are without web access, or if you are having trouble with the web page,
please send mail to [EMAIL PROTECTED] Please try to use the web
page first - it will take a long time for your request to be processed by hand.
Archives for this mailing list are available at
http://www.webnology.com/list-archives/dhcp/dhcp-server
------------------------------------------------------------------------------