Free our flow graph strings when we're done with them. Add a note about
[obnox/wireshark/wip.git] / gtk / hostlist_rsvp.c
1 /* hostlist_rsvp.c
2  * hostlist_rsvp.c August 2005, Manu Pathak <mapathak@cisco.com>
3  *
4  * Ethereal - Network traffic analyzer
5  * By Gerald Combs <gerald@ethereal.com>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include <stdio.h>
28
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
31 #endif
32
33 #include <gtk/gtk.h>
34 #include <string.h>
35 #include "epan/packet.h"
36 #include <epan/stat_cmd_args.h>
37 #include "../stat_menu.h"
38 #include "gui_stat_menu.h"
39 #include <epan/tap.h>
40 #include "../register.h"
41 #include "hostlist_table.h"
42 #include <epan/dissectors/packet-rsvp.h>
43
44
45 static int
46 rsvp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)
47 {
48         hostlist_table *hosts=(hostlist_table *)pit;
49         const rsvp_conversation_info *rsvph = vip;
50
51         /* Take two "add" passes per packet, adding for each direction, ensures
52          * that all packets are counted properly (even if address is sending to 
53          * itself). XXX - this could probably be done more efficiently inside 
54          * hostlist_table 
55          */
56         add_hostlist_table_data(hosts, &rsvph->source, 0, TRUE, 1, 
57                                 pinfo->fd->pkt_len, SAT_NONE, PT_NONE);
58         add_hostlist_table_data(hosts, &rsvph->destination, 0, FALSE, 1, 
59                                 pinfo->fd->pkt_len, SAT_NONE, PT_NONE);
60         return 1;
61 }
62
63 static void
64 gtk_rsvp_hostlist_init(const char *optarg)
65 {
66         const char *filter=NULL;
67
68         if(!strncmp(optarg,"hosts,rsvp,",11)){
69                 filter=optarg+11;
70         } else {
71                 filter=NULL;
72         }
73
74         init_hostlist_table(TRUE, "RSVP Hosts", "rsvp", filter, 
75                             rsvp_hostlist_packet);
76
77 }
78
79
80 static void
81 gtk_rsvp_hostlist_cb(GtkWidget *w _U_, gpointer d _U_)
82 {
83         gtk_rsvp_hostlist_init("hosts,rsvp");
84 }
85
86
87 void
88 register_tap_listener_rsvp_hostlist(void)
89 {
90         register_stat_cmd_arg("hosts,rsvp", gtk_rsvp_hostlist_init);
91
92         register_stat_menu_item("RSVP", REGISTER_STAT_GROUP_ENDPOINT_LIST,
93                                gtk_rsvp_hostlist_cb, NULL, NULL, NULL);
94
95         register_hostlist_table(TRUE, "RSVP", "rsvp", NULL /*filter*/, 
96                                 rsvp_hostlist_packet);
97 }