Commit Graph

188 Commits

Author SHA1 Message Date
Maxim Konovalov
605af08d9f Document ping(8) reaction to SIGINFO.
PR:		doc/33639
Reviewed by:	ru
Approved by:	ru
MFC after:	1 week
2002-02-07 16:47:22 +00:00
Ruslan Ermilov
32af342f58 Fixed two bugs with the "-l preload" option:
- first ping after a preload was sent undelayed
- we could send more than -c packets in preload

PR:		bin/32354
2002-01-14 14:33:35 +00:00
David E. O'Brien
2d68bf45bf Default to WARNS=2.
Binary builds that cannot handle this must explicitly set WARNS=0.

Reviewed by:	mike
2001-12-04 02:19:58 +00:00
Ian Dowse
2510719736 The -A option (beep when packets are dropped) didn't work quite
right; after a single packet was dropped it beeped after every
transmission.

Change its implementation to only output a bell when there is an
increase in the maximum value of the number of packets that were
sent but not yet received. This has the benefit that even for very
long round-trip times, ping -A will do roughly the right thing
after a few inital false-positives.

Reviewed by:	ru
2001-09-25 20:22:33 +00:00
Ruslan Ermilov
cda2a9b2f0 Set BINOWN=root explicitly for setuid root binaries.
This is not "useless", as one may have non-default
setting for BINOWN in make.conf, and we still want
these to be installed setuid root in this case.
2001-09-13 06:48:18 +00:00
Dima Dorfman
f328d583a2 Use CFLAGS, not COPTS, in the Makefile. bsd.prog.mk conveniently adds
COPTS towards the end of final CFLAGS so that it can be used to
override Makefile and other defaults.  Using it in Makefiles risks
having options set using it clobbered when somebody uses it on the
command line.

Approved by:	bde
2001-09-05 20:10:59 +00:00
Ruslan Ermilov
c4d9468ea0 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
9fe48c6e8d mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 11:04:34 +00:00
Matt Jacob
d389e86a04 Ian Dowse writes:
The original code was certainly broken; it knows that whereto is
	to be used for a sockaddr_in, so it should be declared as such.
	To support multiple protocols, there is also a sockaddr_storage
	struct that can be used; I don't think struct sockaddr is supposed
	to be used anywhere other than for casts and pointers.

Submitted by:	Ian Dowse <iedowse@maths.tcd.ie>
MFC after:	3 weeks
2001-07-07 19:09:21 +00:00
Matt Jacob
c77eed5304 Fix unaligned access faults on alpha.
This one is strange and goes against my rusty compiler knowledge.

The global declaration

struct sockaddr whereto;

produces for both i386 && alpha:

        .comm   whereto,16,1

which means common storage, byte aligned. Ahem. I though structs
were supposed to be ALDOUBLE always? I mean, w/o pragma packed?

Later on, this address is coerced to:

		to = (struct sockaddr_in *)&whereto;

Up until now, we've been fine on alpha because the address
just ended up aligned to a 4 byte boundary. Lately, though,
it end up as:

0000000120027b0f B whereto

And, tra la, you get unaligned access faults. The solution I picked, in
lieu of understanding what the compiler was doing, is to put whereto
as a union of a sockaddr and sockaddr_in. That's more formally correct
if somewhat awkward looking.
2001-07-07 05:01:06 +00:00
Robert Watson
e8bd25cef9 Modify ping so that it increases the send socket buffer size if the
user runs with privilege, allowing the sending of icmp packets with
larger size (up to 48k, the default receive buffer size in ping),
which is useful for network driver development testing, as well
as experimentation with fragmentation.

