aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-http.c46
-rw-r--r--epan/dissectors/packet-isup.c11
-rw-r--r--epan/dissectors/packet-smpp.c5
-rw-r--r--epan/dissectors/packet-ucp.c16
-rw-r--r--epan/stats_tree.c252
-rw-r--r--epan/stats_tree.h90
-rw-r--r--epan/stats_tree_priv.h90
-rw-r--r--plugins/stats_tree/pinfo_stats_tree.c4
8 files changed, 285 insertions, 229 deletions
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 17c8f1f359..b7b83482fc 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -277,7 +277,9 @@ static int st_node_reqs_by_http_host = -1;
static int st_node_resps_by_srv_addr = -1;
/* HTTP/Load Distribution stats init function */
-static void http_reqs_stats_tree_init(stats_tree* st) {
+static void
+http_reqs_stats_tree_init(stats_tree* st)
+{
st_node_reqs = stats_tree_create_node(st, st_str_reqs, 0, TRUE);
st_node_reqs_by_srv_addr = stats_tree_create_node(st, st_str_reqs_by_srv_addr, st_node_reqs, TRUE);
st_node_reqs_by_http_host = stats_tree_create_node(st, st_str_reqs_by_http_host, st_node_reqs, TRUE);
@@ -285,7 +287,9 @@ static void http_reqs_stats_tree_init(stats_tree* st) {
}
/* HTTP/Load Distribution stats packet function */
-static int http_reqs_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_dissect_t* edt _U_, const void* p) {
+static int
+http_reqs_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_dissect_t* edt _U_, const void* p)
+{
const http_info_value_t* v = p;
int reqs_by_this_host;
int reqs_by_this_addr;
@@ -331,15 +335,19 @@ static int http_reqs_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_
static int st_node_requests_by_host = -1;
-static const guint8* st_str_requests_by_host = "HTTP Requests by HTTP Host";
+static const gchar *st_str_requests_by_host = "HTTP Requests by HTTP Host";
/* HTTP/Requests stats init function */
-static void http_req_stats_tree_init(stats_tree* st) {
+static void
+http_req_stats_tree_init(stats_tree* st)
+{
st_node_requests_by_host = stats_tree_create_node(st, st_str_requests_by_host, 0, TRUE);
}
/* HTTP/Requests stats packet function */
-static int http_req_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p) {
+static int
+http_req_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p)
+{
const http_info_value_t* v = p;
int reqs_by_this_host;
@@ -360,16 +368,16 @@ static int http_req_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, ep
return 0;
}
-static const guint8* st_str_packets = "Total HTTP Packets";
-static const guint8* st_str_requests = "HTTP Request Packets";
-static const guint8* st_str_responses = "HTTP Response Packets";
-static const guint8* st_str_resp_broken = "???: broken";
-static const guint8* st_str_resp_100 = "1xx: Informational";
-static const guint8* st_str_resp_200 = "2xx: Success";
-static const guint8* st_str_resp_300 = "3xx: Redirection";
-static const guint8* st_str_resp_400 = "4xx: Client Error";
-static const guint8* st_str_resp_500 = "5xx: Server Error";
-static const guint8* st_str_other = "Other HTTP Packets";
+static const gchar *st_str_packets = "Total HTTP Packets";
+static const gchar *st_str_requests = "HTTP Request Packets";
+static const gchar *st_str_responses = "HTTP Response Packets";
+static const gchar *st_str_resp_broken = "???: broken";
+static const gchar *st_str_resp_100 = "1xx: Informational";
+static const gchar *st_str_resp_200 = "2xx: Success";
+static const gchar *st_str_resp_300 = "3xx: Redirection";
+static const gchar *st_str_resp_400 = "4xx: Client Error";
+static const gchar *st_str_resp_500 = "5xx: Server Error";
+static const gchar *st_str_other = "Other HTTP Packets";
static int st_node_packets = -1;
static int st_node_requests = -1;
@@ -384,7 +392,9 @@ static int st_node_other = -1;
/* HTTP/Packet Counter stats init function */
-static void http_stats_tree_init(stats_tree* st) {
+static void
+http_stats_tree_init(stats_tree* st)
+{
st_node_packets = stats_tree_create_node(st, st_str_packets, 0, TRUE);
st_node_requests = stats_tree_create_pivot(st, st_str_requests, st_node_packets);
st_node_responses = stats_tree_create_node(st, st_str_responses, st_node_packets, TRUE);
@@ -398,7 +408,9 @@ static void http_stats_tree_init(stats_tree* st) {
}
/* HTTP/Packet Counter stats packet function */
-static int http_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p) {
+static int
+http_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p)
+{
const http_info_value_t* v = p;
guint i = v->response_code;
int resp_grp;
diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c
index cb089a5a7e..dcb252ab89 100644
--- a/epan/dissectors/packet-isup.c
+++ b/epan/dissectors/packet-isup.c
@@ -7228,12 +7228,16 @@ dissect_application_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static int st_node_msg = -1;
static int st_node_dir = -1;
-static void msg_stats_tree_init(stats_tree* st) {
+static void
+msg_stats_tree_init(stats_tree* st)
+{
st_node_msg = stats_tree_create_node(st, "Messages by Type", 0, TRUE);
st_node_dir = stats_tree_create_node(st, "Messages by Direction", 0, TRUE);
}
-static int msg_stats_tree_packet(stats_tree *st , packet_info *pinfo, epan_dissect_t *edt _U_, const void *p ) {
+static int
+msg_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p )
+{
const gchar* msg = match_strval(((const isup_tap_rec_t*)p)->message_type, isup_message_type_value_acro);
gchar src[MAX_ADDR_STR_LEN];
gchar dst[MAX_ADDR_STR_LEN];
@@ -8249,7 +8253,8 @@ proto_register_isup(void)
&isup_apm_desegment);
/* Register the stats_tree */
- stats_tree_register("isup","isup_msg","ISUP Messages", msg_stats_tree_packet, msg_stats_tree_init, NULL );
+ stats_tree_register("isup", "isup_msg", "ISUP Messages",
+ msg_stats_tree_packet, msg_stats_tree_init, NULL);
}
diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c
index a6acdc8956..9293e9aa94 100644
--- a/epan/dissectors/packet-smpp.c
+++ b/epan/dissectors/packet-smpp.c
@@ -227,7 +227,7 @@ static gboolean reassemble_over_tcp = TRUE;
static int smpp_tap = -1;
/* Stats Tree */
-static guint8* st_str_smpp = "SMPP Operations";
+static gchar* st_str_smpp = "SMPP Operations";
/*
* Value-arrays for field-contents
@@ -2880,5 +2880,6 @@ proto_reg_handoff_smpp(void)
DISSECTOR_ASSERT(gsm_sms_handle);
/* Tapping setup */
- stats_tree_register("smpp","smpp_commands", st_str_smpp, smpp_stats_tree_per_packet, smpp_stats_tree_init, NULL);
+ stats_tree_register("smpp","smpp_commands", st_str_smpp,
+ smpp_stats_tree_per_packet, smpp_stats_tree_init, NULL);
}
diff --git a/epan/dissectors/packet-ucp.c b/epan/dissectors/packet-ucp.c
index 82f85690a8..927886230d 100644
--- a/epan/dissectors/packet-ucp.c
+++ b/epan/dissectors/packet-ucp.c
@@ -110,12 +110,12 @@ static int st_ucp_results = -1;
static int st_ucp_results_pos = -1;
static int st_ucp_results_neg = -1;
-static guint8* st_str_ucp = "UCP Messages";
-static guint8* st_str_ops = "Operations";
-static guint8* st_str_res = "Results";
-static guint8* st_str_ucp_res = "UCP Results Acks/Nacks";
-static guint8* st_str_pos = "Positive";
-static guint8* st_str_neg = "Negative";
+static gchar* st_str_ucp = "UCP Messages";
+static gchar* st_str_ops = "Operations";
+static gchar* st_str_res = "Results";
+static gchar* st_str_ucp_res = "UCP Results Acks/Nacks";
+static gchar* st_str_pos = "Positive";
+static gchar* st_str_neg = "Negative";
/*
* Data (variable) section
@@ -2757,5 +2757,7 @@ proto_reg_handoff_ucp(void)
dissector_add_handle("tcp.port", ucp_handle);
/* Tapping setup */
- stats_tree_register("ucp", "ucp_messages", st_str_ucp, ucp_stats_tree_per_packet, ucp_stats_tree_init, NULL);
+ stats_tree_register("ucp", "ucp_messages", st_str_ucp,
+ ucp_stats_tree_per_packet, ucp_stats_tree_init,
+ NULL);
}
diff --git a/epan/stats_tree.c b/epan/stats_tree.c
index 71c66339d9..292cac1e9d 100644
--- a/epan/stats_tree.c
+++ b/epan/stats_tree.c
@@ -40,11 +40,13 @@ TODO:
*/
/* used to contain the registered stat trees */
-static GHashTable* registry = NULL;
+static GHashTable *registry = NULL;
/* writes into the buffers pointed by value, rate and percent
the string representations of a node*/
-extern void stats_tree_get_strs_from_node(const stat_node* node, guint8* value, guint8* rate, guint8* percent) {
+extern void
+stats_tree_get_strs_from_node(const stat_node *node, guint8 *value, guint8 *rate, guint8 *percent)
+{
float f;
if (value) g_snprintf(value,NUM_BUF_SIZE,"%u",node->counter);
@@ -69,8 +71,9 @@ extern void stats_tree_get_strs_from_node(const stat_node* node, guint8* value,
/* a text representation of a node
if buffer is NULL returns a newly allocated string */
-extern guint8* stats_tree_node_to_str(const stat_node* node,
- guint8* buffer, guint len) {
+extern gchar*
+stats_tree_node_to_str(const stat_node *node, gchar *buffer, guint len)
+{
if (buffer) {
g_snprintf(buffer,len,"%s: %i",node->name, node->counter);
return buffer;
@@ -79,8 +82,10 @@ extern guint8* stats_tree_node_to_str(const stat_node* node,
}
}
-extern guint stats_tree_branch_max_namelen(const stat_node* node, guint indent) {
- stat_node* child;
+extern guint
+stats_tree_branch_max_namelen(const stat_node *node, guint indent)
+{
+ stat_node *child;
guint maxlen = 0;
guint len;
@@ -99,12 +104,14 @@ extern guint stats_tree_branch_max_namelen(const stat_node* node, guint indent)
return maxlen;
}
-static gchar* format;
+static gchar *format;
/* populates the given GString with a tree representation of a branch given by node,
using indent spaces as initial indentation */
-extern void stats_tree_branch_to_str(const stat_node* node, GString* s, guint indent) {
- stat_node* child;
+extern void
+stats_tree_branch_to_str(const stat_node *node, GString *s, guint indent)
+{
+ stat_node *child;
static gchar indentation[INDENT_MAX+1];
static gchar value[NUM_BUF_SIZE];
static gchar rate[NUM_BUF_SIZE];
@@ -144,9 +151,11 @@ extern void stats_tree_branch_to_str(const stat_node* node, GString* s, guint in
/* frees the resources allocated by a stat_tree node */
-static void free_stat_node( stat_node* node ) {
- stat_node* child;
- stat_node* next;
+static void
+free_stat_node(stat_node *node)
+{
+ stat_node *child;
+ stat_node *next;
if (node->children) {
for (child = node->children; child; child = next ) {
@@ -168,19 +177,21 @@ static void free_stat_node( stat_node* node ) {
}
/* destroys the whole tree instance */
-extern void stats_tree_free(stats_tree* st) {
- stat_node* child;
- stat_node* next;
+extern void
+stats_tree_free(stats_tree *st)
+{
+ stat_node *child;
+ stat_node *next;
g_free(st->filter);
g_hash_table_destroy(st->names);
g_ptr_array_free(st->parents,TRUE);
- for (child = st->root.children; child; child = next ) {
- /* child->next will be gone after free_stat_node, so cache it here */
- next = child->next;
+ for (child = st->root.children; child; child = next ) {
+ /* child->next will be gone after free_stat_node, so cache it here */
+ next = child->next;
free_stat_node(child);
- }
+ }
if (st->cfg->free_tree_pr)
st->cfg->free_tree_pr(st);
@@ -193,8 +204,10 @@ extern void stats_tree_free(stats_tree* st) {
/* reset a node to its original state */
-static void reset_stat_node(stat_node* node) {
- stat_node* child;
+static void
+reset_stat_node(stat_node *node)
+{
+ stat_node *child;
if (node->children) {
for (child = node->children; child; child = child->next )
@@ -210,8 +223,10 @@ static void reset_stat_node(stat_node* node) {
}
/* reset the whole stats_tree */
-extern void stats_tree_reset(void* p) {
- stats_tree* st = p;
+extern void
+stats_tree_reset(void *p)
+{
+ stats_tree *st = p;
st->start = -1.0;
st->elapsed = 0.0;
@@ -223,10 +238,12 @@ extern void stats_tree_reset(void* p) {
}
}
-extern void stats_tree_reinit(void* p) {
- stats_tree* st = p;
- stat_node* child;
- stat_node* next;
+extern void
+stats_tree_reinit(void *p)
+{
+ stats_tree *st = p;
+ stat_node *child;
+ stat_node *next;
for (child = st->root.children; child; child = next) {
/* child->next will be gone after free_stat_node, so cache it here */
@@ -243,14 +260,13 @@ extern void stats_tree_reinit(void* p) {
}
/* register a new stats_tree */
-extern void stats_tree_register(const guint8* tapname,
- const guint8* abbr,
- const guint8* name,
- stat_tree_packet_cb packet,
- stat_tree_init_cb init,
- stat_tree_cleanup_cb cleanup) {
+extern void
+stats_tree_register(const char *tapname, const char *abbr, const char *name,
+ stat_tree_packet_cb packet, stat_tree_init_cb init,
+ stat_tree_cleanup_cb cleanup)
+{
- stats_tree_cfg* cfg = g_malloc( sizeof(stats_tree_cfg) );
+ stats_tree_cfg *cfg = g_malloc( sizeof(stats_tree_cfg) );
/* at the very least the abbrev and the packet function should be given */
g_assert( tapname && abbr && packet );
@@ -279,8 +295,10 @@ extern void stats_tree_register(const guint8* tapname,
}
-extern stats_tree* stats_tree_new(stats_tree_cfg* cfg, tree_pres* pr,char* filter) {
- stats_tree* st = g_malloc(sizeof(stats_tree));
+extern stats_tree*
+stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, char *filter)
+{
+ stats_tree *st = g_malloc(sizeof(stats_tree));
st->cfg = cfg;
st->pr = pr;
@@ -307,8 +325,10 @@ extern stats_tree* stats_tree_new(stats_tree_cfg* cfg, tree_pres* pr,char* filte
}
/* will be the tap packet cb */
-extern int stats_tree_packet(void* p, packet_info* pinfo, epan_dissect_t *edt, const void *pri) {
- stats_tree* st = p;
+extern int
+stats_tree_packet(void *p, packet_info *pinfo, epan_dissect_t *edt, const void *pri)
+{
+ stats_tree *st = p;
double now = nstime_to_msec(&pinfo->fd->rel_ts);
if (st->start < 0.0) st->start = now;
@@ -321,7 +341,9 @@ extern int stats_tree_packet(void* p, packet_info* pinfo, epan_dissect_t *edt, c
return 0;
}
-extern stats_tree_cfg* stats_tree_get_cfg_by_abbr(guint8* abbr) {
+extern stats_tree_cfg*
+stats_tree_get_cfg_by_abbr(char *abbr)
+{
return g_hash_table_lookup(registry,abbr);
}
@@ -331,14 +353,16 @@ struct _stats_tree_pres_cbs {
void (*free_node_pr)(stat_node*);
void (*draw_node)(stat_node*);
void (*reset_node)(stat_node*);
- tree_pres* (*new_tree_pr)(stats_tree*);
+ tree_pres *(*new_tree_pr)(stats_tree*);
void (*free_tree_pr)(stats_tree*);
void (*draw_tree)(stats_tree*);
void (*reset_tree)(stats_tree*);
};
-static void setup_tree_presentation(gpointer k _U_, gpointer v, gpointer p) {
- stats_tree_cfg* cfg = v;
+static void
+setup_tree_presentation(gpointer k _U_, gpointer v, gpointer p)
+{
+ stats_tree_cfg *cfg = v;
struct _stats_tree_pres_cbs *d = p;
cfg->in_use = FALSE;
@@ -353,16 +377,18 @@ static void setup_tree_presentation(gpointer k _U_, gpointer v, gpointer p) {
}
-extern void stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,gpointer),
- void (*setup_node_pr)(stat_node*),
- void (*free_node_pr)(stat_node*),
- void (*draw_node)(stat_node*),
- void (*reset_node)(stat_node*),
- tree_pres* (*new_tree_pr)(stats_tree*),
- void (*free_tree_pr)(stats_tree*),
- void (*draw_tree)(stats_tree*),
- void (*reset_tree)(stats_tree*),
- void* data) {
+extern void
+stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,gpointer),
+ void (*setup_node_pr)(stat_node*),
+ void (*free_node_pr)(stat_node*),
+ void (*draw_node)(stat_node*),
+ void (*reset_node)(stat_node*),
+ tree_pres *(*new_tree_pr)(stats_tree*),
+ void (*free_tree_pr)(stats_tree*),
+ void (*draw_tree)(stats_tree*),
+ void (*reset_tree)(stats_tree*),
+ void *data)
+{
static struct _stats_tree_pres_cbs d;
d.setup_node_pr = setup_node_pr;
@@ -388,14 +414,13 @@ extern void stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,
* with_hash: whether or not it should keep a hash with it's children names
* as_named_node: whether or not it has to be registered in the root namespace
*/
-static stat_node* new_stat_node(stats_tree* st,
- const gchar* name,
- int parent_id,
- gboolean with_hash,
- gboolean as_parent_node) {
+static stat_node*
+new_stat_node(stats_tree *st, const gchar *name, int parent_id,
+ gboolean with_hash, gboolean as_parent_node)
+{
stat_node *node = g_malloc (sizeof(stat_node));
- stat_node* last_chld = NULL;
+ stat_node *last_chld = NULL;
node->counter = 0;
node->name = g_strdup(name);
@@ -453,8 +478,10 @@ static stat_node* new_stat_node(stats_tree* st,
}
/***/
-extern int stats_tree_create_node(stats_tree* st, const gchar* name, int parent_id, gboolean with_hash) {
- stat_node* node = new_stat_node(st,name,parent_id,with_hash,TRUE);
+extern int
+stats_tree_create_node(stats_tree *st, const gchar *name, int parent_id, gboolean with_hash)
+{
+ stat_node *node = new_stat_node(st,name,parent_id,with_hash,TRUE);
if (node)
return node->id;
@@ -463,10 +490,10 @@ extern int stats_tree_create_node(stats_tree* st, const gchar* name, int parent_
}
/* XXX: should this be a macro? */
-extern int stats_tree_create_node_by_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name,
- gboolean with_children) {
+extern int
+stats_tree_create_node_by_pname(stats_tree *st, const gchar *name,
+ const gchar *parent_name, gboolean with_children)
+{
return stats_tree_create_node(st,name,stats_tree_parent_id_by_name(st,parent_name),with_children);
}
@@ -478,9 +505,12 @@ extern int stats_tree_create_node_by_pname(stats_tree* st,
* using parent_name as parent node.
* with_hash=TRUE to indicate that the created node will have a parent
*/
-extern int stats_tree_manip_node(manip_node_mode mode, stats_tree* st, const guint8* name, int parent_id, gboolean with_hash, gint value) {
- stat_node* node = NULL;
- stat_node* parent = NULL;
+extern int
+stats_tree_manip_node(manip_node_mode mode, stats_tree *st, const char *name,
+ int parent_id, gboolean with_hash, gint value)
+{
+ stat_node *node = NULL;
+ stat_node *parent = NULL;
g_assert( parent_id >= 0 && parent_id < (int) st->parents->len );
@@ -507,7 +537,9 @@ extern int stats_tree_manip_node(manip_node_mode mode, stats_tree* st, const gui
}
-extern guint8* stats_tree_get_abbr(const guint8* optarg) {
+extern char*
+stats_tree_get_abbr(const char *optarg)
+{
guint i;
/* XXX: this fails when tshark is given any options
@@ -540,9 +572,11 @@ extern guint8* stats_tree_get_abbr(const guint8* optarg) {
* returns NULL, it but may also return a pair with undefined values.
*
*/
-static range_pair_t* get_range(guint8* rngstr) {
- gchar** split;
- range_pair_t* rng;
+static range_pair_t*
+get_range(char *rngstr)
+{
+ gchar **split;
+ range_pair_t *rng;
split = g_strsplit((gchar*)rngstr,"-",2);
@@ -581,17 +615,16 @@ static range_pair_t* get_range(guint8* rngstr) {
}
-extern int stats_tree_create_range_node(stats_tree* st,
- const gchar* name,
- int parent_id,
- ...) {
+extern int
+stats_tree_create_range_node(stats_tree *st, const gchar *name, int parent_id, ...)
+{
va_list list;
- guint8* curr_range;
- stat_node* rng_root = new_stat_node(st, name, parent_id, FALSE, TRUE);
- stat_node* range_node = NULL;
+ gchar *curr_range;
+ stat_node *rng_root = new_stat_node(st, name, parent_id, FALSE, TRUE);
+ stat_node *range_node = NULL;
va_start( list, parent_id );
- while (( curr_range = va_arg(list, guint8*) )) {
+ while (( curr_range = va_arg(list, gchar*) )) {
range_node = new_stat_node(st, curr_range, rng_root->id, FALSE, FALSE);
range_node->rng = get_range(curr_range);
}
@@ -601,8 +634,10 @@ extern int stats_tree_create_range_node(stats_tree* st,
}
/****/
-extern int stats_tree_parent_id_by_name(stats_tree* st, const gchar* parent_name) {
- stat_node* node = g_hash_table_lookup(st->names,parent_name);
+extern int
+stats_tree_parent_id_by_name(stats_tree *st, const gchar *parent_name)
+{
+ stat_node *node = g_hash_table_lookup(st->names,parent_name);
if (node)
return node->id;
@@ -611,18 +646,18 @@ extern int stats_tree_parent_id_by_name(stats_tree* st, const gchar* parent_name
}
-extern int stats_tree_range_node_with_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name,
- ...) {
+extern int
+stats_tree_range_node_with_pname(stats_tree *st, const gchar *name,
+ const gchar *parent_name, ...)
+{
va_list list;
- guint8* curr_range;
- stat_node* range_node = NULL;
+ gchar *curr_range;
+ stat_node *range_node = NULL;
int parent_id = stats_tree_parent_id_by_name(st,parent_name);
- stat_node* rng_root = new_stat_node(st, name, parent_id, FALSE, TRUE);
+ stat_node *rng_root = new_stat_node(st, name, parent_id, FALSE, TRUE);
va_start( list, parent_name );
- while (( curr_range = va_arg(list, guint8*) )) {
+ while (( curr_range = va_arg(list, gchar*) )) {
range_node = new_stat_node(st, curr_range, rng_root->id, FALSE, FALSE);
range_node->rng = get_range(curr_range);
}
@@ -632,14 +667,14 @@ extern int stats_tree_range_node_with_pname(stats_tree* st,
}
-extern int stats_tree_tick_range(stats_tree* st,
- const gchar* name,
- int parent_id,
- int value_in_range) {
+extern int
+stats_tree_tick_range(stats_tree *st, const gchar *name, int parent_id,
+ int value_in_range)
+{
- stat_node* node = NULL;
- stat_node* parent = NULL;
- stat_node* child = NULL;
+ stat_node *node = NULL;
+ stat_node *parent = NULL;
+ stat_node *child = NULL;
gint floor, ceil;
if (parent_id >= 0 && parent_id < (int) st->parents->len) {
@@ -670,10 +705,10 @@ extern int stats_tree_tick_range(stats_tree* st,
return node->id;
}
-extern int stats_tree_create_pivot(stats_tree* st,
- const gchar* name,
- int parent_id) {
- stat_node* node = new_stat_node(st,name,parent_id,TRUE,TRUE);
+extern int
+stats_tree_create_pivot(stats_tree *st, const gchar *name, int parent_id)
+{
+ stat_node *node = new_stat_node(st,name,parent_id,TRUE,TRUE);
if (node)
return node->id;
@@ -681,11 +716,12 @@ extern int stats_tree_create_pivot(stats_tree* st,
return 0;
}
-extern int stats_tree_create_pivot_by_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name) {
+extern int
+stats_tree_create_pivot_by_pname(stats_tree *st, const gchar *name,
+ const gchar *parent_name)
+{
int parent_id = stats_tree_parent_id_by_name(st,parent_name);
- stat_node* node;
+ stat_node *node;
node = new_stat_node(st,name,parent_id,TRUE,TRUE);
@@ -695,11 +731,11 @@ extern int stats_tree_create_pivot_by_pname(stats_tree* st,
return 0;
}
-extern int stats_tree_tick_pivot(stats_tree* st,
- int pivot_id,
- const gchar* pivot_value) {
+extern int
+stats_tree_tick_pivot(stats_tree *st, int pivot_id, const gchar *pivot_value)
+{
- stat_node* parent = g_ptr_array_index(st->parents,pivot_id);
+ stat_node *parent = g_ptr_array_index(st->parents,pivot_id);
parent->counter++;
stats_tree_manip_node( MN_INCREASE, st, pivot_value, pivot_id, FALSE, 1);
diff --git a/epan/stats_tree.h b/epan/stats_tree.h
index b60a0a07d1..207a0670cd 100644
--- a/epan/stats_tree.h
+++ b/epan/stats_tree.h
@@ -39,9 +39,9 @@ typedef struct _stats_tree stats_tree;
/* tap packet callback for stats_tree */
typedef int (*stat_tree_packet_cb)(stats_tree*,
- packet_info*,
- epan_dissect_t*,
- const void *);
+ packet_info*,
+ epan_dissect_t*,
+ const void *);
/* stats_tree initialization callback */
typedef void (*stat_tree_init_cb)(stats_tree*);
@@ -55,14 +55,14 @@ typedef void (*stat_tree_cleanup_cb)(stats_tree*);
* packet: per packet callback
* init: tree initialization callback
*/
-extern void stats_tree_register(const guint8* tapname,
- const guint8* abbr,
- const guint8* name,
- stat_tree_packet_cb packet,
- stat_tree_init_cb init,
- stat_tree_cleanup_cb cleanup);
+extern void stats_tree_register(const gchar *tapname,
+ const gchar *abbr,
+ const gchar *name,
+ stat_tree_packet_cb packet,
+ stat_tree_init_cb init,
+ stat_tree_cleanup_cb cleanup);
-extern int stats_tree_parent_id_by_name(stats_tree* st, const gchar* parent_name);
+extern int stats_tree_parent_id_by_name(stats_tree *st, const gchar *parent_name);
/* Creates a node in the tree (to be used in the in init_cb)
* st: the stats_tree in which to create it
@@ -70,53 +70,53 @@ extern int stats_tree_parent_id_by_name(stats_tree* st, const gchar* parent_name
* parent_name: the name of the parent_node (NULL for root)
* with_children: TRUE if this node will have "dynamically created" children
*/
-extern int stats_tree_create_node(stats_tree* st,
- const gchar* name,
- int parent_id,
- gboolean with_children);
+extern int stats_tree_create_node(stats_tree *st,
+ const gchar *name,
+ int parent_id,
+ gboolean with_children);
/* creates a node using it's parent's tree name */
-extern int stats_tree_create_node_by_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name,
- gboolean with_children);
+extern int stats_tree_create_node_by_pname(stats_tree *st,
+ const gchar *name,
+ const gchar *parent_name,
+ gboolean with_children);
/* creates a node in the tree, that will contain a ranges list.
example:
stats_tree_create_range_node(st,name,parent,
- "-99","100-199","200-299","300-399","400-", NULL);
+ "-99","100-199","200-299","300-399","400-", NULL);
*/
-extern int stats_tree_create_range_node(stats_tree* st,
- const gchar* name,
- int parent_id,
- ...);
+extern int stats_tree_create_range_node(stats_tree *st,
+ const gchar *name,
+ int parent_id,
+ ...);
-extern int stats_tree_range_node_with_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name,
- ...);
+extern int stats_tree_range_node_with_pname(stats_tree *st,
+ const gchar *name,
+ const gchar *parent_name,
+ ...);
/* increases by one the ranged node and the sub node to whose range the value belongs */
-extern int stats_tree_tick_range(stats_tree* st,
- const gchar* name,
- int parent_id,
- int value_in_range);
+extern int stats_tree_tick_range(stats_tree *st,
+ const gchar *name,
+ int parent_id,
+ int value_in_range);
#define stats_tree_tick_range_by_pname(st,name,parent_name,value_in_range) \
stats_tree_tick_range((st),(name),stats_tree_parent_id_by_name((st),(parent_name),(value_in_range))
/* */
-extern int stats_tree_create_pivot(stats_tree* st,
- const gchar* name,
- int parent_id);
+extern int stats_tree_create_pivot(stats_tree *st,
+ const gchar *name,
+ int parent_id);
-extern int stats_tree_create_pivot_by_pname(stats_tree* st,
- const gchar* name,
- const gchar* parent_name);
+extern int stats_tree_create_pivot_by_pname(stats_tree *st,
+ const gchar *name,
+ const gchar *parent_name);
-extern int stats_tree_tick_pivot(stats_tree* st,
- int pivot_id,
- const gchar* pivot_value);
+extern int stats_tree_tick_pivot(stats_tree *st,
+ int pivot_id,
+ const gchar *pivot_value);
/*
* manipulates the value of the node whose name is given
@@ -126,11 +126,11 @@ extern int stats_tree_tick_pivot(stats_tree* st,
*/
typedef enum _manip_node_mode { MN_INCREASE, MN_SET } manip_node_mode;
extern int stats_tree_manip_node(manip_node_mode mode,
- stats_tree* st,
- const guint8* name,
- int parent_id,
- gboolean with_children,
- gint value);
+ stats_tree *st,
+ const gchar *name,
+ int parent_id,
+ gboolean with_children,
+ gint value);
#define increase_stat_node(st,name,parent_id,with_children,value) \
(stats_tree_manip_node(MN_INCREASE,(st),(name),(parent_id),(with_children),(value)))
diff --git a/epan/stats_tree_priv.h b/epan/stats_tree_priv.h
index b6688e028f..5c4a2d3c75 100644
--- a/epan/stats_tree_priv.h
+++ b/epan/stats_tree_priv.h
@@ -54,34 +54,34 @@ typedef struct _range_pair {
struct _stat_node {
gchar* name;
- int id;
+ int id;
/* the counter it keeps */
gint counter;
/* children nodes by name */
- GHashTable* hash;
+ GHashTable *hash;
/* the owner of this node */
- stats_tree* st;
+ stats_tree *st;
/* relatives */
- stat_node* parent;
- stat_node* children;
- stat_node* next;
+ stat_node *parent;
+ stat_node *children;
+ stat_node *next;
/* used to check if value is within range */
- range_pair_t* rng;
+ range_pair_t *rng;
/* node presentation data */
- st_node_pres* pr;
+ st_node_pres *pr;
};
struct _stats_tree {
/* the "class" from which it's derived */
- stats_tree_cfg* cfg;
+ stats_tree_cfg *cfg;
- char* filter;
+ char *filter;
/* times */
double start;
@@ -91,25 +91,25 @@ struct _stats_tree {
* key: parent node name
* value: parent node
*/
- GHashTable* names;
+ GHashTable *names;
/* used for quicker lookups of parent nodes */
- GPtrArray* parents;
+ GPtrArray *parents;
/*
* tree representation
* to be defined (if needed) by the implementations
*/
- tree_pres* pr;
+ tree_pres *pr;
/* every tree in nature has one */
- stat_node root;
+ stat_node root;
};
struct _stats_tree_cfg {
- guint8* abbr;
- guint8* name;
- guint8* tapname;
+ gchar* abbr;
+ gchar* name;
+ gchar* tapname;
gboolean in_use;
@@ -135,10 +135,10 @@ struct _stats_tree_cfg {
/*
* tree presentation callbacks
*/
- tree_cfg_pres* pr;
+ tree_cfg_pres *pr;
- tree_pres* (*new_tree_pr)(stats_tree*);
+ tree_pres *(*new_tree_pr)(stats_tree*);
void (*free_tree_pr)(stats_tree*);
void (*draw_tree)(stats_tree*);
void (*reset_tree)(stats_tree*);
@@ -146,57 +146,57 @@ struct _stats_tree_cfg {
/* guess what, this is it! */
extern void stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,gpointer),
- void (*setup_node_pr)(stat_node*),
- void (*free_node_pr)(stat_node*),
- void (*draw_node)(stat_node*),
- void (*reset_node)(stat_node*),
- tree_pres* (*new_tree_pr)(stats_tree*),
- void (*free_tree_pr)(stats_tree*),
- void (*draw_tree)(stats_tree*),
- void (*reset_tree)(stats_tree*),
- void* data);
-
-extern stats_tree* stats_tree_new(stats_tree_cfg* cfg, tree_pres* pr, char* filter);
+ void (*setup_node_pr)(stat_node*),
+ void (*free_node_pr)(stat_node*),
+ void (*draw_node)(stat_node*),
+ void (*reset_node)(stat_node*),
+ tree_pres *(*new_tree_pr)(stats_tree*),
+ void (*free_tree_pr)(stats_tree*),
+ void (*draw_tree)(stats_tree*),
+ void (*reset_tree)(stats_tree*),
+ void *data);
+
+extern stats_tree *stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, char *filter);
/* callback for taps */
extern int stats_tree_packet(void*, packet_info*, epan_dissect_t*, const void *);
/* callback for reset */
-extern void stats_tree_reset(void* p_st);
+extern void stats_tree_reset(void *p_st);
/* callback for clear */
-extern void stats_tree_reinit(void* p_st);
+extern void stats_tree_reinit(void *p_st);
/* callback for destoy */
-extern void stats_tree_free(stats_tree* st);
+extern void stats_tree_free(stats_tree *st);
/* given an optarg splits the abbr part
and returns a newly allocated buffer containing it */
-extern guint8* stats_tree_get_abbr(const guint8* optarg);
+extern gchar *stats_tree_get_abbr(const gchar *optarg);
/* obtains a stats tree from the registry given its abbr */
-extern stats_tree_cfg* stats_tree_get_cfg_by_abbr(guint8* abbr);
+extern stats_tree_cfg *stats_tree_get_cfg_by_abbr(gchar *abbr);
/* extracts node data as strings from a stat_node into
the buffers given by value, rate and precent
if NULL they are ignored */
-extern void stats_tree_get_strs_from_node(const stat_node* node,
- guint8* value,
- guint8* rate,
- guint8* percent);
+extern void stats_tree_get_strs_from_node(const stat_node *node,
+ guint8 *value,
+ guint8 *rate,
+ guint8 *percent);
/* populates the given GString with a tree representation of a branch given by node,
using indent spaces as indentation */
-extern void stats_tree_branch_to_str(const stat_node* node,
- GString* s,
- guint indent);
+extern void stats_tree_branch_to_str(const stat_node *node,
+ GString *s,
+ guint indent);
/* used to calcuate the size of the indentation and the longest string */
-extern guint stats_tree_branch_max_namelen(const stat_node* node, guint indent);
+extern guint stats_tree_branch_max_namelen(const stat_node *node, guint indent);
/* a text representation of a node,
if buffer is NULL returns a newly allocated string */
-extern guint8* stats_tree_node_to_str(const stat_node* node,
- guint8* buffer, guint len);
+extern gchar *stats_tree_node_to_str(const stat_node *node,
+ gchar *buffer, guint len);
#endif /* __STATS_TREE_PRIV_H */
diff --git a/plugins/stats_tree/pinfo_stats_tree.c b/plugins/stats_tree/pinfo_stats_tree.c
index 31b33a7855..cca4933049 100644
--- a/plugins/stats_tree/pinfo_stats_tree.c
+++ b/plugins/stats_tree/pinfo_stats_tree.c
@@ -58,7 +58,7 @@ static void ip_hosts_stats_tree_init(stats_tree* st) {
}
static 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];
+ static gchar str[128];
tick_stat_node(st, st_str_ip, 0, FALSE);
@@ -118,7 +118,7 @@ static void dsts_stats_tree_init(stats_tree* st) {
}
static int dsts_stats_tree_packet(stats_tree* st, packet_info* pinfo, epan_dissect_t *edt _U_, const void *p _U_) {
- static guint8 str[128];
+ static gchar str[128];
int ip_dst_node;
int proto_node;