aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-11-19 20:18:01 +0000
committerGuy Harris <guy@alum.mit.edu>2011-11-19 20:18:01 +0000
commit2929c93ea276766076aed8bf617befba65d32eb4 (patch)
tree23f6e64eaa570e79fd24e3dd413e77eed56f9737 /editcap.c
parent4b2aa811e14412e3731714e4e54c344e967173c1 (diff)
When reporting "sorry, *this* packet can't be written to a file of that
type" when writing out a capture file (i.e., writing a per-packet-encapsulation capture to a file type that supports it but doesn't support one of the packet's encapsulations), report the packet number and, when doing this in a merge operation, report the file from which it came. When reporting "sorry, that file can't be written to a file of that type, period", show the file type rather than the input file link-layer type that causes the problem. (We could show both. We could be *really* ambitious and iterate through all possible file types and show the ones that will or at least might work....) file_write_error_message() is documented as handling only UNIX-style errnos, and libwireshark should be usable without libwiretap, so leave it up to its callers to handle Wiretap errors such as WTAP_ERR_SHORT_WRITE. Clean up indentation. svn path=/trunk/; revision=39949
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/editcap.c b/editcap.c
index e74946ec82..67badb1f62 100644
--- a/editcap.c
+++ b/editcap.c
@@ -830,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;
@@ -1122,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);
@@ -1443,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++;