aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/stats_tree/pinfo_stats_tree.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-08-16 18:41:53 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-08-22 08:30:52 +0000
commit532070b4e7cfa4bcbf1e10ed14503f9aae0ee7ab (patch)
treedd1ac81241a67c71370d78821765bd1a345b1938 /plugins/stats_tree/pinfo_stats_tree.c
parent953cdd42a2151bddb537b8d934b2ae453f1770a4 (diff)
Add support for IPv6 stats tree statistics
Also add support for alphabetizing stat tree items as the addition of IPv6 stats tree makes it more obvious its needed. Change-Id: I8b319ceac805ce7e3a1fd59f92c1c6fe2a54d3de Reviewed-on: https://code.wireshark.org/review/10062 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'plugins/stats_tree/pinfo_stats_tree.c')
-rw-r--r--plugins/stats_tree/pinfo_stats_tree.c195
1 files changed, 127 insertions, 68 deletions
diff --git a/plugins/stats_tree/pinfo_stats_tree.c b/plugins/stats_tree/pinfo_stats_tree.c
index 295c12c7f2..451bd16d39 100644
--- a/plugins/stats_tree/pinfo_stats_tree.c
+++ b/plugins/stats_tree/pinfo_stats_tree.c
@@ -105,68 +105,151 @@ static void uat_plen_record_post_update_cb(void) {
UAT_RANGE_CB_DEF(uat_plen_records, packet_range, uat_plen_record_t)
/* ip host stats_tree -- basic test */
-static int st_node_ip = -1;
-static const gchar *st_str_ip = "IP Statistics/IP Addresses";
+static int st_node_ipv4 = -1;
+static int st_node_ipv6 = -1;
+static const gchar *st_str_ipv4 = "IPv4 Statistics/All Addresses";
+static const gchar *st_str_ipv6 = "IPv6 Statistics/All Addresses";
-static void ip_hosts_stats_tree_init(stats_tree *st) {
- st_node_ip = stats_tree_create_node(st, st_str_ip, 0, TRUE);
+static void ipv4_hosts_stats_tree_init(stats_tree *st) {
+ st_node_ipv4 = stats_tree_create_node(st, st_str_ipv4, 0, TRUE);
}
-static int ip_hosts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
- tick_stat_node(st, st_str_ip, 0, FALSE);
- tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_src), st_node_ip, FALSE);
- tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node_ip, FALSE);
+static void ipv6_hosts_stats_tree_init(stats_tree *st) {
+ st_node_ipv6 = stats_tree_create_node(st, st_str_ipv6, 0, TRUE);
+}
+static int ip_hosts_stats_tree_packet(stats_tree *st, packet_info *pinfo, int st_node, const gchar *st_str) {
+ tick_stat_node(st, st_str, 0, FALSE);
+ tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_src), st_node, FALSE);
+ tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node, FALSE);
return 1;
}
-/* ip host stats_tree -- separate source and dest, test stats_tree flags */
-static int st_node_ip_src = -1;
-static int st_node_ip_dst = -1;
-static const gchar *st_str_ip_srcdst = "IP Statistics/Source and Dest IP Addresses";
-static const gchar *st_str_ip_src = "Source IP Addresses";
-static const gchar *st_str_ip_dst = "Destination IP Addresses";
+static int ipv4_hosts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return ip_hosts_stats_tree_packet(st, pinfo, st_node_ipv4, st_str_ipv4);
+}
+
+static int ipv6_hosts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return ip_hosts_stats_tree_packet(st, pinfo, st_node_ipv6, st_str_ipv6);
+}
-static void ip_srcdst_stats_tree_init(stats_tree *st) {
+/* ip host stats_tree -- separate source and dest, test stats_tree flags */
+static int st_node_ipv4_src = -1;
+static int st_node_ipv4_dst = -1;
+static int st_node_ipv6_src = -1;
+static int st_node_ipv6_dst = -1;
+static const gchar *st_str_ipv4_srcdst = "IPv4 Statistics/Source and Destination Addresses";
+static const gchar *st_str_ipv6_srcdst = "IPv6 Statistics/Source and Destination Addresses";
+static const gchar *st_str_ipv4_src = "Source IPv4 Addresses";
+static const gchar *st_str_ipv4_dst = "Destination IPv4 Addresses";
+static const gchar *st_str_ipv6_src = "Source IPv6 Addresses";
+static const gchar *st_str_ipv6_dst = "Destination IPv6 Addresses";
+
+static void ip_srcdst_stats_tree_init(stats_tree *st,
+ const gchar *st_str_src, int *st_node_src_ptr,
+ const gchar *st_str_dst, int *st_node_dst_ptr) {
/* create one tree branch for source */
- st_node_ip_src = stats_tree_create_node(st, st_str_ip_src, 0, TRUE);
+ *st_node_src_ptr = stats_tree_create_node(st, st_str_src, 0, TRUE);
/* set flag so this branch will always be sorted to top of tree */
- stat_node_set_flags(st, st_str_ip_src, 0, FALSE, ST_FLG_SORT_TOP);
+ stat_node_set_flags(st, st_str_src, 0, FALSE, ST_FLG_SORT_TOP);
/* creat another top level node for destination branch */
- st_node_ip_dst = stats_tree_create_node(st, st_str_ip_dst, 0, TRUE);
+ *st_node_dst_ptr = stats_tree_create_node(st, st_str_dst, 0, TRUE);
/* set flag so this branch will not be expanded by default */
- stat_node_set_flags(st, st_str_ip_dst, 0, FALSE, ST_FLG_DEF_NOEXPAND);
+ stat_node_set_flags(st, st_str_dst, 0, FALSE, ST_FLG_DEF_NOEXPAND);
+}
+
+static void ipv4_srcdst_stats_tree_init(stats_tree *st) {
+ ip_srcdst_stats_tree_init(st, st_str_ipv4_src, &st_node_ipv4_src, st_str_ipv4_dst, &st_node_ipv4_dst);
}
-static int ip_srcdst_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+static void ipv6_srcdst_stats_tree_init(stats_tree *st) {
+ ip_srcdst_stats_tree_init(st, st_str_ipv6_src, &st_node_ipv6_src, st_str_ipv6_dst, &st_node_ipv6_dst);
+}
+
+static int ip_srcdst_stats_tree_packet(stats_tree *st, packet_info *pinfo,
+ int st_node_src, const gchar *st_str_src,
+ int st_node_dst, const gchar *st_str_dst) {
/* update source branch */
- tick_stat_node(st, st_str_ip_src, 0, FALSE);
- tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_src), st_node_ip_src, FALSE);
+ tick_stat_node(st, st_str_src, 0, FALSE);
+ tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_src), st_node_src, FALSE);
/* update destination branch */
- tick_stat_node(st, st_str_ip_dst, 0, FALSE);
- tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node_ip_dst, FALSE);
-
+ tick_stat_node(st, st_str_dst, 0, FALSE);
+ tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node_dst, FALSE);
return 1;
}
+static int ipv4_srcdst_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return ip_srcdst_stats_tree_packet(st, pinfo, st_node_ipv4_src, st_str_ipv4_src, st_node_ipv4_dst, st_str_ipv4_dst);
+}
+
+static int ipv6_srcdst_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return ip_srcdst_stats_tree_packet(st, pinfo, st_node_ipv6_src, st_str_ipv6_src, st_node_ipv6_dst, st_str_ipv6_dst);
+}
+
/* packet type stats_tree -- test pivot node */
-static int st_node_ptype = -1;
-static const gchar *st_str_ptype = "IP Statistics/IP Protocol Types";
+static int st_node_ipv4_ptype = -1;
+static int st_node_ipv6_ptype = -1;
+static const gchar *st_str_ipv4_ptype = "IPv4 Statistics/IP Protocol Types";
+static const gchar *st_str_ipv6_ptype = "IPv6 Statistics/IP Protocol Types";
-static void ptype_stats_tree_init(stats_tree *st) {
- st_node_ptype = stats_tree_create_pivot(st, st_str_ptype, 0);
+static void ipv4_ptype_stats_tree_init(stats_tree *st) {
+ st_node_ipv4_ptype = stats_tree_create_pivot(st, st_str_ipv4_ptype, 0);
}
-static int ptype_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
- const gchar *ptype;
+static void ipv6_ptype_stats_tree_init(stats_tree *st) {
+ st_node_ipv6_ptype = stats_tree_create_pivot(st, st_str_ipv6_ptype, 0);
+}
+
+static int ipv4_ptype_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ stats_tree_tick_pivot(st, st_node_ipv4_ptype, port_type_to_str(pinfo->ptype));
+ return 1;
+}
- ptype = port_type_to_str(pinfo->ptype);
+static int ipv6_ptype_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ stats_tree_tick_pivot(st, st_node_ipv6_ptype, port_type_to_str(pinfo->ptype));
+ return 1;
+}
- stats_tree_tick_pivot(st,st_node_ptype,ptype);
+/* a tree example
+ - IP
+ - PROTO
+ - PORT
+
+*/
+static int st_node_ipv4_dsts = -1;
+static int st_node_ipv6_dsts = -1;
+static const gchar *st_str_ipv4_dsts = "IPv4 Statistics/Destinations and Ports";
+static const gchar *st_str_ipv6_dsts = "IPv6 Statistics/Destinations and Ports";
+
+static void ipv4_dsts_stats_tree_init(stats_tree *st) {
+ st_node_ipv4_dsts = stats_tree_create_node(st, st_str_ipv4_dsts, 0, TRUE);
+}
+
+static void ipv6_dsts_stats_tree_init(stats_tree *st) {
+ st_node_ipv6_dsts = stats_tree_create_node(st, st_str_ipv6_dsts, 0, TRUE);
+}
+static int dsts_stats_tree_packet(stats_tree *st, packet_info *pinfo, int st_node, const gchar *st_str) {
+ static gchar str[128];
+ int ip_dst_node;
+ int protocol_node;
+
+ tick_stat_node(st, st_str, 0, FALSE);
+ ip_dst_node = tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node, TRUE);
+ protocol_node = tick_stat_node(st, port_type_to_str(pinfo->ptype), ip_dst_node, TRUE);
+ g_snprintf(str, sizeof(str) - 1, "%u", pinfo->destport);
+ tick_stat_node(st, str, protocol_node, TRUE);
return 1;
}
+static int ipv4_dsts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return dsts_stats_tree_packet(st, pinfo, st_node_ipv4_dsts, st_str_ipv4_dsts);
+}
+
+static int ipv6_dsts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
+ return dsts_stats_tree_packet(st, pinfo, st_node_ipv6_dsts, st_str_ipv6_dsts);
+}
+
/* packet length stats_tree -- test range node */
static int st_node_plen = -1;
static const gchar *st_str_plen = "Packet Lengths";
@@ -200,36 +283,6 @@ static int plen_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_disse
return 1;
}
-/* a tree example
- - IP
- - PROTO
- - PORT
-
-*/
-static int st_node_dsts = -1;
-static const gchar *st_str_dsts = "IP Statistics/IP Destinations";
-
-static void dsts_stats_tree_init(stats_tree *st) {
- st_node_dsts = stats_tree_create_node(st, st_str_dsts, 0, TRUE);
-}
-
-static int dsts_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
- static gchar str[128];
- int ip_dst_node;
- int protocol_node;
-
- tick_stat_node(st, st_str_dsts, 0, FALSE);
-
- ip_dst_node = tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node_dsts, TRUE);
-
- protocol_node = tick_stat_node(st,port_type_to_str(pinfo->ptype),ip_dst_node,TRUE);
-
- g_snprintf(str, sizeof(str),"%u",pinfo->destport);
- tick_stat_node(st,str,protocol_node,TRUE);
-
- return 1;
-}
-
/* register all pinfo trees */
void register_pinfo_stat_trees(void) {
module_t *stat_module;
@@ -239,11 +292,17 @@ void register_pinfo_stat_trees(void) {
UAT_END_FIELDS
};
- stats_tree_register_plugin("ip","ip_hosts",st_str_ip, 0, ip_hosts_stats_tree_packet, ip_hosts_stats_tree_init, NULL );
- stats_tree_register_plugin("ip","ip_srcdst",st_str_ip_srcdst, 0, ip_srcdst_stats_tree_packet, ip_srcdst_stats_tree_init, NULL );
- stats_tree_register_plugin("ip","ptype",st_str_ptype, 0, ptype_stats_tree_packet, ptype_stats_tree_init, NULL );
- stats_tree_register_with_group("frame","plen",st_str_plen, 0, plen_stats_tree_packet, plen_stats_tree_init, NULL, REGISTER_STAT_GROUP_GENERIC );
- stats_tree_register_plugin("ip","dests",st_str_dsts, 0, dsts_stats_tree_packet, dsts_stats_tree_init, NULL );
+ stats_tree_register_plugin("ip", "ip_hosts", st_str_ipv4, 0, ipv4_hosts_stats_tree_packet, ipv4_hosts_stats_tree_init, NULL );
+ stats_tree_register_plugin("ip", "ip_srcdst", st_str_ipv4_srcdst, 0, ipv4_srcdst_stats_tree_packet, ipv4_srcdst_stats_tree_init, NULL );
+ stats_tree_register_plugin("ip", "ptype", st_str_ipv4_ptype, 0, ipv4_ptype_stats_tree_packet, ipv4_ptype_stats_tree_init, NULL );
+ stats_tree_register_plugin("ip", "dests", st_str_ipv4_dsts, 0, ipv4_dsts_stats_tree_packet, ipv4_dsts_stats_tree_init, NULL );
+
+ stats_tree_register_plugin("ipv6", "ipv6_hosts", st_str_ipv6, 0, ipv6_hosts_stats_tree_packet, ipv6_hosts_stats_tree_init, NULL );
+ stats_tree_register_plugin("ipv6", "ipv6_srcdst", st_str_ipv6_srcdst, 0, ipv6_srcdst_stats_tree_packet, ipv6_srcdst_stats_tree_init, NULL );
+ stats_tree_register_plugin("ipv6", "ipv6_ptype", st_str_ipv6_ptype, 0, ipv6_ptype_stats_tree_packet, ipv6_ptype_stats_tree_init, NULL );
+ stats_tree_register_plugin("ipv6", "ipv6_dests", st_str_ipv6_dsts, 0, ipv6_dsts_stats_tree_packet, ipv6_dsts_stats_tree_init, NULL );
+
+ stats_tree_register_with_group("frame", "plen", st_str_plen, 0, plen_stats_tree_packet, plen_stats_tree_init, NULL, REGISTER_STAT_GROUP_GENERIC);
stat_module = prefs_register_stat("stat_tree", "Stats Tree", "Stats Tree", NULL);