From Edgar Gladkich:
[obnox/wireshark/wip.git] / tap-bootpstat.c
index 5b3b05c278ffa3ab47461a7a629f4d31fc1b4348..60f044edd968fb23adccd7df010609effa4e4498 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $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
 #endif
 
 #include <stdio.h>
+#include <string.h>
 
 #include "epan/packet_info.h"
-#include "tap.h"
+#include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
 #include "register.h"
-#include <string.h>
 
 
 typedef const char* bootp_info_value_t;
@@ -82,10 +83,10 @@ dhcpstat_reset(void *psp)
        g_hash_table_foreach( sp->hash, (GHFunc)dhcp_reset_hash, NULL); 
 }
 static int
-dhcpstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void *pri)
+dhcpstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri)
 {
        dhcpstat_t *sp=psp;
-       bootp_info_value_t value=pri;
+       const bootp_info_value_t value=pri;
        dhcp_message_type_t *sc;
 
        if (sp==NULL)
@@ -136,10 +137,10 @@ dhcpstat_draw(void *psp)
 /* When called, this function will create a new instance of tap-boopstat.
  */
 static void
-dhcpstat_init(char *optarg)
+dhcpstat_init(const char *optarg, void* userdata _U_)
 {
        dhcpstat_t *sp;
-       char            *filter=NULL;
+       const char      *filter=NULL;
        GString         *error_string;
        
        if (!strncmp (optarg, "bootp,stat,", 11)){
@@ -151,8 +152,7 @@ dhcpstat_init(char *optarg)
        sp = g_malloc( sizeof(dhcpstat_t) );
        sp->hash = g_hash_table_new( g_str_hash, g_str_equal);
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
@@ -162,6 +162,7 @@ dhcpstat_init(char *optarg)
                        "bootp",
                        sp,
                        filter,
+                       0,
                        dhcpstat_reset,
                        dhcpstat_packet,
                        dhcpstat_draw);
@@ -169,7 +170,7 @@ dhcpstat_init(char *optarg)
                /* error, we failed to attach to the tap. clean up */
                g_free(sp->filter);
                g_free(sp);
-               fprintf(stderr, "tethereal: Couldn't register dhcp,stat tap: %s\n",
+               fprintf(stderr, "tshark: Couldn't register dhcp,stat tap: %s\n",
                                error_string->str);
                g_string_free(error_string, TRUE);
                exit(1);
@@ -181,6 +182,6 @@ dhcpstat_init(char *optarg)
 void
 register_tap_listener_gtkdhcpstat(void)
 {
-       register_ethereal_tap("bootp,stat,", dhcpstat_init);
+       register_stat_cmd_arg("bootp,stat,", dhcpstat_init,NULL);
 }