diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-02-24 22:04:34 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-02-24 22:04:34 +0000 |
commit | dfa295919ccd35e2e9e28ff0216643ef946be848 (patch) | |
tree | 4d21b9b84c116af3847047dc1a0931c7cac5cb77 | |
parent | 00435bf3903ca63f3cc4185dffd2cc7d08c6b8c3 (diff) | |
download | wireshark-dfa295919ccd35e2e9e28ff0216643ef946be848.tar.gz |
Change the plugin to be something useful.
Adds more taps,
tests range nodes
tests pivot nodes
svn path=/trunk/; revision=13503
-rw-r--r-- | plugins/stats_tree/pinfo_stats_tree.c | 170 | ||||
-rw-r--r-- | plugins/stats_tree/stats_tree_plugin.c | 6 |
2 files changed, 51 insertions, 125 deletions
diff --git a/plugins/stats_tree/pinfo_stats_tree.c b/plugins/stats_tree/pinfo_stats_tree.c index 607ec068a3..3da0c368b7 100644 --- a/plugins/stats_tree/pinfo_stats_tree.c +++ b/plugins/stats_tree/pinfo_stats_tree.c @@ -30,43 +30,7 @@ #include <epan/stats_tree.h> -static int st_node_pinfo_dl_src = -1; -static gchar* st_str_pinfo_dl_src = "link-layer source address"; - -static int st_node_pinfo_dl_dst = -1; -static gchar* st_str_pinfo_dl_dst = "link-layer destination address"; - -static int st_node_pinfo_net_src = -1; -static gchar* st_str_pinfo_net_src = "network-layer source address"; - -static int st_node_pinfo_net_dst = -1; -static gchar* st_str_pinfo_net_dst = "network-layer destination address"; - -static int st_node_pinfo_src = -1; -static gchar* st_str_pinfo_src = "source address (net if present, DL otherwise )"; - -static int st_node_pinfo_dst = -1; -static gchar* st_str_pinfo_dst = "destination address (net if present, DL otherwise )"; - -static int st_node_pinfo_ethertype = -1; -static gchar* st_str_pinfo_ethertype = "Ethernet Type Code, if this is an Ethernet packet"; - -static int st_node_pinfo_ipproto = -1; -static gchar* st_str_pinfo_ipproto = "IP protocol, if this is an IP packet"; - -static int st_node_pinfo_ipxptype = -1; -static gchar* st_str_pinfo_ipxptype = "IPX packet type, if this is an IPX packet"; - -static int st_node_pinfo_circuit_id = -1; -static gchar* st_str_pinfo_circuit_id = "circuit ID, for protocols with a VC identifier"; - -static int st_node_pinfo_srcport = -1; -static gchar* st_str_pinfo_srcport = "source port"; - -static int st_node_pinfo_destport = -1; -static gchar* st_str_pinfo_destport = "destination port"; - - +/* XXX: this belongs to to_str.c */ static const gchar* port_type_to_str (port_type type) { switch (type) { case PT_NONE: return NULL; @@ -85,97 +49,61 @@ static const gchar* port_type_to_str (port_type type) { return NULL; } -extern void pinfo_stats_tree_init(stats_tree* st) -{ - st_node_pinfo_dl_src = create_node(st, st_str_pinfo_dl_src, 0, TRUE); - st_node_pinfo_dl_dst = create_node(st, st_str_pinfo_dl_dst, 0, TRUE); - st_node_pinfo_net_src = create_node(st, st_str_pinfo_net_src, 0, TRUE); - st_node_pinfo_net_dst = create_node(st, st_str_pinfo_net_dst, 0, TRUE); - st_node_pinfo_src = create_node(st, st_str_pinfo_src, 0, TRUE); - st_node_pinfo_dst = create_node(st, st_str_pinfo_dst, 0, TRUE); - st_node_pinfo_ethertype = create_node(st, st_str_pinfo_ethertype, 0, TRUE); - st_node_pinfo_ipproto = create_node(st, st_str_pinfo_ipproto, 0, TRUE); - st_node_pinfo_ipxptype = create_node(st, st_str_pinfo_ipxptype, 0, TRUE); - st_node_pinfo_circuit_id = create_node(st, st_str_pinfo_circuit_id, 0, TRUE); - st_node_pinfo_srcport = create_node(st, st_str_pinfo_srcport, 0, TRUE); - st_node_pinfo_destport = create_node(st, st_str_pinfo_destport, 0, TRUE); +/* ip host stats_tree -- basic test */ +static int st_node_ip = -1; +static gchar* st_str_ip = "IP address"; + +extern void ip_hosts_stats_tree_init(stats_tree* st) { + st_node_ip = create_node(st, st_str_ip, 0, TRUE); } -extern int pinfo_stats_tree_packet(stats_tree *st , packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) { +extern int ip_hosts_stats_tree_packet(stats_tree *st , packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) { static guint8 str[128]; - const gchar* ptype; - - if (pinfo->dl_src.data) { - tick_stat_node(st, st_str_pinfo_dl_src, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->dl_src)); - tick_stat_node(st, str, st_node_pinfo_dl_src, FALSE); - } - - if (pinfo->dl_dst.data) { - tick_stat_node(st, st_str_pinfo_dl_dst, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->dl_dst)); - tick_stat_node(st, str, st_node_pinfo_dl_dst, FALSE); - } - if (pinfo->net_src.data) { - tick_stat_node(st, st_str_pinfo_net_src, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->net_src)); - tick_stat_node(st, str, st_node_pinfo_net_src, FALSE); - } - - if (pinfo->net_dst.data) { - tick_stat_node(st, st_str_pinfo_net_dst, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->net_dst)); - tick_stat_node(st, str, st_node_pinfo_net_dst, FALSE); - } + tick_stat_node(st, st_str_ip, 0, FALSE); - if (pinfo->src.data) { - tick_stat_node(st, st_str_pinfo_src, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->src)); - tick_stat_node(st, str, st_node_pinfo_src, FALSE); - } - - if (pinfo->dst.data) { - tick_stat_node(st, st_str_pinfo_dst, 0, FALSE); - g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->dst)); - tick_stat_node(st, str, st_node_pinfo_dst, FALSE); - } - - if (pinfo->ethertype) { - tick_stat_node(st, st_str_pinfo_ethertype, 0, FALSE); - g_snprintf(str, sizeof(str),"%u",pinfo->ethertype); - tick_stat_node(st, str, st_node_pinfo_ethertype, FALSE); - } - - if (pinfo->ipproto) { - tick_stat_node(st, st_str_pinfo_ipproto, 0, FALSE); - g_snprintf(str, sizeof(str),"%u",pinfo->ipproto); - tick_stat_node(st, str, st_node_pinfo_ipproto, FALSE); - } - - if (pinfo->ipxptype) { - tick_stat_node(st, st_str_pinfo_ipxptype, 0, FALSE); - g_snprintf(str, sizeof(str),"%u",pinfo->ipxptype); - tick_stat_node(st, str, st_node_pinfo_ipxptype, FALSE); - } - - if (pinfo->circuit_id) { - tick_stat_node(st, st_str_pinfo_circuit_id, 0, FALSE); - g_snprintf(str, sizeof(str),"%u",pinfo->circuit_id); - tick_stat_node(st, str, st_node_pinfo_circuit_id, FALSE); - } - - if (( ptype = port_type_to_str(pinfo->ptype) )) { - tick_stat_node(st, st_str_pinfo_srcport, 0, FALSE); - g_snprintf(str, sizeof(str),"%s:%u",ptype,pinfo->srcport); - tick_stat_node(st, str, st_node_pinfo_srcport, FALSE); + g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->net_src)); + tick_stat_node(st, str, st_node_ip, FALSE); + + g_snprintf(str, sizeof(str),"%s",address_to_str(&pinfo->net_dst)); + tick_stat_node(st, str, st_node_ip, FALSE); - tick_stat_node(st, st_str_pinfo_destport, 0, FALSE); - g_snprintf(str, sizeof(str),"%s:%u",ptype,pinfo->destport); - tick_stat_node(st, str, st_node_pinfo_destport, FALSE); - } +} + + +/* packet type stats_tree -- test pivot node */ +static int st_node_ptype = -1; +static gchar* st_str_ptype = "Port Type"; + +extern void ptype_stats_tree_init(stats_tree* st) { + st_node_ptype = create_pivot_node(st, st_str_ptype, 0); +} + +extern void ptype_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_dissect_t *edt _U_, const void *p _U_) { + const gchar* ptype; - return 1; + ptype = port_type_to_str(pinfo->ptype); + + tick_pivot(st,st_node_ptype,ptype); +} + +/* packet length stats_tree -- test range node */ +static int st_node_plen = -1; +static gchar* st_str_plen = "Packet Lenght"; + +extern void plen_stats_tree_init(stats_tree* st) { + st_node_plen = create_range_node(st, st_str_plen, 0, "0-19","20-39","40-79","80-159","160-319","320-639","640-1279","1280-",NULL); } +extern void plen_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_dissect_t *edt _U_, const void *p _U_) { + tick_stat_node(st, st_str_plen, 0, FALSE); + tick_range(st, st_str_plen, 0, pinfo->fd->pkt_len); +} +/* register all pinfo trees */ +extern void register_pinfo_stat_trees(void) { + register_stats_tree("ip","ip_hosts",st_str_ip, ip_hosts_stats_tree_packet, ip_hosts_stats_tree_init ); + register_stats_tree("ip","ptype",st_str_ptype, ptype_stats_tree_packet, ptype_stats_tree_init ); + register_stats_tree("frame","plen",st_str_plen, plen_stats_tree_packet, plen_stats_tree_init ); +} + diff --git a/plugins/stats_tree/stats_tree_plugin.c b/plugins/stats_tree/stats_tree_plugin.c index fe4ef813a7..ca7e53567c 100644 --- a/plugins/stats_tree/stats_tree_plugin.c +++ b/plugins/stats_tree/stats_tree_plugin.c @@ -33,8 +33,7 @@ #include "plugins/plugin_api_defs.h" #include <epan/stats_tree.h> -extern void pinfo_stats_tree_init(stats_tree*); -extern int pinfo_stats_tree_packet(stats_tree* , packet_info*, epan_dissect_t*, const void*); +extern void register_pinfo_stat_trees(void); G_MODULE_EXPORT const gchar version[] = "0.0"; @@ -42,8 +41,7 @@ G_MODULE_EXPORT void plugin_init(plugin_address_table_t *pat _U_ ) { /* initialise the table of pointers needed in Win32 DLLs */ plugin_address_table_init(pat); - register_stats_tree("frame","Frame counters", pinfo_stats_tree_packet, pinfo_stats_tree_init ); - + register_pinfo_stat_trees(); } G_MODULE_EXPORT void plugin_reg_handoff(void) |