diff options
Diffstat (limited to 'gg_sniff/pcap.c')
-rw-r--r-- | gg_sniff/pcap.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gg_sniff/pcap.c b/gg_sniff/pcap.c index e004b99..f38ef93 100644 --- a/gg_sniff/pcap.c +++ b/gg_sniff/pcap.c @@ -39,10 +39,10 @@ #define PCAP_TO 300 #define NODE_MAX_WITHOUT_TIMEOUT 1000 -#define NODE_TIMEOUT 300 // XXX conf ? -#define CONN_TIMEOUT 300 // XXX conf ? -#define CONN_TIMEOUT_UDP 20 // XXX conf ? -#define CONN_TIMEOUT_ICMP 10 // XXX conf ? +#define NODE_TIMEOUT 60 // XXX conf ? +#define CONN_TIMEOUT 30 // XXX conf ? +#define CONN_TIMEOUT_UDP 30 // XXX conf ? +#define CONN_TIMEOUT_ICMP 30 // XXX conf ? #define CONNTIMER 5 // XXX conf ? struct phandler { @@ -65,6 +65,7 @@ struct _cap_t { static pcap_t *my_pcap_open_live(const char *, int, int, int, char *, u_int, u_int); static void ip_handle(struct ip *, const u_char *, u_int); +static void conn_del(struct ggnet_conn *); static void ether_handle(struct ether_header *, const u_char *, u_int); static pcap_handler lookup_phandler(int); static void phandler_ether(u_char *, @@ -308,7 +309,7 @@ cb_conntimer(int fd, short why, void *data) break; } if (_cap.net->time > c->lastseen + to) - ggnet_conn_del(_cap.net, c); + conn_del(c); else i++; } @@ -467,10 +468,7 @@ ip_handle(struct ip *ip, const u_char *pend, u_int wirelen) gg_client_send(_cap.ggcli, &pkt); ggnet_conn_data(_cap.net, conn, ip->ip_len, response); } else { - pkt.type = PACKET_DELCONN; - pkt.delconn_id = conn->id; - gg_client_send(_cap.ggcli, &pkt); - ggnet_conn_del(_cap.net, conn); + conn_del(conn); } } else { if (!close) { @@ -490,6 +488,18 @@ ip_handle(struct ip *ip, const u_char *pend, u_int wirelen) } static void +conn_del(struct ggnet_conn *c) +{ + struct gg_packet pkt; + + pkt.ver = PACKET_VERSION; + pkt.type = PACKET_DELCONN; + pkt.delconn_id = c->id; + gg_client_send(_cap.ggcli, &pkt); + ggnet_conn_del(_cap.net, c); +} + +static void ether_handle(struct ether_header *ether, const u_char *pend, u_int wirelen) { struct ip *ip; |