Have the Wiretap open, read, and seek-and-read routines return, in
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 25 Jan 2004 21:55:17 +0000 (21:55 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 25 Jan 2004 21:55:17 +0000 (21:55 +0000)
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors.  Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.

Add messages for cases where those errors were returned without printing
an additional message.

Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.

Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument.  (That handles a lot of the work of putting the info
string into the error message.)

Make some variables in "ascend-grammar.y" static.

Check the return value of "erf_read_header()" in "erf_seek_read()".

Get rid of an unused #define in "i4btrace.c".

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9852 f5534014-38df-0310-8fa8-9805f1628bb7

66 files changed:
capture.c
editcap.c
file.c
file.h
gtk/file_dlg.c
gtk/main.c
gtk/menu.c
gtk/rtp_analysis.c
gtk/tcp_graph.c
mergecap.c
proto_hier_stats.c
tethereal.c
wiretap/5views.c
wiretap/5views.h
wiretap/airopeek9.c
wiretap/airopeek9.h
wiretap/ascend-grammar.y
wiretap/ascend-int.h
wiretap/ascend.c
wiretap/ascend.h
wiretap/cosine.c
wiretap/cosine.h
wiretap/csids.c
wiretap/csids.h
wiretap/dbs-etherwatch.c
wiretap/dbs-etherwatch.h
wiretap/erf.c
wiretap/erf.h
wiretap/etherpeek.c
wiretap/etherpeek.h
wiretap/file_access.c
wiretap/hcidump.c
wiretap/hcidump.h
wiretap/i4btrace.c
wiretap/i4btrace.h
wiretap/iptrace.c
wiretap/iptrace.h
wiretap/lanalyzer.c
wiretap/lanalyzer.h
wiretap/libpcap.c
wiretap/libpcap.h
wiretap/netmon.c
wiretap/netmon.h
wiretap/nettl.c
wiretap/nettl.h
wiretap/network_instruments.c
wiretap/network_instruments.h
wiretap/netxray.c
wiretap/netxray.h
wiretap/ngsniffer.c
wiretap/ngsniffer.h
wiretap/pppdump.c
wiretap/pppdump.h
wiretap/radcom.c
wiretap/radcom.h
wiretap/snoop.c
wiretap/snoop.h
wiretap/toshiba.c
wiretap/toshiba.h
wiretap/visual.c
wiretap/visual.h
wiretap/vms.c
wiretap/vms.h
wiretap/wtap-int.h
wiretap/wtap.c
wiretap/wtap.h

index 6a04b9e7b855983cccc07a459323559bad696e10..8523d1db456b4ca824e446371757af19dcfe2720 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
 /* 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>
@@ -677,7 +677,7 @@ do_capture(const char *save_file)
          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:
index e846f5ba7e613da1542ec0d66c8394d83ec78800..6fb6d1593e2c8e052df3ceba080318c94db6634d 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -1,7 +1,7 @@
 /* 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.
@@ -307,6 +307,7 @@ int main(int argc, char *argv[])
 {
   wtap *wth;
   int i, err;
+  gchar *err_info;
   callback_arg args;
   extern char *optarg;
   extern int optind;
@@ -384,12 +385,19 @@ int main(int argc, char *argv[])
 
   }
 
-  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);
 
   }
@@ -430,7 +438,20 @@ int main(int argc, char *argv[])
     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)) {
 
diff --git a/file.c b/file.c
index d580bfb6c5710776b975363a3e47a2bba775f442..6c73f49ec9cc1ea603379aa02a67e72b20584634 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* 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>
@@ -115,8 +115,8 @@ static gboolean find_packet(capture_file *cf,
        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);
@@ -146,10 +146,11 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
 {
   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;
 
@@ -213,7 +214,7 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
 
 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);
 }
 
@@ -326,8 +327,10 @@ set_display_filename(capture_file *cf)
 }
 
 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;
@@ -375,7 +378,7 @@ cf_read(capture_file *cf, int *err)
   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()"
@@ -468,11 +471,11 @@ cf_read(capture_file *cf, int *err)
   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.";
@@ -489,13 +492,16 @@ cf_read(capture_file *cf, int *err)
       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;
     }
@@ -531,12 +537,13 @@ read_status_t
 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
@@ -572,11 +579,12 @@ cf_continue_tail(capture_file *cf, int to_read, int *err)
 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
@@ -1015,6 +1023,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
   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;
@@ -1146,9 +1155,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
     }
 
     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;
     }
 
@@ -1276,6 +1285,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
 {
   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;
@@ -1356,9 +1366,9 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
 
     /* 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;
@@ -2136,6 +2146,7 @@ find_packet(capture_file *cf,
   gboolean    stop_flag;
   int         count;
   int         err;
+  gchar      *err_info;
   int         row;
   float       prog_val;
   GTimeVal    start_time;
@@ -2214,11 +2225,11 @@ find_packet(capture_file *cf,
       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;
         }
@@ -2349,6 +2360,7 @@ select_packet(capture_file *cf, int row)
 {
   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);
@@ -2386,9 +2398,9 @@ select_packet(capture_file *cf, int 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;
   }
 
@@ -2601,7 +2613,7 @@ cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
     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;
     }
 
@@ -2666,7 +2678,7 @@ cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
     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:
@@ -2694,7 +2706,8 @@ fail:
 }
 
 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];
@@ -2713,11 +2726,19 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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),
@@ -2732,6 +2753,17 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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.";
@@ -2740,7 +2772,12 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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:
@@ -2799,13 +2836,26 @@ file_rename_error_message(int err)
 }
 
 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;
 }
 
@@ -2914,7 +2964,7 @@ copy_binary_file(char *from_filename, char *to_filename)
   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;
diff --git a/file.h b/file.h
index f9a6968713897ff3d037154e4842dac50e1bd8be..1d7b666914bb822ba4122f77f5e92ff5208bda1b 100644 (file)
--- a/file.h
+++ b/file.h
@@ -1,7 +1,7 @@
 /* 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>
@@ -44,7 +44,7 @@ typedef enum {
 
 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 *);
@@ -100,6 +100,6 @@ int file_mv(char *from, char *to);
 /* 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 */
index c8f6f3672c041ad67f62c85a37a75550989877b0..49d816a3a08c0b0e0638837e7695ebe5eb7b6570 100644 (file)
@@ -1,7 +1,7 @@
 /* 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>
@@ -391,7 +391,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
   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:
@@ -1010,7 +1010,6 @@ void
 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
@@ -1026,7 +1025,7 @@ file_reload_cmd_cb(GtkWidget *w _U_, gpointer data _U_) {
   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:
index 42ee6fc00bd0d5f467dcb6966dfbb0d923a366c2..f3ca6ee6314c296e417f8b9b07660aab3d2f62d0 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -585,12 +585,13 @@ get_text_from_packet_list(gpointer data)
     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;
        }
 
@@ -2384,7 +2385,7 @@ main(int argc, char *argv[])
           }
 
           /* Read the capture file. */
-          switch (cf_read(&cfile, &err)) {
+          switch (cf_read(&cfile)) {
 
           case READ_SUCCESS:
           case READ_ERROR:
index 0d9ca61f412b9f9ff593c7bea63ceec12af12d7f..f0262e22b98876836935b720be2b90ab02cc68ea 100644 (file)
@@ -1,7 +1,7 @@
 /* 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>
@@ -766,20 +766,19 @@ void
 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 */
index b670148ed0abd1af9a70ab230debbb946c4dac9d..cdf2917f5648aa51663f26b96a8c2b7814b602ac 100644 (file)
@@ -1,7 +1,7 @@
 /* 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>
@@ -2204,6 +2204,7 @@ void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
        capture_file *cf;
        epan_dissect_t *edt;
        gint err;
+       gchar *err_info;
        gboolean frame_matched;
        frame_data *fdata;
        GList *strinfo_list;
@@ -2226,9 +2227,10 @@ void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
                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);
index f4772628390787a9c19b373ecd0aa5c96d566be8..f33d91754b9344cdeef0435d6c472ffec9047fff 100644 (file)
@@ -3,7 +3,7 @@
  * 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>
@@ -1783,6 +1783,7 @@ static void graph_segment_list_get (struct graph *g)
        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, &current);
@@ -1793,10 +1794,10 @@ static void graph_segment_list_get (struct graph *g)
 
        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)
index 30184e6d1a2391eafc611efd0a1f7f35797d6e30..cf659b1b7b29cd9c4a74ef8ee86b2e6b87abd2c0 100644 (file)
@@ -1,6 +1,6 @@
 /* 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
@@ -44,6 +44,7 @@ typedef struct in_file_t {
   const char *filename;
   wtap       *wth;
   int         err;
+  gchar      *err_info;
   long        data_offset;
   gboolean    ok;
 } in_file_t;
@@ -96,12 +97,21 @@ append(int count, in_file_t in_files[], out_file_t *out_file)
 {
   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;
+      }
     }
   }
 }
@@ -158,6 +168,7 @@ merge(int count, in_file_t in_files[], out_file_t *out_file)
   /* 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));
   }
 
@@ -173,7 +184,8 @@ merge(int count, in_file_t in_files[], out_file_t *out_file)
                 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));
   }
 }
 
@@ -309,6 +321,7 @@ open_in_files(int argc, char *argv[], in_file_t *in_files[])
   int i;
   int count = 0;
   int err;
+  gchar *err_info;
   in_file_t *files;
   int files_size = argc * sizeof(in_file_t);
 
@@ -323,13 +336,21 @@ open_in_files(int argc, char *argv[], in_file_t *in_files[])
 
   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],
index e89ac15c27146d848a00ef43c6815b68ad3a5b6b..6490d40b531098c2dfcc7110fc5d105c1706541a 100644 (file)
@@ -1,7 +1,7 @@
 /* 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>
@@ -128,12 +128,13 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
        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 */
        }
 
index 0d885addc7f9241dcad77e7a99a33569373f304d..348325e135f9c9362849d09d3b5245a03ea00fba 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -173,8 +173,8 @@ static void show_capture_file_io_error(const char *, int, gboolean);
 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 *);
@@ -1814,7 +1814,7 @@ capture(int out_file_type)
 
     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;
     }
