[Automatic manuf and enterprise-numbers update for 2010-04-04]
[obnox/wireshark/wip.git] / tap-wspstat.c
index a43a165ac6e77a2a203269bf2348cb1e8376a775..b5c285443c4d2461d082a2cb7e41492e4fa01fec 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
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-/* This module provides WSP  statistics to tethereal.
- * It is only used by tethereal and not ethereal
+/* This module provides WSP  statistics to tshark.
+ * It is only used by tshark and not wireshark
  *
  */
 
-/* With MSVC and a libethereal.dll this file needs to import some variables 
-   in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */   
-#define _NEED_VAR_IMPORT_
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 #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 "epan/value_string.h"
 #include <epan/dissectors/packet-wsp.h>
 
 /* used to keep track of the stats for a specific PDU type*/
 typedef struct _wsp_pdu_t {
-       gchar           *type;
+       const gchar     *type;
        guint32          packets;
 } wsp_pdu_t;
 /* used to keep track of RTT statistics */
 typedef struct _wsp_status_code_t {
-       gchar           *name;
+       const gchar     *name;
        guint32          packets;
 } wsp_status_code_t;
 /* used to keep track of the statictics for an entire program interface */
@@ -133,11 +130,11 @@ index2pdut(gint pdut)
        return 0;
 }
 static int
-wspstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void *pri)
+wspstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri)
 {
        wspstat_t *sp=psp;
-       wsp_info_value_t *value=pri;
-       gint index = pdut2index(value->pdut);
+       const wsp_info_value_t *value=pri;
+       gint idx = pdut2index(value->pdut);
        int retour=0;
 
        if (value->status_code != 0) {
@@ -163,20 +160,20 @@ wspstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void
 
                
 
-       if (index!=0) {
-               sp->pdu_stats[ index ].packets++;
+       if (idx!=0) {
+               sp->pdu_stats[ idx ].packets++;
                retour = 1;
        }
        return retour;
 }
 
 
-/* This callback is used when tethereal wants us to draw/update our
- * data to the output device. Since this is tethereal only output is
+/* This callback is used when tshark wants us to draw/update our
+ * data to the output device. Since this is tshark only output is
  * stdout.
- * Tethereal will only call this callback once, which is when tethereal has
+ * TShark will only call this callback once, which is when tshark has
  * finished reading all packets and exists.
- * If used with ethereal this may be called any time, perhaps once every 3 
+ * If used with wireshark this may be called any time, perhaps once every 3 
  * seconds or so.
  * This function may even be called in parallell with (*reset) or (*draw)
  * so make sure there are no races. The data in the rpcstat_t can thus change
@@ -212,15 +209,15 @@ wspstat_draw(void *psp)
 /* When called, this function will create a new instance of wspstat.
  * program and version are whick onc-rpc program/version we want to
  * collect statistics for.
- * This function is called from tethereal when it parses the -z wsp, arguments
+ * This function is called from tshark when it parses the -z wsp, arguments
  * and it creates a new instance to store statistics in and registers this
  * new instance for the wsp tap.
  */
 static void
-wspstat_init(char *optarg)
+wspstat_init(const char *optarg, void* userdata _U_)
 {
        wspstat_t *sp;
-       char *filter=NULL;
+       const char *filter=NULL;
        guint32 i;
        GString *error_string;
        wsp_status_code_t *sc;
@@ -250,8 +247,7 @@ wspstat_init(char *optarg)
        sp->num_pdus = 16;
        sp->pdu_stats=g_malloc( (sp->num_pdus+1) * sizeof( wsp_pdu_t) );
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
@@ -265,6 +261,7 @@ wspstat_init(char *optarg)
                        "wsp",
                        sp,
                        filter,
+                       0,
                        wspstat_reset,
                        wspstat_packet,
                        wspstat_draw);
@@ -275,7 +272,7 @@ wspstat_init(char *optarg)
                g_free(sp);
                g_hash_table_foreach( sp->hash, (GHFunc) wsp_free_hash_table, NULL ) ;
                g_hash_table_destroy( sp->hash );
-               fprintf(stderr, "tethereal: Couldn't register wsp,stat tap: %s\n",
+               fprintf(stderr, "tshark: Couldn't register wsp,stat tap: %s\n",
                                error_string->str);
                g_string_free(error_string, TRUE);
                exit(1);
@@ -284,5 +281,5 @@ wspstat_init(char *optarg)
 void 
 register_tap_listener_wspstat(void)
 {
-       register_ethereal_tap("wsp,stat,", wspstat_init);
+       register_stat_cmd_arg("wsp,stat,", wspstat_init,NULL);
 }