Have "sap_capture_func()" return "capture_data" rather than

"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
This commit is contained in:
Guy Harris 1999-03-22 03:44:44 +00:00
parent dad4930e18
commit 8f70ffdda9
3 changed files with 19 additions and 10 deletions

View 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>
@ -39,6 +39,11 @@
#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) {

View 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>
@ -41,10 +41,13 @@
#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] = {

View File

@ -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 *);