@@ -2206,6 +2206,7 @@ load_cap_file(capture_file *cf, int out_file_type)
   int          snapshot_length;
   wtap_dumper *pdh;
   int          err;
+  gchar        *err_info;
   int          success;
   cb_args_t    args;
 
@@ -2261,25 +2262,25 @@ load_cap_file(capture_file *cf, int out_file_type)
     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;
@@ -2287,14 +2288,13 @@ load_cap_file(capture_file *cf, int out_file_type)
       }
     }
   } 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:
@@ -2311,8 +2311,8 @@ load_cap_file(capture_file *cf, int out_file_type)
 
     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:
@@ -2321,6 +2321,11 @@ load_cap_file(capture_file *cf, int out_file_type)
        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:
@@ -2861,7 +2866,8 @@ show_print_file_io_error(int err)
 }
 
 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];
@@ -2875,11 +2881,19 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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),
@@ -2894,6 +2908,17 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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.";
@@ -2902,7 +2927,12 @@ cf_open_error_message(int err, gboolean for_writing, int file_type)
       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:
@@ -2939,9 +2969,10 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
 {
   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;
 
@@ -2984,8 +3015,8 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
   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);
 }
index 327653e8f21d4070d04575706e48b285f6e53853..23f63445f5a76da969965d007c0da0771b3a8e8d 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -102,10 +102,15 @@ typedef struct
 #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,
