summaryrefslogtreecommitdiffstats
path: root/usr.sbin/traceroute6/traceroute6.c
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2009-08-23 17:00:16 +0000
committerume <ume@FreeBSD.org>2009-08-23 17:00:16 +0000
commite9fb7bf28d0712b4366f9f39010c865c03853ac6 (patch)
treeed9630d75b8bf64e28c5ab5abefdd3666898f3d8 /usr.sbin/traceroute6/traceroute6.c
parent5868b7c961bb6a513bde2e133aaeae679b9cb648 (diff)
downloadFreeBSD-src-e9fb7bf28d0712b4366f9f39010c865c03853ac6.zip
FreeBSD-src-e9fb7bf28d0712b4366f9f39010c865c03853ac6.tar.gz
- Add AS lookup functionality to traceroute6(8) as well.
- Support for IPv6 transport for AS lookup. - Introduce $RA_SERVER to set whois server. - Support for 4 byte ASN. - ANSIfy function declaration in as.c. Tested by: IHANet folks.
Diffstat (limited to 'usr.sbin/traceroute6/traceroute6.c')
-rw-r--r--usr.sbin/traceroute6/traceroute6.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index d06502f..699af68 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -282,6 +282,8 @@ static const char rcsid[] =
#include <netipsec/ipsec.h>
#endif
+#include "as.h"
+
#define DUMMY_PORT 10010
#define MAXPACKET 65535 /* max ip packet size */
@@ -359,6 +361,9 @@ int waittime = 5; /* time to wait for response (in seconds) */
int nflag; /* print addresses numerically */
int useproto = IPPROTO_UDP; /* protocol to use to send packet */
int lflag; /* print both numerical address & hostname */
+int as_path; /* print as numbers for each hop */
+char *as_server = NULL;
+void *asn;
int
main(argc, argv)
@@ -411,8 +416,15 @@ main(argc, argv)
seq = 0;
- while ((ch = getopt(argc, argv, "df:g:Ilm:nNp:q:rs:Uvw:")) != -1)
+ while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:Uvw:")) != -1)
switch (ch) {
+ case 'a':
+ as_path = 1;
+ break;
+ case 'A':
+ as_path = 1;
+ as_server = optarg;
+ break;
case 'd':
options |= SO_DEBUG;
break;
@@ -867,6 +879,17 @@ main(argc, argv)
srcport = ntohs(Src.sin6_port);
}
+ if (as_path) {
+ asn = as_setup(as_server);
+ if (asn == NULL) {
+ fprintf(stderr,
+ "traceroute6: as_setup failed, AS# lookups"
+ " disabled\n");
+ (void)fflush(stderr);
+ as_path = 0;
+ }
+ }
+
/*
* Message to users
*/
@@ -948,6 +971,8 @@ main(argc, argv)
exit(0);
}
}
+ if (as_path)
+ as_shutdown(asn);
exit(0);
}
@@ -1361,6 +1386,8 @@ print(mhdr, cc)
if (getnameinfo((struct sockaddr *)from, from->sin6_len,
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)
strlcpy(hbuf, "invalid", sizeof(hbuf));
+ if (as_path)
+ printf(" [AS%u]", as_lookup(asn, hbuf, AF_INET6));
if (nflag)
printf(" %s", hbuf);
else if (lflag)
OpenPOWER on IntegriCloud