Reviewed by:	wpaul
2001-06-30 06:46:33 +00:00
Poul-Henning Kamp
ca517ad854 Add a -A option to ping which beeps when packets are lost.
PR:		11818
Submitted by:	Marc Evans marc@destek.net
2001-05-24 09:17:52 +00:00
Ruslan Ermilov
0a5779d45b - Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.
2001-03-26 14:33:27 +00:00
Ruslan Ermilov
fe655281c5 Set the default manual section for sbin/ to 8. 2001-03-20 18:13:31 +00:00
Ruslan Ermilov
211bfbd228 Add new option -m which allows the user to set IP TTL. 2001-03-09 13:20:23 +00:00
Ruslan Ermilov
1252c1bb05 Prepare for mdoc(7)NG. 2000-12-18 15:16:24 +00:00
Ruslan Ermilov
7c7fb079b9 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 16:52:27 +00:00
Kris Kennaway
ffd4007070 Format string paranoia 2000-11-19 13:30:36 +00:00
Yoshinobu Inoue
6ecbec7768 Use CMSG_LEN() to compute ping SCM_TIMESTAMP cmsg_len.
Without this, cmsg_len size should be smaller than necessary on alpha.
(Though, no obvious error was seen on ping time value on beast.)
2000-03-14 17:37:19 +00:00
Yoshinobu Inoue
7d0d8dc306 CMSG_XXX macros alignment fixes to follow RFC2292.
Approved by: jkh

Submitted by: Partly from tech@openbsd
Reviewed by: itojun
2000-03-03 11:13:12 +00:00
Sheldon Hearn
ef8f7ac935 Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-01 11:27:47 +00:00
Yoshinobu Inoue
e870738008 ping -S option was missing from IPsec merge, so enable it again.
Approved by: jkh

Submitted by: Matthew Reimer <mreimer@vpop.net>
2000-02-08 05:07:50 +00:00
Bill Fumerola
bf113f1b05 Brucify:
add an upper limit to -t
	match the types of return values and the variables they are stuffed in
	make the man page and usage() a little more consistantly ugly
	less obfuscation.

Submitted by:	adrian, billf
2000-01-20 20:48:51 +00:00
Bill Fumerola
7237fd9478 Add '-t X' which times out after pinging for X seconds.
Submitted by:	adrian
2000-01-14 23:40:38 +00:00
Mike Smith
3285f64159 Don't try to include ipsec support if we are building for the install
floppy image.
2000-01-07 19:06:54 +00:00
Yoshinobu Inoue
9a4365d0e0 libipsec and IPsec related apps. (and some KAME related man pages)
Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
2000-01-06 12:40:54 +00:00
Pierre Beyssac
09333e7833 Make last commit bde-compliant:
- correct indentation
	- change data types for consistency with the rest of ping.c
	- create new variable separate from "answer" for clarity
1999-11-18 10:20:45 +00:00
Pierre Beyssac
3ec12efecc Fix aliasing bug causing in_cksum() to fail on odd packet sizes
due to compiler optimization.

PR:		bin/13292
Suggested by:	wollman
1999-11-15 20:04:53 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Chris Costello
d6636ad7b3 Re-add -Wmissing-prototypes to `COPTS'. I mistook -W for -Wno in this case. 1999-08-16 21:22:39 +00:00
Chris Costello
55cb3cb6be -Wmissing-prototypes is unnecessary here. There are no warnings produced
with this option disabled.
1999-08-16 08:13:17 +00:00
Stephen McKay
5e2cc0f4b0 Make flood ping flood again. It hasn't worked since 2.2.6. Make the "-l"
option work as described in the manual, not as another flood ping variant.

Once discussed to death with: bde
1999-05-07 14:38:48 +00:00
Warner Losh
ebe70c8f68 More egcs warning fixes:
o main returns int not void
	o use braces to avoid potentially ambiguous else

Note: The fix to natd is potentially functional in nature since I used
the indentation as the right thing rather than the struct semantics.
Someone more familiar with the code should double check me on this one.

Reviewed by: obrien and chuckr
1999-04-25 22:33:30 +00:00
Warner Losh
2faab3cddd Finish documenting -S src-addr change.
Forgotten by: me
Forgotten for: Far Too Long
Gently Reminded by: Ruslan Ermilov <ru@ucb.crimea.ua>
Submitted by: Ruslan Ermilov <ru@ucb.crimea.ua>
1999-02-19 07:40:59 +00:00
Warner Losh
99490ede3a Allow PINGing from any address on multihomed hosts
In the words of the submitter:
"The patch below allows to ping from any address on the multihomed host.
 The man page is also updated, the text was cutted from traceroute(8)."

Submitted by: Ruslan Ermilov
PR: 6832
1999-01-06 07:54:28 +00:00
Bruce Evans
0ed77db893 Fixed non-use of .Nm and hard line breaks in rev.1.16-1.17: 1998-11-29 13:20:04 +00:00
David E. O'Brien
be0cde6f10 Remove useless `BINOWN=root' now that it is the default. 1998-09-19 22:42:06 +00:00
Doug Rabson
69beb1913e Disable gcc's builtin memcpy for alpha since it doesn't cope with unaligned
regions properly and this triggers an unaligned access trap.
1998-09-05 15:11:47 +00:00
Matthew Dillon
0b0c1554a8 Updated manual page. Removed description of (now defunct) -c restrictions. 1998-08-27 16:34:38 +00:00
Dag-Erling Smørgrav
ce6f26dde3 Remove -c restrictions from previous commit. 1998-08-26 18:51:37 +00:00
Matthew Dillon
526f06b278 (well tested at BEST): -i option can now take FP values (e.g. -i 0.1),
extremely useful for networking testing.  Other options secured from
    user-level D.O.S. attacks.  -f, -s now root-only.  -i wait times < 1.0
    root-only.  -c count limited to 100 and defaults to 16 when ping run
    by non-root user.