@@ -113,7 +118,7 @@ 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;
@@ -145,8 +150,8 @@ int _5views_open(wtap *wth, int *err)
                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;
        }
 
@@ -155,8 +160,8 @@ int _5views_open(wtap *wth, int *err)
            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;
        }
 
@@ -169,9 +174,9 @@ int _5views_open(wtap *wth, int *err)
                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;
        }
 
@@ -197,7 +202,7 @@ int _5views_open(wtap *wth, int *err)
 
 /* 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;
@@ -309,7 +314,8 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header  *hdr,
 
 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;
index d626d6c622dc5c34598666e1905876aaef1be666..69f84f2675ad26a38539e096d5fbfff995edd03a 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -23,7 +23,7 @@
 #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);
 
index 81ad4a61c43236bed321176900d799e612f579da..777628934acbc1ae3d4bf489ea30b9b4fcc3d0e3 100644 (file)
@@ -1,7 +1,7 @@
 /* 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>
@@ -69,9 +69,11 @@ typedef struct airopeek_utime {
 
 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)
 {
@@ -162,7 +164,7 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, 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;
@@ -199,8 +201,9 @@ int airopeek9_open(wtap *wth, int *err)
     /* 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;
     }
 
@@ -218,8 +221,8 @@ int airopeek9_open(wtap *wth, int *err)
     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
@@ -229,8 +232,8 @@ int airopeek9_open(wtap *wth, int *err)
     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;
     }
 
@@ -264,7 +267,8 @@ int airopeek9_open(wtap *wth, int *err)
     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;
@@ -341,7 +345,8 @@ static gboolean airopeek_read_v9(wtap *wth, int *err, 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 _U_)
 {
     guchar ap_pkt[AIROPEEK_V9_PKT_SIZE];
 
index ce2435db1a80891d23d99051b9ee1227566a779e..f7ad4bd820a121a9d04801b34d0b38eeb58e1b43 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #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
index 8a32a2ec0279b93f7ab0f3f9554dddeccd3e2c5e..fd0e776567da0e8c74c1610948b1fa1f44cd6823 100644 (file)
@@ -1,7 +1,7 @@
 %{
 /* 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>
@@ -117,16 +117,16 @@ XMIT-Max7:20: (task "_brouterControlTask" at 0xb094ac20, time: 1481.51) 20 octet
 
 #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;
 
 %}
  
@@ -409,6 +409,7 @@ parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
 }
 
 void
-yyerror (char *s _U_)
+yyerror (char *s)
 {
+  ascend_parse_error = s;
 }
index acfd94f3342a6e3bc33b11d3c31f8a1662d2dbf3..9a506a0e0dc5395eba54534da1cfa0893920ad2e 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -34,6 +34,10 @@ typedef struct {
   guint32 len;
 } ascend_pkthdr;
 
+extern int at_eof;
+
+extern gchar *ascend_parse_error;
+
 /*
  * Pointer to the pseudo-header for the current packet.
  */
index c62b8d15e87bc7a6e608cfdc43ba206b93b99c6a..31f76eecb70ab62ce55167824d73d8fd7d835330 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -101,9 +101,11 @@ static const char ascend_w2magic[] = { 'W', 'D', '_', 'D', 'I', 'A', 'L', 'O', '
 #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
@@ -232,7 +234,7 @@ found:
   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;
@@ -283,7 +285,8 @@ int ascend_open(wtap *wth, int *err)
 }
 
 /* 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);
@@ -301,6 +304,7 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset)
     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;
   }
 
@@ -336,13 +340,15 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset)
   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;
index 50e2c895831594b23dbf7a8ea90f71bfd78a1b98..4f462957fdc799ccc0411f72ce44526310e86231 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -28,6 +28,6 @@
 #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
index 3eeddbd25006cbce64311674a4fc02e441f389eb..4c0e541db4b7a8681d2fff1ec71dc66b975ea05a 100644 (file)
@@ -1,6 +1,6 @@
 /* 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);
 
@@ -279,7 +280,7 @@ static gboolean cosine_check_file_type(wtap *wth, int *err)
 }
 
 
-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)) {
@@ -303,7 +304,8 @@ int cosine_open(wtap *wth, int *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;
@@ -316,7 +318,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_offset)
                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;
 
@@ -325,7 +328,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_offset)
        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;
@@ -337,7 +341,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_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];
 
@@ -352,10 +357,10 @@ cosine_seek_read (wtap *wth, long seek_off,
                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:
@@ -364,7 +369,8 @@ cosine_seek_read (wtap *wth, long seek_off,
     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;
@@ -385,6 +391,7 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu
 
                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 {
@@ -397,6 +404,7 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu
 
                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;
@@ -455,7 +463,8 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu
 /* 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;
@@ -477,6 +486,7 @@ parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
                }
                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;
index f2eeaf44cd0e1fb194d4a57f3d97e28ad60c7a2f..db74316c9db9e1ea3ee4880100fb5e093406ad31 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -27,6 +27,6 @@
 #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
index 09b9455fb6937e171473e329d46757682645a923..5b19959627af8917023b1d23b5595957b85051fc 100644 (file)
@@ -1,6 +1,6 @@
 /* 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 {
@@ -56,7 +58,7 @@ 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
@@ -141,7 +143,8 @@ int csids_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -201,7 +204,8 @@ csids_seek_read (wtap *wth,
                 union wtap_pseudo_header *pseudo_header _U_,
                 guint8 *pd,
                 int len,
-                int *err)
+                int *err,
+                gchar **err_info)
 {
   int bytesRead;
   struct csids_header hdr;
@@ -222,6 +226,8 @@ csids_seek_read (wtap *wth,
 
   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;
   }
 
index fecb608187808fe7948595203de64301ef83e192..00fbf69ab9ed54e384b5f648d9ee53df8b63df91 100644 (file)
@@ -1,6 +1,6 @@
  /* 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
@@ -24,6 +24,6 @@
 #ifndef __CSIDS_H__
 #define __CSIDS_H__
 
-int csids_open(wtap *wth, int *err);
+int csids_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index ad50f228b9d9b4f01737e6363a7f6f38f2fae130..b41521258e035a207b3188ece6e6c2feae85ab6c 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -84,11 +84,13 @@ static const char dbs_etherwatch_rec_magic[]  =
  */
 #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);
