Deleted Added
full compact
ping6.c (206889) ping6.c (209236)
1/* $KAME: ping6.c,v 1.169 2003/07/25 06:01:47 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 64 unchanged lines hidden (view full) ---

73 The Regents of the University of California. All rights reserved.\n";
74#endif /* not lint */
75
76#ifndef lint
77#if 0
78static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
79#endif
80static const char rcsid[] =
1/* $KAME: ping6.c,v 1.169 2003/07/25 06:01:47 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 64 unchanged lines hidden (view full) ---

73 The Regents of the University of California. All rights reserved.\n";
74#endif /* not lint */
75
76#ifndef lint
77#if 0
78static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
79#endif
80static const char rcsid[] =
81 "$FreeBSD: head/sbin/ping6/ping6.c 206889 2010-04-20 06:10:05Z maxim $";
81 "$FreeBSD: head/sbin/ping6/ping6.c 209236 2010-06-16 15:49:17Z brucec $";
82#endif /* not lint */
83
84/*
85 * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility,
86 * measure round-trip-delays and packet loss across network paths.
87 *
88 * Author -
89 * Mike Muuss

--- 115 unchanged lines hidden (view full) ---

205 * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
206 * number of received sequence numbers we can keep track of. Change 128
207 * to 8192 for complete accuracy...
208 */
209#define MAX_DUP_CHK (8 * 8192)
210int mx_dup_ck = MAX_DUP_CHK;
211char rcvd_tbl[MAX_DUP_CHK / 8];
212
82#endif /* not lint */
83
84/*
85 * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility,
86 * measure round-trip-delays and packet loss across network paths.
87 *
88 * Author -
89 * Mike Muuss

--- 115 unchanged lines hidden (view full) ---

205 * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
206 * number of received sequence numbers we can keep track of. Change 128
207 * to 8192 for complete accuracy...
208 */
209#define MAX_DUP_CHK (8 * 8192)
210int mx_dup_ck = MAX_DUP_CHK;
211char rcvd_tbl[MAX_DUP_CHK / 8];
212
213struct addrinfo *res;
213struct addrinfo *res = NULL;
214struct sockaddr_in6 dst; /* who to ping6 */
215struct sockaddr_in6 src; /* src addr of this packet */
216socklen_t srclen;
217int datalen = DEFDATALEN;
218int s; /* socket file descriptor */
219u_char outpack[MAXPACKETLEN];
220char BSPACE = '\b'; /* characters written for flood */
221char BBELL = '\a'; /* characters written for AUDIBLE */
222char DOT = '.';
223char *hostname;
224int ident; /* process id to identify our packets */
225u_int8_t nonce[8]; /* nonce field for node information */
226int hoplimit = -1; /* hoplimit */
227int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */
214struct sockaddr_in6 dst; /* who to ping6 */
215struct sockaddr_in6 src; /* src addr of this packet */
216socklen_t srclen;
217int datalen = DEFDATALEN;
218int s; /* socket file descriptor */
219u_char outpack[MAXPACKETLEN];
220char BSPACE = '\b'; /* characters written for flood */
221char BBELL = '\a'; /* characters written for AUDIBLE */
222char DOT = '.';
223char *hostname;
224int ident; /* process id to identify our packets */
225u_int8_t nonce[8]; /* nonce field for node information */
226int hoplimit = -1; /* hoplimit */
227int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */
228u_char *packet = NULL;
229#ifdef HAVE_POLL_H
230struct pollfd fdmaskp[1];
231#else
232fd_set *fdmaskp = NULL;
233int fdmasks;
234#endif
228
229/* counters */
230long nmissedmax; /* max value of ntransmitted - nreceived - 1 */
231long npackets; /* max packets to transmit */
232long nreceived; /* # of packets we got back */
233long nrepeats; /* number of duplicates */
234long ntransmitted; /* sequence # for outbound packets = #sent */
235struct timeval interval = {1, 0}; /* interval between packets */

--- 61 unchanged lines hidden (view full) ---

297 struct timeval seed;
298#endif
299#ifdef HAVE_POLL_H
300 int timeout;
301#else
302 struct timeval timeout, *tv;
303#endif
304 struct addrinfo hints;
235
236/* counters */
237long nmissedmax; /* max value of ntransmitted - nreceived - 1 */
238long npackets; /* max packets to transmit */
239long nreceived; /* # of packets we got back */
240long nrepeats; /* number of duplicates */
241long ntransmitted; /* sequence # for outbound packets = #sent */
242struct timeval interval = {1, 0}; /* interval between packets */

--- 61 unchanged lines hidden (view full) ---

304 struct timeval seed;
305#endif
306#ifdef HAVE_POLL_H
307 int timeout;
308#else
309 struct timeval timeout, *tv;
310#endif
311 struct addrinfo hints;
305#ifdef HAVE_POLL_H
306 struct pollfd fdmaskp[1];
307#else
308 fd_set *fdmaskp;
309 int fdmasks;
310#endif
311 int cc, i;
312 int ch, hold, packlen, preload, optval, ret_ga;
312 int cc, i;
313 int ch, hold, packlen, preload, optval, ret_ga;
313 u_char *datap, *packet;
314 u_char *datap;
314 char *e, *target, *ifname = NULL, *gateway = NULL;
315 int ip6optlen = 0;
316 struct cmsghdr *scmsgp = NULL;
315 char *e, *target, *ifname = NULL, *gateway = NULL;
316 int ip6optlen = 0;
317 struct cmsghdr *scmsgp = NULL;
317 struct cmsghdr *cm;
318 /* For control (ancillary) data received from recvmsg() */
319 struct cmsghdr cm[CONTROLLEN];
318#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
319 u_long lsockbufsize;
320 int sockbufsize = 0;
321#endif
322 int usepktinfo = 0;
323 struct in6_pktinfo *pktinfo = NULL;
324#ifdef USE_RFC2292BIS
325 struct ip6_rthdr *rthdr = NULL;

