aboutsummaryrefslogtreecommitdiff
path: root/networking/traceroute.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/traceroute.c')
-rw-r--r--networking/traceroute.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index c32103519..d197e5410 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -418,39 +418,6 @@ wait_for_reply(len_and_sockaddr *from_lsa, struct sockaddr *to, unsigned *timest
418 return read_len; 418 return read_len;
419} 419}
420 420
421/*
422 * Checksum routine for Internet Protocol family headers (C Version)
423 */
424static uint16_t
425in_cksum(uint16_t *addr, int len)
426{
427 int nleft = len;
428 uint16_t *w = addr;
429 uint16_t answer;
430 int sum = 0;
431
432 /*
433 * Our algorithm is simple, using a 32 bit accumulator (sum),
434 * we add sequential 16 bit words to it, and at the end, fold
435 * back all the carry bits from the top 16 bits into the lower
436 * 16 bits.
437 */
438 while (nleft > 1) {
439 sum += *w++;
440 nleft -= 2;
441 }
442
443 /* mop up an odd byte, if necessary */
444 if (nleft == 1)
445 sum += *(unsigned char *)w;
446
447 /* add back carry outs from top 16 bits to low 16 bits */
448 sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
449 sum += (sum >> 16); /* add carry */
450 answer = ~sum; /* truncate to 16 bits */
451 return answer;
452}
453
454static void 421static void
455send_probe(int seq, int ttl) 422send_probe(int seq, int ttl)
456{ 423{
@@ -477,7 +444,7 @@ send_probe(int seq, int ttl)
477 444
478 /* Always calculate checksum for icmp packets */ 445 /* Always calculate checksum for icmp packets */
479 outicmp->icmp_cksum = 0; 446 outicmp->icmp_cksum = 0;
480 outicmp->icmp_cksum = in_cksum((uint16_t *)outicmp, 447 outicmp->icmp_cksum = inet_cksum((uint16_t *)outicmp,
481 packlen - (sizeof(*outip) + optlen)); 448 packlen - (sizeof(*outip) + optlen));
482 if (outicmp->icmp_cksum == 0) 449 if (outicmp->icmp_cksum == 0)
483 outicmp->icmp_cksum = 0xffff; 450 outicmp->icmp_cksum = 0xffff;