@@ -181,7 +183,7 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err)
 }
 
 
-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)) {
@@ -202,7 +204,8 @@ int dbs_etherwatch_open(wtap *wth, int *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;
@@ -218,7 +221,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset)
        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;
 
@@ -236,18 +239,22 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset)
 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;
        }
 
@@ -304,7 +311,8 @@ unnumbered. Unnumbered has length 1, numbered 2.
 #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;
@@ -333,12 +341,14 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
        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;
@@ -356,6 +366,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
        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;
@@ -372,6 +383,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
        /* 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;
        }
 
@@ -384,6 +396,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
 
        if (num_items_scanned != 8) {
                *err = WTAP_ERR_BAD_RECORD;
+               *err_info = g_strdup("dbs_etherwatch: header line not valid");
                return -1;
        }
        
@@ -395,6 +408,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                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;
@@ -410,6 +424,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                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;
@@ -417,6 +432,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                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 */
@@ -426,6 +442,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                                                &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;
@@ -439,6 +456,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                        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;
@@ -477,11 +495,13 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err)
                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;
                }
        }
@@ -590,7 +610,6 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) {
 /* Parse a hex dump */
 static guint
 parse_hex_dump(char* dump, guint8 *buf, char seperator, char end) {
-
        int             pos, count;
 
        /* Parse the hex dump */
index 0c29783510edda815b1ae1b00651b545a3d352cf..5a6ecb836aaf132a7f706197541cc8907bf040b1 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #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
index 57341ac413031765bc0152ecd905372d5e5c0695..777b860f2ce98352b8b861ce394cf69ecdc23cdf 100644 (file)
@@ -32,7 +32,7 @@
 * 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 $
 */
 
 /* 
@@ -61,12 +61,14 @@ static int erf_read_header(
                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(
@@ -76,7 +78,7 @@ 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;
@@ -213,7 +215,8 @@ int erf_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -224,7 +227,7 @@ static gboolean erf_read(wtap *wth, int *err, long *data_offset)
        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;
@@ -255,7 +258,7 @@ static gboolean erf_read(wtap *wth, int *err, 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)
 {
        erf_header_t erf_header;
        guint32 packet_size;
@@ -264,7 +267,9 @@ static gboolean erf_seek_read(wtap *wth, long seek_off,
        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);
@@ -291,6 +296,7 @@ static int erf_read_header(
        erf_header_t *erf_header,
        erf_t *erf,
        int *err,
+       gchar **err_info,
        guint32 *bytes_read,
        guint32 *packet_size)
 {
@@ -310,9 +316,9 @@ static int erf_read_header(
                 * 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;
        }
 
@@ -339,7 +345,6 @@ static int erf_read_header(
 
        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);
@@ -393,6 +398,8 @@ static int erf_read_header(
                break;
        default:
                *err = WTAP_ERR_UNSUPPORTED_ENCAP;
+               *err_info = g_strdup_printf("erf: unknown record encapsulation %u",
+                   erf_header->type);
                return FALSE;
        }
 
index ff9daa2dbdef6d6d6838d8d58eadd1054840be1a..2c1e404de12c4fb477c43c8f5c263a337905d605 100644 (file)
@@ -32,7 +32,7 @@
 * 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__
@@ -96,6 +96,6 @@ typedef struct erf_record {
 #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__ */
index 53bd8f66f402ccbb267423c8f5fd2c37e4923b59..9da771ae030c7359fd2d654b178e3012b7601179 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -136,15 +136,19 @@ static const etherpeek_encap_lookup_t etherpeek_encap[] = {
 #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;
@@ -349,7 +353,8 @@ static void etherpeek_close(wtap *wth)
        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;
@@ -400,6 +405,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset)
                         * 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);
@@ -458,7 +464,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, 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)
+    union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+    int *err, gchar **err_info)
 {
        guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE];
        guint8  status;
@@ -484,6 +491,7 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off,
                         * 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,
@@ -510,7 +518,8 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off,
        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;
