/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.227 2004/01/24 01:44:28 guy Exp $
+ * $Id: capture.c,v 1.228 2004/01/25 21:55:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
supplies, allowing us to display only the ones it does. */
cfile.drops = stats.ps_drop;
}
- switch (cf_read(&cfile, &err)) {
+ switch (cf_read(&cfile)) {
case READ_SUCCESS:
case READ_ERROR:
/* Edit capture files. We can delete records, adjust timestamps, or
* simply convert from one format to another format.
*
- * $Id: editcap.c,v 1.27 2004/01/18 16:21:12 jmayer Exp $
+ * $Id: editcap.c,v 1.28 2004/01/25 21:55:09 guy Exp $
*
* Originally written by Richard Sharpe.
* Improved by Guy Harris.
{
wtap *wth;
int i, err;
+ gchar *err_info;
callback_arg args;
extern char *optarg;
extern int optind;
}
- wth = wtap_open_offline(argv[optind], &err, FALSE);
+ wth = wtap_open_offline(argv[optind], &err, &err_info, FALSE);
if (!wth) {
-
fprintf(stderr, "editcap: Can't open %s: %s\n", argv[optind],
wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
exit(1);
}
for (i = optind + 2; i < argc; i++)
add_selection(argv[i]);
- wtap_loop(wth, 0, edit_callback, (char *)&args, &err);
+ if (!wtap_loop(wth, 0, edit_callback, (char *)&args, &err, &err_info)) {
+ /* Print a message noting that the read failed somewhere along the line. */
+ fprintf(stderr,
+ "editcap: An error occurred while reading \"%s\": %s.\n",
+ argv[optind], wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
+ }
if (!wtap_dump_close(args.pdh, &err)) {
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.348 2004/01/25 00:58:11 guy Exp $
+ * $Id: file.c,v 1.349 2004/01/25 21:55:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
gboolean (*match_function)(capture_file *, frame_data *, void *),
void *criterion);
-static char *cf_open_error_message(int err, gboolean for_writing,
- int file_type);
+static char *cf_open_error_message(int err, gchar *err_info,
+ gboolean for_writing, int file_type);
static char *file_rename_error_message(int err);
static char *cf_write_error_message(int);
static char *cf_close_error_message(int err);
{
wtap *wth;
int err;
+ gchar *err_info;
int fd;
struct stat cf_stat;
- wth = wtap_open_offline(fname, &err, TRUE);
+ wth = wtap_open_offline(fname, &err, &err_info, TRUE);
if (wth == NULL)
goto fail;
fail:
simple_dialog(ESD_TYPE_CRIT, NULL,
- cf_open_error_message(err, FALSE, 0), fname);
+ cf_open_error_message(err, err_info, FALSE, 0), fname);
return (err);
}
}
read_status_t
-cf_read(capture_file *cf, int *err)
+cf_read(capture_file *cf)
{
+ int err;
+ gchar *err_info;
gchar *name_ptr, *load_msg, *load_fmt = "%s";
size_t msg_len;
char *errmsg;
stop_flag = FALSE;
g_get_current_time(&start_time);
- while ((wtap_read(cf->wth, err, &data_offset))) {
+ while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
/* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
when we update it, we have to run the GTK+ main loop to get it
to repaint what's pending, and doing so may involve an "ioctl()"
if (cf->first_displayed != NULL)
packet_list_select_row(0);
- if (*err != 0) {
+ if (err != 0) {
/* Put up a message box noting that the read failed somewhere along
the line. Don't throw out the stuff we managed to read, though,
if any. */
- switch (*err) {
+ switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
errmsg = "The capture file is for a network type that Ethereal doesn't support.";
break;
case WTAP_ERR_BAD_RECORD:
- errmsg = "The capture file appears to be damaged or corrupt.";
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The capture file appears to be damaged or corrupt.\n(%s)",
+ err_info);
+ errmsg = errmsg_errno;
break;
default:
snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the"
- " capture file: %s.", wtap_strerror(*err));
+ " capture file: %s.", wtap_strerror(err));
errmsg = errmsg_errno;
break;
}
cf_continue_tail(capture_file *cf, int to_read, int *err)
{
long data_offset = 0;
+ gchar *err_info;
*err = 0;
packet_list_freeze();
- while (to_read != 0 && (wtap_read(cf->wth, err, &data_offset))) {
+ while (to_read != 0 && (wtap_read(cf->wth, err, &err_info, &data_offset))) {
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to exit Ethereal. Break out of the
loop, and let the code below (which is called even if there
read_status_t
cf_finish_tail(capture_file *cf, int *err)
{
+ gchar *err_info;
long data_offset;
packet_list_freeze();
- while ((wtap_read(cf->wth, err, &data_offset))) {
+ while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to abort the read. Break out of the
loop, and let the code below (which is called even if there
gboolean stop_flag;
int count;
int err;
+ gchar *err_info;
frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame;
int selected_row, prev_row, preceding_row, following_row;
gboolean selected_frame_seen;
}
if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len, &err)) {
+ cf->pd, fdata->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cf->filename);
+ cf_read_error_message(err, err_info), cf->filename);
break;
}
{
frame_data *fdata;
int err;
+ gchar *err_info;
union wtap_pseudo_header pseudo_header;
guint8 pd[WTAP_MAX_PACKET_SIZE+1];
psp_return_t ret = PSP_FINISHED;
/* Get the packet */
if (!wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header,
- pd, fdata->cap_len, &err)) {
+ pd, fdata->cap_len, &err, &err_info)) {
/* Attempt to get the packet failed. */
- simple_dialog(ESD_TYPE_CRIT, NULL, file_read_error_message(err),
+ simple_dialog(ESD_TYPE_CRIT, NULL, cf_read_error_message(err, err_info),
cf->filename);
ret = PSP_FAILED;
break;
gboolean stop_flag;
int count;
int err;
+ gchar *err_info;
int row;
float prog_val;
GTimeVal start_time;
if (fdata->flags.passed_dfilter) {
/* Yes. Load its data. */
if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len, &err)) {
+ cf->pd, fdata->cap_len, &err, &err_info)) {
/* Read error. Report the error, and go back to the frame
where we started. */
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cf->filename);
+ cf_read_error_message(err, err_info), cf->filename);
new_fd = start_fd;
break;
}
{
frame_data *fdata;
int err;
+ gchar *err_info;
/* Get the frame data struct pointer for this frame */
fdata = (frame_data *)packet_list_get_row_data(row);
/* Get the data in that frame. */
if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len, &err)) {
+ cf->pd, fdata->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cf->filename);
+ cf_read_error_message(err, err_info), cf->filename);
return;
}
pdh = wtap_dump_open(fname, save_format, cf->lnk_t, cf->snap, &err);
if (pdh == NULL) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- cf_open_error_message(err, TRUE, save_format), fname);
+ cf_open_error_message(err, NULL, TRUE, save_format), fname);
goto fail;
}
if ((err = cf_open(fname, FALSE, cf)) == 0) {
/* XXX - report errors if this fails?
What should we return if it fails or is aborted? */
- switch (cf_read(cf, &err)) {
+ switch (cf_read(cf)) {
case READ_SUCCESS:
case READ_ERROR:
}
static char *
-cf_open_error_message(int err, gboolean for_writing, int file_type)
+cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
+ int file_type)
{
char *errmsg;
static char errmsg_errno[1024+1];
break;
case WTAP_ERR_FILE_UNKNOWN_FORMAT:
- case WTAP_ERR_UNSUPPORTED:
/* Seen only when opening a capture file for reading. */
errmsg = "The file \"%s\" is not a capture file in a format Ethereal understands.";
break;
+ case WTAP_ERR_UNSUPPORTED:
+ /* Seen only when opening a capture file for reading. */
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" is not a capture file in a format Ethereal understands.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
case WTAP_ERR_CANT_WRITE_TO_PIPE:
/* Seen only when opening a capture file for writing. */
snprintf(errmsg_errno, sizeof(errmsg_errno),
break;
case WTAP_ERR_UNSUPPORTED_ENCAP:
+ if (for_writing)
+ errmsg = "Ethereal cannot save this capture in that format.";
+ else {
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" is a capture for a network type that Ethereal doesn't support.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ }
+ break;
+
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
if (for_writing)
errmsg = "Ethereal cannot save this capture in that format.";
break;
case WTAP_ERR_BAD_RECORD:
- errmsg = "The file \"%s\" appears to be damaged or corrupt.";
+ /* Seen only when opening a capture file for reading. */
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
break;
case WTAP_ERR_CANT_OPEN:
}
char *
-file_read_error_message(int err)
+cf_read_error_message(int err, gchar *err_info)
{
static char errmsg_errno[1024+1];
- snprintf(errmsg_errno, sizeof(errmsg_errno),
- "An error occurred while reading from the file \"%%s\": %s.",
- wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "An error occurred while reading from the file \"%%s\": %s.\n(%s)",
+ wtap_strerror(err), err_info);
+ break;
+
+ default:
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "An error occurred while reading from the file \"%%s\": %s.",
+ wtap_strerror(err));
+ break;
+ }
return errmsg_errno;
}
if (nread < 0) {
err = errno;
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), from_filename);
+ cf_read_error_message(err, NULL), from_filename);
close(from_fd);
close(to_fd);
goto done;
/* file.h
* Definitions for file structures and routines
*
- * $Id: file.h,v 1.114 2004/01/25 00:58:12 guy Exp $
+ * $Id: file.h,v 1.115 2004/01/25 21:55:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
int cf_open(char *, gboolean, capture_file *);
void cf_close(capture_file *);
-read_status_t cf_read(capture_file *, int *);
+read_status_t cf_read(capture_file *);
int cf_start_tail(char *, gboolean, capture_file *);
read_status_t cf_continue_tail(capture_file *, int, int *);
read_status_t cf_finish_tail(capture_file *, int *);
/* Copies a file. Returns 0 on failure, 1 on success */
int file_cp(char *from, char *to);
-char *file_read_error_message(int);
+char *cf_read_error_message(int, gchar *);
#endif /* file.h */
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.83 2004/01/20 02:21:17 ulfl Exp $
+ * $Id: file_dlg.c,v 1.84 2004/01/25 21:55:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
gtk_widget_hide(GTK_WIDGET (fs));
gtk_widget_destroy(GTK_WIDGET (fs));
- switch (cf_read(&cfile, &err)) {
+ switch (cf_read(&cfile)) {
case READ_SUCCESS:
case READ_ERROR:
file_reload_cmd_cb(GtkWidget *w _U_, gpointer data _U_) {
gchar *filename;
gboolean is_tempfile;
- int err;
/* If the file could be opened, "cf_open()" calls "cf_close()"
to get rid of state for the old capture file before filling in state
is_tempfile = cfile.is_tempfile;
cfile.is_tempfile = FALSE;
if (cf_open(filename, is_tempfile, &cfile) == 0) {
- switch (cf_read(&cfile, &err)) {
+ switch (cf_read(&cfile)) {
case READ_SUCCESS:
case READ_ERROR:
/* main.c
*
- * $Id: main.c,v 1.374 2004/01/25 18:51:25 ulfl Exp $
+ * $Id: main.c,v 1.375 2004/01/25 21:55:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
gchar *buf=NULL;
int len;
int err;
+ gchar *err_info;
if (fdata != NULL) {
if (!wtap_seek_read(cfile.wth, fdata->file_off, &cfile.pseudo_header,
- cfile.pd, fdata->cap_len, &err)) {
+ cfile.pd, fdata->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cfile.filename);
+ cf_read_error_message(err, err_info), cfile.filename);
return NULL;
}
}
/* Read the capture file. */
- switch (cf_read(&cfile, &err)) {
+ switch (cf_read(&cfile)) {
case READ_SUCCESS:
case READ_ERROR:
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.146 2004/01/23 16:10:09 ulfl Exp $
+ * $Id: menu.c,v 1.147 2004/01/25 21:55:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
menu_open_recent_file_cmd_cb(GtkWidget *w, gpointer unused _U_)
{
GtkWidget *submenu_recent_files;
- int err;
GtkWidget *menu_item_child;
gchar *cf_name;
-
+ int err;
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
- /* get capture filename from the menu item label */
+ /* get capture filename from the menu item label */
menu_item_child = (GTK_BIN(w))->child;
gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
/* open and read the capture file (this will close an existing file) */
if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
- cf_read(&cfile, &err);
+ cf_read(&cfile);
} else {
/* the capture file isn't existing any longer, remove menu item */
/* XXX: ask user to remove item, it's maybe only a temporary problem */
/* rtp_analysis.c
* RTP analysis addition for ethereal
*
- * $Id: rtp_analysis.c,v 1.26 2004/01/25 02:14:05 guy Exp $
+ * $Id: rtp_analysis.c,v 1.27 2004/01/25 21:55:11 guy Exp $
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <lars.ruoff@gmx.net>
capture_file *cf;
epan_dissect_t *edt;
gint err;
+ gchar *err_info;
gboolean frame_matched;
frame_data *fdata;
GList *strinfo_list;
return; /* if we exit here it's an error */
/* dissect the current frame */
- if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, cf->pd, fdata->cap_len, &err)) {
+ if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
+ cf->pd, fdata->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL, NULL,
- file_read_error_message(err), cf->filename);
+ cf_read_error_message(err, err_info), cf->filename);
return;
}
edt = epan_dissect_new(TRUE, FALSE);
* By Pavel Mores <pvl@uh.cz>
* Win32 port: rwh@unifiedtech.com
*
- * $Id: tcp_graph.c,v 1.46 2004/01/21 21:19:34 ulfl Exp $
+ * $Id: tcp_graph.c,v 1.47 2004/01/25 21:55:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
struct segment current;
int condition;
int err;
+ gchar *err_info;
debug(DBS_FENTRY) puts ("graph_segment_list_get()");
get_headers (cfile.current_frame, cfile.pd, ¤t);
for (ptr=cfile.plist; ptr; ptr=ptr->next) {
if (!wtap_seek_read (cfile.wth, ptr->file_off, &pseudo_header,
- pd, ptr->cap_len, &err)) {
+ pd, ptr->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err),
- cfile.filename);
+ cf_read_error_message(err, err_info),
+ cfile.filename);
break;
}
if (!segment)
/* Combine two dump files, either by appending or by merging by timestamp
*
- * $Id: mergecap.c,v 1.15 2004/01/18 16:21:12 jmayer Exp $
+ * $Id: mergecap.c,v 1.16 2004/01/25 21:55:10 guy Exp $
*
* Written by Scott Renfro <scott@renfro.org> based on
* editcap by Richard Sharpe and Guy Harris
const char *filename;
wtap *wth;
int err;
+ gchar *err_info;
long data_offset;
gboolean ok;
} in_file_t;
{
int i;
int err;
+ gchar *err_info;
for (i = 0; i < count; i++) {
if (!wtap_loop(in_files[i].wth, 0, write_frame,
- (guchar*)out_file->pdh, &err)) {
- fprintf(stderr, "mergecap: Error appending from %s to %s: %s\n",
- in_files[i].filename, out_file->filename, wtap_strerror(err));
+ (guchar*)out_file->pdh, &err, &err_info)) {
+ fprintf(stderr, "mergecap: Error reading %s to append to %s: %s\n",
+ in_files[i].filename, out_file->filename, wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
}
}
}
/* prime the pump (read in first frame from each file) */
for (i = 0; i < count; i++) {
in_files[i].ok = wtap_read(in_files[i].wth, &(in_files[i].err),
+ &(in_files[i].err_info),
&(in_files[i].data_offset));
}
wtap_pseudoheader(in_files[i].wth),
wtap_buf_ptr(in_files[i].wth));
in_files[i].ok = wtap_read(in_files[i].wth, &(in_files[i].err),
- &(in_files[i].data_offset));
+ &(in_files[i].err_info),
+ &(in_files[i].data_offset));
}
}
int i;
int count = 0;
int err;
+ gchar *err_info;
in_file_t *files;
int files_size = argc * sizeof(in_file_t);
for (i = 0; i < argc; i++) {
files[count].filename = argv[i];
- files[count].wth = wtap_open_offline(argv[i], &err, FALSE);
+ files[count].wth = wtap_open_offline(argv[i], &err, &err_info, FALSE);
files[count].err = 0;
files[count].data_offset = 0;
files[count].ok = TRUE;
if (!files[count].wth) {
fprintf(stderr, "mergecap: skipping %s: %s\n", argv[i],
wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
} else {
if (verbose) {
fprintf(stderr, "mergecap: %s is type %s.\n", argv[i],
/* proto_hier_stats.c
* Routines for calculating statistics based on protocol.
*
- * $Id: proto_hier_stats.c,v 1.22 2004/01/21 22:00:28 ulfl Exp $
+ * $Id: proto_hier_stats.c,v 1.23 2004/01/25 21:55:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
union wtap_pseudo_header phdr;
guint8 pd[WTAP_MAX_PACKET_SIZE];
int err;
+ gchar *err_info;
/* Load the frame from the capture file */
if (!wtap_seek_read(cfile.wth, frame->file_off, &phdr, pd,
- frame->cap_len, &err)) {
+ frame->cap_len, &err, &err_info)) {
simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cfile.filename);
+ cf_read_error_message(err, err_info), cfile.filename);
return FALSE; /* failure */
}
/* tethereal.c
*
- * $Id: tethereal.c,v 1.226 2004/01/25 01:19:48 guy Exp $
+ * $Id: tethereal.c,v 1.227 2004/01/25 21:55:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
static void wtap_dispatch_cb_print(guchar *, const struct wtap_pkthdr *, long,
union wtap_pseudo_header *, const guchar *);
static void show_print_file_io_error(int err);
-static char *cf_open_error_message(int err, gboolean for_writing,
- int file_type);
+static char *cf_open_error_message(int err, gchar *err_info,
+ gboolean for_writing, int file_type);
#ifdef HAVE_LIBPCAP
#ifndef _WIN32
static void adjust_header(loop_data *, struct pcap_hdr *, struct pcaprec_hdr *);
if (ld.pdh == NULL) {
snprintf(errmsg, sizeof errmsg,
- cf_open_error_message(err, TRUE, out_file_type),
+ cf_open_error_message(err, NULL, TRUE, out_file_type),
*cfile.save_file == '\0' ? "stdout" : cfile.save_file);
goto error;
}
int snapshot_length;
wtap_dumper *pdh;
int err;
+ gchar *err_info;
int success;
cb_args_t args;
args.cf = cf;
args.pdh = pdh;
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb_write, (guchar *) &args,
- &err);
-
- /* Now close the capture file. */
- if (!wtap_dump_close(pdh, &err))
- show_capture_file_io_error(cfile.save_file, err, TRUE);
+ &err, &err_info);
} else {
- args.cf = cf;
- args.pdh = NULL;
print_preamble(stdout, print_format);
if (ferror(stdout)) {
err = errno;
show_print_file_io_error(err);
goto out;
}
+ args.cf = cf;
+ args.pdh = NULL;
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb_print, (guchar *) &args,
- &err);
+ &err, &err_info);
}
if (success) {
- if (cf->save_file == NULL) {
+ if (cf->save_file != NULL) {
+ /* Now close the capture file. */
+ if (!wtap_dump_close(args.pdh, &err))
+ show_capture_file_io_error(cfile.save_file, err, TRUE);
+ } else {
print_finale(stdout, print_format);
if (ferror(stdout)) {
err = errno;
}
}
} else {
- /* Print up a message box noting that the read failed somewhere along
- the line. */
+ /* Print a message noting that the read failed somewhere along the line. */
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
fprintf(stderr,
-"tethereal: \"%s\" is a capture file is for a network type that Tethereal doesn't support.\n",
- cf->filename);
+"tethereal: \"%s\" is a capture file is for a network type that Tethereal doesn't support.\n(%s)\n",
+ cf->filename, err_info);
break;
case WTAP_ERR_CANT_READ:
case WTAP_ERR_BAD_RECORD:
fprintf(stderr,
-"tethereal: \"%s\" appears to be damaged or corrupt.\n",
- cf->filename);
+"tethereal: \"%s\" appears to be damaged or corrupt.\n(%s)\n",
+ cf->filename, err_info);
break;
default:
cf->filename, wtap_strerror(err));
break;
}
+ if (cf->save_file != NULL) {
+ /* Now close the capture file. */
+ if (!wtap_dump_close(args.pdh, &err))
+ show_capture_file_io_error(cfile.save_file, err, TRUE);
+ }
}
out:
}
static char *
-cf_open_error_message(int err, gboolean for_writing, int file_type)
+cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
+ int file_type)
{
char *errmsg;
static char errmsg_errno[1024+1];
break;
case WTAP_ERR_FILE_UNKNOWN_FORMAT:
- case WTAP_ERR_UNSUPPORTED:
/* Seen only when opening a capture file for reading. */
errmsg = "The file \"%s\" is not a capture file in a format Tethereal understands.";
break;
+ case WTAP_ERR_UNSUPPORTED:
+ /* Seen only when opening a capture file for reading. */
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" is not a capture file in a format Tethereal understands.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
case WTAP_ERR_CANT_WRITE_TO_PIPE:
/* Seen only when opening a capture file for writing. */
snprintf(errmsg_errno, sizeof(errmsg_errno),
break;
case WTAP_ERR_UNSUPPORTED_ENCAP:
+ if (for_writing)
+ errmsg = "Tethereal cannot save this capture in that format.";
+ else {
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" is a capture for a network type that Tethereal doesn't support.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ }
+ break;
+
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
if (for_writing)
errmsg = "Tethereal cannot save this capture in that format.";
break;
case WTAP_ERR_BAD_RECORD:
- errmsg = "The file \"%s\" appears to be damaged or corrupt.";
+ /* Seen only when opening a capture file for reading. */
+ snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The file \"%%s\" appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
break;
case WTAP_ERR_CANT_OPEN:
{
wtap *wth;
int err;
+ gchar *err_info;
char err_msg[2048+1];
- wth = wtap_open_offline(fname, &err, FALSE);
+ wth = wtap_open_offline(fname, &err, &err_info, FALSE);
if (wth == NULL)
goto fail;
return (0);
fail:
- snprintf(err_msg, sizeof err_msg, cf_open_error_message(err, FALSE, 0),
- fname);
+ snprintf(err_msg, sizeof err_msg,
+ cf_open_error_message(err, err_info, FALSE, 0), fname);
fprintf(stderr, "tethereal: %s\n", err_msg);
return (err);
}
/* 5views.c
*
- * $Id: 5views.c,v 1.3 2003/10/01 07:11:46 guy Exp $
+ * $Id: 5views.c,v 1.4 2004/01/25 21:55:11 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */
#define CST_5VW_SYSTEM_RECORD 0x00000000
-static gboolean _5views_read(wtap *wth, int *err, long *data_offset);
-static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length,int *err);
-static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err);
-static gboolean _5views_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
+static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length,
+ int *err);
+static int _5views_read_header(wtap *wth, FILE_T fh,
+ t_5VW_TimeStamped_Header *hdr, int *err);
+static gboolean _5views_seek_read(wtap *wth, long seek_off,
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err);
-int _5views_open(wtap *wth, int *err)
+int _5views_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
t_5VW_Capture_Header Capture_Header;
break;
default:
- g_message("5views: header version %u unsupported", Capture_Header.Info_Header.Version);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("5views: header version %u unsupported", Capture_Header.Info_Header.Version);
return -1;
}
pletohl(&Capture_Header.Info_Header.FileType);
if((Capture_Header.Info_Header.FileType & CST_5VW_CAPTURE_FILE_TYPE_MASK) != CST_5VW_CAPTURE_FILEID)
{
- g_message("5views: file is not a capture file (filetype is %u)", Capture_Header.Info_Header.Version);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("5views: file is not a capture file (filetype is %u)", Capture_Header.Info_Header.Version);
return -1;
}
break;
*/
default:
- g_message("5views: network type %u unknown or unsupported",
- Capture_Header.Info_Header.FileType);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("5views: network type %u unknown or unsupported",
+ Capture_Header.Info_Header.FileType);
return -1;
}
/* Read the next packet */
static gboolean
-_5views_read(wtap *wth, int *err, long *data_offset)
+_5views_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset)
{
t_5VW_TimeStamped_Header TimeStamped_Header;
int bytes_read;
static gboolean
_5views_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
/* 5views.h
*
- * $Id: 5views.h,v 1.1 2003/07/29 19:42:00 guy Exp $
+ * $Id: 5views.h,v 1.2 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __5VIEWS_H__
#define __5VIEWS_H__
-int _5views_open(wtap *wth, int *err);
+int _5views_open(wtap *wth, int *err, gchar **err_info);
gboolean _5views_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int _5views_dump_can_write_encap(int encap);
/* airopeek9.c
* Routines for opening AiroPeek V9 files
*
- * $Id: airopeek9.c,v 1.3 2003/12/03 19:47:36 guy Exp $
+ * $Id: airopeek9.c,v 1.4 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
static const unsigned int mac2unix = 2082844800u;
-static gboolean airopeek_read_v9(wtap *wth, int *err, long *data_offset);
+static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean airopeek_seek_read_v9(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static int wtap_file_read_pattern (wtap *wth, char *pattern, int *err)
{
}
-int airopeek9_open(wtap *wth, int *err)
+int airopeek9_open(wtap *wth, int *err, gchar **err_info)
{
airopeek_section_header_t ap_hdr;
int ret;
/* If we got this far, we assume it's an AiroPeek V9 file. */
if (fileVersion != 9) {
/* We only support version 9 and later. */
- g_message("airopeekv9: version %u unsupported", fileVersion);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("airopeekv9: version %u unsupported",
+ fileVersion);
return -1;
}
if (ret == -1)
return -1;
if (ret == 0) {
- g_message("airopeekv9: <MediaType> tag not found");
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup("airopeekv9: <MediaType> tag not found");
return -1;
}
/* XXX - this appears to be 0, which is also the media type for
if (ret == -1)
return -1;
if (ret == 0) {
- g_message("airopeekv9: <MediaType> value not found");
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup("airopeekv9: <MediaType> value not found");
return -1;
}
return 1;
}
-static gboolean airopeek_read_v9(wtap *wth, int *err, long *data_offset)
+static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
guchar ap_pkt[AIROPEEK_V9_PKT_SIZE];
guint32 length;
static gboolean
airopeek_seek_read_v9(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
guchar ap_pkt[AIROPEEK_V9_PKT_SIZE];
/* airopeek9.h
*
- * $Id: airopeek9.h,v 1.1 2003/12/02 19:37:05 guy Exp $
+ * $Id: airopeek9.h,v 1.2 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __W_AIROPEEK9_H__
#define __W_AIROPEEK9_H__
-int airopeek9_open(wtap *wth, int *err);
+int airopeek9_open(wtap *wth, int *err, gchar **err_info);
#endif
%{
/* ascend-grammar.y
*
- * $Id: ascend-grammar.y,v 1.25 2004/01/06 20:05:39 guy Exp $
+ * $Id: ascend-grammar.y,v 1.26 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define NO_USER "<none>"
-extern int at_eof;
-
int yyparse(void);
void yyerror(char *);
-unsigned int bcur = 0, bcount;
-guint32 start_time, secs, usecs, caplen, wirelen;
-ascend_pkthdr *header;
+gchar *ascend_parse_error;
+
+static unsigned int bcur = 0, bcount;
+static guint32 start_time, secs, usecs, caplen, wirelen;
+static ascend_pkthdr *header;
struct ascend_phdr *pseudo_header;
-guint8 *pkt_data;
+static guint8 *pkt_data;
%}
}
void
-yyerror (char *s _U_)
+yyerror (char *s)
{
+ ascend_parse_error = s;
}
* Definitions for routines common to multiple modules in the Lucent/Ascend
* capture file reading code code, but not used outside that code.
*
- * $Id: ascend-int.h,v 1.10 2004/01/06 20:05:39 guy Exp $
+ * $Id: ascend-int.h,v 1.11 2004/01/25 21:55:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
guint32 len;
} ascend_pkthdr;
+extern int at_eof;
+
+extern gchar *ascend_parse_error;
+
/*
* Pointer to the pseudo-header for the current packet.
*/
/* ascend.c
*
- * $Id: ascend.c,v 1.31 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: ascend.c,v 1.32 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define ASCEND_W1_SIZE (sizeof ascend_w1magic / sizeof ascend_w1magic[0])
#define ASCEND_W2_SIZE (sizeof ascend_w2magic / sizeof ascend_w2magic[0])
-static gboolean ascend_read(wtap *wth, int *err, long *data_offset);
-static gboolean ascend_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
+static gboolean ascend_seek_read(wtap *wth, long seek_off,
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static void ascend_close(wtap *wth);
/* Seeks to the beginning of the next packet, and returns the
return packet_off;
}
-int ascend_open(wtap *wth, int *err)
+int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
{
long offset;
struct stat statbuf;
}
/* Read the next packet; called from wtap_loop(). */
-static gboolean ascend_read(wtap *wth, int *err, long *data_offset)
+static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset;
guint8 *buf = buffer_start_ptr(wth->frame_buffer);
return FALSE;
if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, 0)) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
}
return TRUE;
}
-static gboolean ascend_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err)
+static gboolean ascend_seek_read(wtap *wth, long seek_off,
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
if (! parse_ascend(wth->random_fh, pd, &pseudo_header->ascend, NULL, len)) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
}
return TRUE;
/* ascend.h
*
- * $Id: ascend.h,v 1.9 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: ascend.h,v 1.10 2004/01/25 21:55:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define ASCEND_MAX_DATA_COLS 16
#define ASCEND_MAX_PKT_LEN (ASCEND_MAX_DATA_ROWS * ASCEND_MAX_DATA_COLS)
-int ascend_open(wtap *wth, int *err);
+int ascend_open(wtap *wth, int *err, gchar **err_info);
#endif
/* cosine.c
*
- * $Id: cosine.c,v 1.7 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: cosine.c,v 1.8 2004/01/25 21:55:12 guy Exp $
*
* CoSine IPNOS L2 debug output parsing
* Copyright (c) 2002 by Motonori Shindo <mshindo@mshindo.net>
static gboolean empty_line(const gchar *line);
static long cosine_seek_next_packet(wtap *wth, int *err, char *hdr);
static gboolean cosine_check_file_type(wtap *wth, int *err);
-static gboolean cosine_read(wtap *wth, int *err, long *data_offset);
+static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean cosine_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd,
- int len, int *err);
+ int len, int *err, gchar **err_info);
static int parse_cosine_rec_hdr(wtap *wth, const char *line,
- union wtap_pseudo_header *pseudo_header, int *err);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static int parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf,
- int *err);
+ int *err, gchar **err_info);
static int parse_single_hex_dump_line(char* rec, guint8 *buf,
guint byte_offset);
}
-int cosine_open(wtap *wth, int *err)
+int cosine_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* Look for CoSine header */
if (!cosine_check_file_type(wth, err)) {
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean cosine_read(wtap *wth, int *err, long *data_offset)
+static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset;
guint8 *buf;
return FALSE;
/* Parse the header */
- pkt_len = parse_cosine_rec_hdr(wth, line, &wth->pseudo_header, err);
+ pkt_len = parse_cosine_rec_hdr(wth, line, &wth->pseudo_header, err,
+ err_info);
if (pkt_len == -1)
return FALSE;
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- if ((caplen = parse_cosine_hex_dump(wth->fh, pkt_len, buf, err)) == -1)
+ if ((caplen = parse_cosine_hex_dump(wth->fh, pkt_len, buf, err,
+ err_info)) == -1)
return FALSE;
wth->data_offset = offset;
/* Used to read packets in random-access fashion */
static gboolean
cosine_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err)
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info)
{
char line[COSINE_LINE_LENGTH];
return FALSE;
}
- if (parse_cosine_rec_hdr(NULL, line, pseudo_header, err) == -1)
+ if (parse_cosine_rec_hdr(NULL, line, pseudo_header, err, err_info) == -1)
return FALSE;
- return parse_cosine_hex_dump(wth->random_fh, len, pd, err);
+ return parse_cosine_hex_dump(wth->random_fh, len, pd, err, err_info);
}
/* Parses a packet record header. There are two possible formats:
2) output to PE without date and time
l2-tx (FR:3/7/1:1), Length:18, Pro:0, Off:0, Pri:0, RM:0, Err:0 [0x4000, 0x0] */
static int
-parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseudo_header, int *err)
+parse_cosine_rec_hdr(wtap *wth, const char *line,
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
int num_items_scanned;
int yy, mm, dd, hr, min, sec, csec, pkt_len;
if (num_items_scanned != 17) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("cosine: purported control blade line doesn't have code values");
return -1;
}
} else {
if (num_items_scanned != 10) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("cosine: header line is neither control blade nor PE output");
return -1;
}
yy = mm = dd = hr = min = sec = csec = 0;
/* Converts ASCII hex dump to binary data. Returns the capture length.
If any error is encountered, -1 is returned. */
static int
-parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
+parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
+ gchar **err_info)
{
gchar line[COSINE_LINE_LENGTH];
int i, hex_lines, n, caplen = 0;
}
if ((n = parse_single_hex_dump_line(line, buf, i*16)) == -1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("cosine: hex dump line doesn't have 16 numbers");
return -1;
}
caplen += n;
/* cosine.h
*
- * $Id: cosine.h,v 1.2 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: cosine.h,v 1.3 2004/01/25 21:55:12 guy Exp $
*
* CoSine IPNOS L2 debug output parsing
* Copyright (c) 2002 by Motonori Shindo <mshindo@mshindo.net>
#ifndef __W_COSINE_H__
#define __W_COSINE_H__
-int cosine_open(wtap *wth, int *err);
+int cosine_open(wtap *wth, int *err, gchar **err_info);
#endif
/* csids.c
*
- * $Id: csids.c,v 1.15 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: csids.c,v 1.16 2004/01/25 21:55:12 guy Exp $
*
* Copyright (c) 2000 by Mike Hall <mlh@io.com>
* Copyright (c) 2000 by Cisco Systems
* ethereal.
*/
-static gboolean csids_read(wtap *wth, int *err, long *data_offset);
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean csids_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static void csids_close(wtap *wth);
struct csids_header {
};
/* XXX - return -1 on I/O error and actually do something with 'err'. */
-int csids_open(wtap *wth, int *err)
+int csids_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* There is no file header. There is only a header for each packet
* so we read a packet header and compare the caplen with iplen. They
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean csids_read(wtap *wth, int *err, long *data_offset)
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
guint8 *buf;
int bytesRead = 0;
union wtap_pseudo_header *pseudo_header _U_,
guint8 *pd,
int len,
- int *err)
+ int *err,
+ gchar **err_info)
{
int bytesRead;
struct csids_header hdr;
if( len != hdr.caplen ) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("csids: record length %u doesn't match requested length %d",
+ hdr.caplen, len);
return FALSE;
}
/* csids.h
*
- * $Id: csids.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: csids.h,v 1.4 2004/01/25 21:55:13 guy Exp $
*
* Copyright (c) 2000 by Mike Hall <mlh@io.com>
* Copyright (c) Cisco Systems
#ifndef __CSIDS_H__
#define __CSIDS_H__
-int csids_open(wtap *wth, int *err);
+int csids_open(wtap *wth, int *err, gchar **err_info);
#endif
/* dbs-etherwatch.c
*
- * $Id: dbs-etherwatch.c,v 1.14 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: dbs-etherwatch.c,v 1.15 2004/01/25 21:55:13 guy Exp $
*
* Wiretap Library
* Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
*/
#define DBS_ETHERWATCH_MAX_PACKET_LEN 16384
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset);
+static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean dbs_etherwatch_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static int parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf,
- int *err);
+ int *err, gchar **err_info);
static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
int byte_offset);
static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end);
}
-int dbs_etherwatch_open(wtap *wth, int *err)
+int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* Look for DBS ETHERWATCH header */
if (!dbs_etherwatch_check_file_type(wth, err)) {
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset)
+static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset;
guint8 *buf;
buf = buffer_start_ptr(wth->frame_buffer);
/* Parse the packet */
- pkt_len = parse_dbs_etherwatch_packet(wth, wth->fh, buf, err);
+ pkt_len = parse_dbs_etherwatch_packet(wth, wth->fh, buf, err, err_info);
if (pkt_len == -1)
return FALSE;
static gboolean
dbs_etherwatch_seek_read (wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int len, int *err)
+ guint8 *pd, int len, int *err, gchar **err_info)
{
int pkt_len;
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return FALSE;
- pkt_len = parse_dbs_etherwatch_packet(NULL, wth->random_fh, pd, err);
+ pkt_len = parse_dbs_etherwatch_packet(NULL, wth->random_fh, pd, err,
+ err_info);
if (pkt_len != len) {
- if (pkt_len != -1)
+ if (pkt_len != -1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("dbs_etherwatch: packet length %d doesn't match requested length %d",
+ pkt_len, len);
+ }
return FALSE;
}
#define CTL_UNNUMB_MASK 0x03
#define CTL_UNNUMB_VALUE 0x03
static int
-parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
+parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
+ gchar **err_info)
{
char line[DBS_ETHERWATCH_LINE_LENGTH];
int num_items_scanned;
p = strstr(line, DEST_MAC_PREFIX);
if(!p) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: destination address not found");
return -1;
}
p += strlen(DEST_MAC_PREFIX);
if(parse_hex_dump(p, &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END)
!= MAC_ADDR_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: destination address not valid");
return -1;
}
eth_hdr_len += MAC_ADDR_LENGTH;
if(parse_hex_dump(p, &buf[eth_hdr_len], HEX_HDR_SPR,
HEX_HDR_END) != MAC_ADDR_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: source address not valid");
return -1;
}
eth_hdr_len += MAC_ADDR_LENGTH;
/* Check the lines is as least as long as the length position */
if(strlen(line) < LENGTH_POS) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: line too short");
return -1;
}
if (num_items_scanned != 8) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: header line not valid");
return -1;
}
if(parse_hex_dump(&line[PROTOCOL_POS], &buf[eth_hdr_len], HEX_HDR_SPR,
HEX_HDR_END) != PROTOCOL_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
return -1;
}
eth_hdr_len += PROTOCOL_LENGTH;
if(parse_hex_dump(&line[SAP_POS], &buf[eth_hdr_len], HEX_HDR_SPR,
HEX_HDR_END) != SAP_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid");
return -1;
}
eth_hdr_len += SAP_LENGTH;
if(parse_hex_dump(&line[CTL_POS], &buf[eth_hdr_len], HEX_HDR_SPR,
HEX_HDR_END) != CTL_UNNUMB_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid");
return -1;
}
/* Determine whether the control is numbered, and thus longer */
&buf[eth_hdr_len + CTL_UNNUMB_LENGTH], HEX_HDR_END,
HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid");
return -1;
}
eth_hdr_len += CTL_NUMB_LENGTH;
if(parse_hex_dump(&line[PID_POS], &buf[eth_hdr_len], HEX_HDR_SPR,
HEX_PID_END) != PID_LENGTH) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
return -1;
}
eth_hdr_len += PID_LENGTH;
if (!(line_count = parse_single_hex_dump_line(line,
&buf[eth_hdr_len + count], count))) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: packet data value not valid");
return -1;
}
count += line_count;
if (count > pkt_len) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes");
return -1;
}
}
/* Parse a hex dump */
static guint
parse_hex_dump(char* dump, guint8 *buf, char seperator, char end) {
-
int pos, count;
/* Parse the hex dump */
/* dbs-etherwatch.h
*
- * $Id: dbs-etherwatch.h,v 1.4 2003/01/17 23:54:19 guy Exp $
+ * $Id: dbs-etherwatch.h,v 1.5 2004/01/25 21:55:13 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __W_DBS_ETHERWATCH_H__
#define __W_DBS_ETHERWATCH_H__
-int dbs_etherwatch_open(wtap *wth, int *err);
+int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info);
#endif
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
-* $Id: erf.c,v 1.6 2004/01/05 17:33:27 ulfl Exp $
+* $Id: erf.c,v 1.7 2004/01/25 21:55:13 guy Exp $
*/
/*
erf_header_t *erf_header,
erf_t *erf,
int *err,
+ gchar **err_info,
guint32 *bytes_read,
guint32 *packet_size);
-static gboolean erf_read(wtap *wth, int *err, long *data_offset);
+static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean erf_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd,
- int length, int *err);
+ int length, int *err, gchar **err_info);
static void erf_close(wtap *wth);
static int erf_encap_to_wtap_encap(erf_t *erf, guint8 erf_encap);
static void erf_set_pseudo_header(
int length,
union wtap_pseudo_header *pseudo_header);
-int erf_open(wtap *wth, int *err)
+int erf_open(wtap *wth, int *err, gchar **err_info _U_)
{
guint32 i, n;
char *s;
}
/* Read the next packet */
-static gboolean erf_read(wtap *wth, int *err, long *data_offset)
+static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
erf_header_t erf_header;
guint32 packet_size, bytes_read;
if (!erf_read_header(
wth->fh,
&wth->phdr, &wth->pseudo_header, &erf_header, wth->capture.erf,
- err, &bytes_read, &packet_size)) {
+ err, err_info, &bytes_read, &packet_size)) {
return FALSE;
}
wth->data_offset += bytes_read;
static gboolean erf_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd,
- int length, int *err)
+ int length, int *err, gchar **err_info)
{
erf_header_t erf_header;
guint32 packet_size;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- erf_read_header(wth->random_fh, NULL, pseudo_header, &erf_header, wth->capture.erf, err, NULL, &packet_size);
+ if (!erf_read_header(wth->random_fh, NULL, pseudo_header, &erf_header,
+ wth->capture.erf, err, err_info, NULL, &packet_size))
+ return FALSE;
if (wth->capture.erf->is_rawatm) {
wtap_file_read_expected_bytes(pd, (int)sizeof(atm_hdr_t), wth->random_fh, err);
erf_header_t *erf_header,
erf_t *erf,
int *err,
+ gchar **err_info,
guint32 *bytes_read,
guint32 *packet_size)
{
* Probably a corrupt capture file; don't blow up trying
* to allocate space for an immensely-large packet.
*/
- g_message("erf: File has %u-byte packet, bigger than maximum of %u",
- *packet_size, WTAP_MAX_PACKET_SIZE);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("erf: File has %u-byte packet, bigger than maximum of %u",
+ *packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
case TYPE_ATM:
case TYPE_AAL5:
-
if (phdr != NULL) {
if (erf_header->type == TYPE_AAL5) {
phdr->caplen = phdr->len = *packet_size - sizeof(atm_hdr_t);
break;
default:
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("erf: unknown record encapsulation %u",
+ erf_header->type);
return FALSE;
}
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
-* $Id: erf.h,v 1.1 2003/08/26 07:10:38 guy Exp $
+* $Id: erf.h,v 1.2 2004/01/25 21:55:13 guy Exp $
*/
#ifndef __W_ERF_H__
#define HDLC_WLEN(h, e) (g_htons((h)->wlen))
#define HDLC_SLEN(h, e) min(HDLC_WLEN(h, e), g_htons((h)->rlen) - sizeof(*(h)))
-int erf_open(wtap *wth, int *err);
+int erf_open(wtap *wth, int *err, gchar **err_info);
#endif /* __W_ERF_H__ */
* Routines for opening EtherPeek (and TokenPeek?) files
* Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net>
*
- * $Id: etherpeek.c,v 1.25 2003/12/18 03:43:40 guy Exp $
+ * $Id: etherpeek.c,v 1.26 2004/01/25 21:55:13 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define NUM_ETHERPEEK_ENCAPS \
(sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0]))
-static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset);
+static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
-static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
+static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean etherpeek_seek_read_v56(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static void etherpeek_close(wtap *wth);
-int etherpeek_open(wtap *wth, int *err)
+int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
{
etherpeek_header_t ep_hdr;
struct timeval reference_time;
g_free(wth->capture.etherpeek);
}
-static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset)
+static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE];
guint16 protoNum;
* We don't *have* 4 bytes of packet data.
*/
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("etherpeek: packet not long enough for 802.11 radio header");
return FALSE;
}
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->fh, err);
static gboolean
etherpeek_seek_read_v7(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info)
{
guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE];
guint8 status;
* We don't *have* 4 bytes of packet data.
*/
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("etherpeek: packet not long enough for 802.11 radio header");
return FALSE;
}
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->random_fh,
return TRUE;
}
-static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset)
+static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
guint16 length;
static gboolean
etherpeek_seek_read_v56(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
int pkt_encap;
/* etherpeek.h
*
- * $Id: etherpeek.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: etherpeek.h,v 1.4 2004/01/25 21:55:13 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __W_ETHERPEEK_H__
#define __W_ETHERPEEK_H__
-int etherpeek_open(wtap *wth, int *err);
+int etherpeek_open(wtap *wth, int *err, gchar **err_info);
#endif
/* file_access.c
*
- * $Id: file_access.c,v 1.8 2003/12/02 19:37:05 guy Exp $
+ * $Id: file_access.c,v 1.9 2004/01/25 21:55:13 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
* should be discovered as a libpcap file, not a toshiba file.
*/
-static int (*const open_routines[])(wtap *, int *) = {
+static int (*const open_routines[])(wtap *, int *, char **) = {
/* Files that have magic bytes in fixed locations. These
* are easy to identify.
*/
so that it can do sequential I/O to a capture file that's being
written to as new packets arrive independently of random I/O done
to display protocol trees for packets when they're selected. */
-wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
+wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
+ gboolean do_random)
{
struct stat statb;
wtap *wth;
return NULL;
}
wth->data_offset = 0;
- switch ((*open_routines[i])(wth, err)) {
+ switch ((*open_routines[i])(wth, err, err_info)) {
case -1:
/* I/O error - give up */
/* hcidump.c
*
- * $Id: hcidump.c,v 1.2 2003/10/30 11:53:48 guy Exp $
+ * $Id: hcidump.c,v 1.3 2004/01/25 21:55:13 guy Exp $
*
* Copyright (c) 2003 by Marcel Holtmann <marcel@holtmann.org>
*
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
-static gboolean hcidump_read(wtap *wth, int *err, long *data_offset)
+static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
struct dump_hdr dh;
guint8 *buf;
* Probably a corrupt capture file; don't blow up trying
* to allocate space for an immensely-large packet.
*/
- g_message("hcidump: File has %u-byte packet, bigger than maximum of %u",
- packet_size, WTAP_MAX_PACKET_SIZE);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
+ packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
return TRUE;
}
-static gboolean hcidump_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int length, int *err)
+static gboolean hcidump_seek_read(wtap *wth, long seek_off,
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int length,
+ int *err, gchar **err_info _U_)
{
struct dump_hdr dh;
int bytes_read;
return TRUE;
}
-int hcidump_open(wtap *wth, int *err)
+int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
{
struct dump_hdr dh;
guint8 type;
/* hcidump.h
*
- * $Id: hcidump.h,v 1.1 2003/10/30 03:11:02 guy Exp $
+ * $Id: hcidump.h,v 1.2 2004/01/25 21:55:14 guy Exp $
*
* Copyright (c) 2003 by Marcel Holtmann <marcel@holtmann.org>
*
#ifndef __HCIDUMP_H__
#define __HCIDUMP_H__
-int hcidump_open(wtap *wth, int *err);
+int hcidump_open(wtap *wth, int *err, gchar **err_info);
#endif
/* i4btrace.c
*
- * $Id: i4btrace.c,v 1.23 2002/10/31 07:12:41 guy Exp $
+ * $Id: i4btrace.c,v 1.24 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
#include "buffer.h"
#include "i4b_trace.h"
-static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset);
+static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean i4btrace_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err);
static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
(unsigned)hdr.type > 4 || (unsigned)hdr.dir > 2 || \
(unsigned)hdr.trunc > 2048))
-int i4btrace_open(wtap *wth, int *err)
+int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
{
int bytes_read;
i4b_trace_hdr_t hdr;
return 1;
}
-#define V120SABME "\010\001\177"
-
/* Read the next packet */
-static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset)
+static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
int ret;
i4b_trace_hdr_t hdr;
i4b_byte_swap_header(wth, &hdr);
if (hdr.length < sizeof(hdr)) {
*err = WTAP_ERR_BAD_RECORD; /* record length < header! */
+ *err_info = g_strdup_printf("i4btrace: record length %u < header length %u",
+ hdr.length, sizeof(hdr));
return FALSE;
}
length = hdr.length - sizeof(hdr);
static gboolean
i4btrace_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
int ret;
i4b_trace_hdr_t hdr;
/* i4btrace.h
*
- * $Id: i4btrace.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: i4btrace.h,v 1.4 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
#ifndef __I4BTRACE_H__
#define __I4BTRACE_H__
-int i4btrace_open(wtap *wth, int *err);
+int i4btrace_open(wtap *wth, int *err, gchar **err_info);
#endif
/* iptrace.c
*
- * $Id: iptrace.c,v 1.49 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: iptrace.c,v 1.50 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#include "atm.h"
#include "iptrace.h"
-static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset);
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
-static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset);
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
int *err);
union wtap_pseudo_header *pseudo_header, guint8 *header);
static int wtap_encap_ift(unsigned int ift);
-int iptrace_open(wtap *wth, int *err)
+int iptrace_open(wtap *wth, int *err, gchar **err_info _U_)
{
int bytes_read;
char name[12];
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
int ret;
guint32 packet_size;
wth->phdr.ts.tv_usec = 0;
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
- g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
- pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
+ pkt_hdr.if_type);
return FALSE;
}
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err)
+ int *err, gchar **err_info _U_)
{
int ret;
guint8 header[IPTRACE_1_0_PHDR_SIZE];
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
int ret;
guint32 packet_size;
wth->phdr.ts.tv_usec = pntohl(&header[36]) / 1000;
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
- g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
- pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
+ pkt_hdr.if_type);
return FALSE;
}
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err)
+ int *err, gchar **err_info _U_)
{
int ret;
guint8 header[IPTRACE_2_0_PHDR_SIZE];
/* iptrace.h
*
- * $Id: iptrace.h,v 1.7 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: iptrace.h,v 1.8 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __IPTRACE_H__
#define __IPTRACE_H__
-int iptrace_open(wtap *wth, int *err);
+int iptrace_open(wtap *wth, int *err, gchar **err_info);
#endif
/* lanalyzer.c
*
- * $Id: lanalyzer.c,v 1.45 2004/01/07 04:50:21 guy Exp $
+ * $Id: lanalyzer.c,v 1.46 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
-static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset);
+static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean lanalyzer_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static void lanalyzer_close(wtap *wth);
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
-int lanalyzer_open(wtap *wth, int *err)
+int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char LE_record_type[2];
wth->file_encap = WTAP_ENCAP_TOKEN_RING;
break;
default:
- g_message("lanalyzer: board type %u unknown",
- board_type);
g_free(wth->capture.lanalyzer);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("lanalyzer: board type %u unknown",
+ board_type);
return -1;
}
break;
#define DESCRIPTOR_LEN 32
/* Read the next packet */
-static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset)
+static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
int packet_size = 0;
int bytes_read;
* the middle of reading packets. If any other record type exists
* after a Trace Packet Data Record, mark it as an error. */
if (record_type != RT_PacketData) {
- g_message("lanalyzer: record type %u seen after trace summary record",
- record_type);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record",
+ record_type);
return FALSE;
}
else {
/*
* Yes - treat this as an error.
*/
- g_message("lanalyzer: Record length is less than packet size");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("lanalyzer: Record length is less than packet size");
return FALSE;
}
}
static gboolean lanalyzer_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
int bytes_read;
/* lanalyzer.h
*
- * $Id: lanalyzer.h,v 1.8 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: lanalyzer.h,v 1.9 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
int lastlen;
} LA_TmpInfo;
-int lanalyzer_open(wtap *wth, int *err);
+int lanalyzer_open(wtap *wth, int *err, gchar **err_info);
gboolean lanalyzer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int lanalyzer_dump_can_write_encap(int encap);
/* libpcap.c
*
- * $Id: libpcap.c,v 1.107 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: libpcap.c,v 1.108 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
} libpcap_try_t;
static libpcap_try_t libpcap_try(wtap *wth, int *err);
-static gboolean libpcap_read(wtap *wth, int *err, long *data_offset);
+static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean libpcap_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
-static int libpcap_read_header(wtap *wth, int *err,
- struct pcaprec_ss990915_hdr *hdr, gboolean silent);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
+static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
+ struct pcaprec_ss990915_hdr *hdr);
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
static void libpcap_get_atm_pseudoheader(const struct sunatm_hdr *atm_phdr,
union wtap_pseudo_header *pseudo_header);
static gboolean libpcap_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean libpcap_get_irda_pseudoheader(const struct irda_sll_hdr *irda_phdr,
- union wtap_pseudo_header *pseudo_header, int *err);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean libpcap_read_irda_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void libpcap_close(wtap *wth);
}
-int libpcap_open(wtap *wth, int *err)
+int libpcap_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
guint32 magic;
}
if (hdr.version_major < 2) {
/* We only support version 2.0 and later. */
- g_message("pcap: major version %u unsupported",
- hdr.version_major);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("pcap: major version %u unsupported",
+ hdr.version_major);
return -1;
}
}
file_encap = wtap_pcap_encap_to_wtap_encap(hdr.network);
if (file_encap == WTAP_ENCAP_UNKNOWN) {
- g_message("pcap: network type %u unknown or unsupported",
- hdr.network);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("pcap: network type %u unknown or unsupported",
+ hdr.network);
return -1;
}
/*
* Attempt to read the first record's header.
*/
- if (libpcap_read_header(wth, err, &first_rec_hdr, TRUE) == -1) {
+ if (libpcap_read_header(wth, err, NULL, &first_rec_hdr) == -1) {
if (*err == 0 || *err == WTAP_ERR_SHORT_READ) {
/*
* EOF or short read - assume the file is in this
/*
* Now attempt to read the second record's header.
*/
- if (libpcap_read_header(wth, err, &second_rec_hdr, TRUE) == -1) {
+ if (libpcap_read_header(wth, err, NULL, &second_rec_hdr) == -1) {
if (*err == 0 || *err == WTAP_ERR_SHORT_READ) {
/*
* EOF or short read - assume the file is in this
}
/* Read the next packet */
-static gboolean libpcap_read(wtap *wth, int *err, long *data_offset)
+static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
struct pcaprec_ss990915_hdr hdr;
guint packet_size;
int bytes_read;
guchar fddi_padding[3];
- bytes_read = libpcap_read_header(wth, err, &hdr, FALSE);
+ bytes_read = libpcap_read_header(wth, err, err_info, &hdr);
if (bytes_read == -1) {
/*
* We failed to read the header.
* Uh-oh, the packet isn't big enough to even
* have a pseudo-header.
*/
- g_message("libpcap: SunATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
- packet_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("libpcap: SunATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
+ packet_size);
return FALSE;
}
if (!libpcap_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
* Uh-oh, the packet isn't big enough to even
* have a pseudo-header.
*/
- g_message("libpcap: IrDA file has a %u-byte packet, too small to have even an IrDA pseudo-header\n",
- packet_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("libpcap: IrDA file has a %u-byte packet, too small to have even an IrDA pseudo-header\n",
+ packet_size);
return FALSE;
}
if (!libpcap_read_irda_pseudoheader(wth->fh, &wth->pseudo_header,
- err))
+ err, err_info))
return FALSE; /* Read error */
/*
static gboolean
libpcap_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
case WTAP_ENCAP_IRDA:
if (!libpcap_read_irda_pseudoheader(wth->random_fh, pseudo_header,
- err)) {
+ err, err_info)) {
/* Read error */
return FALSE;
}
return TRUE;
}
-/* Read the header of the next packet; if "silent" is TRUE, don't complain
- to the console, as we're testing to see if the file appears to be of a
- particular type.
+/* Read the header of the next packet.
Return -1 on an error, or the number of bytes of header read on success. */
-static int libpcap_read_header(wtap *wth, int *err,
- struct pcaprec_ss990915_hdr *hdr, gboolean silent)
+static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
+ struct pcaprec_ss990915_hdr *hdr)
{
int bytes_to_read, bytes_read;
* this is can tell when it's not the type we're guessing
* it is.
*/
- if (!silent) {
- g_message("pcap: File has %u-byte packet, bigger than maximum of %u",
+ *err = WTAP_ERR_BAD_RECORD;
+ if (err_info != NULL) {
+ *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u",
hdr->hdr.incl_len, WTAP_MAX_PACKET_SIZE);
}
- *err = WTAP_ERR_BAD_RECORD;
return -1;
}
* this is can tell when it's not the type we're guessing
* it is.
*/
- if (!silent) {
- g_message("pcap: File has %u-byte packet, bigger than maximum of %u",
+ *err = WTAP_ERR_BAD_RECORD;
+ if (err_info != NULL) {
+ *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u",
hdr->hdr.orig_len, WTAP_MAX_PACKET_SIZE);
}
- *err = WTAP_ERR_BAD_RECORD;
return -1;
}
static gboolean
libpcap_get_irda_pseudoheader(const struct irda_sll_hdr *irda_phdr,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
if (pntohs(&irda_phdr->sll_protocol) != 0x0017) {
- g_message("libpcap: IrDA capture has a packet with an invalid sll_protocol field\n");
*err = WTAP_ERR_BAD_RECORD;
+ if (err_info != NULL)
+ *err_info = g_strdup("libpcap: IrDA capture has a packet with an invalid sll_protocol field\n");
return FALSE;
}
pseudo_header->irda.pkttype = pntohs(&irda_phdr->sll_pkttype);
- return TRUE;
+ return TRUE;
}
static gboolean
libpcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err)
+ int *err, gchar **err_info)
{
struct irda_sll_hdr irda_phdr;
int bytes_read;
return FALSE;
}
- return libpcap_get_irda_pseudoheader(&irda_phdr, pseudo_header, err);
+ return libpcap_get_irda_pseudoheader(&irda_phdr, pseudo_header, err,
+ err_info);
}
static gboolean
return NULL;
}
if (!libpcap_get_irda_pseudoheader((const struct irda_sll_hdr *)pd,
- pseudo_header, err))
+ pseudo_header, err, NULL))
return NULL;
/*
/* libpcap.h
*
- * $Id: libpcap.h,v 1.14 2002/08/28 20:30:44 jmayer Exp $
+ * $Id: libpcap.h,v 1.15 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
guint8 stuff[4]; /* mysterious stuff */
};
-int libpcap_open(wtap *wth, int *err);
+int libpcap_open(wtap *wth, int *err, gchar **err_info);
gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int libpcap_dump_can_write_encap(int encap);
/* netmon.c
*
- * $Id: netmon.c,v 1.67 2003/12/23 00:15:02 ulfl Exp $
+ * $Id: netmon.c,v 1.68 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
guint16 vci; /* VCI */
};
-static gboolean netmon_read(wtap *wth, int *err, long *data_offset);
+static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean netmon_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
-int netmon_open(wtap *wth, int *err)
+int netmon_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof netmon_1_x_magic];
break;
default:
- g_message("netmon: major version %u unsupported", hdr.ver_major);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netmon: major version %u unsupported", hdr.ver_major);
return -1;
}
hdr.network = pletohs(&hdr.network);
if (hdr.network >= NUM_NETMON_ENCAPS
|| netmon_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
- g_message("netmon: network type %u unknown or unsupported",
- hdr.network);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("netmon: network type %u unknown or unsupported",
+ hdr.network);
return -1;
}
frame_table_length = pletohl(&hdr.frametablelength);
frame_table_size = frame_table_length / sizeof (guint32);
if ((frame_table_size * sizeof (guint32)) != frame_table_length) {
- g_message("netmon: frame table length is %u, which is not a multiple of the size of an entry",
- frame_table_length);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry",
+ frame_table_length);
return -1;
}
if (frame_table_size == 0) {
- g_message("netmon: frame table length is %u, which means it's less than one entry in size",
- frame_table_length);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size",
+ frame_table_length);
return -1;
}
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
}
/* Read the next packet */
-static gboolean netmon_read(wtap *wth, int *err, long *data_offset)
+static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
netmon_t *netmon = wth->capture.netmon;
guint32 packet_size = 0;
* Probably a corrupt capture file; don't blow up trying
* to allocate space for an immensely-large packet.
*/
- g_message("netmon: File has %u-byte packet, bigger than maximum of %u",
- packet_size, WTAP_MAX_PACKET_SIZE);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("netmon: File has %u-byte packet, bigger than maximum of %u",
+ packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
* Uh-oh, the packet isn't big enough to even
* have a pseudo-header.
*/
- g_message("netmon: ATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
- packet_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("netmon: ATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
+ packet_size);
return FALSE;
}
if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
static gboolean
netmon_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
/* netmon.h
*
- * $Id: netmon.h,v 1.11 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: netmon.h,v 1.12 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __NETMON_H__
#define __NETMON_H__
-int netmon_open(wtap *wth, int *err);
+int netmon_open(wtap *wth, int *err, gchar **err_info);
gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int netmon_dump_can_write_encap(int encap);
/* nettl.c
*
- * $Id: nettl.c,v 1.33 2003/10/01 07:11:48 guy Exp $
+ * $Id: nettl.c,v 1.34 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
};
-static gboolean nettl_read(wtap *wth, int *err, long *data_offset);
+static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean nettl_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd,
- int length, int *err);
+ int length, int *err, gchar **err_info);
static int nettl_read_rec_header(wtap *wth, FILE_T fh,
struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
- int *err);
+ int *err, gchar **err_info);
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void nettl_close(wtap *wth);
-int nettl_open(wtap *wth, int *err)
+int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
{
char magic[12], os_vers[2];
int bytes_read;
}
/* Read the next packet */
-static gboolean nettl_read(wtap *wth, int *err, long *data_offset)
+static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
int ret;
/* Read record header. */
*data_offset = wth->data_offset;
ret = nettl_read_rec_header(wth, wth->fh, &wth->phdr, &wth->pseudo_header,
- err);
+ err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
static gboolean
nettl_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd,
- int length, int *err)
+ int length, int *err, gchar **err_info)
{
int ret;
struct wtap_pkthdr phdr;
/* Read record header. */
ret = nettl_read_rec_header(wth, wth->random_fh, &phdr, pseudo_header,
- err);
+ err, err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
static int
nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err,
+ gchar **err_info)
{
int bytes_read;
struct nettlrec_sx25l2_hdr lapb_hdr;
(lapb_hdr.from_dce & 0x20 ? FROM_DCE : 0x00);
break;
default:
- g_message("nettl: network type %u unknown or unsupported",
- encap[3]);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("nettl: network type %u unknown or unsupported",
+ encap[3]);
return -1;
}
return offset;
/* nettl.h
*
- * $Id: nettl.h,v 1.9 2003/05/05 01:01:36 guy Exp $
+ * $Id: nettl.h,v 1.10 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define NETTL_SUBSYS_IGELAN 0xFC
-int nettl_open(wtap *wth, int *err);
+int nettl_open(wtap *wth, int *err, gchar **err_info);
#endif
/*
- * $Id: network_instruments.c,v 1.6 2004/01/05 17:33:28 ulfl Exp $
+ * $Id: network_instruments.c,v 1.7 2004/01/25 21:55:16 guy Exp $
*/
/***************************************************************************
}
static gboolean fill_time_struct(guint64 ns_since2000, observer_time* time_conversion);
-static gboolean observer_read(wtap *wth, int *err, long *data_offset);
+static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean observer_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static gboolean observer_dump_close(wtap_dumper *wdh, int *err);
static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
-int network_instruments_open(wtap *wth, int *err)
+int network_instruments_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
/* check the version */
if (strncmp(network_instruments_magic, file_header.observer_version, 30)!=0) {
- g_message("Observer: unsupported file version %s", file_header.observer_version);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("Observer: unsupported file version %s", file_header.observer_version);
return -1;
}
/* check the packet's magic number; the magic number is all 8's,
so the byte order doesn't matter */
if (packet_header.packet_magic != observer_packet_magic) {
- g_message("Observer: unsupported packet version %ul", packet_header.packet_magic);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("Observer: unsupported packet version %ul", packet_header.packet_magic);
return -1;
}
/* Check the data link type. */
if (packet_header.network_type >= NUM_OBSERVER_ENCAPS) {
- g_message("observer: network type %u unknown or unsupported", packet_header.network_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("observer: network type %u unknown or unsupported", packet_header.network_type);
return -1;
}
wth->file_encap = observer_encap[packet_header.network_type];
}
/* reads the next packet */
-static gboolean observer_read(wtap *wth, int *err, long *data_offset)
+static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
int bytes_read;
long seek_increment;
/* check the packet's magic number; the magic number is all 8's,
so the byte order doesn't matter */
if (packet_header.packet_magic != observer_packet_magic) {
- g_message("Observer: bad record");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("Observer: bad record");
return FALSE;
}
packet_header.offset_to_frame =
GUINT16_FROM_LE(packet_header.offset_to_frame);
if (packet_header.offset_to_frame < sizeof(packet_header)) {
- g_message("Observer: bad record (offset to frame %u < %lu)",
+ *err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("Observer: bad record (offset to frame %u < %lu)",
packet_header.offset_to_frame,
(unsigned long)sizeof(packet_header));
- *err = WTAP_ERR_BAD_RECORD;
return FALSE;
}
seek_increment = packet_header.offset_to_frame - sizeof(packet_header);
/* reads a packet at an offset */
static gboolean observer_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info)
{
packet_entry_header packet_header;
/* check the packets magic number */
if (packet_header.packet_magic != observer_packet_magic) {
- g_message("Observer: bad record in observer_seek_read");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("Observer: bad magic number for record in observer_seek_read");
return FALSE;
}
bytes_read = file_read(pd, 1, length, wth->random_fh);
if (bytes_read != length) {
*err = file_error(wth->fh);
- g_message("Observer: read error in observer_seek_read");
return FALSE;
}
/*
- * $Id: network_instruments.h,v 1.4 2003/11/06 22:45:28 guy Exp $
+ * $Id: network_instruments.h,v 1.5 2004/01/25 21:55:16 guy Exp $
*/
/***************************************************************************
#ifndef __NETWORK_INSTRUMENTS_H__
#define __NETWORK_INSTRUMENTS_H__
-int network_instruments_open(wtap *wth, int *err);
+int network_instruments_open(wtap *wth, int *err, gchar **err_info);
int network_instruments_dump_can_write_encap(int encap);
gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
/* netxray.c
*
- * $Id: netxray.c,v 1.86 2004/01/19 02:23:18 guy Exp $
+ * $Id: netxray.c,v 1.87 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
struct netxrayrec_2_x_hdr hdr_2_x;
};
-static gboolean netxray_read(wtap *wth, int *err, long *data_offset);
+static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean netxray_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static int netxray_read_rec_header(wtap *wth, FILE_T fh,
union netxrayrec_hdr *hdr, int *err);
static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err);
-int netxray_open(wtap *wth, int *err)
+int netxray_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof netxray_magic];
version_minor = 2;
file_type = WTAP_FILE_NETXRAY_2_00x;
} else {
- g_message("netxray: version \"%.8s\" unsupported", hdr.version);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netxray: version \"%.8s\" unsupported", hdr.version);
return -1;
}
}
break;
default:
- g_message("netxray: the byte after the network type has the value %u, which I don't understand",
- hdr.xxz[0]);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netxray: the byte after the network type has the value %u, which I don't understand",
+ hdr.xxz[0]);
return -1;
}
if (network_type >= NUM_NETXRAY_ENCAPS
|| netxray_encap[network_type] == WTAP_ENCAP_UNKNOWN) {
- g_message("netxray: network type %u (%u) unknown or unsupported",
- network_type, hdr.xxz[0]);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("netxray: network type %u (%u) unknown or unsupported",
+ network_type, hdr.xxz[0]);
return -1;
}
}
} else {
if (hdr.timeunit > NUM_NETXRAY_TIMEUNITS) {
- g_message("netxray: Unknown timeunit %u",
- hdr.timeunit);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("netxray: Unknown timeunit %u",
+ hdr.timeunit);
return -1;
}
timeunit = TpS[hdr.timeunit];
break;
default:
- g_message("netxray: WAN HDLC capture subsubtype 0x%02x unknown or unsupported",
- hdr.xxb[28]);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("netxray: WAN HDLC capture subsubtype 0x%02x unknown or unsupported",
+ hdr.xxb[28]);
return -1;
}
break;
break;
default:
- g_message("netxray: WAN capture subtype 0x%02x unknown or unsupported",
- hdr.xxb[20]);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("netxray: WAN capture subtype 0x%02x unknown or unsupported",
+ hdr.xxb[20]);
return -1;
}
} else
}
/* Read the next packet */
-static gboolean netxray_read(wtap *wth, int *err, long *data_offset)
+static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
guint32 packet_size;
union netxrayrec_hdr hdr;
static gboolean
netxray_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
union netxrayrec_hdr hdr;
gboolean ret;
/* netxray.h
*
- * $Id: netxray.h,v 1.11 2003/01/30 22:38:47 guy Exp $
+ * $Id: netxray.h,v 1.12 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __NETXRAY_H__
#define __NETXRAY_H__
-int netxray_open(wtap *wth, int *err);
+int netxray_open(wtap *wth, int *err, gchar **err_info);
int netxray_dump_can_write_encap_1_1(int encap);
gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err);
int netxray_dump_can_write_encap_2_0(int encap);
/* ngsniffer.c
*
- * $Id: ngsniffer.c,v 1.112 2003/10/25 07:17:27 guy Exp $
+ * $Id: ngsniffer.c,v 1.113 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define NUM_NGSNIFF_TIMEUNITS 7
static double Usec[] = { 15.0, 0.838096, 15.0, 0.5, 2.0, 1.0, 0.1 };
-static int process_header_records(wtap *wth, int *err, gint16 maj_vers);
+static int process_header_records(wtap *wth, int *err, gchar **err_info,
+ gint16 maj_vers);
static int process_rec_header2_v2(wtap *wth, unsigned char *buffer,
- guint16 length, int *err);
+ guint16 length, int *err, gchar **err_info);
static int process_rec_header2_v145(wtap *wth, unsigned char *buffer,
- guint16 length, gint16 maj_vers, int *err);
-static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset);
+ guint16 length, gint16 maj_vers, int *err, gchar **err_info);
+static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean ngsniffer_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
guint16 *typep, guint16 *lengthp, int *err);
static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random,
static long ng_file_seek_seq(wtap *wth, long offset, int whence, int *err);
static long ng_file_seek_rand(wtap *wth, long offset, int whence, int *err);
-int ngsniffer_open(wtap *wth, int *err)
+int ngsniffer_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof ngsniffer_magic];
length = pletohs(record_length);
if (type != REC_VERS) {
- g_message("ngsniffer: Sniffer file doesn't start with a version record");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("ngsniffer: Sniffer file doesn't start with a version record");
return -1;
}
/* Check the data link type. */
if (version.network >= NUM_NGSNIFF_ENCAPS
|| sniffer_encap[version.network] == WTAP_ENCAP_UNKNOWN) {
- g_message("ngsniffer: network type %u unknown or unsupported",
- version.network);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("ngsniffer: network type %u unknown or unsupported",
+ version.network);
return -1;
}
/* Check the time unit */
if (version.timeunit >= NUM_NGSNIFF_TIMEUNITS) {
- g_message("ngsniffer: Unknown timeunit %u", version.timeunit);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("ngsniffer: Unknown timeunit %u", version.timeunit);
return -1;
}
* the DOS Sniffer understands?
*/
maj_vers = pletohs(&version.maj_vers);
- if (process_header_records(wth, err, maj_vers) < 0)
+ if (process_header_records(wth, err, err_info, maj_vers) < 0)
return -1;
if (wth->file_encap == WTAP_ENCAP_PER_PACKET) {
/*
}
static int
-process_header_records(wtap *wth, int *err, gint16 maj_vers)
+process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers)
{
int bytes_read;
char record_type[2];
case 2:
if (process_rec_header2_v2(wth, buffer,
- length, err) < 0)
+ length, err, err_info) < 0)
return -1;
break;
case 4:
case 5:
if (process_rec_header2_v145(wth, buffer,
- length, maj_vers, err) < 0)
+ length, maj_vers, err, err_info) < 0)
return -1;
break;
}
static int
process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length,
- int *err)
+ int *err, gchar **err_info)
{
static const char x_25_str[] = "HDLC\nX.25\n";
/*
* There's not enough data to compare.
*/
- g_message("ngsniffer: WAN capture has too-short protocol list");
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("ngsniffer: WAN capture has too-short protocol list");
return -1;
}
- if (strncmp(buffer, x_25_str, sizeof x_25_str - 1) == 0) {
+ if (strncmp((char *)buffer, x_25_str, sizeof x_25_str - 1) == 0) {
/*
* X.25.
*/
wth->file_encap = WTAP_ENCAP_LAPB;
} else {
- g_message("ngsniffer: WAN capture protocol string %.*s unknown",
- length, buffer);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("ngsniffer: WAN capture protocol string %.*s unknown",
+ length, buffer);
return -1;
}
return 0;
static int
process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
- gint16 maj_vers, int *err)
+ gint16 maj_vers, int *err, gchar **err_info)
{
/*
* The 5th byte of the REC_HEADER2 record appears to be a
/*
* There is no 5th byte; give up.
*/
- g_message("ngsniffer: WAN capture has no network subtype");
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup("ngsniffer: WAN capture has no network subtype");
return -1;
}
/*
* There is no 5th byte; give up.
*/
- g_message("ngsniffer: WAN bridge/router capture has no ISDN flag");
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup("ngsniffer: WAN bridge/router capture has no ISDN flag");
return -1;
}
if (buffer[6] == 0x01)
/*
* Reject these until we can figure them out.
*/
- g_message("ngsniffer: WAN network subtype %u unknown or unsupported",
- buffer[4]);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("ngsniffer: WAN network subtype %u unknown or unsupported",
+ buffer[4]);
return -1;
}
return 0;
}
/* Read the next packet */
-static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset)
+static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
int ret;
guint16 type, length;
* We shouldn't get a frame2 record in
* an ATM capture.
*/
- g_message("ngsniffer: REC_FRAME2 record in an ATM Sniffer file");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("ngsniffer: REC_FRAME2 record in an ATM Sniffer file");
return FALSE;
}
* We shouldn't get a frame2 record in
* a non-ATM capture.
*/
- g_message("ngsniffer: REC_FRAME4 record in a non-ATM Sniffer file");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("ngsniffer: REC_FRAME4 record in a non-ATM Sniffer file");
return FALSE;
}
/*
* Yes - treat this as an error.
*/
- g_message("ngsniffer: Record length is less than packet size");
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("ngsniffer: Record length is less than packet size");
return FALSE;
}
static gboolean ngsniffer_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err)
+ int *err, gchar **err_info _U_)
{
int ret;
guint16 type, length;
/* ngsniffer.h
*
- * $Id: ngsniffer.h,v 1.12 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: ngsniffer.h,v 1.13 2004/01/25 21:55:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __NGSNIFFER_H__
#define __NGSNIFFER_H__
-int ngsniffer_open(wtap *wth, int *err);
+int ngsniffer_open(wtap *wth, int *err, gchar **err_info);
gboolean ngsniffer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int ngsniffer_dump_can_write_encap(int encap);
/* pppdump.c
*
- * $Id: pppdump.c,v 1.24 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: pppdump.c,v 1.25 2004/01/25 21:55:17 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
DIRECTION_RECV
} direction_enum;
-static gboolean pppdump_read(wtap *wth, int *err, long *data_offset);
+static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean pppdump_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
/*
* Information saved about a packet, during the initial sequential pass
int *err, pkt_id *pid);
static gboolean
-collate(pppdump_t*, FILE_T fh, int *err, guint8 *pd, int *num_bytes,
- direction_enum *direction, pkt_id *pid, int num_bytes_to_skip);
+collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
+ int *num_bytes, direction_enum *direction, pkt_id *pid,
+ int num_bytes_to_skip);
static void
pppdump_close(wtap *wth);
int
-pppdump_open(wtap *wth, int *err)
+pppdump_open(wtap *wth, int *err, gchar **err_info _U_)
{
guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */
pppdump_t *state;
/* Find the next packet and parse it; called from wtap_loop(). */
static gboolean
-pppdump_read(wtap *wth, int *err, long *data_offset)
+pppdump_read(wtap *wth, int *err, gchar **err_info, long *data_offset)
{
int num_bytes;
direction_enum direction;
} else
pid = NULL; /* sequential only */
- if (!collate(state, wth->fh, err, buf, &num_bytes, &direction,
+ if (!collate(state, wth->fh, err, err_info, buf, &num_bytes, &direction,
pid, 0)) {
if (pid != NULL)
g_free(pid);
/* Returns TRUE if packet data copied, FALSE if error occurred or EOF (no more records). */
static gboolean
-collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes,
- direction_enum *direction, pkt_id *pid, int num_bytes_to_skip)
+collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
+ int *num_bytes, direction_enum *direction, pkt_id *pid,
+ int num_bytes_to_skip)
{
int id;
pkt_t *pkt = NULL;
default:
/* XXX - bad file */
- g_message("pppdump: bad ID byte 0x%02x", id);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("pppdump: bad ID byte 0x%02x", id);
return FALSE;
}
union wtap_pseudo_header *pseudo_header,
guint8 *pd,
int len,
- int *err)
+ int *err,
+ gchar **err_info)
{
int num_bytes;
direction_enum direction;
pid = g_ptr_array_index(state->pids, seek_off);
if (!pid) {
*err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */
+ *err_info = g_strdup("pppdump: PID not found for record");
return FALSE;
}
*/
num_bytes_to_skip = pid->num_bytes_to_skip;
do {
- if (!collate(state->seek_state, wth->random_fh, err, pd,
- &num_bytes, &direction, NULL, num_bytes_to_skip))
+ if (!collate(state->seek_state, wth->random_fh, err, err_info,
+ pd, &num_bytes, &direction, NULL, num_bytes_to_skip))
return FALSE;
num_bytes_to_skip = 0;
} while (direction != pid->dir);
if (len != num_bytes) {
*err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */
+ *err_info = g_strdup_printf("pppdump: requested length %d doesn't match record length %d",
+ len, num_bytes);
return FALSE;
}
/* pppdump.h
*
- * $Id: pppdump.h,v 1.3 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: pppdump.h,v 1.4 2004/01/25 21:55:17 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
#ifndef __PPPDUMP_H__
#define __PPPDUMP_H__
-int pppdump_open(wtap *wth, int *err);
+int pppdump_open(wtap *wth, int *err, gchar **err_info);
#endif
/* radcom.c
*
- * $Id: radcom.c,v 1.43 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: radcom.c,v 1.44 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
char xxw[9]; /* unknown */
};
-static gboolean radcom_read(wtap *wth, int *err, long *data_offset);
+static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean radcom_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
- int *err);
+ int *err, gchar **err_info);
static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr,
int *err);
static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
-int radcom_open(wtap *wth, int *err)
+int radcom_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
guint8 r_magic[8], t_magic[11], search_encap[7];
else if (memcmp(search_encap, "ATM/", 4) == 0)
wth->file_encap = WTAP_ENCAP_ATM_RFC1483;
else {
- g_message("pcap: network type \"%.4s\" unknown", search_encap);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("radcom: network type \"%.4s\" unknown", search_encap);
return -1;
}
}
/* Read the next packet */
-static gboolean radcom_read(wtap *wth, int *err, long *data_offset)
+static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
int ret;
struct radcomrec_hdr hdr;
static gboolean
radcom_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
int ret;
struct radcomrec_hdr hdr;
/* radcom.h
*
- * $Id: radcom.h,v 1.7 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: radcom.h,v 1.8 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __RADCOM_H__
#define __RADCOM_H__
-int radcom_open(wtap *wth, int *err);
+int radcom_open(wtap *wth, int *err, gchar **err_info);
#endif
/* snoop.c
*
- * $Id: snoop.c,v 1.67 2004/01/05 17:33:28 ulfl Exp $
+ * $Id: snoop.c,v 1.68 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#define RX_STATUS_FIFO_ERROR 0x0080 /* receive FIFO error */
#define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */
-static gboolean snoop_read(wtap *wth, int *err, long *data_offset);
+static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean snoop_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info);
static gboolean snoop_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length,
* and distinguishing 4MB from 16MB Token Ring, and distinguishing both
* of them from the "Shomiti" versions of same.
*/
-int snoop_open(wtap *wth, int *err)
+int snoop_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof snoop_magic];
break;
default:
- g_message("snoop: version %u unsupported", hdr.version);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("snoop: version %u unsupported", hdr.version);
return -1;
}
if (is_shomiti) {
if (hdr.network >= NUM_SHOMITI_ENCAPS
|| shomiti_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
- g_message("snoop: Shomiti network type %u unknown or unsupported",
- hdr.network);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("snoop: Shomiti network type %u unknown or unsupported",
+ hdr.network);
return -1;
}
file_encap = shomiti_encap[hdr.network];
} else {
if (hdr.network >= NUM_SNOOP_ENCAPS
|| snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
- g_message("snoop: network type %u unknown or unsupported",
- hdr.network);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("snoop: network type %u unknown or unsupported",
+ hdr.network);
return -1;
}
file_encap = snoop_encap[hdr.network];
}
/* Read the next packet */
-static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
+static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
guint32 rec_size;
guint32 packet_size;
* Probably a corrupt capture file; don't blow up trying
* to allocate space for an immensely-large packet.
*/
- g_message("snoop: File has %u-byte packet, bigger than maximum of %u",
- packet_size, WTAP_MAX_PACKET_SIZE);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than maximum of %u",
+ packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
if (packet_size > rec_size) {
/*
* Probably a corrupt capture file.
*/
- g_message("snoop: File has %u-byte packet, bigger than record size %u",
- packet_size, rec_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than record size %u",
+ packet_size, rec_size);
return FALSE;
}
* Uh-oh, the packet isn't big enough to even
* have a pseudo-header.
*/
- g_message("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
- packet_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n",
+ packet_size);
return FALSE;
}
if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
/*
* What, *negative* padding? Bogus.
*/
- g_message("snoop: File has %u-byte record with packet size of %u",
- rec_size, packet_size);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("snoop: File has %u-byte record with packet size of %u",
+ rec_size, packet_size);
return FALSE;
}
padbytes = rec_size - (sizeof hdr + packet_size);
static gboolean
snoop_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
+ union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+ int *err, gchar **err_info _U_)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
/* snoop.h
*
- * $Id: snoop.h,v 1.12 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: snoop.h,v 1.13 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __W_SNOOP_H__
#define __W_SNOOP_H__
-int snoop_open(wtap *wth, int *err);
+int snoop_open(wtap *wth, int *err, gchar **err_info);
gboolean snoop_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int snoop_dump_can_write_encap(int encap);
/* toshiba.c
*
- * $Id: toshiba.c,v 1.28 2004/01/05 17:33:28 ulfl Exp $
+ * $Id: toshiba.c,v 1.29 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
*/
#define TOSHIBA_MAX_PACKET_LEN 16384
-static gboolean toshiba_read(wtap *wth, int *err, long *data_offset);
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean toshiba_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
guint byte_offset);
static gboolean parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf,
- int *err);
+ int *err, gchar **err_info);
static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error. */
}
-int toshiba_open(wtap *wth, int *err)
+int toshiba_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* Look for Toshiba header */
if (!toshiba_check_file_type(wth, err)) {
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean toshiba_read(wtap *wth, int *err, long *data_offset)
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset;
guint8 *buf;
return FALSE;
/* Parse the header */
- pkt_len = parse_toshiba_rec_hdr(wth, wth->fh, &wth->pseudo_header, err);
+ pkt_len = parse_toshiba_rec_hdr(wth, wth->fh, &wth->pseudo_header,
+ err, err_info);
if (pkt_len == -1)
return FALSE;
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err))
+ if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err, err_info))
return FALSE;
wth->data_offset = offset;
/* Used to read packets in random-access fashion */
static gboolean
toshiba_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err)
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info)
{
int pkt_len;
return FALSE;
pkt_len = parse_toshiba_rec_hdr(NULL, wth->random_fh, pseudo_header,
- err);
+ err, err_info);
if (pkt_len != len) {
- if (pkt_len != -1)
+ if (pkt_len != -1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("toshiba: requested length %d doesn't match record length %d",
+ len, pkt_len);
+ }
return FALSE;
}
- return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err);
+ return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err, err_info);
}
/* Parses a packet record header. */
static int
parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
char line[TOSHIBA_LINE_LENGTH];
int num_items_scanned;
if (num_items_scanned != 7) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("toshiba: record header isn't valid");
return -1;
}
num_items_scanned = sscanf(line+64, "LEN=%d", &pkt_len);
if (num_items_scanned != 1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("toshiba: OFFSET line doesn't have valid LEN item");
return -1;
}
/* Converts ASCII hex dump to binary data */
static gboolean
-parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
+parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
+ gchar **err_info)
{
char line[TOSHIBA_LINE_LENGTH];
int i, hex_lines;
}
if (!parse_single_hex_dump_line(line, buf, i * 16)) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup("toshiba: hex dump not valid");
return FALSE;
}
}
/* toshiba.h
*
- * $Id: toshiba.h,v 1.5 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: toshiba.h,v 1.6 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef __W_TOSHIBA_H__
#define __W_TOSHIBA_H__
-int toshiba_open(wtap *wth, int *err);
+int toshiba_open(wtap *wth, int *err, gchar **err_info);
#endif
* File read and write routines for Visual Networks cap files.
* Copyright (c) 2001, Tom Nisbet tnisbet@visualnetworks.com
*
- * $Id: visual.c,v 1.14 2003/10/25 07:17:28 guy Exp $
+ * $Id: visual.c,v 1.15 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
/* Local functions to handle file reads and writes */
-static gboolean visual_read(wtap *wth, int *err, long *data_offset);
+static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static void visual_close(wtap *wth);
static gboolean visual_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
static void visual_set_pseudo_header(int encap, struct visual_pkt_hdr *vpkt_hdr,
union wtap_pseudo_header *pseudo_header);
static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
/* Open a file for reading */
-int visual_open(wtap *wth, int *err)
+int visual_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof visual_magic];
vfile_hdr.file_version = pletohs(&vfile_hdr.file_version);
if (vfile_hdr.file_version != 1)
{
- g_message("visual: file version %u unsupported", vfile_hdr.file_version);
*err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("visual: file version %u unsupported", vfile_hdr.file_version);
return -1;
}
break;
default:
- g_message("visual: network type %u unknown or unsupported",
- vfile_hdr.media_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("visual: network type %u unknown or unsupported",
+ vfile_hdr.media_type);
return -1;
}
in a loop to sequentially read the entire file one time. After
the file has been read once, any Future access to the packets is
done through seek_read. */
-static gboolean visual_read(wtap *wth, int *err, long *data_offset)
+static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
struct visual_read_info *visual = wth->capture.generic;
guint32 packet_size = 0;
{
/* Probably a corrupt capture file; don't blow up trying
to allocate space for an immensely-large packet. */
- g_message("visual: File has %u-byte packet, bigger than maximum of %u",
- packet_size, WTAP_MAX_PACKET_SIZE);
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("visual: File has %u-byte packet, bigger than maximum of %u",
+ packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
buffer_assure_space(wth->frame_buffer, packet_size);
This gets the packet data and rebuilds the pseudo header so that
the direction flag works. */
static gboolean visual_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err)
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info _U_)
{
struct visual_pkt_hdr vpkt_hdr;
int phdr_size = sizeof(vpkt_hdr);
*
* Based on the code that handles netmon files.
*
- * $Id: visual.h,v 1.5 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: visual.h,v 1.6 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
#ifndef __VISUAL_H__
#define __VISUAL_H__
-int visual_open(wtap *wth, int *err);
+int visual_open(wtap *wth, int *err, gchar **err_info);
gboolean visual_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err);
int visual_dump_can_write_encap(int encap);
/* vms.c
*
- * $Id: vms.c,v 1.20 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: vms.c,v 1.21 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
#define VMS_HEADER_LINES_TO_CHECK 200
#define VMS_LINE_LENGTH 240
-static gboolean vms_read(wtap *wth, int *err, long *data_offset);
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean vms_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
long byte_offset, int in_off, int remaining_bytes);
static gboolean parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf,
- int *err);
-static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err);
+ int *err, gchar **err_info);
+static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info);
#ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE
/* Seeks to the beginning of the next packet, and returns the
}
-int vms_open(wtap *wth, int *err)
+int vms_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* Look for VMS header */
if (!vms_check_file_type(wth, err)) {
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean vms_read(wtap *wth, int *err, long *data_offset)
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset = 0;
guint8 *buf;
return FALSE;
/* Parse the header */
- pkt_len = parse_vms_rec_hdr(wth, wth->fh, err);
+ pkt_len = parse_vms_rec_hdr(wth, wth->fh, err, err_info);
if (pkt_len == -1)
return FALSE;
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err))
+ if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err, err_info))
return FALSE;
wth->data_offset = offset;
static gboolean
vms_seek_read (wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int len, int *err)
+ guint8 *pd, int len, int *err, gchar **err_info)
{
int pkt_len;
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return FALSE;
- pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err);
+ pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err, err_info);
if (pkt_len != len) {
- if (pkt_len != -1)
+ if (pkt_len != -1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: requested length %d doesn't match length %d",
+ len, pkt_len);
+ }
return FALSE;
}
- return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err);
+ return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err, err_info);
}
/* isdumpline assumes that dump lines start with some non-alphanumerics
/* Parses a packet record header. */
static int
-parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
+parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
{
char line[VMS_LINE_LENGTH + 1];
int num_items_scanned;
/* We will need to add code to handle new format */
if (num_items_scanned != 8) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: header line not valid");
return -1;
}
}
if ( !*p ) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: Length field not valid");
return -1;
}
/* Converts ASCII hex dump to binary data */
static gboolean
-parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
+parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
+ gchar **err_info)
{
gchar line[VMS_LINE_LENGTH + 1];
int i;
if (!parse_single_hex_dump_line(line, buf, i,
offset, pkt_len - i)) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: hex dump not valid");
return FALSE;
}
}
/* vms.h
*
- * $Id: vms.h,v 1.2 2003/01/17 23:54:19 guy Exp $
+ * $Id: vms.h,v 1.3 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
#ifndef __W_VMS_H__
#define __W_VMS_H__
-int vms_open(wtap *wth, int *err);
+int vms_open(wtap *wth, int *err, gchar **err_info);
#endif
/* wtap-int.h
*
- * $Id: wtap-int.h,v 1.43 2004/01/05 17:33:28 ulfl Exp $
+ * $Id: wtap-int.h,v 1.44 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
gboolean is_ppp;
} erf_t;
-typedef gboolean (*subtype_read_func)(struct wtap*, int*, long*);
+typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, long*);
typedef gboolean (*subtype_seek_read_func)(struct wtap*, long, union wtap_pseudo_header*,
- guint8*, int, int *);
+ guint8*, int, int *, char **);
struct wtap {
FILE_T fh;
int fd; /* File descriptor for cap file */
/* wtap.c
*
- * $Id: wtap.c,v 1.86 2003/12/18 19:07:13 guy Exp $
+ * $Id: wtap.c,v 1.87 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
}
gboolean
-wtap_read(wtap *wth, int *err, long *data_offset)
+wtap_read(wtap *wth, int *err, gchar **err_info, long *data_offset)
{
- if (!wth->subtype_read(wth, err, data_offset))
+ if (!wth->subtype_read(wth, err, err_info, data_offset))
return FALSE; /* failure */
/*
}
gboolean
-wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err)
+wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err,
+ gchar **err_info)
{
long data_offset;
int loop = 0;
/* Start by clearing error flag */
*err = 0;
- while ( (wtap_read(wth, err, &data_offset)) ) {
+ while ( (wtap_read(wth, err, err_info, &data_offset)) ) {
callback(user, &wth->phdr, data_offset,
&wth->pseudo_header, buffer_start_ptr(wth->frame_buffer));
if (count > 0 && ++loop >= count)
gboolean
wtap_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
- int *err)
+ int *err, gchar **err_info)
{
return wth->subtype_seek_read(wth, seek_off, pseudo_header, pd, len,
- err);
+ err, err_info);
}
/* wtap.h
*
- * $Id: wtap.h,v 1.147 2003/12/18 19:07:14 guy Exp $
+ * $Id: wtap.h,v 1.148 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
*
* a negative number, indicating the type of error, on other failures.
*/
-struct wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random);
+struct wtap* wtap_open_offline(const char *filename, int *err,
+ gchar **err_info, gboolean do_random);
/* Returns TRUE if entire loop-reading was successful. If read failure
* happened, FALSE is returned and err is set. */
-gboolean wtap_loop(wtap *wth, int, wtap_handler, guchar*, int *err);
+gboolean wtap_loop(wtap *wth, int, wtap_handler, guchar*, int *err,
+ gchar **err_info);
/* Returns TRUE if read was successful. FALSE if failure. data_offset is
* set the the offset in the file where the data for the read packet is
* located. */
-gboolean wtap_read(wtap *wth, int *err, long *data_offset);
+gboolean wtap_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
struct wtap_pkthdr *wtap_phdr(wtap *wth);
union wtap_pseudo_header *wtap_pseudoheader(wtap *wth);
void wtap_sequential_close(wtap *wth);
void wtap_close(wtap *wth);
gboolean wtap_seek_read (wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
gboolean wtap_dump_can_open(int filetype);
gboolean wtap_dump_can_write_encap(int filetype, int encap);