diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-05 00:07:48 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-05 00:07:48 +0000 |
commit | f529a50ff509043b679016239a6d36d74d4439f8 (patch) | |
tree | 5af0fdc33bddb11afdfde2d5b1b0ff5f40a38760 /sbin | |
parent | ced24f7c04f3e5bb34349704e4ecd4462f551956 (diff) |
Allow ping to use an alternate routing domain by using the -V flag.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ping/ping.8 | 7 | ||||
-rw-r--r-- | sbin/ping/ping.c | 21 |
2 files changed, 22 insertions, 6 deletions
diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index e79bac81a87..76977f9cfcf 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ping.8,v 1.38 2009/06/01 14:16:02 jmc Exp $ +.\" $OpenBSD: ping.8,v 1.39 2009/06/05 00:07:47 claudio Exp $ .\" $NetBSD: ping.8,v 1.10 1995/12/31 04:55:35 ghudson Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)ping.8 8.2 (Berkeley) 12/11/93 .\" -.Dd $Mdocdate: June 1 2009 $ +.Dd $Mdocdate: June 5 2009 $ .Dt PING 8 .Os .Sh NAME @@ -49,6 +49,7 @@ .Op Fl T Ar tos .Op Fl t Ar ttl .Op Fl w Ar maxwait +.Op Fl V Ar rdomain .Ar host .Ek .Sh DESCRIPTION @@ -189,6 +190,8 @@ header data are included in Use the specified type of service. .It Fl t Ar ttl Use the specified time-to-live. +.It Fl V Ar rdomain +Set the routing domain, the default is 0. .It Fl v Verbose output. ICMP packets other than diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 0b496db8257..6525d6be9eb 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.81 2009/06/01 14:16:02 jmc Exp $ */ +/* $OpenBSD: ping.c,v 1.82 2009/06/05 00:07:47 claudio Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: ping.c,v 1.81 2009/06/01 14:16:02 jmc Exp $"; +static const char rcsid[] = "$OpenBSD: ping.c,v 1.82 2009/06/05 00:07:47 claudio Exp $"; #endif #endif /* not lint */ @@ -202,6 +202,7 @@ main(int argc, char *argv[]) fd_set *fdmaskp; size_t fdmasks; uid_t uid; + u_int rdomain; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(1, "socket"); @@ -214,7 +215,7 @@ main(int argc, char *argv[]) preload = 0; datap = &outpack[8 + sizeof(struct tvi)]; while ((ch = getopt(argc, argv, - "DEI:LRS:c:defi:jl:np:qrs:T:t:vw:")) != -1) + "DEI:LRS:c:defi:jl:np:qrs:T:t:V:vw:")) != -1) switch(ch) { case 'c': npackets = (unsigned long)strtonum(optarg, 1, INT_MAX, &errstr); @@ -317,11 +318,23 @@ main(int argc, char *argv[]) if (errstr) errx(1, "ttl value is %s: %s", errstr, optarg); break; + case 'V': + rdomain = (unsigned int)strtonum(optarg, 0, + RT_TABLEID_MAX, &errstr); + if (errstr) + errx(1, "rdomain value is %s: %s", + errstr, optarg); + + if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain, + sizeof(rdomain)) == -1) + err(1, "setsockopt SO_RDOMAIN"); + break; case 'v': options |= F_VERBOSE; break; case 'w': - maxwait = (unsigned int)strtonum(optarg, 1, INT_MAX, &errstr); + maxwait = (unsigned int)strtonum(optarg, 1, INT_MAX, + &errstr); if (errstr) errx(1, "maxwait value is %s: %s", errstr, optarg); |