Try to fix some of the build problems, it still bumms out on:
[obnox/wireshark/wip.git] / editcap.c
index 517e94d23bbb06e2848eee31f7824d0d48a6e7ca..d643ea45c6ead4f3bed4bcd898fe64f7768ea80e 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -42,9 +42,7 @@
 
 #include "wtap.h"
 
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#else
+#ifndef HAVE_GETOPT
 #include "wsutil/wsgetopt.h"
 #endif
 
@@ -60,7 +58,7 @@
 # include "wsutil/strptime.h"
 #endif
 
-#include "epan/crypt/crypt-md5.h"
+#include "epan/crypt/md5.h"
 #include "epan/plugins.h"
 #include "epan/report_err.h"
 #include "epan/filesystem.h"
@@ -725,7 +723,7 @@ usage(gboolean is_error)
   fprintf(output, "  -i <seconds per file>  split the packet output to different files\n");
   fprintf(output, "                         based on uniform time intervals\n");
   fprintf(output, "                         with a maximum of <seconds per file> each.\n");
-  fprintf(output, "  -F <capture type>      set the output file type; default is libpcap.\n");
+  fprintf(output, "  -F <capture type>      set the output file type; default is pcapng.\n");
   fprintf(output, "                         an empty \"-F\" option will list the file types.\n");
   fprintf(output, "  -T <encap type>        set the output file encapsulation type;\n");
   fprintf(output, "                         default is the same as the input file.\n");
@@ -832,6 +830,7 @@ main(int argc, char *argv[])
   const struct wtap_pkthdr *phdr;
   int err_type;
   guint8 *buf;
+  guint32 read_count = 0;
   int split_packet_count = 0;
   int written_count = 0;
   char *filename = NULL;
@@ -1087,7 +1086,7 @@ main(int argc, char *argv[])
 
     case WTAP_ERR_UNSUPPORTED:
     case WTAP_ERR_UNSUPPORTED_ENCAP:
-    case WTAP_ERR_BAD_RECORD:
+    case WTAP_ERR_BAD_FILE:
       fprintf(stderr, "(%s)\n", err_info);
       g_free(err_info);
       break;
@@ -1124,6 +1123,8 @@ main(int argc, char *argv[])
     }
 
     while (wtap_read(wth, &err, &err_info, &data_offset)) {
+      read_count++;
+
       phdr = wtap_phdr(wth);
       buf = wtap_buf_ptr(wth);
 
@@ -1445,8 +1446,22 @@ main(int argc, char *argv[])
         }
 
         if (!wtap_dump(pdh, phdr, wtap_pseudoheader(wth), buf, &err)) {
-          fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                  filename, wtap_strerror(err));
+          switch (err) {
+
+          case WTAP_ERR_UNSUPPORTED_ENCAP:
+            /*
+             * This is a problem with the particular frame we're writing;
+             * note that, and give the frame number.
+             */
+            fprintf(stderr, "editcap: Frame %u of \"%s\" has a network type that can't be saved in a file with that format\n.",
+                    read_count, argv[optind]);
+            break;
+
+          default:
+            fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                    filename, wtap_strerror(err));
+            break;
+          }
           exit(2);
         }
         written_count++;
@@ -1466,7 +1481,7 @@ main(int argc, char *argv[])
 
       case WTAP_ERR_UNSUPPORTED:
       case WTAP_ERR_UNSUPPORTED_ENCAP:
-      case WTAP_ERR_BAD_RECORD:
+      case WTAP_ERR_BAD_FILE:
         fprintf(stderr, "(%s)\n", err_info);
         g_free(err_info);
         break;