--- 198 unchanged lines hidden (view full) ---

524 }
525 /*
526 * res->ai_family must be AF_INET6 and res->ai_addrlen
527 * must be sizeof(src).
528 */
529 memcpy(&src, res->ai_addr, res->ai_addrlen);
530 srclen = res->ai_addrlen;
531 freeaddrinfo(res);
320#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
321 u_long lsockbufsize;
322 int sockbufsize = 0;
323#endif
324 int usepktinfo = 0;
325 struct in6_pktinfo *pktinfo = NULL;
326#ifdef USE_RFC2292BIS
327 struct ip6_rthdr *rthdr = NULL;

--- 198 unchanged lines hidden (view full) ---

526 }
527 /*
528 * res->ai_family must be AF_INET6 and res->ai_addrlen
529 * must be sizeof(src).
530 */
531 memcpy(&src, res->ai_addr, res->ai_addrlen);
532 srclen = res->ai_addrlen;
533 freeaddrinfo(res);
534 res = NULL;
532 options |= F_SRCADDR;
533 break;
534 case 's': /* size of packet to send */
535 datalen = strtol(optarg, &e, 10);
536 if (datalen <= 0 || *optarg == '\0' || *e != '\0')
537 errx(1, "illegal datalen value -- %s", optarg);
538 if (datalen > MAXDATALEN) {
539 errx(1,

--- 536 unchanged lines hidden (view full) ---

1076 err(1, "malloc");
1077#endif
1078
1079 seenalrm = seenint = 0;
1080#ifdef SIGINFO
1081 seeninfo = 0;
1082#endif
1083
535 options |= F_SRCADDR;
536 break;
537 case 's': /* size of packet to send */
538 datalen = strtol(optarg, &e, 10);
539 if (datalen <= 0 || *optarg == '\0' || *e != '\0')
540 errx(1, "illegal datalen value -- %s", optarg);
541 if (datalen > MAXDATALEN) {
542 errx(1,

--- 536 unchanged lines hidden (view full) ---

1079 err(1, "malloc");
1080#endif
1081
1082 seenalrm = seenint = 0;
1083#ifdef SIGINFO
1084 seeninfo = 0;
1085#endif
1086
1084 /* For control (ancillary) data received from recvmsg() */
1085 cm = (struct cmsghdr *)malloc(CONTROLLEN);
1086 if (cm == NULL)
1087 err(1, "malloc");
1088
1089 for (;;) {
1090 struct msghdr m;
1091 struct iovec iov[2];
1092
1093 /* signal handling */
1094 if (seenalrm) {
1095 /* last packet sent, timeout reached? */
1096 if (npackets && ntransmitted >= npackets)

--- 97 unchanged lines hidden (view full) ---

1194 break;
1195 if (ntransmitted - nreceived - 1 > nmissedmax) {
1196 nmissedmax = ntransmitted - nreceived - 1;
1197 if (options & F_MISSED)
1198 (void)write(STDOUT_FILENO, &BBELL, 1);
1199 }
1200 }
1201 summary();
1087 for (;;) {
1088 struct msghdr m;
1089 struct iovec iov[2];
1090
1091 /* signal handling */
1092 if (seenalrm) {
1093 /* last packet sent, timeout reached? */
1094 if (npackets && ntransmitted >= npackets)

--- 97 unchanged lines hidden (view full) ---

1192 break;
1193 if (ntransmitted - nreceived - 1 > nmissedmax) {
1194 nmissedmax = ntransmitted - nreceived - 1;
1195 if (options & F_MISSED)
1196 (void)write(STDOUT_FILENO, &BBELL, 1);
1197 }
1198 }
1199 summary();
1200
1201 if (res != NULL)
1202 freeaddrinfo(res);
1203
1204 if(packet != NULL)
1205 free(packet);
1206
1207#ifndef HAVE_POLL_H
1208 if(fdmaskp != NULL)
1209 free(fdmaskp);
1210#endif
1211
1202 exit(nreceived == 0 ? 2 : 0);
1203}
1204
1205void
1206onsignal(sig)
1207 int sig;
1208{
1209

--- 1040 unchanged lines hidden (view full) ---

2250 */
2251/* ARGSUSED */
2252void
2253onint(notused)
2254 int notused;
2255{
2256 summary();
2257
1212 exit(nreceived == 0 ? 2 : 0);
1213}
1214
1215void
1216onsignal(sig)
1217 int sig;
1218{
1219

--- 1040 unchanged lines hidden (view full) ---

2260 */
2261/* ARGSUSED */
2262void
2263onint(notused)
2264 int notused;
2265{
2266 summary();
2267
2268 if (res != NULL)
2269 freeaddrinfo(res);
2270
2271 if(packet != NULL)
2272 free(packet);
2273
2274#ifndef HAVE_POLL_H
2275 if(fdmaskp != NULL)
2276 free(fdmaskp);
2277#endif
2278
2258 (void)signal(SIGINT, SIG_DFL);
2259 (void)kill(getpid(), SIGINT);
2260
2261 /* NOTREACHED */
2262 exit(1);
2263}
2264
2265/*

--- 544 unchanged lines hidden ---
2279 (void)signal(SIGINT, SIG_DFL);
2280 (void)kill(getpid(), SIGINT);
2281
2282 /* NOTREACHED */
2283 exit(1);
2284}
2285
2286/*

--- 544 unchanged lines hidden ---