"hex_str_to_bytes()" modifies the GByteArray supplied to it, so don't
[obnox/wireshark/wip.git] / tap-protocolinfo.c
index c750466b89d50679909a416ab782f6defd2dcfea..eade2065be752f095c9e379d2ce6844eae30447b 100644 (file)
@@ -1,7 +1,7 @@
 /* tap-protocolinfo.c
  * protohierstat   2002 Ronnie Sahlberg
  *
- * $Id: tap-protocolinfo.c,v 1.1 2002/11/04 12:10:59 sahlberg Exp $
+ * $Id: tap-protocolinfo.c,v 1.4 2003/05/03 00:48:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -61,9 +61,11 @@ protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, void *du
        }
 
        for(i=0;i<gp->len;i++){
-               str=proto_alloc_dfilter_string(gp->pdata[i], NULL);
-               col_append_fstr(pinfo->cinfo, COL_INFO, "  %s",str);
-               g_free(str);
+               str=proto_construct_dfilter_string(gp->pdata[i], NULL);
+               if(str){
+                       col_append_fstr(pinfo->cinfo, COL_INFO, "  %s",str);
+                       g_free(str);
+               }
        }
        return 0;
 }
@@ -77,6 +79,7 @@ protocolinfo_init(char *optarg)
        char *field=NULL;
        char *filter=NULL;
        header_field_info *hfi;
+       GString *error_string;
 
        if(!strncmp("proto,colinfo,",optarg,14)){
                filter=optarg+14;
@@ -106,14 +109,17 @@ protocolinfo_init(char *optarg)
                rs->filter=NULL;
        }
 
-       if(register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL)){
-               /* error, we failed to attach to the tap. clean up */
+       error_string=register_tap_listener("frame", rs, rs->filter, 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",
+                   error_string->str);
+               g_string_free(error_string, TRUE);
                if(rs->filter){
                        g_free(rs->filter);
                }
                g_free(rs);
 
-               fprintf(stderr,"tethereal: protocolinfo_init() failed to attach to tap.\n");
                exit(1);
        }
 }
@@ -122,6 +128,6 @@ protocolinfo_init(char *optarg)
 void
 register_tap_listener_protocolinfo(void)
 {
-       register_ethereal_tap("proto,colinfo,", protocolinfo_init, NULL, NULL);
+       register_ethereal_tap("proto,colinfo,", protocolinfo_init);
 }