Ethereal-dev: Re: [Ethereal-dev] A new counters tree window, and some implementations (IP, HTT
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: LEGO <luis.ontanon@xxxxxxxxx>
Date: Wed, 5 Jan 2005 16:07:29 +0100
By the same token: Ethernet and UDP On Wed, 5 Jan 2005 14:03:42 +0100, LEGO <luis.ontanon@xxxxxxxxx> wrote: > Hi, > > As a byproduct of some work I'm doing on HTTP I've written a counters > tree window interface, it is very straightforward to implement, as a > matter of fact as once I was done with HTTP, it took me just minutes > to write the ISUP and the IP implementations . > > Attached you will find: > - gtk/gtk_stats_tree.[ch] the code for the stats_tree tap-window > - gtk/ip_stat.c the stats window for IP > - a patch to gtk/isup_stat.c (which replaces thee old window with the newer one) > - a patch to gtk/http_stat.c and packet-http.[ch] > - three snapshots to the stat windows I've made > > There are still some things to do: > I don't know if it runs under GTK1. > Being this my first GTK widget I do not know If I've got all straight. > Do I need to destroy myself the tree and other GTK "items" that belong > to the window or they are freed as the window is destroyed? > > However being so simple to use (take a look at ip_stat.c and see it > yourselves) I think is worth a try. > > Cheers, > Luis > > > _______________________________________________ > Ethereal-dev mailing list > Ethereal-dev@xxxxxxxxxxxx > http://www.ethereal.com/mailman/listinfo/ethereal-dev > > > >
/* http_stat.c
* http_stat 2004 Luis E. G. Ontanon
*
* $Id: $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@xxxxxxxxxxxx>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gtk_stats_tree.h"
#include <epan/dissectors/packet-eth.h>
static const guint8* frames = "Total Ethernet Frames";
static const guint8* frames_by_addr = "Ethernet Frames by address";
static const guint8* frames_by_src = "Ethernet Frames by sender";
static const guint8* frames_by_dst = "Ethernet Frames by receiver";
static const guint8* frames_by_type = "Ethernet Frames by type";
static int ethstat_packet(void *psp , packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) {
static guint8 src[128];
static guint8 dst[128];
static guint8 addr_a[128];
static guint8 addr_b[128];
static guint8 type[128];
const eth_hdr *value = pri;
stats_tree *sp = (stats_tree *) psp;
guint8* addr = NULL;
guint len;
stat_tree_update(sp,pinfo);
tick_node(sp, frames, NULL, FALSE);
tick_node(sp, frames_by_src, frames, FALSE);
tick_node(sp, frames_by_dst, frames, FALSE);
tick_node(sp, frames_by_addr, frames, FALSE);
tick_node(sp, frames_by_addr, frames, FALSE);
tick_node(sp, frames_by_type, frames, FALSE);
g_snprintf(src, sizeof(src),"Src: %s",address_to_str(&pinfo->dl_src));
tick_node(sp, src, frames_by_src,FALSE);
g_snprintf(dst, sizeof(dst),"Dst: %s",address_to_str(&pinfo->dl_dst));
tick_node(sp, dst, frames_by_dst,FALSE);
g_snprintf(type, sizeof(type),"Type: %u", (guint)value->type);
tick_node(sp, type, frames_by_type,FALSE);
g_snprintf(addr_a, sizeof(addr_a),"Addr: %s",address_to_str(&pinfo->dl_src));
addr = tick_node(sp, addr_a, frames_by_addr,FALSE);
g_snprintf(addr_b, sizeof(addr_b),"Addr: %s",address_to_str(&pinfo->dl_dst));
addr = tick_node(sp, addr_b, frames_by_addr,FALSE);
return 1;
}
static void
gtk_ethstat_init(char *optarg)
{
stats_tree *sp = new_stat_tree("ip","Ethernet Statistics",optarg);
create_node(sp, frames, NULL, FALSE);
create_node(sp, frames_by_addr, frames, TRUE);
create_node(sp, frames_by_src, frames, TRUE);
create_node(sp, frames_by_dst, frames, TRUE);
create_node(sp, frames_by_type, frames, TRUE);
init_stat_tree_window(sp,ethstat_packet);
}
static tap_dfilter_dlg ip_stat_dlg = {
"Ethernet Frame Counter",
"eth,stat",
gtk_ethstat_init,
-1
};
void
register_tap_listener_gtkethstat(void)
{
register_ethereal_tap("eth,stat", gtk_ethstat_init);
register_tap_menu_item("Ethernet", REGISTER_TAP_GROUP_NONE,
gtk_tap_dfilter_dlg_cb, NULL, NULL, &(ip_stat_dlg));
}
/* http_stat.c
* http_stat 2004 Luis E. G. Ontanon
*
* $Id: $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@xxxxxxxxxxxx>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gtk_stats_tree.h"
#include <epan/dissectors/packet-udp.h>
static const guint8* packets = "Total UDP Packets";
static const guint8* packets_by_addr = "UDP Packets by address";
static const guint8* packets_by_src = "UDP Packets by src";
static const guint8* packets_by_dst = "UDP Packets by dst";
static const guint8* packets_by_port = "UDP Packets by port";
static const guint8* packets_by_srcpt = "UDP Packets by src port";
static const guint8* packets_by_dstpt = "UDP Packets by dst port";
static const guint8* packets_by_len = "UDP Packets by length";
static const guint8* packets_sizes[] = {
"<100","100-199","200,299","300-399","400-499",
"500-599","600-699","700-799","800-899","900-999","1000-1099",
"1100-1199","1200-1299","1300-1399","1400-1499","1500-1599",
"1600-1699","1700-1799","1800-1899","1900-1999",">2000"};
static int udpstat_packet(void *psp , packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) {
static guint8 src[128];
static guint8 dst[128];
static guint8 addr_a[128];
static guint8 addr_b[128];
static guint8 src_pt[128];
static guint8 dst_pt[128];
static guint8 port[128];
const e_udphdr *value = pri;
stats_tree *sp = (stats_tree *) psp;
guint len;
stat_tree_update(sp,pinfo);
tick_node(sp, packets, NULL, FALSE);
tick_node(sp, packets_by_src, packets, FALSE);
tick_node(sp, packets_by_dst, packets, FALSE);
tick_node(sp, packets_by_addr, packets, FALSE);
tick_node(sp, packets_by_addr, packets, FALSE);
tick_node(sp, packets_by_port, packets, FALSE);
tick_node(sp, packets_by_port, packets, FALSE);
tick_node(sp, packets_by_srcpt, packets, FALSE);
tick_node(sp, packets_by_dstpt, packets, FALSE);
tick_node(sp, packets_by_len, packets, FALSE);
g_snprintf(src, sizeof(src),"Src: %s",address_to_str(&pinfo->src));
tick_node(sp, src, packets_by_src,FALSE);
g_snprintf(dst, sizeof(dst),"Dst: %s",address_to_str(&pinfo->dst));
tick_node(sp, dst, packets_by_dst,FALSE);
g_snprintf(addr_a, sizeof(addr_a),"Addr: %s",address_to_str(&pinfo->src));
tick_node(sp, addr_a, packets_by_addr,FALSE);
g_snprintf(addr_b, sizeof(addr_b),"Addr: %s",address_to_str(&pinfo->dst));
tick_node(sp, addr_b, packets_by_addr,FALSE);
g_snprintf(port, sizeof(port),"Port: %u", (guint)value->uh_sport);
tick_node(sp, port, packets_by_port,FALSE);
g_snprintf(port, sizeof(port),"Port: %u", (guint)value->uh_dport);
tick_node(sp, port, packets_by_port,FALSE);
g_snprintf(src_pt, sizeof(src_pt),"Src Port: %u", (guint)value->uh_sport);
tick_node(sp, src_pt, packets_by_srcpt,FALSE);
g_snprintf(dst_pt, sizeof(dst_pt),"Dst Port: %u", (guint)value->uh_dport);
tick_node(sp, dst_pt, packets_by_dstpt,FALSE);
len = value->uh_ulen/100;
if (len > 20) len = 20;
tick_node(sp, packets_sizes[len],packets_by_len,FALSE);
return 1;
}
static void
gtk_udpstat_init(char *optarg)
{
guint i;
stats_tree *sp = new_stat_tree("udp","UDP Statistics",optarg);
create_node(sp, packets, NULL, FALSE);
create_node(sp, packets_by_addr, packets, TRUE);
create_node(sp, packets_by_src, packets, TRUE);
create_node(sp, packets_by_dst, packets, TRUE);
create_node(sp, packets_by_port, packets, TRUE);
create_node(sp, packets_by_srcpt, packets, TRUE);
create_node(sp, packets_by_dstpt, packets, TRUE);
create_node(sp, packets_by_len, packets, TRUE);
for (i=0; i < 20; i++)
create_node(sp, packets_sizes[i], packets_by_len, TRUE);
init_stat_tree_window(sp,udpstat_packet);
}
static tap_dfilter_dlg udp_stat_dlg = {
"UDP Packet Counter",
"udp,stat",
gtk_udpstat_init,
-1
};
void
register_tap_listener_gtkudpstat(void)
{
register_ethereal_tap("udp,stat", gtk_udpstat_init);
register_tap_menu_item("UDP", REGISTER_TAP_GROUP_NONE,
gtk_tap_dfilter_dlg_cb, NULL, NULL, &(udp_stat_dlg));
}
- References:
- Prev by Date: Re: [Ethereal-dev] svn diff
- Next by Date: Re: [Ethereal-dev] SIP calls analysis
- Previous by thread: [Ethereal-dev] A new counters tree window, and some implementations (IP, HTTP, ISUP)
- Next by thread: Re: [Ethereal-dev] A new counters tree window, and some implementations (IP, HTTP, ISUP)
- Index(es):