@@ -594,7 +603,8 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, 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 _U_)
 {
        guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
        int pkt_encap;
index d0da41a9152c315314a09a3ff3a798a4cc197928..7d28a0abad180585ef01497d9cc7d9d177511103 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #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
index 47d475a1982bd6f29c28f7a82e977cdf81dee77a..b6cb870ded5f6d4971291b9221b7e99be5754977 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -91,7 +91,7 @@
  * 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.
         */
@@ -156,7 +156,8 @@ static int (*const open_routines[])(wtap *, int *) = {
    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;
@@ -257,7 +258,7 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
                        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 */
index 9d79792fbd9c02d319964a4a30533431f60116ba..6de99d12914abcdb07ec5a5585270d8b38130b05 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
  *
@@ -38,7 +38,8 @@ struct dump_hdr {
 
 #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;
@@ -61,9 +62,9 @@ static gboolean hcidump_read(wtap *wth, int *err, long *data_offset)
                 * 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;
        }
 
@@ -90,7 +91,9 @@ static gboolean hcidump_read(wtap *wth, int *err, long *data_offset)
        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;
@@ -119,7 +122,7 @@ static gboolean hcidump_seek_read(wtap *wth, long seek_off, union wtap_pseudo_he
        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;
index 134fbf0fb40effee9d2195d492cc39f97a9500ff..e1d0b0c4de8af08261495f2e569b79109234de8f 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
  *
@@ -23,6 +23,6 @@
 #ifndef __HCIDUMP_H__
 #define __HCIDUMP_H__
 
-int hcidump_open(wtap *wth, int *err);
+int hcidump_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index 4e1cb3feb5cf31a01eed516662edb07b1f89291f..fc0be6ac3142189c8b40a6896610644d25d4ebb4 100644 (file)
@@ -1,6 +1,6 @@
 /* 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);
@@ -50,7 +52,7 @@ static void i4btrace_close(wtap *wth);
            (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;
@@ -110,10 +112,9 @@ int i4btrace_open(wtap *wth, int *err)
        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;
@@ -131,6 +132,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset)
        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);
@@ -178,7 +181,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, 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 _U_)
 {
        int     ret;
        i4b_trace_hdr_t hdr;
index 28bd99e13fdfd6f6eb49eaf7300a93bdfadeedf1..56bbfbc7f9d909c1154df68883f9a160733cf6fa 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #ifndef __I4BTRACE_H__
 #define __I4BTRACE_H__
 
-int i4btrace_open(wtap *wth, int *err);
+int i4btrace_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index 8d91f940de8331a6e5a120da55d7f58dc3389cf7..e580155a62e5a2ff40da6854f1b51c197eb8c0d0 100644 (file)
@@ -1,6 +1,6 @@
 /* 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);
@@ -50,7 +52,7 @@ static void fill_in_pseudo_header(int encap, const guint8 *pd, guint32 len,
     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];
@@ -119,7 +121,8 @@ typedef struct {
 #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;
@@ -180,9 +183,9 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
        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;
        }
 
@@ -208,7 +211,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, 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 _U_)
 {
        int                     ret;
        guint8                  header[IPTRACE_1_0_PHDR_SIZE];
@@ -297,7 +300,8 @@ typedef struct {
 #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;
@@ -362,9 +366,9 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
        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;
        }
 
@@ -390,7 +394,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, 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 _U_)
 {
        int                     ret;
        guint8                  header[IPTRACE_2_0_PHDR_SIZE];
index 0a0f53d63af152e50a120200e90184b0a849c308..617b7bc3ab8939d193f5b509bbccba0d059240f3 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #ifndef __IPTRACE_H__
 #define __IPTRACE_H__
 
-int iptrace_open(wtap *wth, int *err);
+int iptrace_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index dff4ddf0086b8785fc2f832faa1a4011e42e1901..51bec6af0b8466f0d4e274b0c288b4d4dc947995 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -117,13 +117,15 @@ static const guint8 LA_CyclicInformationFake[] = {
 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];
@@ -242,10 +244,10 @@ int lanalyzer_open(wtap *wth, int *err)
                                                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;
@@ -270,7 +272,8 @@ int lanalyzer_open(wtap *wth, int *err)
 #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;
@@ -308,9 +311,9 @@ static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset)
         * 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 {
@@ -357,8 +360,8 @@ static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset)
                /*
                 * 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;
        }
 
@@ -396,7 +399,8 @@ static gboolean lanalyzer_read(wtap *wth, int *err, 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 _U_)
 {
        int bytes_read;
 
index b896558bdbab310ea1a94261bcc4441e41370183..7f597da6db69bb2b91573a2bc2bdc70c06eb32ce 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -169,7 +169,7 @@ typedef struct {
       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);
 
index fad1c2204d59469b7290230ae66f136ed36001ef..5dc5b02e971bb3c0dd4071dad35be9baa4005d69 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -79,20 +79,22 @@ typedef enum {
 } 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);
@@ -490,7 +492,7 @@ int wtap_pcap_encap_to_wtap_encap(int encap)
 }
 
 
-int libpcap_open(wtap *wth, int *err)
+int libpcap_open(wtap *wth, int *err, gchar **err_info)
 {
        int bytes_read;
        guint32 magic;
@@ -568,9 +570,9 @@ int libpcap_open(wtap *wth, int *err)
        }
        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;
        }
 
@@ -636,9 +638,9 @@ int libpcap_open(wtap *wth, int *err)
        }
        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;
        }
 
@@ -883,7 +885,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
        /*
         * 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
@@ -922,7 +924,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
        /*
         * 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
@@ -960,7 +962,8 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
 }
 
 /* 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;
@@ -968,7 +971,7 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset)
        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.
@@ -1018,9 +1021,9 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset)
                         * 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,
@@ -1048,13 +1051,13 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset)
                         * 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 */
 
                /*
@@ -1093,7 +1096,8 @@ static gboolean libpcap_read(wtap *wth, int *err, 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)
+    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;
@@ -1117,7 +1121,7 @@ libpcap_seek_read(wtap *wth, long seek_off,
 
        case WTAP_ENCAP_IRDA:
                if (!libpcap_read_irda_pseudoheader(wth->random_fh, pseudo_header,
-                   err)) {
+                   err, err_info)) {
                        /* Read error */
                        return FALSE;
                }
@@ -1140,13 +1144,11 @@ libpcap_seek_read(wtap *wth, long seek_off,
        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;
 
@@ -1196,11 +1198,11 @@ static int libpcap_read_header(wtap *wth, int *err,
                 * 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;
        }
 
@@ -1213,11 +1215,11 @@ static int libpcap_read_header(wtap *wth, int *err,
                 * 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;
        }
 
@@ -1369,22 +1371,23 @@ libpcap_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header
 
 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;
@@ -1398,7 +1401,8 @@ libpcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_heade
                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
@@ -1529,7 +1533,7 @@ wtap_process_pcap_packet(gint linktype, const struct pcap_pkthdr *phdr,
                        return NULL;
                }
                if (!libpcap_get_irda_pseudoheader((const struct irda_sll_hdr *)pd,
-                       pseudo_header, err))
+                       pseudo_header, err, NULL))
                        return NULL;
 
                /*
index 0b3921433925fd56a7d22c233c9ac6c39d1bce83..98a2c36f6df670a27d7a3fe3f6dbf8ca9c60a20d 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -91,7 +91,7 @@ struct pcaprec_nokia_hdr {
        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);
 
index 2beefcdbe27026b64cd549366cbe88006bb9e390..c5c48411e974ece6610cebe868186c033584665f 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -104,9 +104,11 @@ struct netmon_atm_hdr {
        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,
@@ -117,7 +119,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     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];
@@ -184,17 +186,17 @@ int netmon_open(wtap *wth, int *err)
                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;
        }
 
@@ -256,15 +258,15 @@ int netmon_open(wtap *wth, int *err)
        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) {
@@ -298,7 +300,8 @@ int netmon_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -377,9 +380,9 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset)
                 * 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;
        }
 
@@ -400,9 +403,9 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset)
                         * 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,
@@ -465,7 +468,8 @@ static gboolean netmon_read(wtap *wth, int *err, 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 _U_)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
                return FALSE;
index 44a60dbb0a763fa5e8ad5fa43e08f33030eb7c6b..d1c26595604f3c9de6ee4e8e1de63087c63b8ec9 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -23,7 +23,7 @@
 #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);
 
index a4252d4c06bb53d534b587b8f056a2f8e26316f5..32cc1107311ac76d6128c7b979f6f2a849d97e99 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -123,18 +123,19 @@ struct nettlrec_ns_ls_drv_eth_hdr {
 };
 
 
-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;
@@ -185,14 +186,15 @@ int nettl_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -213,7 +215,7 @@ static gboolean nettl_read(wtap *wth, int *err, 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)
 {
     int ret;
     struct wtap_pkthdr phdr;
@@ -223,7 +225,7 @@ nettl_seek_read(wtap *wth, long seek_off,
 
     /* 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) {
@@ -241,7 +243,8 @@ nettl_seek_read(wtap *wth, long seek_off,
 
 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;
@@ -435,9 +438,9 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                (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;
index 2202fa1fe277a9043bbecaec1db9e71dfd4532ee..acad0ce7ce902665b3a58895f49b34b28997c971 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -80,6 +80,6 @@
 #define NETTL_SUBSYS_IGELAN            0xFC
 
 
-int nettl_open(wtap *wth, int *err);
+int nettl_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index 594945eebd8e7aff07b0e31fe1e8d123fc54d760..4bd41fda4e14891f678f0c682ce35bece4166d01 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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 $
  */
 
 /***************************************************************************
@@ -96,14 +96,16 @@ static void init_time_offset(void)
 }
 
 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;
 
@@ -128,8 +130,8 @@ int network_instruments_open(wtap *wth, int *err)
 
        /* 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;
        }
 
@@ -155,15 +157,15 @@ int network_instruments_open(wtap *wth, int *err)
        /* 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];
@@ -192,7 +194,8 @@ int network_instruments_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -217,8 +220,8 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset)
        /* 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;
        }
 
@@ -244,10 +247,10 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset)
        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);
@@ -276,7 +279,8 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset)
 
 /* 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;
 
@@ -296,8 +300,8 @@ static gboolean observer_seek_read(wtap *wth, long seek_off,
 
        /* 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;
        }
 
@@ -305,7 +309,6 @@ static gboolean observer_seek_read(wtap *wth, long seek_off,
        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;
        }
 
index 7760f1580ad77e57181ba6aa9130e2b7ae8bf9a0..63c6b833027a0da0bc4a537fb7d88c4fc616dd23 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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 $
  */
 
 /***************************************************************************
@@ -22,7 +22,7 @@
 #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);
 
index c604fd223c091c78447c49dfb4f322cc31c9315f..8922a8b429454836172dc30c6954d99cc84901ad 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -151,9 +151,11 @@ union netxrayrec_hdr {
        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,
@@ -170,7 +172,7 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
     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];
@@ -274,8 +276,8 @@ int netxray_open(wtap *wth, int *err)
                        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;
                }
        }
@@ -302,17 +304,17 @@ int netxray_open(wtap *wth, int *err)
                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;
        }
 
@@ -380,9 +382,9 @@ int netxray_open(wtap *wth, int *err)
                        }
                } 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];
@@ -442,9 +444,9 @@ int netxray_open(wtap *wth, int *err)
                                        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;
@@ -457,9 +459,9 @@ int netxray_open(wtap *wth, int *err)
                                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
@@ -544,7 +546,8 @@ int netxray_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -650,7 +653,8 @@ reread:
 
 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;
index e4b49148149c2e939a373b2c4dc0ddf2a6effb76..0aae12380a739e85c2ea98010eacf791c93ce384 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -23,7 +23,7 @@
 #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);
index b0994cfcda50fc1e1fb9028e86aa6bb20a25ad4b..fcabc3f20eef1c6d34d57eefd1732c07acad48e9 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -353,15 +353,17 @@ struct frame6_rec {
 #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,
@@ -395,7 +397,7 @@ static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream,
 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];
@@ -457,8 +459,8 @@ int ngsniffer_open(wtap *wth, int *err)
        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;
        }
 
@@ -475,16 +477,16 @@ int ngsniffer_open(wtap *wth, int *err)
        /* 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;
        }
 
@@ -515,7 +517,7 @@ int ngsniffer_open(wtap *wth, int *err)
         * 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) {
                /*
@@ -630,7 +632,7 @@ int ngsniffer_open(wtap *wth, int *err)
 }
 
 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];
@@ -713,7 +715,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers)
 
                        case 2:
                                if (process_rec_header2_v2(wth, buffer,
-                                   length, err) < 0)
+                                   length, err, err_info) < 0)
                                        return -1;
                                break;
 
@@ -721,7 +723,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers)
                        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;
                        }
@@ -745,7 +747,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers)
 
 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";
 
@@ -760,20 +762,20 @@ process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length,
                /*
                 * 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;
@@ -781,7 +783,7 @@ process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length,
 
 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
@@ -791,8 +793,8 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
                /*
                 * 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;
        }
 
@@ -860,8 +862,8 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
                                /*
                                 * 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)
@@ -878,16 +880,17 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
                /*
                 * 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;
@@ -919,8 +922,8 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset)
                                 * 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;
                        }
 
@@ -951,8 +954,8 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset)
                                 * 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;
                        }
 
@@ -1048,8 +1051,8 @@ found:
                /*
                 * 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;
        }
 
@@ -1078,7 +1081,7 @@ found:
 
 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;
index 2d3e48b338040b71acff07e2ddabc3cb430b513c..c861e9c4e868c98d50557c5912108d3354c82fd4 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -23,7 +23,7 @@
 #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);
 
index 2fe86b40bd26d10ab773d8b231ba86e06668712b..914460c977126363eb019f5a511c19e1a89b23bb 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
  *
@@ -98,9 +98,11 @@ typedef enum {
        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
@@ -211,8 +213,9 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
     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);
@@ -244,7 +247,7 @@ init_state(pppdump_t *state)
 
 
 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;
@@ -308,7 +311,7 @@ pppdump_open(wtap *wth, int *err)
 
 /* 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;
@@ -333,7 +336,7 @@ pppdump_read(wtap *wth, int *err, long *data_offset)
        } 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);
@@ -522,8 +525,9 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
 
 /* 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;
@@ -660,8 +664,8 @@ collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes,
 
                        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;
                }
 
@@ -680,7 +684,8 @@ pppdump_seek_read(wtap *wth,
                 union wtap_pseudo_header *pseudo_header,
                 guint8 *pd,
                 int len,
-                int *err)
+                int *err,
+                gchar **err_info)
 {
        int             num_bytes;
        direction_enum  direction;
@@ -693,6 +698,7 @@ pppdump_seek_read(wtap *wth,
        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;
        }
 
@@ -715,14 +721,16 @@ pppdump_seek_read(wtap *wth,
         */
        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;
        }
 
