diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-17 16:02:50 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-18 00:03:26 +0000 |
commit | 51522b33723dec4dd0481dcabc261010be39937c (patch) | |
tree | 4c772ba5dd3a61a470784464e39573ca27c5028c /tshark.c | |
parent | 8ce0f122011f26ab4e81172e9899ed27a5508abd (diff) |
Handle "I can't map this for that file format" better.
For cases where record (meta)data is something that can't be written out
in a particular file format, return WTAP_ERR_UNWRITABLE_REC_DATA along
with an err_info string.
Report (and free) that err_info string in cases where
WTAP_ERR_UNWRITABLE_REC_DATA is returned.
Clean up some other error reporting cases, and flag with an XXX some
cases where we aren't reporting errors at all, while we're at it.
Change-Id: I91d02093af0d42c24ec4634c2c773b30f3d39ab3
Reviewed-on: https://code.wireshark.org/review/5823
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 62 |
1 files changed, 60 insertions, 2 deletions
@@ -3238,7 +3238,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, filter, so, if we're writing to a capture file, write this packet out. */ if (pdh != NULL) { - if (!wtap_dump(pdh, &phdr, ws_buffer_start_ptr(&buf), &err)) { + if (!wtap_dump(pdh, &phdr, ws_buffer_start_ptr(&buf), &err, &err_info)) { /* Error writing to a capture file */ switch (err) { @@ -3272,6 +3272,38 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, wtap_file_type_subtype_short_string(out_file_type)); break; + case WTAP_ERR_REC_TYPE_UNSUPPORTED: + /* + * This is a problem with the particular record we're writing + * and the file type and subtype we're writing; note that, + * and report the record number and file type/subtype. + * + * XXX - framenum is not necessarily the record number in + * the input file if there was a read filter. + */ + fprintf(stderr, + "Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.\n", + framenum, cf->filename, + wtap_file_type_subtype_short_string(out_file_type)); + break; + + case WTAP_ERR_UNWRITABLE_REC_DATA: + /* + * This is a problem with the particular record we're writing + * and the file type and subtype we're writing; note that, + * and report the record number and file type/subtype. + * + * XXX - framenum is not necessarily the record number in + * the input file if there was a read filter. + */ + fprintf(stderr, + "Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)\n", + framenum, cf->filename, + wtap_file_type_subtype_short_string(out_file_type), + err_info); + g_free(err_info); + break; + default: show_capture_file_io_error(save_file, err, FALSE); break; @@ -3321,7 +3353,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, filter, so, if we're writing to a capture file, write this packet out. */ if (pdh != NULL) { - if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) { + if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err, &err_info)) { /* Error writing to a capture file */ switch (err) { @@ -3349,6 +3381,32 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, wtap_file_type_subtype_short_string(out_file_type)); break; + case WTAP_ERR_REC_TYPE_UNSUPPORTED: + /* + * This is a problem with the particular record we're writing + * and the file type and subtype we're writing; note that, + * and report the record number and file type/subtype. + */ + fprintf(stderr, + "Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.\n", + framenum, cf->filename, + wtap_file_type_subtype_short_string(out_file_type)); + break; + + case WTAP_ERR_UNWRITABLE_REC_DATA: + /* + * This is a problem with the particular record we're writing + * and the file type and subtype we're writing; note that, + * and report the record number and file type/subtype. + */ + fprintf(stderr, + "Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)\n", + framenum, cf->filename, + wtap_file_type_subtype_short_string(out_file_type), + err_info); + g_free(err_info); + break; + default: show_capture_file_io_error(save_file, err, FALSE); break; |