diff options
author | ru <ru@FreeBSD.org> | 2003-02-23 01:50:07 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2003-02-23 01:50:07 +0000 |
commit | 8a2a9091301e63f3908b341bcc984162e59a845d (patch) | |
tree | f358c6eb2249574e755e6d64c4b7ce42f92a6fb8 /sbin/ping | |
parent | 5ecd4995a53ef83a3ed6cc0e466632e66719f8c0 (diff) | |
download | FreeBSD-src-8a2a9091301e63f3908b341bcc984162e59a845d.zip FreeBSD-src-8a2a9091301e63f3908b341bcc984162e59a845d.tar.gz |
Sort options.
Diffstat (limited to 'sbin/ping')
-rw-r--r-- | sbin/ping/ping.8 | 80 | ||||
-rw-r--r-- | sbin/ping/ping.c | 80 |
2 files changed, 83 insertions, 77 deletions
diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index 5efdcdf..eae6b1e 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -42,24 +42,22 @@ packets to network hosts .Sh SYNOPSIS .Nm -.Op Fl ADQRadfMnoqrv +.Op Fl AaDdfMnoQqRrv .Op Fl c Ar count .Op Fl i Ar wait .Op Fl l Ar preload .Op Fl m Ar ttl -.Op Fl p Ar pattern .Op Fl P Ar policy -.Op Fl s Ar packetsize +.Op Fl p Ar pattern .Op Fl S Ar src_addr +.Op Fl s Ar packetsize .Op Fl t Ar timeout .Op Fl z Ar tos -.Bo .Ar host | .Op Fl L .Op Fl I Ar interface .Op Fl T Ar ttl .Ar mcast-group -.Bc .Sh DESCRIPTION The .Nm @@ -79,7 +77,8 @@ header, followed by a .Dq struct timeval and then an arbitrary number of .Dq pad -bytes used to fill out the packet. The options are as follows: +bytes used to fill out the packet. +The options are as follows: .Bl -tag -width indent .It Fl A Audible. @@ -108,12 +107,12 @@ packets. If this option is not specified, .Nm will operate until interrupted. +.It Fl D +Set the Don't Fragment bit. .It Fl d Set the .Dv SO_DEBUG option on the socket being used. -.It Fl D -Set the Don't Fragment bit. .It Fl f Flood ping. Outputs packets as fast as they come back or one hundred times per second, @@ -130,6 +129,9 @@ Only the super-user may use this option. .Bf -emphasis This can be very hard on a network and should be used with caution. .Ef +.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 i Ar wait Wait .Ar wait @@ -141,8 +143,8 @@ values less than 1 second. This option is incompatible with the .Fl f option. -.It Fl I Ar interface -Source multicast packets with the given interface address. +.It Fl L +Suppress loopback of multicast packets. This flag only applies if the ping destination is a multicast address. .It Fl l Ar preload If @@ -152,24 +154,33 @@ is specified, sends that many packets as fast as possible before falling into its normal mode of behavior. Only the super-user may use this option. -.It Fl L -Suppress loopback of multicast packets. -This flag only applies if the ping destination is a multicast address. +.It Fl M +Use +.Dv ICMP_MASKREQ +instead of +.Dv ICMP_ECHO . +Print the netmask of the remote machine. +Set the +.Va net.inet.icmp.maskrepl +MIB variable to enable +.Dv ICMP_MASKREPLY . .It Fl m Ar ttl Set the IP Time To Live for outgoing packets. If not specified, the kernel uses the value of the .Va net.inet.ip.ttl MIB variable. -.It Fl M -Use ICMP_MASKREQ instead of ICMP_ECHO. Print the netmask of the remote -machine. Set the -.Va net.inet.icmp.maskrepl -MIB variable to enable ICMP_MASKREPLY. .It Fl n Numeric output only. No attempt will be made to lookup symbolic names for host addresses. .It Fl o Exit successfully after receiving one reply packet. +.It Fl P Ar policy +.Ar policy +specifies IPsec policy for the ping session. +For details please refer to +.Xr ipsec 4 +and +.Xr ipsec_set_policy 3 . .It Fl p Ar pattern You may specify up to 16 .Dq pad @@ -179,13 +190,6 @@ For example, .Dq Li \-p ff will cause the sent packet to be filled with all ones. -.It Fl P Ar policy -.Ar policy -specifies IPsec policy for the ping session. -For details please refer to -.Xr ipsec 4 -and -.Xr ipsec_set_policy 3 . .It Fl Q Somewhat quiet output. .No Don Ap t @@ -194,8 +198,9 @@ Originally, the .Fl v flag was required to display such errors, but .Fl v -displays all ICMP error messages. On a busy machine, this output can -be overbearing. Without the +displays all ICMP error messages. +On a busy machine, this output can be overbearing. +Without the .Fl Q flag, .Nm @@ -232,6 +237,14 @@ This option can be used to ping a local host through an interface that has no route through it (e.g., after the interface was dropped by .Xr routed 8 ) . +.It Fl S Ar src_addr +Use the following IP address as the source address in outgoing packets. +On hosts with more than one IP address, this option can be used to +force the source address to be something other than the IP address +of the interface the probe packet is sent on. +If the IP address +is not one of this machine's interface addresses, an error is +returned and nothing is sent. .It Fl s Ar packetsize Specify the number of data bytes to be sent. The default is 56, which translates into 64 @@ -241,19 +254,12 @@ with the 8 bytes of .Tn ICMP header data. Only the super-user may specify values more than default. -.It Fl S Ar src_addr -Use the following IP address as the source address in outgoing packets. -On hosts with more than one IP address, this option can be used to -force the source address to be something other than the IP address -of the interface the probe packet is sent on. If the IP address -is not one of this machine's interface addresses, an error is -returned and nothing is sent. -.It Fl t Ar timeout -Specify a timeout, in seconds, before ping exits regardless of how -many packets have been received. .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 t Ar timeout +Specify a timeout, in seconds, before ping exits regardless of how +many packets have been received. .It Fl v Verbose output. .Tn ICMP diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index a1f2450..593ab20 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -250,7 +250,7 @@ main(argc, argv) outpack = outpackhdr + sizeof(struct ip); while ((ch = getopt(argc, argv, - "ADI:LQRS:T:c:adfi:l:m:Mnop:qrs:t:vz:" + "Aac:DdfI:i:Ll:Mm:nop:QqRrS:s:T:t:vz:" #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC "P:" @@ -288,6 +288,13 @@ main(argc, argv) options |= F_FLOOD; setbuf(stdout, (char *)NULL); break; + case 'I': /* multicast interface */ + if (inet_aton(optarg, &ifaddr) == 0) + errx(EX_USAGE, + "invalid multicast interface: `%s'", + optarg); + options |= F_MIF; + break; case 'i': /* wait between sending packets */ t = strtod(optarg, &ep) * 1000.0; if (*ep || ep == optarg || t > (double)INT_MAX) @@ -300,12 +307,9 @@ main(argc, argv) err(EX_NOPERM, "-i interval too short"); } break; - case 'I': /* multicast interface */ - if (inet_aton(optarg, &ifaddr) == 0) - errx(EX_USAGE, - "invalid multicast interface: `%s'", - optarg); - options |= F_MIF; + case 'L': + options |= F_NOLOOP; + loop = 0; break; case 'l': ultmp = strtoul(optarg, &ep, 0); @@ -318,9 +322,8 @@ main(argc, argv) } preload = ultmp; break; - case 'L': - options |= F_NOLOOP; - loop = 0; + case 'M': + options |= F_MASK; break; case 'm': /* TTL */ ultmp = strtoul(optarg, &ep, 0); @@ -329,15 +332,25 @@ main(argc, argv) ttl = ultmp; options |= F_TTL; break; - case 'M': - options |= F_MASK; - break; case 'n': options |= F_NUMERIC; break; case 'o': options |= F_ONCE; break; +#ifdef IPSEC +#ifdef IPSEC_POLICY_IPSEC + case 'P': + options |= F_POLICY; + if (!strncmp("in", optarg, 2)) + policy_in = strdup(optarg); + else if (!strncmp("out", optarg, 3)) + policy_out = strdup(optarg); + else + errx(1, "invalid security policy"); + break; +#endif /*IPSEC_POLICY_IPSEC*/ +#endif /*IPSEC*/ case 'p': /* fill buffer with user pattern */ options |= F_PINGFILLED; payload = optarg; @@ -354,6 +367,9 @@ main(argc, argv) case 'r': options |= F_SO_DONTROUTE; break; + case 'S': + source = optarg; + break; case 's': /* size of packet to send */ ultmp = strtoul(optarg, &ep, 0); if (*ep || ep == optarg) @@ -367,8 +383,13 @@ main(argc, argv) } datalen = ultmp; break; - case 'S': - source = optarg; + case 'T': /* multicast TTL */ + ultmp = strtoul(optarg, &ep, 0); + if (*ep || ep == optarg || ultmp > MAXTTL) + errx(EX_USAGE, "invalid multicast TTL: `%s'", + optarg); + mttl = ultmp; + options |= F_MTTL; break; case 't': alarmtimeout = strtoul(optarg, &ep, 0); @@ -380,28 +401,9 @@ main(argc, argv) optarg, MAXALARM); alarm((int)alarmtimeout); break; - case 'T': /* multicast TTL */ - ultmp = strtoul(optarg, &ep, 0); - if (*ep || ep == optarg || ultmp > MAXTTL) - errx(EX_USAGE, "invalid multicast TTL: `%s'", - optarg); - mttl = ultmp; - options |= F_MTTL; - break; case 'v': options |= F_VERBOSE; break; -#ifdef IPSEC -#ifdef IPSEC_POLICY_IPSEC - case 'P': - options |= F_POLICY; - if (!strncmp("in", optarg, 2)) - policy_in = strdup(optarg); - else if (!strncmp("out", optarg, 3)) - policy_out = strdup(optarg); - else - errx(1, "invalid security policy"); - break; case 'z': options |= F_HDRINCL; ultmp = strtoul(optarg, &ep, 0); @@ -409,8 +411,6 @@ main(argc, argv) errx(EX_USAGE, "invalid TOS: `%s'", optarg); tos = ultmp; break; -#endif /*IPSEC_POLICY_IPSEC*/ -#endif /*IPSEC*/ default: usage(); } @@ -1515,14 +1515,14 @@ static void usage() { (void)fprintf(stderr, "%s\n%s\n%s\n", -"usage: ping [-ADQRadfnoqrv] [-c count] [-i wait] [-l preload] [-m ttl]", -" [-p pattern] " +"usage: ping [-AaDdfMnoQqRrv] [-c count] [-i wait] [-l preload] [-m ttl]", +" " #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC "[-P policy] " #endif #endif -"[-s packetsize] [-S src_addr] [-t timeout]", -" [-z tos ] [host | [-L] [-I iface] [-T ttl] mcast-group]"); +"[-p pattern] [-S src_addr] [-s packetsize] [-t timeout]", +" [-z tos ] host | [-L] [-I iface] [-T ttl] mcast-group"); exit(EX_USAGE); } |