*
* $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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* This module provides Protocol Column Info tap for tethereal */
+/* This module provides Protocol Column Info tap for tshark */
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "epan/column-utils.h"
#include "epan/proto.h"
#include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
+#include <epan/strutil.h>
#include "register.h"
typedef struct _pci_t {
* is to modify the columns, and if the columns aren't being
* displayed, that makes this tap somewhat pointless.
*
- * To prevent a crash, we check whether pinfo->cinfo is null
- * and, if so, we report that error and exit.
+ * To prevent a crash, we check whether INFO column is writable
+ * and, if not, we report that error and exit.
*/
- if (pinfo->cinfo == NULL) {
- fprintf(stderr, "tethereal: the proto,colinfo tap doesn't work if the columns aren't being printed.\n");
+ if (!check_col(pinfo->cinfo, COL_INFO)) {
+ fprintf(stderr, "tshark: the proto,colinfo tap doesn't work if the INFO column isn't being printed.\n");
exit(1);
}
gp=proto_get_finfo_ptr_array(edt->tree, rs->hf_index);
}
for(i=0;i<gp->len;i++){
- str=proto_construct_dfilter_string(gp->pdata[i], NULL);
+ str=proto_construct_match_selected_string(gp->pdata[i], NULL);
if(str){
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",str);
- g_free(str);
}
}
return 0;
static void
-protocolinfo_init(char *optarg)
+protocolinfo_init(const char *optarg, void* userdata _U_)
{
pci_t *rs;
- char *field=NULL;
- char *filter=NULL;
+ const char *field=NULL;
+ const char *filter=NULL;
header_field_info *hfi;
GString *error_string;
}
}
if(!field){
- fprintf(stderr, "tethereal: invalid \"-z proto,colinfo,<filter>,<field>\" argument\n");
+ fprintf(stderr, "tshark: invalid \"-z proto,colinfo,<filter>,<field>\" argument\n");
exit(1);
}
hfi=proto_registrar_get_byname(field);
if(!hfi){
- fprintf(stderr, "tethereal: Field \"%s\" doesn't exist.\n", field);
+ fprintf(stderr, "tshark: Field \"%s\" doesn't exist.\n", field);
exit(1);
}
rs->hf_index=hfi->id;
if((field-filter)>1){
rs->filter=g_malloc(field-filter);
- strncpy(rs->filter,filter,(field-filter)-1);
- rs->filter[(field-filter)-1]=0;
+ g_strlcpy(rs->filter,filter,(field-filter));
} else {
rs->filter=NULL;
}
- error_string=register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL);
+ error_string=register_tap_listener("frame", rs, rs->filter, TL_REQUIRES_PROTO_TREE, NULL, protocolinfo_packet, NULL);
if(error_string){
/* error, we failed to attach to the tap. complain and clean up */
- fprintf(stderr, "tethereal: Couldn't register proto,colinfo tap: %s\n",
+ fprintf(stderr, "tshark: Couldn't register proto,colinfo tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
- if(rs->filter){
- g_free(rs->filter);
- }
+ g_free(rs->filter);
g_free(rs);
exit(1);
void
register_tap_listener_protocolinfo(void)
{
- register_ethereal_tap("proto,colinfo,", protocolinfo_init);
+ register_stat_cmd_arg("proto,colinfo,", protocolinfo_init,NULL);
}