Deleted Added
full compact
ping.c (103229) ping.c (104339)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Muuss.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
46#endif
47static const char rcsid[] =
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Muuss.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
46#endif
47static const char rcsid[] =
48 "$FreeBSD: head/sbin/ping/ping.c 103229 2002-09-11 18:16:40Z peter $";
48 "$FreeBSD: head/sbin/ping/ping.c 104339 2002-10-02 03:24:27Z dd $";
49#endif /* not lint */
50
51/*
52 * P I N G . C
53 *
54 * Using the Internet Control Message Protocol (ICMP) "ECHO" facility,
55 * measure round-trip-delays and packet loss across network paths.
56 *

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

132#define F_AUDIBLE 0x2000
133#ifdef IPSEC
134#ifdef IPSEC_POLICY_IPSEC
135#define F_POLICY 0x4000
136#endif /*IPSEC_POLICY_IPSEC*/
137#endif /*IPSEC*/
138#define F_TTL 0x8000
139#define F_MISSED 0x10000
49#endif /* not lint */
50
51/*
52 * P I N G . C
53 *
54 * Using the Internet Control Message Protocol (ICMP) "ECHO" facility,
55 * measure round-trip-delays and packet loss across network paths.
56 *

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

132#define F_AUDIBLE 0x2000
133#ifdef IPSEC
134#ifdef IPSEC_POLICY_IPSEC
135#define F_POLICY 0x4000
136#endif /*IPSEC_POLICY_IPSEC*/
137#endif /*IPSEC*/
138#define F_TTL 0x8000
139#define F_MISSED 0x10000
140#define F_ONCE 0x20000
140
141/*
142 * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
143 * number of received sequence numbers we can keep track of. Change 128
144 * to 8192 for complete accuracy...
145 */
146#define MAX_DUP_CHK (8 * 128)
147int mx_dup_ck = MAX_DUP_CHK;

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

237
238 setuid(getuid());
239 uid = getuid();
240
241 alarmtimeout = preload = 0;
242
243 datap = &outpack[MINICMPLEN + PHDR_LEN];
244 while ((ch = getopt(argc, argv,
141
142/*
143 * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
144 * number of received sequence numbers we can keep track of. Change 128
145 * to 8192 for complete accuracy...
146 */
147#define MAX_DUP_CHK (8 * 128)
148int mx_dup_ck = MAX_DUP_CHK;

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

238
239 setuid(getuid());
240 uid = getuid();
241
242 alarmtimeout = preload = 0;
243
244 datap = &outpack[MINICMPLEN + PHDR_LEN];
245 while ((ch = getopt(argc, argv,
245 "AI:LQRS:T:c:adfi:l:m:np:qrs:t:v"
246 "AI:LQRS:T:c:adfi:l:m:nop:qrs:t:v"
246#ifdef IPSEC
247#ifdef IPSEC_POLICY_IPSEC
248 "P:"
249#endif /*IPSEC_POLICY_IPSEC*/
250#endif /*IPSEC*/
251 )) != -1)
252 {
253 switch(ch) {

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

315 if (*ep || ep == optarg || ultmp > 255)
316 errx(EX_USAGE, "invalid TTL: `%s'", optarg);
317 ttl = ultmp;
318 options |= F_TTL;
319 break;
320 case 'n':
321 options |= F_NUMERIC;
322 break;
247#ifdef IPSEC
248#ifdef IPSEC_POLICY_IPSEC
249 "P:"
250#endif /*IPSEC_POLICY_IPSEC*/
251#endif /*IPSEC*/
252 )) != -1)
253 {
254 switch(ch) {

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

316 if (*ep || ep == optarg || ultmp > 255)
317 errx(EX_USAGE, "invalid TTL: `%s'", optarg);
318 ttl = ultmp;
319 options |= F_TTL;
320 break;
321 case 'n':
322 options |= F_NUMERIC;
323 break;
324 case 'o':
325 options |= F_ONCE;
326 break;
323 case 'p': /* fill buffer with user pattern */
324 options |= F_PINGFILLED;
325 fill((char *)datap, optarg);
326 break;
327 case 'Q':
328 options |= F_QUIET2;
329 break;
330 case 'q':

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

691 t = &now;
692 }
693#endif
694 if (t == NULL) {
695 (void)gettimeofday(&now, NULL);
696 t = &now;
697 }
698 pr_pack((char *)packet, cc, &from, t);
327 case 'p': /* fill buffer with user pattern */
328 options |= F_PINGFILLED;
329 fill((char *)datap, optarg);
330 break;
331 case 'Q':
332 options |= F_QUIET2;
333 break;
334 case 'q':

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

695 t = &now;
696 }
697#endif
698 if (t == NULL) {
699 (void)gettimeofday(&now, NULL);
700 t = &now;
701 }
702 pr_pack((char *)packet, cc, &from, t);
699 if (npackets && nreceived >= npackets)
703 if (options & F_ONCE && nreceived ||
704 npackets && nreceived >= npackets)
700 break;
701 }
702 if (n == 0 || options & F_FLOOD) {
703 if (!npackets || ntransmitted < npackets)
704 pinger();
705 else {
706 if (almost_done)
707 break;

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

1436 (void)printf("\n");
1437 }
1438}
1439
1440static void
1441usage()
1442{
1443 (void)fprintf(stderr, "%s\n%s\n%s\n",
705 break;
706 }
707 if (n == 0 || options & F_FLOOD) {
708 if (!npackets || ntransmitted < npackets)
709 pinger();
710 else {
711 if (almost_done)
712 break;

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

1441 (void)printf("\n");
1442 }
1443}
1444
1445static void
1446usage()
1447{
1448 (void)fprintf(stderr, "%s\n%s\n%s\n",
1444"usage: ping [-AQRadfnqrv] [-c count] [-i wait] [-l preload] [-m ttl]",
1449"usage: ping [-AQRadfnoqrv] [-c count] [-i wait] [-l preload] [-m ttl]",
1445" [-p pattern] "
1446#ifdef IPSEC
1447#ifdef IPSEC_POLICY_IPSEC
1448"[-P policy] "
1449#endif
1450#endif
1451"[-s packetsize] [-S src_addr] [-t timeout]",
1452" [host | [-L] [-I iface] [-T ttl] mcast-group]");
1453 exit(EX_USAGE);
1454}
1450" [-p pattern] "
1451#ifdef IPSEC
1452#ifdef IPSEC_POLICY_IPSEC
1453"[-P policy] "
1454#endif
1455#endif
1456"[-s packetsize] [-S src_addr] [-t timeout]",
1457" [host | [-L] [-I iface] [-T ttl] mcast-group]");
1458 exit(EX_USAGE);
1459}