aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2011-11-19 20:18:01 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2011-11-19 20:18:01 +0000
commita33e6528d96478e58aad7ff1a0dc2e6ad7db2a8a (patch)
tree23f6e64eaa570e79fd24e3dd413e77eed56f9737
parent93a8dcc5e29222c3c48ad706146cad165cb8695f (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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39949 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--alert_box.c24
-rw-r--r--editcap.c21
-rw-r--r--epan/filesystem.c4
-rw-r--r--file.c167
-rw-r--r--merge.c28
-rw-r--r--merge.h13
-rw-r--r--mergecap.c37
-rw-r--r--tshark.c71
8 files changed, 247 insertions, 118 deletions
diff --git a/alert_box.c b/alert_box.c
index fd53c84c9f..666759df0f 100644
--- a/alert_box.c
+++ b/alert_box.c
@@ -80,7 +80,8 @@ read_failure_alert_box(const char *filename, int err)
/*
* Alert box for a failed attempt to write to a file.
- * "err" is assumed to be a UNIX-style errno.
+ * "err" is assumed to be a UNIX-style errno if positive and a
+ * Wiretap error if negative.
*
* XXX - add explanatory secondary text for at least some of the errors;
* various HIGs suggest that you should, for example, suggest that the
@@ -91,8 +92,25 @@ read_failure_alert_box(const char *filename, int err)
void
write_failure_alert_box(const char *filename, int err)
{
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(err), filename);
+ if (err < 0) {
+ switch (err) {
+
+ case WTAP_ERR_SHORT_WRITE:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "A full write couldn't be done to the file \"%s\".",
+ filename);
+ break;
+
+ default:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "An error occurred while writing to the file \"%s\": %s.",
+ filename, wtap_strerror(err));
+ break;
+ }
+ } else {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ file_write_error_message(err), filename);
+ }
}
/*
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++;
diff --git a/epan/filesystem.c b/epan/filesystem.c
index d3a5beeda5..2e744455ca 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -1688,10 +1688,6 @@ file_write_error_message(int err)
break;
#endif
- case WTAP_ERR_SHORT_WRITE:
- errmsg = "A full write couldn't be done to the file \"%s\".";
- break;
-
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while writing to the file \"%%s\": %s.",
diff --git a/file.c b/file.c
index cad7f9fb40..60e16149f9 100644
--- a/file.c
+++ b/file.c
@@ -126,7 +126,6 @@ static void cf_open_failure_alert_box(const char *filename, int err,
gchar *err_info, gboolean for_writing,
int file_type);
static const char *file_rename_error_message(int err);
-static void cf_write_failure_alert_box(const char *filename, int err);
static void cf_close_failure_alert_box(const char *filename, int err);
static void ref_time_packets(capture_file *cf);
/* Update the progress bar this many times when reading a file. */
@@ -1203,8 +1202,7 @@ cf_status_t
cf_merge_files(char **out_filenamep, int in_file_count,
char *const *in_filenames, int file_type, gboolean do_append)
{
- merge_in_file_t *in_files;
- wtap *wth;
+ merge_in_file_t *in_files, *in_file;
char *out_filename;
char *tmpname;
int out_fd;
@@ -1287,12 +1285,12 @@ cf_merge_files(char **out_filenamep, int in_file_count,
/* do the merge (or append) */
for (;;) {
if (do_append)
- wth = merge_append_read_packet(in_file_count, in_files, &read_err,
- &err_info);
+ in_file = merge_append_read_packet(in_file_count, in_files, &read_err,
+ &err_info);
else
- wth = merge_read_packet(in_file_count, in_files, &read_err,
- &err_info);
- if (wth == NULL) {
+ in_file = merge_read_packet(in_file_count, in_files, &read_err,
+ &err_info);
+ if (in_file == NULL) {
if (read_err != 0)
got_read_error = TRUE;
break;
@@ -1344,8 +1342,8 @@ cf_merge_files(char **out_filenamep, int in_file_count,
break;
}
- if (!wtap_dump(pdh, wtap_phdr(wth), wtap_pseudoheader(wth),
- wtap_buf_ptr(wth), &write_err)) {
+ if (!wtap_dump(pdh, wtap_phdr(in_file->wth), wtap_pseudoheader(in_file->wth),
+ wtap_buf_ptr(in_file->wth), &write_err)) {
got_write_error = TRUE;
break;
}
@@ -1368,51 +1366,51 @@ cf_merge_files(char **out_filenamep, int in_file_count,
*/
for (i = 0; i < in_file_count; i++) {
if (in_files[i].state == GOT_ERROR) {
- /* Put up a message box noting that a read failed somewhere along
- the line. */
- switch (read_err) {
-
- case WTAP_ERR_UNSUPPORTED_ENCAP:
- g_snprintf(errmsg_errno, sizeof(errmsg_errno),
- "The capture file %%s has a packet with a network type that Wireshark doesn't support.\n(%s)",
- err_info);
- g_free(err_info);
- errmsg = errmsg_errno;
- break;
+ /* Put up a message box noting that a read failed somewhere along
+ the line. */
+ switch (read_err) {
+
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The capture file %%s has a packet with a network type that Wireshark doesn't support.\n(%s)",
+ err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
- case WTAP_ERR_CANT_READ:
- errmsg = "An attempt to read from the capture file %s failed for"
- " some unknown reason.";
- break;
+ case WTAP_ERR_CANT_READ:
+ errmsg = "An attempt to read from the capture file %s failed for"
+ " some unknown reason.";
+ break;
- case WTAP_ERR_SHORT_READ:
- errmsg = "The capture file %s appears to have been cut short"
- " in the middle of a packet.";
- break;
+ case WTAP_ERR_SHORT_READ:
+ errmsg = "The capture file %s appears to have been cut short"
+ " in the middle of a packet.";
+ break;
- case WTAP_ERR_BAD_RECORD:
- g_snprintf(errmsg_errno, sizeof(errmsg_errno),
- "The capture file %%s appears to be damaged or corrupt.\n(%s)",
- err_info);
- g_free(err_info);
- errmsg = errmsg_errno;
- break;
+ case WTAP_ERR_BAD_RECORD:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The capture file %%s appears to be damaged or corrupt.\n(%s)",
+ err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
- case WTAP_ERR_DECOMPRESS:
- g_snprintf(errmsg_errno, sizeof(errmsg_errno),
- "The compressed capture file %%s appears to be damaged or corrupt.\n"
- "(%s)", err_info);
- g_free(err_info);
- errmsg = errmsg_errno;
- break;
+ case WTAP_ERR_DECOMPRESS:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The compressed capture file %%s appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
- default:
- g_snprintf(errmsg_errno, sizeof(errmsg_errno),
- "An error occurred while reading the"
- " capture file %%s: %s.", wtap_strerror(read_err));
- errmsg = errmsg_errno;
- break;
- }
+ default:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "An error occurred while reading the"
+ " capture file %%s: %s.", wtap_strerror(read_err));
+ errmsg = errmsg_errno;
+ break;
+ }
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, errmsg, in_files[i].filename);
}
}
@@ -1420,7 +1418,31 @@ cf_merge_files(char **out_filenamep, int in_file_count,
if (got_write_error) {
/* Put up an alert box for the write error. */
- cf_write_failure_alert_box(out_filename, write_err);
+ if (write_err < 0) {
+ /* Wiretap error. */
+ switch (write_err) {
+
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ /*
+ * This is a problem with the particular frame we're writing;
+ * note that, and give the frame number.
+ */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.",
+ in_file->packet_num, in_file->filename,
+ wtap_file_type_string(file_type));
+ break;
+
+ default:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "An error occurred while writing to the file \"%s\": %s.",
+ out_filename, wtap_strerror(write_err));
+ break;
+ }
+ } else {
+ /* OS error. */
+ write_failure_alert_box(out_filename, write_err);
+ }
}
if (got_read_error || got_write_error || stop_flag) {
@@ -3571,6 +3593,7 @@ cf_unignore_frame(capture_file *cf, frame_data *frame)
typedef struct {
wtap_dumper *pdh;
const char *fname;
+ int file_type;
} save_callback_args_t;
/*
@@ -3598,7 +3621,30 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
/* and save the packet */
if (!wtap_dump(args->pdh, &hdr, pseudo_header, pd, &err)) {
- cf_write_failure_alert_box(args->fname, err);
+ if (err < 0) {
+ /* Wiretap error. */
+ 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.
+ */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Frame %u has a network type that can't be saved in a \"%s\" file.",
+ fdata->num, wtap_file_type_string(args->file_type));
+ break;
+
+ default:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "An error occurred while writing to the file \"%s\": %s.",
+ args->fname, wtap_strerror(err));
+ break;
+ }
+ } else {
+ /* OS error. */
+ write_failure_alert_box(args->fname, err);
+ }
return FALSE;
}
return TRUE;
@@ -3695,7 +3741,7 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f
if (do_copy) {
/* Copy the file, if we haven't moved it. */
if (!copy_file_binary_mode(from_filename, fname))
- goto fail;
+ goto fail;
}
} else {
/* Either we're filtering packets, or we're saving in a different
@@ -3723,6 +3769,7 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f
"range" since we initialized it. */
callback_args.pdh = pdh;
callback_args.fname = fname;
+ callback_args.file_type = save_format;
switch (process_specified_packets(cf, range, "Saving", "selected packets",
TRUE, save_packet, &callback_args)) {
@@ -3953,20 +4000,6 @@ file_rename_error_message(int err)
return errmsg;
}
-static void
-cf_write_failure_alert_box(const char *filename, int err)
-{
- if (err < 0) {
- /* Wiretap error. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "An error occurred while writing to the file \"%s\": %s.",
- filename, wtap_strerror(err));
- } else {
- /* OS error. */
- write_failure_alert_box(filename, err);
- }
-}
-
/* Check for write errors - if the file is being written to an NFS server,
a write error may not show up until the file is closed, as NFS clients
might not send writes to the server until the "write()" call finishes,
diff --git a/merge.c b/merge.c
index b64d65baee..a489fc233a 100644
--- a/merge.c
+++ b/merge.c
@@ -49,6 +49,7 @@ merge_open_in_files(int in_file_count, char *const *in_file_names,
files[i].wth = wtap_open_offline(in_file_names[i], err, err_info, FALSE);
files[i].data_offset = 0;
files[i].state = PACKET_NOT_PRESENT;
+ files[i].packet_num = 0;
if (!files[i].wth) {
/* Close the files we've already opened. */
for (j = 0; j < i; j++)
@@ -149,11 +150,13 @@ is_earlier(struct wtap_nstime *l, struct wtap_nstime *r) {
/*
* Read the next packet, in chronological order, from the set of files
- * to be merged.
+ * to be merged. Return a pointer to the merge_in_file_t for the file
+ * from which the packet was read on success, or NULL on EOF or error.
+ * On EOF, *err is 0; on an error, it's an error code.
*/
-wtap *
-merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err,
- gchar **err_info)
+merge_in_file_t *
+merge_read_packet(int in_file_count, merge_in_file_t in_files[],
+ int *err, gchar **err_info)
{
int i;
int ei = -1;
@@ -199,15 +202,20 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err,
/* We'll need to read another packet from this file. */
in_files[ei].state = PACKET_NOT_PRESENT;
- /* Return a pointer to the wtap structure for the file with that frame. */
- return in_files[ei].wth;
+ /* Count this packet. */
+ in_files[ei].packet_num++;
+
+ /* Return the ordinal of the file from which the packet was read. */
+ return &in_files[ei];
}
/*
* Read the next packet, in file sequence order, from the set of files
- * to be merged.
+ * to be merged. Return a pointer to the merge_in_file_t for the file
+ * from which the packet was read on success, or NULL on EOF or error.
+ * On EOF, *err is 0; on an error, it's an error code.
*/
-wtap *
+merge_in_file_t *
merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
int *err, gchar **err_info)
{
@@ -235,6 +243,6 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
return NULL;
}
- /* Return a pointer to the wtap structure for the file with that frame. */
- return in_files[i].wth;
+ /* Return the ordinal of the file from which the packet was read. */
+ return &in_files[i];
}
diff --git a/merge.h b/merge.h
index 2a0a1bbd9a..afa28bdedf 100644
--- a/merge.h
+++ b/merge.h
@@ -44,6 +44,7 @@ typedef struct merge_in_file_s {
wtap *wth;
gint64 data_offset;
in_file_state_e state;
+ guint32 packet_num; /* current packet number */
gint64 size; /* file size */
} merge_in_file_t;
@@ -95,10 +96,10 @@ merge_max_snapshot_length(int in_file_count, merge_in_file_t in_files[]);
* @param in_files input file array
* @param err wiretap error, if failed
* @param err_info wiretap error string, if failed
- * @return pointer to wtap for file from which that packet came, or NULL on
- * error or EOF
+ * @return pointer to merge_in_file_t for file from which that packet
+ * came, or NULL on error or EOF
*/
-extern wtap *
+extern merge_in_file_t *
merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err,
gchar **err_info);
@@ -110,10 +111,10 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err,
* @param in_files input file array
* @param err wiretap error, if failed
* @param err_info wiretap error string, if failed
- * @return pointer to wtap for file from which that packet came, or NULL on
- * error or EOF
+ * @return pointer to merge_in_file_t for file from which that packet
+ * came, or NULL on error or EOF
*/
-extern wtap *
+extern merge_in_file_t *
merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
int *err, gchar **err_info);
diff --git a/mergecap.c b/mergecap.c
index 99a9cf26f2..51e64464c8 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -157,9 +157,8 @@ main(int argc, char *argv[])
#endif
int frame_type = -2;
int out_fd;
- merge_in_file_t *in_files = NULL;
+ merge_in_file_t *in_files = NULL, *in_file;
int i;
- wtap *wth;
struct wtap_pkthdr *phdr, snap_phdr;
wtap_dumper *pdh;
int open_err, read_err, write_err, close_err;
@@ -346,12 +345,12 @@ main(int argc, char *argv[])
count = 1;
for (;;) {
if (do_append)
- wth = merge_append_read_packet(in_file_count, in_files, &read_err,
- &err_info);
+ in_file = merge_append_read_packet(in_file_count, in_files, &read_err,
+ &err_info);
else
- wth = merge_read_packet(in_file_count, in_files, &read_err,
- &err_info);
- if (wth == NULL) {
+ in_file = merge_read_packet(in_file_count, in_files, &read_err,
+ &err_info);
+ if (in_file == NULL) {
if (read_err != 0)
got_read_error = TRUE;
break;
@@ -362,15 +361,15 @@ main(int argc, char *argv[])
/* We simply write it, perhaps after truncating it; we could do other
* things, like modify it. */
- phdr = wtap_phdr(wth);
+ phdr = wtap_phdr(in_file->wth);
if (snaplen != 0 && phdr->caplen > snaplen) {
snap_phdr = *phdr;
snap_phdr.caplen = snaplen;
phdr = &snap_phdr;
}
- if (!wtap_dump(pdh, phdr, wtap_pseudoheader(wth),
- wtap_buf_ptr(wth), &write_err)) {
+ if (!wtap_dump(pdh, phdr, wtap_pseudoheader(in_file->wth),
+ wtap_buf_ptr(in_file->wth), &write_err)) {
got_write_error = TRUE;
break;
}
@@ -405,8 +404,22 @@ main(int argc, char *argv[])
}
if (got_write_error) {
- fprintf(stderr, "mergecap: Error writing to outfile: %s\n",
- wtap_strerror(write_err));
+ switch (write_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, "mergecap: Frame %u of \"%s\" has a network type that can't be saved in a file with that format\n.",
+ in_file->packet_num, in_file->filename);
+ break;
+
+ default:
+ fprintf(stderr, "mergecap: Error writing to outfile: %s\n",
+ wtap_strerror(write_err));
+ break;
+ }
}
g_free(in_files);
diff --git a/tshark.c b/tshark.c
index 7a836f9406..e74d7a98b8 100644
--- a/tshark.c
+++ b/tshark.c
@@ -2672,6 +2672,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
gint linktype;
int snapshot_length;
wtap_dumper *pdh;
+ guint32 framenum;
int err;
gchar *err_info = NULL;
gint64 data_offset;
@@ -2707,8 +2708,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
- cmdarg_err("The capture file being read can't be written in "
- "the format \"%s\".", wtap_encap_short_string(linktype));
+ cmdarg_err("The capture file being read can't be written as a "
+ "\"%s\" file.", wtap_file_type_short_string(out_file_type));
break;
case WTAP_ERR_CANT_OPEN:
@@ -2753,7 +2754,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
tap_flags = union_of_tap_listener_flags();
if (perform_two_pass_analysis) {
- guint32 framenum;
frame_data *fdata;
int old_max_packet_count = max_packet_count;
@@ -2799,7 +2799,26 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth),
&err)) {
/* Error writing to a capture file */
- show_capture_file_io_error(save_file, err, FALSE);
+ 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.
+ *
+ * XXX - framenum is not necessarily the frame number in
+ * the input file if there was a read filter.
+ */
+ fprintf(stderr,
+ "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
+ framenum, cf->filename,
+ wtap_file_type_short_string(out_file_type));
+ break;
+
+ default:
+ show_capture_file_io_error(save_file, err, FALSE);
+ break;
+ }
wtap_dump_close(pdh, &err);
exit(2);
}
@@ -2818,7 +2837,10 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
}
}
else {
+ framenum = 0;
while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
+ framenum++;
+
if (process_packet(cf, data_offset, wtap_phdr(cf->wth),
wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth),
filtering_tap_listeners, tap_flags)) {
@@ -2830,7 +2852,23 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth),
&err)) {
/* Error writing to a capture file */
- show_capture_file_io_error(save_file, err, FALSE);
+ 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,
+ "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
+ framenum, cf->filename,
+ wtap_file_type_short_string(out_file_type));
+ break;
+
+ default:
+ show_capture_file_io_error(save_file, err, FALSE);
+ break;
+ }
wtap_dump_close(pdh, &err);
exit(2);
}
@@ -3598,8 +3636,8 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
case WTAP_ERR_CANT_WRITE_TO_PIPE:
/* Seen only when opening a capture file for writing. */
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
- "The file \"%%s\" is a pipe, and %s capture files can't be "
- "written to a pipe.", wtap_file_type_string(file_type));
+ "The file \"%%s\" is a pipe, and \"%s\" capture files can't be "
+ "written to a pipe.", wtap_file_type_short_string(file_type));
errmsg = errmsg_errno;
break;
@@ -3609,21 +3647,26 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
break;
case WTAP_ERR_UNSUPPORTED_ENCAP:
- if (for_writing)
- errmsg = "TShark can't save this capture in that format.";
- else {
+ if (for_writing) {
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "TShark can't save this capture as a \"%s\" file.",
+ wtap_file_type_short_string(file_type));
+ } else {
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" is a capture for a network type that TShark doesn't support.\n"
"(%s)", err_info);
g_free(err_info);
- errmsg = errmsg_errno;
}
+ errmsg = errmsg_errno;
break;
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
- if (for_writing)
- errmsg = "TShark can't save this capture in that format.";
- else
+ if (for_writing) {
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "TShark can't save this capture as a \"%s\" file.",
+ wtap_file_type_short_string(file_type));
+ errmsg = errmsg_errno;
+ } else
errmsg = "The file \"%s\" is a capture for a network type that TShark doesn't support.";
break;