#include "display.h"
#include "net.h"
#include "dns.h"
+#include "asn.h"
+#include <glib.h>
#endif
#include <time.h>
mpls = net_mpls(at);
if( addrcmp( (void *) addr, (void *) &unspec_addr, af ) != 0 ) {
+ struct in6_addr addr6 = *addr;
+
+ if (PrintAS) {
+ u_char ipv4[4];
+ ipv4[0] = addr6.s6_addr[0];
+ ipv4[1] = addr6.s6_addr[1];
+ ipv4[2] = addr6.s6_addr[2];
+ ipv4[3] = addr6.s6_addr[3];
+
+#define NAMELEN 127
+ char ipv4_buf[NAMELEN];
+ char* chip = (char*) &ipv4_buf;
+ char* chas = NULL;
+ char** key_ptr = &chip;
+ char** value_ptr = &chas;
+
+
+ if (snprintf(ipv4_buf, NAMELEN, "%d.%d.%d.%d.asn.routeviews.org", ipv4[3],
+ ipv4[2], ipv4[1], ipv4[0]) >= NAMELEN) {
+ return;
+ }
+
+
+
+ gboolean result =
+ g_hash_table_lookup_extended
+ (ashash, ipv4_buf, (gpointer*)key_ptr, (gpointer*)value_ptr);
+ if (!result) {
+ char* as = asn_lookup(ipv4_buf);
+ chip = (char*) strdup(ipv4_buf);
+ chas = (char*) as;
+ g_hash_table_insert(ashash, chip, chas);
+ }
+ //g_hash_table_destroy(hash);
+
+
+ printw("[AS%s] ", chas);
+ }
name = dns_lookup(addr);
if (! net_up(at))
attron(A_BOLD);
void mtr_curses_open(void)
{
+ ashash = g_hash_table_new(g_str_hash, g_str_equal);
initscr();
raw();
noecho();
#include "dns.h"
#include "report.h"
#include "net.h"
+#include "asn.h"
#ifdef ENABLE_IPV6
{ "udp", 0, 0, 'u' }, /* UDP (default is ICMP) */
{ "inet", 0, 0, '4' }, /* IPv4 only */
{ "inet6", 0, 0, '6' }, /* IPv6 only */
+ { "aslookup", 0, 0, 'z' }, /* Do AS lookup */
{ 0, 0, 0, 0 }
};
fprintf( stderr, "IPv6 not enabled.\n" );
break;
#endif
+ case 'z':
+ PrintAS = 1;
+ break;
}
}
printf("usage: %s [-hvrwctglspniu46] [--help] [--version] [--report]\n"
"\t\t[--report-wide] [--report-cycles=COUNT] [--curses] [--gtk]\n"
"\t\t[--raw] [--split] [--mpls] [--no-dns] [--show-ips]\n"
- "\t\t[--address interface]\n" /* BL */
+ "\t\t[--address interface] [--aslookup]\n" /* BL */
"\t\t[--psize=bytes/-s bytes]\n" /* ok */
"\t\t[--report-wide|-w] [-u]\n" /* rew */
"\t\t[--interval=SECONDS] HOSTNAME [PACKETSIZE]\n", argv[0]);