summaryrefslogtreecommitdiff
path: root/sbin/ping/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ping/ping.c')
-rw-r--r--sbin/ping/ping.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 5dfbb02eef7..cde44350a5a 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.230 2018/10/14 19:47:53 kn Exp $ */
+/* $OpenBSD: ping.c,v 1.231 2018/11/10 05:03:23 dlg Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -150,7 +150,7 @@ int options;
/* 0x0200 */
#define F_HDRINCL 0x0400
#define F_TTL 0x0800
-/* 0x1000 */
+#define F_TOS 0x1000
#define F_AUD_RECV 0x2000
#define F_AUD_MISS 0x4000
@@ -291,7 +291,7 @@ main(int argc, char *argv[])
preload = 0;
datap = &outpack[ECHOLEN + ECHOTMLEN];
while ((ch = getopt(argc, argv, v6flag ?
- "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" :
+ "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" :
"DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) {
switch(ch) {
case 'c':
@@ -386,6 +386,7 @@ main(int argc, char *argv[])
#ifndef SMALL
case 'T':
options |= F_HDRINCL;
+ options |= F_TOS;
errno = 0;
errstr = NULL;
if (map_tos(optarg, &tos))
@@ -673,6 +674,13 @@ main(int argc, char *argv[])
*(int *)(CMSG_DATA(scmsg)) = hoplimit;
}
+ if (options & F_TOS) {
+ optval = tos;
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &optval,
+ (socklen_t)sizeof(optval)) < 0)
+ warn("setsockopt(IPV6_TVAL)"); /* XXX err? */
+ }
+
optval = 1;
if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &optval,
(socklen_t)sizeof(optval)) < 0)
@@ -2160,7 +2168,8 @@ usage(void)
fprintf(stderr,
"usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] "
"[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] "
- "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n");
+ "[-s packetsize] [-T toskeyword]\n\t"
+ "[-V rtable] [-w maxwait] host\n");
} else {
fprintf(stderr,
"usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]"