#include "wtap.h"
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#else
+#ifndef HAVE_GETOPT
#include "wsutil/wsgetopt.h"
#endif
# 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"
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");
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;
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;
}
while (wtap_read(wth, &err, &err_info, &data_offset)) {
+ read_count++;
+
phdr = wtap_phdr(wth);
buf = wtap_buf_ptr(wth);
}
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++;
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;