*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* 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.
*/
-/* This module provides ProtocolHierarchyStatistics for tethereal */
+/* This module provides ProtocolHierarchyStatistics for tshark */
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "epan/proto.h"
#include <epan/tap.h>
#include <epan/stat_cmd_args.h>
-#include "register.h"
typedef struct _phs_t {
struct _phs_t *sibling;
int protocol;
const char *proto_name;
guint32 frames;
- guint32 bytes;
+ guint64 bytes;
} phs_t;
{
phs_t *rs=prs;
phs_t *tmprs;
- proto_tree *tree;
+ proto_node *node;
field_info *fi;
if(!edt){
return 0;
}
- for(tree=edt->tree->first_child;tree;tree=tree->next){
- fi=PITEM_FINFO(tree);
+ for(node=edt->tree->first_child;node;node=node->next){
+ fi=PNODE_FINFO(node);
/* first time we saw a protocol at this leaf */
if(rs->protocol==-1){
}
stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, " ");
}
- stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, rs->proto_name);
- printf("%-40s frames:%d bytes:%d\n",str, rs->frames, rs->bytes);
+ g_snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name);
+ printf("%-40s frames:%d bytes:%" G_GINT64_MODIFIER "d\n",str, rs->frames, rs->bytes);
phs_draw(rs->child, indentation+1);
}
}
const char *filter=NULL;
GString *error_string;
- if(!strcmp("io,phs",optarg)){
- filter="frame";
+ if(strcmp("io,phs",optarg)==0){
+ /* No arguments */
} else if(sscanf(optarg,"io,phs,%n",&pos)==0){
if(pos){
filter=optarg+pos;
- } else {
- /* We must use a filter to guarantee that edt->tree
- will be populated. "frame" matches everything so
- that one is used instead of no filter.
- */
- filter="frame";
}
} else {
- fprintf(stderr, "tethereal: invalid \"-z io,phs[,<filter>]\" argument\n");
+ fprintf(stderr, "tshark: invalid \"-z io,phs[,<filter>]\" argument\n");
exit(1);
}
rs=new_phs_t(NULL);
if(filter){
- rs->filter=g_malloc(strlen(filter)+1);
- strcpy(rs->filter, filter);
+ rs->filter=g_strdup(filter);
} else {
rs->filter=NULL;
}
- error_string=register_tap_listener("frame", rs, filter, NULL, protohierstat_packet, protohierstat_draw);
+ error_string=register_tap_listener("frame", rs, filter, TL_REQUIRES_PROTO_TREE, NULL, protohierstat_packet, protohierstat_draw);
if(error_string){
/* error, we failed to attach to the tap. clean up */
g_free(rs->filter);
g_free(rs);
- fprintf(stderr, "tethereal: Couldn't register io,phs tap: %s\n",
+ fprintf(stderr, "tshark: Couldn't register io,phs tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);