]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/icmp/Icmp.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 37 ICMP Routines */
14 #include "SquidTime.h"
38 Icmp::CheckSum(unsigned short *ptr
, int size
)
41 unsigned short oddbyte
;
42 unsigned short answer
;
44 if (!ptr
) return (int)htons(0xffff); // bad input.
56 *((unsigned char *) &oddbyte
) = *(unsigned char *) ptr
;
60 sum
= (sum
>> 16) + (sum
& 0xffff);
62 answer
= (unsigned short) ~sum
;
73 return 63 - ttl
; /* 62 = (64+60)/2 */
76 return 65 - ttl
; /* 62 = (64+60)/2 */
88 Icmp::Log(const Ip::Address
&addr
, const uint8_t type
, const char* pkt_str
, const int rtt
, const int hops
)
90 debugs(42, 2, "pingerLog: " << std::setw(9) << current_time
.tv_sec
<<
91 "." << std::setfill('0') << std::setw(6) <<
92 current_time
.tv_usec
<< " " << std::left
<< std::setfill(' ') <<
93 std::setw(45) << addr
<< " " << type
<<
94 " " << std::setw(15) << pkt_str
<< " " << rtt
<<
95 "ms " << hops
<< " hops");