2 * protohierstat 2002 Ronnie Sahlberg
4 * $Id: tap-protocolinfo.c,v 1.1 2002/11/04 12:10:59 sahlberg Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /* This module provides Protocol Column Info tap for tethereal */
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
38 #include "epan/epan_dissect.h"
39 #include "epan/column-utils.h"
40 #include "epan/proto.h"
44 typedef struct _pci_t {
51 protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, void *dummy _U_)
58 gp=proto_get_finfo_ptr_array(edt->tree, rs->hf_index);
63 for(i=0;i<gp->len;i++){
64 str=proto_alloc_dfilter_string(gp->pdata[i], NULL);
65 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",str);
74 protocolinfo_init(char *optarg)
79 header_field_info *hfi;
81 if(!strncmp("proto,colinfo,",optarg,14)){
83 field=strchr(filter,',');
85 field+=1; /* skip the ',' */
89 fprintf(stderr, "tethereal: invalid \"-z proto,colinfo,<filter>,<field>\" argument\n");
93 hfi=proto_registrar_get_byname(field);
95 fprintf(stderr, "tethereal: Field \"%s\" does not exist.\n", field);
99 rs=g_malloc(sizeof(pci_t));
100 rs->hf_index=hfi->id;
101 if((field-filter)>1){
102 rs->filter=g_malloc(field-filter);
103 strncpy(rs->filter,filter,(field-filter)-1);
104 rs->filter[(field-filter)-1]=0;
109 if(register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL)){
110 /* error, we failed to attach to the tap. clean up */
116 fprintf(stderr,"tethereal: protocolinfo_init() failed to attach to tap.\n");
123 register_tap_listener_protocolinfo(void)
125 register_ethereal_tap("proto,colinfo,", protocolinfo_init, NULL, NULL);