1998-08-26 01:58:39 +00:00
Philippe Charnier
e345a80d5d Correct use of .Nm. Remove unused #includes. Use warn(). cosmetic in usage()
string.
Translate 0 sec 1000000 usec to 1 sec 0 usec.
1998-07-15 06:45:02 +00:00
John Birrell
fa05a94c42 Fix an alignment problem on alpha by doing a bytewise copy. 1998-06-06 23:33:28 +00:00
Bill Fenner
039d6aa45a Use select() timeouts instead of SIGALRM to schedule packet transmission.
Fixes bin/6649 and removes the last abusive signal handler.
Use SO_TIMESTAMP to get the kernel to timestamp packets on reception.
 Fixes bin/5658 and provides slightly better accuracy.
Explicitly zero and terminate the IP options when using -R.

PR:		bin/5658
PR:		bin/6649
1998-05-25 20:16:05 +00:00
Steve Price
dd033c223d Revert the previous fix. As it turns out Warner Losh is
working a better fix.
1998-05-25 06:53:17 +00:00
Steve Price
a39f52db0f Attempt to stop another DoS attack related to ping flooding.
PR:		6649
Submitted by:	Jason Young <doogie@forbidden-donut.anet-stl.com>
1998-05-25 03:50:51 +00:00
John Birrell
d32ff0376f When a timeval is stored at the beginning of icmp_data, the fields
are unaligned for access by the alpha, so copy the value to a variable
that is aligned.

When checking the returned data, be careful to avoid confusing the
size of the icmp header with the size of a timeval. On i386 these
are both 8, but on alpha, a timeval is 16 bytes. This means that
a packet sent from an alpha contains 48 bytes of data, not 56 like
on i386.
1998-05-16 00:19:27 +00:00
Poul-Henning Kamp
416aa49b70 If ping write fails with short packet count, the
error message prints the two numbers backwards.
PR:		6313
Reviewed by:	phk
Submitted by:	Archie Cobbs
1998-04-15 19:55:14 +00:00
Warner Losh
47b630b949 Add aback in a line a accidentally killed in my last commit.
Submitted by:	Bill Fenner
1998-04-02 04:33:18 +00:00
Eivind Eklund
3aa4b74433 Make this compile (and seemingly work). 1998-04-02 01:12:55 +00:00
Warner Losh
c03e877a88 A fairly rare possible buffer overflow:
Theo fixed this and tqbf reported it
Obtained from: OpenBSD
1998-04-01 00:32:18 +00:00
Philippe Charnier
68085a0ef1 .Sh AUTHOR -> .Sh AUTHORS. Use .An/.Aq. 1998-03-19 07:46:04 +00:00
Warner Losh
b10d9d5f10 Minor style nit noticed by bde. 1997-12-24 00:59:02 +00:00
Bruce Evans
e3d099c303 Fixed DPADD. 1997-12-16 15:03:14 +00:00
Bill Fenner
ff49597ed1 Add an ntohs() and format an IP address with inet_ntoa() when
printing the details of a received ICMP packet.

