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
This commit is contained in:
parent
d26d022d05
commit
854569350f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20540
@ -30,7 +30,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
||||||
.\" $Id$
|
.\" $Id: ping.8,v 1.3 1996/10/05 22:27:04 wosch Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd December 11, 1993
|
.Dd December 11, 1993
|
||||||
.Dt PING 8
|
.Dt PING 8
|
||||||
@ -42,12 +42,15 @@
|
|||||||
packets to network hosts
|
packets to network hosts
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm ping
|
.Nm ping
|
||||||
.Op Fl dfnqrvRQ
|
.Op Fl dfnqrvLRQ
|
||||||
.Op Fl c Ar count
|
.Op Fl c Ar count
|
||||||
.Op Fl i Ar wait
|
.Op Fl i Ar wait
|
||||||
|
.Op Fl I Ar interface
|
||||||
.Op Fl l Ar preload
|
.Op Fl l Ar preload
|
||||||
.Op Fl p Ar pattern
|
.Op Fl p Ar pattern
|
||||||
.Op Fl s Ar packetsize
|
.Op Fl s Ar packetsize
|
||||||
|
.Op Fl T Ar ttl
|
||||||
|
.Ar host
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Ping
|
.Nm Ping
|
||||||
uses the
|
uses the
|
||||||
@ -99,6 +102,9 @@ The default is to wait for one second between each packet.
|
|||||||
This option is incompatible with the
|
This option is incompatible with the
|
||||||
.Fl f
|
.Fl f
|
||||||
option.
|
option.
|
||||||
|
.It Fl I Ar interface
|
||||||
|
Source multicast packets with the given interface address.
|
||||||
|
This flag only applies if the ping destination is a multicast address.
|
||||||
.It Fl l Ar preload
|
.It Fl l Ar preload
|
||||||
If
|
If
|
||||||
.Ar preload
|
.Ar preload
|
||||||
@ -106,6 +112,9 @@ is specified,
|
|||||||
.Nm ping
|
.Nm ping
|
||||||
sends that many packets as fast as possible before falling into its normal
|
sends that many packets as fast as possible before falling into its normal
|
||||||
mode of behavior.
|
mode of behavior.
|
||||||
|
.It Fl L
|
||||||
|
Suppress loopback of multicast packets.
|
||||||
|
This flag only applies if the ping destination is a multicast address.
|
||||||
.It Fl n
|
.It Fl n
|
||||||
Numeric output only.
|
Numeric output only.
|
||||||
No attempt will be made to lookup symbolic names for host addresses.
|
No attempt will be made to lookup symbolic names for host addresses.
|
||||||
@ -159,6 +168,9 @@ data bytes when combined
|
|||||||
with the 8 bytes of
|
with the 8 bytes of
|
||||||
.Tn ICMP
|
.Tn ICMP
|
||||||
header data.
|
header data.
|
||||||
|
.It Fl T Ar ttl
|
||||||
|
Set the IP Time To Live for multicasted packets.
|
||||||
|
This flag only applies if the ping destination is a multicast address.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Verbose output.
|
Verbose output.
|
||||||
.Tn ICMP
|
.Tn ICMP
|
||||||
@ -216,11 +228,15 @@ given.
|
|||||||
.Sh DUPLICATE AND DAMAGED PACKETS
|
.Sh DUPLICATE AND DAMAGED PACKETS
|
||||||
.Nm Ping
|
.Nm Ping
|
||||||
will report duplicate and damaged packets.
|
will report duplicate and damaged packets.
|
||||||
Duplicate packets should never occur, and seem to be caused by
|
Duplicate packets should never occur when pinging a unicast address,
|
||||||
|
and seem to be caused by
|
||||||
inappropriate link-level retransmissions.
|
inappropriate link-level retransmissions.
|
||||||
Duplicates may occur in many situations and are rarely (if ever) a
|
Duplicates may occur in many situations and are rarely (if ever) a
|
||||||
good sign, although the presence of low levels of duplicates may not
|
good sign, although the presence of low levels of duplicates may not
|
||||||
always be cause for alarm.
|
always be cause for alarm.
|
||||||
|
Duplicates are expected when pinging a broadcast or multicast address,
|
||||||
|
since they are not really duplicates but replies from different hosts
|
||||||
|
to the same request.
|
||||||
.Pp
|
.Pp
|
||||||
Damaged packets are obviously serious cause for alarm and often
|
Damaged packets are obviously serious cause for alarm and often
|
||||||
indicate broken hardware somewhere in the
|
indicate broken hardware somewhere in the
|
||||||
|
@ -96,16 +96,19 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
|
|||||||
|
|
||||||
/* various options */
|
/* various options */
|
||||||
int options;
|
int options;
|
||||||
#define F_FLOOD 0x001
|
#define F_FLOOD 0x0001
|
||||||
#define F_INTERVAL 0x002
|
#define F_INTERVAL 0x0002
|
||||||
#define F_NUMERIC 0x004
|
#define F_NUMERIC 0x0004
|
||||||
#define F_PINGFILLED 0x008
|
#define F_PINGFILLED 0x0008
|
||||||
#define F_QUIET 0x010
|
#define F_QUIET 0x0010
|
||||||
#define F_RROUTE 0x020
|
#define F_RROUTE 0x0020
|
||||||
#define F_SO_DEBUG 0x040
|
#define F_SO_DEBUG 0x0040
|
||||||
#define F_SO_DONTROUTE 0x080
|
#define F_SO_DONTROUTE 0x0080
|
||||||
#define F_VERBOSE 0x100
|
#define F_VERBOSE 0x0100
|
||||||
#define F_QUIET2 0x200
|
#define F_QUIET2 0x0200
|
||||||
|
#define F_NOLOOP 0x0400
|
||||||
|
#define F_MTTL 0x0800
|
||||||
|
#define F_MIF 0x1000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
|
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
|
||||||
@ -157,6 +160,8 @@ main(argc, argv)
|
|||||||
struct termios ts;
|
struct termios ts;
|
||||||
register int i;
|
register int i;
|
||||||
int ch, fdmask, hold, packlen, preload, sockerrno;
|
int ch, fdmask, hold, packlen, preload, sockerrno;
|
||||||
|
struct in_addr ifaddr;
|
||||||
|
unsigned char ttl, loop;
|
||||||
u_char *datap, *packet;
|
u_char *datap, *packet;
|
||||||
char *target, hnamebuf[MAXHOSTNAMELEN], *malloc();
|
char *target, hnamebuf[MAXHOSTNAMELEN], *malloc();
|
||||||
#ifdef IP_OPTIONS
|
#ifdef IP_OPTIONS
|
||||||
@ -180,7 +185,7 @@ main(argc, argv)
|
|||||||
preload = 0;
|
preload = 0;
|
||||||
|
|
||||||
datap = &outpack[8 + sizeof(struct timeval)];
|
datap = &outpack[8 + sizeof(struct timeval)];
|
||||||
while ((ch = getopt(argc, argv, "QRc:dfh:i:l:np:qrs:v")) != EOF)
|
while ((ch = getopt(argc, argv, "I:LQRT:c:dfh:i:l:np:qrs:v")) != EOF)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'c':
|
case 'c':
|
||||||
npackets = atoi(optarg);
|
npackets = atoi(optarg);
|
||||||
@ -211,6 +216,14 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
options |= F_INTERVAL;
|
options |= F_INTERVAL;
|
||||||
break;
|
break;
|
||||||
|
case 'I': /* multicast interface */
|
||||||
|
if (inet_aton(optarg, &ifaddr) == 0) {
|
||||||
|
(void)fprintf(stderr,
|
||||||
|
"ping: bad multicast interface.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
options |= F_MIF;
|
||||||
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
preload = atoi(optarg);
|
preload = atoi(optarg);
|
||||||
if (preload < 0) {
|
if (preload < 0) {
|
||||||
@ -219,6 +232,10 @@ main(argc, argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
options |= F_NOLOOP;
|
||||||
|
loop = 0;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
options |= F_NUMERIC;
|
options |= F_NUMERIC;
|
||||||
break;
|
break;
|
||||||
@ -251,6 +268,16 @@ main(argc, argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'T': /* multicast TTL */
|
||||||
|
i = atoi(optarg);
|
||||||
|
if (i < 0 || i > 255) {
|
||||||
|
(void)fprintf(stderr,
|
||||||
|
"ping: illegal multicast TTL.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
ttl = i;
|
||||||
|
options |= F_MTTL;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
options |= F_VERBOSE;
|
options |= F_VERBOSE;
|
||||||
break;
|
break;
|
||||||
@ -337,6 +364,28 @@ main(argc, argv)
|
|||||||
#endif /* IP_OPTIONS */
|
#endif /* IP_OPTIONS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options & F_NOLOOP) {
|
||||||
|
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop,
|
||||||
|
sizeof(loop)) < 0) {
|
||||||
|
perror("ping: IP_MULTICAST_LOOP");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options & F_MTTL) {
|
||||||
|
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
|
||||||
|
sizeof(ttl)) < 0) {
|
||||||
|
perror("ping: IP_MULTICAST_TTL");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options & F_MIF) {
|
||||||
|
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &ifaddr,
|
||||||
|
sizeof(ifaddr)) < 0) {
|
||||||
|
perror("ping: IP_MULTICAST_IF");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When pinging the broadcast address, you can get a lot of answers.
|
* When pinging the broadcast address, you can get a lot of answers.
|
||||||
* Doing something so evil is useful if you are trying to stress the
|
* Doing something so evil is useful if you are trying to stress the
|
||||||
@ -1085,6 +1134,6 @@ fill(bp, patp)
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"usage: ping [-Rdfnqrv] [-c count] [-i wait] [-l preload]\n\t[-p pattern] [-s packetsize] host\n");
|
"usage: ping [-LQRdfnqrv] [-c count] [-i wait] [-I interface]\n\t[-l preload] [-p pattern] [-s packetsize] [-T ttl] host\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user