Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping/ping.c
Show First 20 Lines • Show All 1,144 Lines • ▼ Show 20 Lines | pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) | ||||
struct in_addr ina; | struct in_addr ina; | ||||
u_char *cp, *dp, l; | u_char *cp, *dp, l; | ||||
struct icmp icp; | struct icmp icp; | ||||
struct ip ip; | struct ip ip; | ||||
const u_char *icmp_data_raw; | const u_char *icmp_data_raw; | ||||
ssize_t icmp_data_raw_len; | ssize_t icmp_data_raw_len; | ||||
double triptime; | double triptime; | ||||
int dupflag, i, j, recv_len; | int dupflag, i, j, recv_len; | ||||
uint8_t hlen; | int8_t hlen; | ||||
uint16_t seq; | uint16_t seq; | ||||
static int old_rrlen; | static int old_rrlen; | ||||
static char old_rr[MAX_IPOPTLEN]; | static char old_rr[MAX_IPOPTLEN]; | ||||
struct ip oip; | struct ip oip; | ||||
u_char oip_header_len; | u_char oip_header_len; | ||||
struct icmp oicmp; | struct icmp oicmp; | ||||
const u_char *oicmp_raw; | const u_char *oicmp_raw; | ||||
/* | /* | ||||
* Get size of IP header of the received packet. | * Get size of IP header of the received packet. | ||||
* The header length is contained in the lower four bits of the first | * The header length is contained in the lower four bits of the first | ||||
* byte and represents the number of 4 byte octets the header takes up. | * byte and represents the number of 4 byte octets the header takes up. | ||||
* | * | ||||
* The IHL minimum value is 5 (20 bytes) and its maximum value is 15 | * The IHL minimum value is 5 (20 bytes) and its maximum value is 15 | ||||
* (60 bytes). | * (60 bytes). | ||||
*/ | */ | ||||
memcpy(&l, buf, sizeof(l)); | memcpy(&l, buf, sizeof(l)); | ||||
hlen = (l & 0x0f) << 2; | hlen = (l & 0x0f) << 2; | ||||
/* Reject IP packets with a short header */ | /* Reject IP packets with a short header */ | ||||
if (hlen < sizeof(struct ip)) { | if (hlen < (int8_t) sizeof(struct ip)) { | ||||
if (options & F_VERBOSE) | if (options & F_VERBOSE) | ||||
warn("IHL too short (%d bytes) from %s", hlen, | warn("IHL too short (%d bytes) from %s", hlen, | ||||
inet_ntoa(from->sin_addr)); | inet_ntoa(from->sin_addr)); | ||||
return; | return; | ||||
} | } | ||||
memcpy(&ip, buf, sizeof(struct ip)); | memcpy(&ip, buf, sizeof(struct ip)); | ||||
▲ Show 20 Lines • Show All 631 Lines • Show Last 20 Lines |