PR:		bin/3766
Submitted by:	denny1@home.com (Denton Gentry)
1997-08-11 04:33:07 +00:00
Julian Elischer
363d7bbe50 don't lose track of how many packets we've sent
if we get 'host unreachable'. (or any other errors than ENOBUFS)
makes -c work again even if you can't get there..
This really needs a rework..
1997-08-07 02:41:15 +00:00
Bruce Evans
8f975bb321 Cleaned up revisions 1.22 and 1.23.
Fixed minor bugs in revisions 1.12 and 1.23 (variables assigned to in signal
handlers weren't declared as volatile).
1997-07-20 06:09:55 +00:00
Garrett Wollman
3109a91002 Calculate and print out the standard deviation of the round trip times.
This isn't necessarily the best statistic, but it is by far the easiest to
calculate.  Update the man page to be more explicit about precisely which
statistics are printed out.  Revert some of jmg's bogus man page changes from
rev 1.11.
1997-07-18 17:52:05 +00:00
Sean Eric Fagan
a2a0088805 Fix a problem introduced with a recent change that caused a hang with
unreachable hosts.  Note that most of this consists of telling SIGINT
and SIGALRM to interrupt the system call, instead of restarting them.
Also try to get rid of some potential races Bruce didn't like; hopefully
they aren't a problem (potential or otherwise) now.

Reviewed by:	julian
1997-07-13 06:16:44 +00:00
Julian Elischer
0e59c641dc don't count packets as being transmitted when we know that the sendto()
failed (e.g. ENOBUFS)
1997-07-09 20:33:58 +00:00
Julian Elischer
515dd2fa3f ping called printf() from a signal handler..
this is a NO-NO

re-arange to just set a "please die immediatly" flag in the signal handler
and handle this in the normal thread.

also handle ping -f better on slow links by backing off a bit when
we get a ENOBUFFS from the sendto().
1997-07-09 19:40:43 +00:00
Warner Losh
624ff93821 Fix typo introduced in 1.17.
Submitted by:	"Philippe Charnier" <charnier@xp11.frmug.org>
1997-03-04 22:05:49 +00:00
Warner Losh
1ffae4a6dd Check the size of the IP address reutrned from gethostbyname2, per PR
2578 from Julian A.  Likely not strictly needed, but it doesn't hurt
and protects ping against possible buffer overflows if the resolver
were to return large IP addresses.
1997-03-03 09:50:21 +00:00
John-Mark Gurney
50ceac8822 fix man page to use marcos instead of parens, quotes and braces
plus other minor fixes
1997-03-02 23:38:05 +00:00
Warner Losh
ee2bf73496 1) Minor nits in the usage message from bde. I took out the hard tabs and
used spaces to align the second line under the program name.
2) Cache uid after call to setuid(getuid()) so we don't waste a system call
   for each packet with a call to getuid for the -v case.
3) Update manual to reflect new restriction on -l from last delta.

Suggested by:	bde, Bill Fenner
1997-03-02 20:01:13 +00:00
Warner Losh
f78ac61b3a 1) Fix usage to match convention and manual. Fix manual to match usage.
2) Must be root to run preload (OpenBSD ping.c 1.8)
3) Don't print all replies unless verbose and root (from idea in
   OpenBSD ping.c 1.10 and 1.11) to avoid leaking information available
   only to root.
4) Remove unused h: from option string to getopt.
5) Make the compiler happy with exit(0) (Lite-2?)

Reviewed by: Dan Cross <tenser@spitfire.ecsel.psu.edu>

