diff -u --new-file --recursive traceroute-1.4a12.orig/Makefile.in traceroute-1.4a12/Makefile.in
--- traceroute-1.4a12.orig/Makefile.in	Thu Nov 23 21:05:29 2000
+++ traceroute-1.4a12/Makefile.in	Sun Mar 30 01:34:31 2003
@@ -42,7 +42,7 @@
 CC = @CC@
 CCOPT = @V_CCOPT@
 INCLS = -I. @V_INCLS@
-DEFS = @DEFS@
+DEFS = @DEFS@ -DBGP_SUPPORT
 
 # Standard CFLAGS
 CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
@@ -59,7 +59,7 @@
 	@rm -f $@
 	$(CC) $(CFLAGS) -c $(srcdir)/$*.c
 
-CSRC =	traceroute.c ifaddrlist.c @V_FINDSADDR@
+CSRC =	traceroute.c bgp.c ifaddrlist.c @V_FINDSADDR@
 GENSRC = version.c
 
 SRC =	$(CSRC) $(GENSRC)
diff -u --new-file --recursive traceroute-1.4a12.orig/bgp.c traceroute-1.4a12/bgp.c
--- traceroute-1.4a12.orig/bgp.c	Thu Jan  1 01:00:00 1970
+++ traceroute-1.4a12/bgp.c	Sun Mar 30 01:33:29 2003
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2003 Florian Weimer <fw@deneb.enyo.de>
+ *	All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this notice in
+ * its entirety, (2) distributions including binary code include the
+ * above copyright notice and this notice in its entirety in the
+ * documentation or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+
+#include <bgp.h>
+
+#define DOMAIN "ipv4.asn.beta.bgpdns.enyo.de"
+
+long
+bgp_asn_for_ipv4 (struct in_addr *address)
+{
+	int result;
+	char dname[512];
+	struct hostent *host;
+	unsigned char *p;
+
+	p = (unsigned char *)address;
+	snprintf (dname, sizeof(dname), "%d.%d.%d.%d.%s.",
+		  p[3], p[2], p[1], p[0], DOMAIN);
+
+	host = gethostbyname(dname);
+	
+	if (host == NULL) {
+		switch (h_errno) {
+		case HOST_NOT_FOUND:
+			return -2;
+		default:
+			return -1;
+		}
+	}
+	
+	/* FIXME: Shall we support multiple origin ASNs? */
+	if ((host->h_addrtype != AF_INET) 
+	    || (host->h_length != 4)
+	    || (!host->h_addr_list[0])
+	    || (host->h_addr_list[0][0] != 127)) {
+		/* host->h_addr_list[0][1] != 0 will become prefix
+		   length */
+		return -1;
+	}
+
+	/* Extract ASN. */
+	p = (unsigned char *)host->h_addr_list[0];
+	return p[2] * 256 + p[3];
+}
diff -u --new-file --recursive traceroute-1.4a12.orig/bgp.h traceroute-1.4a12/bgp.h
--- traceroute-1.4a12.orig/bgp.h	Thu Jan  1 01:00:00 1970
+++ traceroute-1.4a12/bgp.h	Sun Mar 30 01:33:29 2003
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2003 Florian Weimer <fw@deneb.enyo.de>
+ *	All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this notice in
+ * its entirety, (2) distributions including binary code include the
+ * above copyright notice and this notice in its entirety in the
+ * documentation or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef BGP_H
+#define BGP_H
+
+struct in_addr;
+
+long bgp_asn_for_ipv4 (struct in_addr *address);
+/* Returns an ASN for the given IPv4 address, or a negative value on
+   error: -1 indicates a generic error, -2 means "address not
+   routed". */
+
+#endif /* !BGP_H */
diff -u --new-file --recursive traceroute-1.4a12.orig/traceroute.c traceroute-1.4a12/traceroute.c
--- traceroute-1.4a12.orig/traceroute.c	Thu Dec 14 09:04:50 2000
+++ traceroute-1.4a12/traceroute.c	Sun Mar 30 01:33:54 2003
@@ -250,6 +250,10 @@
 #include "ifaddrlist.h"
 #include "traceroute.h"
 
+#ifdef BGP_SUPPORT
+#include "bgp.h"
+#endif /* BGP_SUPPORT */
+
 /* Maximum number of gateways (include room for one noop) */
 #define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(u_int32_t)))
 
@@ -1138,6 +1142,9 @@
 {
 	register struct ip *ip;
 	register int hlen;
+#ifdef BGP_SUPPORT
+	long asn;
+#endif /* BGP_SUPPORT */
 
 	ip = (struct ip *) buf;
 	hlen = ip->ip_hl << 2;
@@ -1145,9 +1152,30 @@
 
 	if (nflag)
 		Printf(" %s", inet_ntoa(from->sin_addr));
-	else
+	else {
+#ifdef BGP_SUPPORT
+		asn = bgp_asn_for_ipv4 (&from->sin_addr);
+		switch (asn) {
+		case -2:
+			Printf(" %s [bogon] (%s)", inetname(from->sin_addr),
+			       inet_ntoa(from->sin_addr));
+			break;
+		case -1:
+			Printf(" %s (%s)", inetname(from->sin_addr),
+			       inet_ntoa(from->sin_addr));
+			break;
+		default:
+			Printf(" %s [AS %ld] (%s)", inetname(from->sin_addr),
+			       asn,
+			       inet_ntoa(from->sin_addr));
+			break;
+		}
+
+#else /* BGP_SUPPORT */
 		Printf(" %s (%s)", inetname(from->sin_addr),
 		    inet_ntoa(from->sin_addr));
+#endif /* BGP_SUPPORT */
+	}
 
 	if (verbose)
 		Printf(" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
