-.\" $OpenBSD: ping6.8,v 1.51 2015/10/13 16:26:54 florian Exp $
+.\" $OpenBSD: ping6.8,v 1.52 2015/10/14 17:26:01 florian Exp $
.\" $KAME: ping6.8,v 1.57 2002/05/26 13:18:25 itojun Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: October 13 2015 $
+.Dd $Mdocdate: October 14 2015 $
.Dt PING6 8
.Os
.Sh NAME
.Op Fl c Ar count
.Op Fl g Ar gateway
.Op Fl h Ar hoplimit
-.Op Fl I Ar interface
+.Op Fl I Ar sourceaddr
.Op Fl i Ar wait
.Op Fl l Ar preload
.Op Fl p Ar pattern
-.Op Fl S Ar sourceaddr
.Op Fl s Ar packetsize
.Op Fl V Ar rtable
.Ar host
command does not try reverse-lookup unless the option is specified.
.It Fl h Ar hoplimit
Set the IPv6 hoplimit.
-.It Fl I Ar interface
-Source packets with the given interface address.
-This flag applies if the ping destination is a multicast address,
-or link-local/site-local unicast address.
+.It Fl I Ar sourceaddr
+Specifies the source address of request packets.
+The source address must be one of the unicast addresses of the sending node,
+and must be numeric.
.It Fl i Ar wait
Wait
.Ar wait
.\".Ar host
.\".Pq or the first hop
.\"is a neighbor.
-.It Fl S Ar sourceaddr
-Specifies the source address of request packets.
-The source address must be one of the unicast addresses of the sending node,
-and must be numeric.
.It Fl s Ar packetsize
Specifies the number of data bytes to be sent.
The default is 56, which translates into 64
-/* $OpenBSD: ping6.c,v 1.122 2015/10/13 16:26:54 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.123 2015/10/14 17:26:01 florian Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
#define F_VERBOSE 0x0100
#define F_NODEADDR 0x0800
#define F_FQDN 0x1000
-#define F_INTERFACE 0x2000
#define F_SRCADDR 0x4000
#define F_HOSTNAME 0x10000
#define F_NIGROUP 0x40000
int ch, i, maxsize, packlen, preload, optval, error;
socklen_t maxsizelen;
u_char *datap, *packet;
- char *e, *target, *ifname = NULL, *gateway = NULL;
+ char *e, *target, *gateway = NULL;
const char *errstr;
int ip6optlen = 0;
struct cmsghdr *scmsgp = NULL;
- int usepktinfo = 0;
struct in6_pktinfo *pktinfo = NULL;
double intval;
int mflag = 0;
errx(1, "hoplimit is %s: %s", errstr, optarg);
break;
case 'I':
- ifname = optarg;
- options |= F_INTERFACE;
- usepktinfo++;
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_flags = AI_NUMERICHOST; /* allow hostname? */
+ hints.ai_family = AF_INET6;
+ hints.ai_socktype = SOCK_RAW;
+ hints.ai_protocol = IPPROTO_ICMPV6;
+
+ error = getaddrinfo(optarg, NULL, &hints, &res0);
+ if (error)
+ errx(1, "invalid source address: %s",
+ gai_strerror(error));
+
+ if (res0->ai_family != AF_INET6 || res0->ai_addrlen !=
+ sizeof(src))
+ errx(1, "invalid source address");
+ memcpy(&src, res0->ai_addr, sizeof(src));
+ freeaddrinfo(res0);
+ options |= F_SRCADDR;
break;
case 'i': /* wait between sending packets */
intval = strtod(optarg, &e);
case 'q':
options |= F_QUIET;
break;
- case 'S':
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_flags = AI_NUMERICHOST; /* allow hostname? */
- hints.ai_family = AF_INET6;
- hints.ai_socktype = SOCK_RAW;
- hints.ai_protocol = IPPROTO_ICMPV6;
-
- error = getaddrinfo(optarg, NULL, &hints, &res0);
- if (error)
- errx(1, "invalid source address: %s",
- gai_strerror(error));
-
- if (res0->ai_family != AF_INET6 || res0->ai_addrlen !=
- sizeof(src))
- errx(1, "invalid source address");
- memcpy(&src, res0->ai_addr, sizeof(src));
- freeaddrinfo(res0);
- options |= F_SRCADDR;
- break;
case 's': /* size of packet to send */
datalen = strtonum(optarg, 1, MAXDATALEN, &errstr);
if (errstr)
err(1, "setsockopt(IPV6_RECVRTHDR)");
}
- /* Specify the outgoing interface and/or the source address */
- if (usepktinfo)
- ip6optlen += CMSG_SPACE(sizeof(struct in6_pktinfo));
-
if (hoplimit != -1)
ip6optlen += CMSG_SPACE(sizeof(int));
smsghdr.msg_controllen = ip6optlen;
scmsgp = (struct cmsghdr *)scmsg;
}
- if (usepktinfo) {
- pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp));
- memset(pktinfo, 0, sizeof(*pktinfo));
- scmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
- scmsgp->cmsg_level = IPPROTO_IPV6;
- scmsgp->cmsg_type = IPV6_PKTINFO;
- scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp);
- }
- /* set the outgoing interface */
- if (ifname) {
- /* pktinfo must have already been allocated */
- if ((pktinfo->ipi6_ifindex = if_nametoindex(ifname)) == 0)
- errx(1, "%s: invalid interface name", ifname);
- }
if (hoplimit != -1) {
scmsgp->cmsg_len = CMSG_LEN(sizeof(int));
scmsgp->cmsg_level = IPPROTO_IPV6;
"m"
"Nnqtvw"
"] [-a addrtype] [-c count] [-g gateway]\n\t"
- "[-h hoplimit] [-I interface] [-i wait] [-l preload] [-p pattern]"
- "\n\t[-S sourceaddr] [-s packetsize] [-V rtable] host\n");
+ "[-h hoplimit] [-I sourceaddr] [-i wait] [-l preload] [-p pattern]"
+ "\n\t[-s packetsize] [-V rtable] host\n");
exit(1);
}