diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2013-01-12 23:37:32 +0100 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2013-01-12 23:37:32 +0100 |
commit | 8aa15027443ef20e1d65c127f882511c2ee2e7ab (patch) | |
tree | c61672acb42d88065242ea324f56c7a6b3d065af /gg_sniff/pcap.c | |
parent | update requirements (diff) | |
download | glouglou-8aa15027443ef20e1d65c127f882511c2ee2e7ab.tar.xz glouglou-8aa15027443ef20e1d65c127f882511c2ee2e7ab.zip |
work in progress on traceroute and it's integration in gg_sniff
Diffstat (limited to 'gg_sniff/pcap.c')
-rw-r--r-- | gg_sniff/pcap.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gg_sniff/pcap.c b/gg_sniff/pcap.c index fd9470f..4522fc8 100644 --- a/gg_sniff/pcap.c +++ b/gg_sniff/pcap.c @@ -81,6 +81,7 @@ static void phandler_sll(u_char *, static void cb_pcap(int, short, void *); static void cb_conntimer(int, short, void *); static void cb_nodename(struct ggnet *, struct ggnet_node *); +static void cb_nodetraceroute(struct ggnet *, struct ggnet_node *); static struct phandler phandlers[] = { { phandler_ether, DLT_EN10MB }, @@ -137,8 +138,10 @@ ggsniff_pcap_init(struct event_base *ev_base, struct gg_client *ggcli, if (evtimer_add(_cap.conntimer_ev, &_cap.conntimer_tv) == -1) gg_log_fatal("user: event_add conntimer failed: %s", strerror(errno)); - if (active) + if (active) { ggnet_set_dns(net, 1, ev_base, cb_nodename); + ggnet_set_traceroute(net, 1, ev_base, cb_nodetraceroute); + } _cap.ggcli = ggcli; _cap.net = net; @@ -348,6 +351,24 @@ cb_nodename(struct ggnet *net, struct ggnet_node *n) } } +static void +cb_nodetraceroute(struct ggnet *net, struct ggnet_node *n) +{ + struct gg_packet pkt; + int len; + + len = strnlen(n->fqdn, GGNET_DNSNAME_MAX); + if (len > 0) { + pkt.ver = PACKET_VERSION; + pkt.type = PACKET_TRACE; + pkt.name_addr = n->addr.s_addr; + // XXX IN PROGRESS + //pkt.name_len = len; + //strncpy((char *)pkt.name_fqdn, n->fqdn, sizeof(pkt.name_fqdn)); + gg_client_send(_cap.ggcli, &pkt); + } +} + /* * Parse an IP packet and descide what to do with it. * 'ip' is a pointer the the captured IP packet |