summaryrefslogtreecommitdiffstats
path: root/sbin/ping/ping.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix LSRR option length check: it has to be less or equal remained header'smaxim2002-10-211-1/+2
| | | | | | length minus sizeof(struct ip). MFC after: 1 week
* Add an -o option to exit after receiving one reply. This can be useddd2002-10-021-3/+8
| | | | | | | | to test whether a link is live. PR: 38573 Submitted by: David Taylor <davidt@yadt.co.uk> Obtained from: NetBSD
* Commit "unrelated style fixes" part of Bruce's patch (regardingpeter2002-09-111-5/+5
| | | | | | bcopy/memcpy) seperately. Submitted by: bde
* Modify previous commit to solve the real problem that made gcc thinkpeter2002-09-111-5/+5
| | | | | | | the timestamp was aligned. ie: Use a void * instead of struct timeval * which gcc assumes will be aligned. Go back to memcpy(). Submitted by: bde
* In reference to previous commit: use err(3).nectar2002-09-091-4/+2
| | | | Noticed by: bde
* Check for FD_SET overrun.nectar2002-09-091-0/+4
|
* Add the -A flag to the usage line.iedowse2002-08-271-1/+1
| | | | | Submitted by: Yutaka KAWASE <yutaka@mailhost.net> MFC after: 3 days
* Fix the broken "avoid unaligned data" fix. The problem is that the builtinpeter2002-08-101-2/+2
| | | | | | | | | | | | | | | | | | gcc memcpy "knows" about types that are supposed to be actually already aligned and triggers alignment errors doing the memcpy itself. "Fix" this by changing it to a bcopy(). In this case, we had: struct timeval *tp; struct timeval tv1; memcpy(&tv1,tp,sizeof(tv1)); .. and since gcc *knows* that a pointer to a timeval is longword aligned and that tv1 is longword aligned, then it can use an inline that assumes alignment. The following works too: cp = (char *)tp; memcpy(&tv1,cp,sizeof(tv1)); Simply casting (char *)tp for the memcpy doesn't work. :-( This affected different 64 bit platforms in different ways and depends a lot on gcc as well. I've seen this on alpha and ia64 at least, although alpha isn't doing it right now.
* o Change almost all magic numbers to the appropriate constants.maxim2002-07-051-28/+32
| | | | | | | | | o Fix zero payloading, unbreak ping -s 0. o Increase socket recieve buffer, ping -s 65467 is working now. Submitted by: anti-magic sweep based on kris's patch Reviewed by: bde, silence on -audit MFC after: 2 months
* More strict ip options parsing.maxim2002-07-051-53/+44
| | | | | Reviewed by: bde (style), silence on -audit MFC after: 2 months
* WARNS fixes.maxim2002-04-021-3/+3
| | | | | | | Submitted by: kris Reviewed by: bde Approved by: ru MFC after: 2 weeks
* style(9) cleanup.maxim2002-04-021-57/+53
| | | | | | | Submitted by: kris (an early version of this patch) Reviewed by: bde Approved by: ru MFC after: 2 weeks
* Style(9) local vars after 'register' removal.obrien2002-03-231-33/+41
| | | | Requested by: bde
* Remove 'register' keyword.obrien2002-03-201-13/+13
| | | | | | It does not help modern compilers, and some may take some hit from it. (I also found several functions that listed *every* of its 10 local vars with "register" -- just how many free registers do people think machines have?)
* Use network byte order for the ICMP sequence number. This is onlyfenner2002-02-271-6/+8
| | | | | significant when monitoring packets on another system, since otherwise the ICMP sequence number is only used by the ping client.
* Fixed two bugs with the "-l preload" option:ru2002-01-141-5/+9
| | | | | | | - first ping after a preload was sent undelayed - we could send more than -c packets in preload PR: bin/32354
* The -A option (beep when packets are dropped) didn't work quiteiedowse2001-09-251-2/+6
| | | | | | | | | | | | | 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
* Ian Dowse writes:mjacob2001-07-071-16/+7
| | | | | | | | | | | 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
* Fix unaligned access faults on alpha.mjacob2001-07-071-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Modify ping so that it increases the send socket buffer size if therwatson2001-06-301-0/+5
| | | | | | | | | 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
* Add a -A option to ping which beeps when packets are lost.phk2001-05-241-2/+10
| | | | | PR: 11818 Submitted by: Marc Evans marc@destek.net
* Add new option -m which allows the user to set IP TTL.ru2001-03-091-12/+28
|
* Format string paranoiakris2000-11-191-2/+2
|
* Use CMSG_LEN() to compute ping SCM_TIMESTAMP cmsg_len.shin2000-03-141-1/+1
| | | | | Without this, cmsg_len size should be smaller than necessary on alpha. (Though, no obvious error was seen on ping time value on beast.)
* CMSG_XXX macros alignment fixes to follow RFC2292.shin2000-03-031-1/+1
| | | | | | | Approved by: jkh Submitted by: Partly from tech@openbsd Reviewed by: itojun
* ping -S option was missing from IPsec merge, so enable it again.shin2000-02-081-2/+2
| | | | | | Approved by: jkh Submitted by: Matthew Reimer <mreimer@vpop.net>
* Brucify:billf2000-01-201-8/+15
| | | | | | | | | 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
* Add '-t X' which times out after pinging for X seconds.billf2000-01-141-4/+15
| | | | Submitted by: adrian
* libipsec and IPsec related apps. (and some KAME related man pages)shin2000-01-061-3/+68
| | | | | Reviewed by: freebsd-arch, cvs-committers Obtained from: KAME project
* Make last commit bde-compliant:pb1999-11-181-8/+9
| | | | | | - correct indentation - change data types for consistency with the rest of ping.c - create new variable separate from "answer" for clarity
* Fix aliasing bug causing in_cksum() to fail on odd packet sizespb1999-11-151-5/+9
| | | | | | | due to compiler optimization. PR: bin/13292 Suggested by: wollman
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Make flood ping flood again. It hasn't worked since 2.2.6. Make the "-l"mckay1999-05-071-4/+6
| | | | | | option work as described in the manual, not as another flood ping variant. Once discussed to death with: bde
* More egcs warning fixes:imp1999-04-251-2/+3
| | | | | | | | | | | 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
* Allow PINGing from any address on multihomed hostsimp1999-01-061-11/+44
| | | | | | | | | 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
* Remove -c restrictions from previous commit.des1998-08-261-13/+1
|
* (well tested at BEST): -i option can now take FP values (e.g. -i 0.1),dillon1998-08-261-11/+38
| | | | | | | 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.
* Correct use of .Nm. Remove unused #includes. Use warn(). cosmetic in usage()charnier1998-07-151-20/+13
| | | | | string. Translate 0 sec 1000000 usec to 1 sec 0 usec.
* Fix an alignment problem on alpha by doing a bytewise copy.jb1998-06-061-3/+6
|
* Use select() timeouts instead of SIGALRM to schedule packet transmission.fenner1998-05-251-81/+104
| | | | | | | | | | 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
* Revert the previous fix. As it turns out Warner Losh issteve1998-05-251-21/+9
| | | | working a better fix.
* Attempt to stop another DoS attack related to ping flooding.steve1998-05-251-9/+21
| | | | | PR: 6649 Submitted by: Jason Young <doogie@forbidden-donut.anet-stl.com>
* When a timeval is stored at the beginning of icmp_data, the fieldsjb1998-05-161-14/+27
| | | | | | | | | | | 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.
* If ping write fails with short packet count, thephk1998-04-151-2/+2
| | | | | | | error message prints the two numbers backwards. PR: 6313 Reviewed by: phk Submitted by: Archie Cobbs
* Add aback in a line a accidentally killed in my last commit.imp1998-04-021-1/+2
| | | | Submitted by: Bill Fenner
* Make this compile (and seemingly work).eivind1998-04-021-2/+2
|
* A fairly rare possible buffer overflow:imp1998-04-011-4/+13
| | | | | Theo fixed this and tqbf reported it Obtained from: OpenBSD
* Minor style nit noticed by bde.imp1997-12-241-2/+2
|
* Add an ntohs() and format an IP address with inet_ntoa() whenfenner1997-08-111-3/+3
| | | | | | | printing the details of a received ICMP packet. PR: bin/3766 Submitted by: denny1@home.com (Denton Gentry)
* don't lose track of how many packets we've sentjulian1997-08-071-3/+3
| | | | | | 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..
OpenPOWER on IntegriCloud