Have "sap_capture_func()" return "capture_data" rather than
authorGuy Harris <guy@alum.mit.edu>
Mon, 22 Mar 1999 03:44:44 +0000 (03:44 -0000)
committerGuy Harris <guy@alum.mit.edu>
Mon, 22 Mar 1999 03:44:44 +0000 (03:44 -0000)
"dissect_data"; if you call "dissect_data()" with an argument list of
the type expected by a "capture_XXX()" routine, it won't do the right
thing (and may do the wrong thing, e.g. crash).

Have "sap_capture_func()" (and "sap_dissect_func()") return function
pointers rather than "void *"s, so that I don't make a mistake like the
above in the future....

svn path=/trunk/; revision=219

packet-data.c
packet-llc.c
packet.h

index e389ab56c63984ef7d5ba120b7b75dacf49a7eaf..77f5cde17c1123bbfe838c44818fd4abcf652bf4 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for raw data (default case)
  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
  *
- * $Id: packet-data.c,v 1.5 1998/11/12 00:06:25 gram Exp $
+ * $Id: packet-data.c,v 1.6 1999/03/22 03:44:43 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@unicom.net>
 #include "ethereal.h"
 #include "packet.h"
 
+void
+capture_data(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
+
+       ld->other++;
+}
 
 void
 dissect_data(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
index c5abf9a564e1157261ed2b01f112bea3b923c90e..a995afc9fa4530c4796f20d127e4b9256b27c143 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for IEEE 802.2 LLC layer
  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
  *
- * $Id: packet-llc.c,v 1.11 1999/02/09 00:35:37 guy Exp $
+ * $Id: packet-llc.c,v 1.12 1999/03/22 03:44:44 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@unicom.net>
 #include "packet.h"
 #include "etypes.h"
 
+typedef void (capture_func_t)(const u_char *, int, guint32, packet_counts *);
+typedef void (dissect_func_t)(const u_char *, int, frame_data *, GtkTree *);
+
 struct sap_info {
        guint8  sap;
-       void    (*capture_func) (const u_char *, int, guint32, packet_counts *);
-       void    (*dissect_func) (const u_char *, int, frame_data *, GtkTree *);
+       capture_func_t *capture_func;
+       dissect_func_t *dissect_func;
        char    *text;
 };
 
@@ -90,7 +93,7 @@ sap_text(u_char sap) {
        return "Unknown";
 }
 
-static void*
+static capture_func_t *
 sap_capture_func(u_char sap) {
        int i=0;
 
@@ -100,10 +103,10 @@ sap_capture_func(u_char sap) {
                }
                i++;
        }
-       return dissect_data;
+       return capture_data;
 }
 
-static void*
+static dissect_func_t *
 sap_dissect_func(u_char sap) {
        int i=0;
 
@@ -136,7 +139,7 @@ capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
 
        guint16         etype;
        int             is_snap;
-       void            (*capture) (const u_char *, int, guint32, packet_counts *);
+       capture_func_t  *capture;
 
        is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
        if (is_snap) {
@@ -166,7 +169,7 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
        GtkWidget       *llc_tree = NULL, *ti;
        guint16         etype;
        int             is_snap;
-       void            (*dissect) (const u_char *, int, frame_data *, GtkTree *);
+       dissect_func_t  *dissect;
 
        /* LLC Strings */
        char *llc_ctrl[4] = {
index af1aa134b88a5b1fd1d4725cdde892d6e5305fba..0d1c59b17282b50773f9650cdce8cc15fcf3b367 100644 (file)
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
 /* packet.h
  * Definitions for packet disassembly structures and routines
  *
- * $Id: packet.h,v 1.38 1999/02/15 06:36:57 guy Exp $
+ * $Id: packet.h,v 1.39 1999/03/22 03:44:44 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -545,6 +545,7 @@ void capture_tr(const u_char *, guint32, packet_counts *);
  * packet_counts *
  * They should never modify the packet data.
  */
+void capture_data(const u_char *, int, guint32, packet_counts *);
 void capture_llc(const u_char *, int, guint32, packet_counts *);
 void capture_ip(const u_char *, int, guint32, packet_counts *);