summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2011-04-06 12:05:01 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2011-04-06 12:05:01 +0000
commitf434fcb18676651f6f0f1f799d864d88a884a381 (patch)
treec14dcb7273efbb6c1e00dec47ddfe73ff267d4c5 /usr.sbin
parent5e4fb44a4336d98c236fd72d004742b54c2dac92 (diff)
When specifying tos with -t, display a message if the returned packet
has a different tos type. ok claudio@ phessler@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/traceroute/traceroute.88
-rw-r--r--usr.sbin/traceroute/traceroute.c19
2 files changed, 22 insertions, 5 deletions
diff --git a/usr.sbin/traceroute/traceroute.8 b/usr.sbin/traceroute/traceroute.8
index d699c7543d8..685d7272765 100644
--- a/usr.sbin/traceroute/traceroute.8
+++ b/usr.sbin/traceroute/traceroute.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: traceroute.8,v 1.44 2010/07/08 20:23:03 claudio Exp $
+.\" $OpenBSD: traceroute.8,v 1.45 2011/04/06 12:05:00 sthen Exp $
.\" $NetBSD: traceroute.8,v 1.6 1995/10/12 03:05:50 mycroft Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
@@ -33,7 +33,7 @@
.\"
.\" @(#)traceroute.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: July 8 2010 $
+.Dd $Mdocdate: April 6 2011 $
.Dt TRACEROUTE 8
.Os
.Sh NAME
@@ -177,6 +177,8 @@ in probe packets to the following value (default zero).
The value must be a decimal integer in the range 0 to 255.
This option can be used to
see if different types-of-service result in different paths.
+If this option is used, changes to the type-of-service in the
+returned packets are displayed.
(If you are not running a
.Bx 4.3 tahoe
or later system, this may be academic since the normal network
@@ -384,6 +386,8 @@ ever occur and the associated gateway is busted if you see one),
(destination network or host unreachable for TOS),
.Sy !<code>
(other ICMP unreachable code).
+.Sy TOS=xxx!
+(TOS bit in returned packet differs from last hop).
If almost all the probes result in some kind of unreachable,
.Nm
will give up and exit.
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index 8a3eb6d640c..71b8404b77f 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.74 2011/03/22 10:16:23 okan Exp $ */
+/* $OpenBSD: traceroute.c,v 1.75 2011/04/06 12:05:00 sthen Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
@@ -293,11 +293,13 @@ main(int argc, char *argv[])
int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL };
int ttl_flag = 0, incflag = 1, protoset = 0, sump = 0;
int ch, i, lsrr = 0, on = 1, probe, seq = 0, tos = 0;
+ int last_tos, tos_returned;
size_t size = sizeof(max_ttl);
struct sockaddr_in from, to;
struct hostent *hp;
u_int32_t tmprnd;
- struct ip *ip;
+ struct ip *ip, *inner_ip;
+ struct icmp *icp;
u_int8_t ttl;
char *ep;
const char *errstr;
@@ -427,7 +429,7 @@ main(int argc, char *argv[])
l = strtol(optarg, &ep, 10);
if (errno || !*optarg || *ep || l < 0 || l > 255)
errx(1, "tos must be 0 to 255.");
- tos = (int)l;
+ last_tos = tos = (int)l;
break;
case 'v':
verbose++;
@@ -636,6 +638,17 @@ main(int argc, char *argv[])
++got_there;
break;
}
+
+ icp = (struct icmp *) (((u_char *)ip)+(ip->ip_hl<<2));
+ inner_ip = (struct ip *) (((u_char *)icp)+8);
+
+ tos_returned = inner_ip->ip_tos;
+
+ if (tos_returned != last_tos)
+ printf (" (TOS=%d!)", tos_returned);
+
+ last_tos = tos_returned;
+
/* time exceeded in transit */
if (i == -1)
break;