Good candidate for 2.2 and 2.1 (as are many of the 1.17 changes).
1997-03-02 06:32:42 +00:00
Garrett Wollman
43470e3be8 Make ping -Wall clean (except for one warning).
Do a better job of argument parsing.
Don't permit ping -f to a multicast address (very antisocial).
Don't permit -L, -I, -T options with unicast addresses.
Ensure that we ask for only AF_INET addresses (should close PR#2584).
Return <sysexits.h> error codes for failures.  Document this.
Fix man page to identify the author and put sections in correct order.
1997-03-01 20:19:18 +00:00
Peter Wemm
c0ec1f37ef Revert $FreeBSD$ to $Id$ 1997-02-22 14:40:44 +00:00
Daniel O'Callaghan
772dfa7231 Reviewed by: Gary Jennejohn <gj@freebsd.org>
Submitted by:	Bruce Murphy <packrat@iinet.net.au>

Add '-a' audible flag, so terminal will beep upon receipt of a reply
packet.  Useful for debugging ethernet runs, among other things.
1997-02-08 01:43:56 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bill Fenner
854569350f Add multicast options -I (source interface), -T (set ttl), -L (no loopback).
They were all lowercase in the original, but our ping already uses -i and
-l so I made them all uppercase.

Obtained from:	Multicast release 3.5
1996-12-15 23:41:29 +00:00
Bruce Evans
7d81b35c91 Cleaned up recent SIGINFO changes.
Simplified average calculations.  This also fixes potential overflow errors
and minor rounding inconsistencies (always round to nearest now).

Don't lose more SIGINFOs than necessary.

Print \r at the start of the status message.  This clears the dots that
are sometimes left by ping -f.

Reviewed by:	sef
1996-12-10 14:41:22 +00:00
Paul Traina
f6bd468bf0 Fix typo in last patch. empty!=emtpy 1996-12-08 06:27:09 +00:00
Sean Eric Fagan
37e5b2c618 Change how SIGINFO is handled -- set a flag (of sig_atomic_t), and check
that flag on every iteration of the loop.  This avoids calling fprintf
inside a signal handler, which is always somewhat icky.

Reviewed by:	bde
1996-12-07 20:20:41 +00:00
Bill Fenner
0b71f5af34 Fix math in SIGINFO printer. 1996-12-02 21:42:11 +00:00
Sean Eric Fagan
4055611a53 Move the terminal handling code to a later location; this allows
the signal handlers to be set up; it also means that a failed name lookup
won't mess up the nokerninfo setting of the tty.

Reviewed by:	pst, nate
1996-11-19 03:32:32 +00:00
Bruce Evans
2ceaae21e9 Fixed backgrounding of ping, which was broken by the ^T changes in rev.1.3. 1996-11-04 17:25:03 +00:00
Wolfram Schneider
e83201b43a delete doubled words, e.g.: "the the" -> "the" 1996-10-05 22:27:30 +00:00
Bill Fenner
ef9e6dc7ee Print out ICMP errors that are responses to our own packets by default.
Turn this behavior off using '-Q'.  This makes '-v' useless other than as
an ICMP-sniffer, which tcpdump is better at anyway.

Print out another couple of ICMP messages, and fix the printing of the
original packet (mostly byte order problems).
1996-08-20 23:50:16 +00:00
Bill Fenner
f1284d7a51 Drop setuid ASAP, to minimize code executed as root.
Reviewed by:	pst
1996-08-09 06:00:53 +00:00
Peter Wemm
efa3853949 Limit the risk of `buf' overrun in ping.c when printing hostnames.
Note, this is not really a security risk, because the buffer in question
is a static variable in the data segment and not on the stack, and hence
cannot subert the flow of execution in any way.  About the worst case was
that if you pinged a long hostname, ping could coredump.

Pointed out on: bugtraq  (listserv@netspace.org)
1996-07-28 20:29:10 +00:00
Rodney W. Grimes
5ebc7e6281 Remove trailing whitespace. 1995-05-30 06:12:45 +00:00
David Greenman
6e1173dc29 In past releases of FreeBSD, I have used the exit status of "ping" to
determine whether a connection to a given machine is up or not.

In FreeBSD 2.0 (and therefore, I assume, BSD 4.4) the exit code of ping
is always zero, even if no packets were received.

I would like to propose the following change to /usr/src/sbin/ping/ping.c
to restore this useful behaviour:

Submitted by:	Denis Fortin
1994-11-29 16:09:56 +00:00
Sean Eric Fagan
badd813805 Reviewed by: jkh
Print out summary information on receipt of SIGINFO; also, stop the
kernel printing of information and restore it on exit.  Now, it needs
an option to be quiet. ;)
1994-10-22 17:30:35 +00:00
David Greenman
d410b6f150 Changed output formatting to accurately represent the precision. 1994-08-05 10:34:19 +00:00
Garrett Wollman
404c1a5fc1 Convert to our man installation style. Also fixed long-standing bug
in `fastboot'/`fasthalt' in which the interpreter would hang around
after `reboot' or `halt' is run, causing an irritating ``Killed'' message.
1994-08-05 02:42:42 +00:00
Rodney W. Grimes
8fae3551ec BSD 4.4 Lite sbin Sources
Note:  XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.
1994-05-26 06:35:07 +00:00