index d57548ad9223ea199ae376e185442bf0c89c135c..49ea0eda4058f5aaebbed39fdc78712308900069 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
  *
@@ -23,6 +23,6 @@
 #ifndef __PPPDUMP_H__
 #define __PPPDUMP_H__
 
-int pppdump_open(wtap *wth, int *err);
+int pppdump_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index 7754c1555eb30a52f424624ca629fe225ce7d491..0c93110908346f7bcd676ea92b5ccc8af576253a 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -89,16 +89,17 @@ struct radcomrec_hdr {
        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];
@@ -218,8 +219,8 @@ int radcom_open(wtap *wth, int *err)
        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;
        }
 
@@ -264,7 +265,8 @@ read_error:
 }
 
 /* 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;
@@ -372,7 +374,8 @@ static gboolean radcom_read(wtap *wth, int *err, 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)
+    union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
+    int *err, gchar **err_info _U_)
 {
        int     ret;
        struct radcomrec_hdr hdr;
index 81051fbe639956210796ba07447b076d40a41b0a..a345a0f0ff845e602ac6113643d0dfbf0528d168 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #ifndef __RADCOM_H__
 #define __RADCOM_H__
 
-int radcom_open(wtap *wth, int *err);
+int radcom_open(wtap *wth, int *err, gchar **err_info);
 
 #endif
index 2003a4ad5f3987d6d5ce3be916a2f2e486eb0d33..bc3a8811c4ae422c58b4cb78673741b98c96a3f1 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -88,9 +88,11 @@ struct shomiti_trailer {
 #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,
@@ -171,7 +173,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
  * 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];
@@ -269,8 +271,8 @@ int snoop_open(wtap *wth, int *err)
                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;
        }
 
@@ -364,9 +366,9 @@ int snoop_open(wtap *wth, int *err)
        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];
@@ -376,9 +378,9 @@ int snoop_open(wtap *wth, int *err)
        } 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];
@@ -400,7 +402,8 @@ int snoop_open(wtap *wth, int *err)
 }
 
 /* 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;
@@ -430,18 +433,18 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
                 * 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;
        }
 
@@ -461,9 +464,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
                         * 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,
@@ -525,9 +528,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
                /*
                 * 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);
@@ -552,7 +555,8 @@ static gboolean snoop_read(wtap *wth, int *err, 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 _U_)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
                return FALSE;
index 3571c6bbaa0f7ce211dc12fe98dff3c9aa873c1f..7be282ab047f93b060cda341878ceddba02de361 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -23,7 +23,7 @@
 #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);
 
index 68370ecaa6e2da0094c95e66980429bd2a915254..315ab9649a4adf5c2c47c005b1547b938f05daf7 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -109,15 +109,17 @@ static const char toshiba_rec_magic[]  = { '[', 'N', 'o', '.' };
  */
 #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. */
