From 2854f228a7b9aacbb7873b5ba0d474f959ad9605 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Sun, 7 Jul 2013 04:25:45 +0200 Subject: traceroute improvements * don't group traceroute nodes by address * put src ip in traceroute glouglou packet * correctly link nodes in gg_map --- gg_map/gg_map.c | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'gg_map/gg_map.c') diff --git a/gg_map/gg_map.c b/gg_map/gg_map.c index 515554d..3fbc329 100644 --- a/gg_map/gg_map.c +++ b/gg_map/gg_map.c @@ -261,35 +261,48 @@ _conn_name(u_int32_t addr, u_int8_t pktsize, u_char *fqdn) { egraph_vertice_rename(_egraph, ggnet_node_usrdata_get(n), (char *)fqdn); } +static struct ggnet_node * +_node_link_next(struct ggnet_node *np, struct in_addr *ip) +{ + struct ggnet_node *n; + Egraph_Vertice *v; + + n = ggnet_node_find(_ggnet, ip); + if (!n) { + n = ggnet_node_add(_ggnet, ip, 0); + v = _node_to_vertice(n); + if (v) + egraph_vertice_type_set(_egraph, v, + "vertice_alt1"); + else + printf("gg_map: ERROR: could not create trace vertice !\n"); + } + ggnet_node_path_link(np, n); + return n; +} + static void -_conn_trace(u_int32_t addr, u_int8_t hopcount, struct gg_packet *pkt) { +_conn_trace(u_int32_t addr, u_int32_t src, u_int8_t hopcount, struct gg_packet *pkt) { struct gg_packet_tracehop *h; - struct ggnet_node *n, *np; + struct ggnet_node *n; struct in_addr ip; - Egraph_Vertice *v; int i; - ip.s_addr = addr; - np = ggnet_node_find(_ggnet, &ip); - if (!np) + ip.s_addr = src; + printf("XXX ==== SRC %x\n", src); + n = ggnet_node_find(_ggnet, &ip); + printf("XXX ==== SRC node %p\n", n); + if (!n) return; + for (i=0; itrace_hops[i]; ip.s_addr = h->addr; - n = ggnet_node_find(_ggnet, &ip); - if (!n) { - n = ggnet_node_add(_ggnet, &ip); - v = _node_to_vertice(n); - if (v) - egraph_vertice_type_set(_egraph, v, - "vertice_alt1"); - else - printf("gg_map: ERROR: could not create trace vertice !\n"); - - } - ggnet_node_path_link(np, n); - np = n; + n = _node_link_next(n, &ip); } + + ip.s_addr = addr; + n = _node_link_next(n, &ip); } static int @@ -345,10 +358,12 @@ _cb_packet(struct gg_client *cli, struct gg_packet *pkt) if (_loglevel >= 1) { printf(" type PACKET_TRACE\n"); printf(" trace_addr %4x\n", pkt->trace_addr); + printf(" trace_src %4x\n", pkt->trace_src); printf(" trace_hopcount %d\n", pkt->trace_hopcount); } - _conn_trace(pkt->trace_addr, pkt->trace_hopcount, pkt); + _conn_trace(pkt->trace_addr, pkt->trace_src, + pkt->trace_hopcount, pkt); break; } -- cgit v1.2.3-59-g8ed1b