@@ -208,7 +210,7 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err)
 }
 
 
-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)) {
@@ -229,7 +231,8 @@ int toshiba_open(wtap *wth, int *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;
@@ -241,7 +244,8 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset)
                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;
 
@@ -250,7 +254,7 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset)
        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;
@@ -261,7 +265,8 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_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;
 
@@ -269,21 +274,24 @@ toshiba_seek_read (wtap *wth, long seek_off,
                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;
@@ -310,6 +318,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
 
        if (num_items_scanned != 7) {
                *err = WTAP_ERR_BAD_RECORD;
+               *err_info = g_strdup("toshiba: record header isn't valid");
                return -1;
        }
 
@@ -339,6 +348,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
        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;
        }
 
@@ -376,7 +386,8 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
 
 /* 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;
@@ -395,6 +406,7 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
                }
                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;
                }
        }
index 146a7d1b41d3e0d6a1623033792eb9fb521c5132..1dd684fb6df3954f1c35fc5a990e55659a0543e8 100644 (file)
@@ -1,6 +1,6 @@
 /* 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
index 013634a47c77fdc2250ef2566f0e8e8ef1f4cd31..0447b4b7e7b589786ac52f5281bed92f241aa9a6 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -112,11 +112,12 @@ struct visual_write_info
 
 
 /* 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,
@@ -126,7 +127,7 @@ static void visual_dump_free(wtap_dumper *wdh);
 
 
 /* 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];
@@ -164,8 +165,8 @@ int visual_open(wtap *wth, int *err)
     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;
     }
 
@@ -195,9 +196,9 @@ int visual_open(wtap *wth, int *err)
         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;
     }
 
@@ -230,7 +231,8 @@ int visual_open(wtap *wth, int *err)
    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;
@@ -271,9 +273,9 @@ static gboolean visual_read(wtap *wth, int *err, long *data_offset)
     {
         /* 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);
@@ -330,7 +332,8 @@ static void visual_close(wtap *wth)
    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);
index 6ef65146e0fe7ffca85bb16a324cf7c3cb617a8b..7becff9bf7d0cc31f570453977bea90dbffe8fb3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * 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>
@@ -28,7 +28,7 @@
 #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);
 
index 9258b234d77dd4bf50b56814bf1251b738b67595..a8f9ee7d60be528c82167fe1504775bec840d781 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -143,14 +143,16 @@ to handle them.
 #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
@@ -253,7 +255,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
 }
 
 
-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)) {
@@ -274,7 +276,8 @@ int vms_open(wtap *wth, int *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;
@@ -290,7 +293,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
         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;
 
@@ -299,7 +302,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
     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;
@@ -311,22 +314,25 @@ static gboolean vms_read(wtap *wth, int *err, long *data_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
@@ -356,7 +362,7 @@ isdumpline( gchar *line )
 
 /* 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;
@@ -406,6 +412,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
            /* 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;
            }
        }
@@ -416,6 +423,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
 
             if ( !*p ) {
                 *err = WTAP_ERR_BAD_RECORD;
+               *err_info = g_strdup_printf("vms: Length field not valid");
                 return -1;
             }
 
@@ -444,7 +452,8 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
 
 /* 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;
@@ -476,6 +485,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
        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;
         }
     }
index 799df5f62a20c35e7858e4d1874202a4440ea940..23cfdf3fabfc2a57580c921ea53d0eeb7b53a06f 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -24,6 +24,6 @@
 #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
index 53fe4e59fe570039d79ecc3064ced15076aa6525..0900220c5ca543561c0b0f3c9f21d3668d9d4757 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -130,9 +130,9 @@ typedef struct {
        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 */
index ce016140c0eabe04e1c4ebd5608a2ecc4695bd2b..106bbae9720d21dfc6d885c5e3d3591f4eb090b2 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -315,9 +315,9 @@ wtap_close(wtap *wth)
 }
 
 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 */
 
        /*
@@ -348,7 +348,8 @@ wtap_buf_ptr(wtap *wth)
 }
 
 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;
@@ -356,7 +357,7 @@ wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err)
        /* 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)
@@ -372,8 +373,8 @@ wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err)
 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);
 }
index 3b2133a7f8ed113c1a478b4d13a63a60b1a1bd37..9dfed9bf968e22bebda222d1afa5c490d669d4f3 100644 (file)
@@ -1,6 +1,6 @@
 /* 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>
@@ -427,16 +427,19 @@ typedef struct wtap_dumper wtap_dumper;
  *
  * 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);
@@ -459,7 +462,8 @@ const char *wtap_strerror(int err);
 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);