From 51522b33723dec4dd0481dcabc261010be39937c Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 17 Dec 2014 16:02:50 -0800 Subject: 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 --- capinfos.c | 2 ++ captype.c | 1 + editcap.c | 36 ++++++++++++++++++++++--- epan/wslua/wslua_dumper.c | 36 ++++++++++++++++++++----- epan/wslua/wslua_file.c | 4 +-- file.c | 61 +++++++++++++++++++++++++++++++++++++++--- mergecap.c | 32 +++++++++++++++++++--- randpkt.c | 14 +++++++++- reordercap.c | 20 +++++++++++--- tshark.c | 62 +++++++++++++++++++++++++++++++++++++++++-- ui/tap_export_pdu.c | 13 ++++++++- ui/text_import.c | 14 +++++++++- wiretap/5views.c | 4 +-- wiretap/btsnoop.c | 19 ++++++++----- wiretap/catapult_dct2000.c | 4 +-- wiretap/commview.c | 4 +-- wiretap/erf.c | 3 ++- wiretap/eyesdn.c | 4 +-- wiretap/file_access.c | 4 +-- wiretap/k12.c | 2 +- wiretap/k12text.l | 2 +- wiretap/lanalyzer.c | 2 +- wiretap/libpcap.c | 4 +-- wiretap/logcat.c | 2 +- wiretap/logcat_text.c | 6 +++-- wiretap/netmon.c | 4 +-- wiretap/netscaler.c | 4 +-- wiretap/nettl.c | 4 +-- wiretap/network_instruments.c | 4 +-- wiretap/netxray.c | 8 +++--- wiretap/ngsniffer.c | 4 +-- wiretap/pcapng.c | 2 +- wiretap/snoop.c | 4 +-- wiretap/visual.c | 4 +-- wiretap/wtap-int.h | 2 +- wiretap/wtap.c | 5 +++- wiretap/wtap.h | 6 ++++- 37 files changed, 333 insertions(+), 73 deletions(-) diff --git a/capinfos.c b/capinfos.c index 01b1122c09..7c98f33b6d 100644 --- a/capinfos.c +++ b/capinfos.c @@ -908,6 +908,7 @@ process_cap_file(wtap *wth, const char *filename) case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: case WTAP_ERR_DECOMPRESS: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); /* fallthrough */ @@ -1488,6 +1489,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: case WTAP_ERR_DECOMPRESS: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/captype.c b/captype.c index 6f6cac0242..17d21e8053 100644 --- a/captype.c +++ b/captype.c @@ -259,6 +259,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/editcap.c b/editcap.c index d91c53af48..aa1a275048 100644 --- a/editcap.c +++ b/editcap.c @@ -1253,6 +1253,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -1638,7 +1639,7 @@ main(int argc, char *argv[]) } } - if (!wtap_dump(pdh, phdr, buf, &err)) { + if (!wtap_dump(pdh, phdr, buf, &err, &err_info)) { switch (err) { case WTAP_ERR_UNWRITABLE_ENCAP: /* @@ -1648,7 +1649,7 @@ main(int argc, char *argv[]) * and file type/subtype. */ fprintf(stderr, - "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.", + "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n", read_count, argv[optind], wtap_file_type_subtype_string(out_file_type_subtype)); break; @@ -1661,11 +1662,39 @@ main(int argc, char *argv[]) * and file type/subtype. */ fprintf(stderr, - "editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.", + "editcap: Frame %u of \"%s\" is too large for a \"%s\" file.\n", read_count, argv[optind], wtap_file_type_subtype_string(out_file_type_subtype)); 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, + "editcap: Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.\n", + read_count, argv[optind], + wtap_file_type_subtype_string(out_file_type_subtype)); + 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, + "editcap: Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)\n", + read_count, argv[optind], + wtap_file_type_subtype_string(out_file_type_subtype), + err_info); + g_free(err_info); + break; + default: fprintf(stderr, "editcap: Error writing to %s: %s\n", filename, wtap_strerror(err)); @@ -1691,6 +1720,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c index 1c59c5d8f9..747bb700f2 100644 --- a/epan/wslua/wslua_dumper.c +++ b/epan/wslua/wslua_dumper.c @@ -301,6 +301,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) { struct wtap_pkthdr pkthdr; double ts; int err; + gchar *err_info; if (!d) return 0; @@ -335,9 +336,20 @@ WSLUA_METHOD Dumper_dump(lua_State* L) { /* TODO: Can we get access to pinfo->pkt_comment here somehow? We * should be copying it to pkthdr.opt_comment if we can. */ - if (! wtap_dump(d, &pkthdr, ba->data, &err)) { - luaL_error(L,"error while dumping: %s", - wtap_strerror(err)); + if (! wtap_dump(d, &pkthdr, ba->data, &err, &err_info)) { + switch (err) { + + case WTAP_ERR_UNWRITABLE_REC_DATA: + luaL_error(L,"error while dumping: %s (%s)", + wtap_strerror(err), err_info); + g_free(err_info); + break; + + default: + luaL_error(L,"error while dumping: %s", + wtap_strerror(err)); + break; + } } return 0; @@ -402,6 +414,7 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) { tvbuff_t* tvb; struct data_source *data_src; int err = 0; + gchar *err_info; if (!d) return 0; @@ -432,9 +445,20 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) { data = (const guchar *)tvb_memdup(wmem_packet_scope(),tvb,0,pkthdr.caplen); - if (! wtap_dump(d, &pkthdr, data, &err)) { - luaL_error(L,"error while dumping: %s", - wtap_strerror(err)); + if (! wtap_dump(d, &pkthdr, data, &err, &err_info)) { + switch (err) { + + case WTAP_ERR_UNWRITABLE_REC_DATA: + luaL_error(L,"error while dumping: %s (%s)", + wtap_strerror(err), err_info); + g_free(err_info); + break; + + default: + luaL_error(L,"error while dumping: %s", + wtap_strerror(err)); + break; + } } return 0; diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c index 355d972204..85818b9aca 100644 --- a/epan/wslua/wslua_file.c +++ b/epan/wslua/wslua_file.c @@ -1948,7 +1948,7 @@ wslua_filehandler_can_write_encap(int encap, void* data) /* some declarations */ static gboolean wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean wslua_filehandler_dump_close(wtap_dumper *wdh, int *err); @@ -2019,7 +2019,7 @@ wslua_filehandler_dump_open(wtap_dumper *wdh, int *err) */ static gboolean wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { FileHandler fh = (FileHandler)(wdh->wslua_data); int retval = -1; diff --git a/file.c b/file.c index 3d744571c2..160c31de5e 100644 --- a/file.c +++ b/file.c @@ -1248,7 +1248,7 @@ cf_merge_files(char **out_filenamep, int in_file_count, int out_fd; wtap_dumper *pdh; int open_err, read_err, write_err, close_err; - gchar *err_info; + gchar *err_info, *write_err_info; int err_fileno; int i; gboolean got_read_error = FALSE, got_write_error = FALSE; @@ -1491,7 +1491,7 @@ cf_merge_files(char **out_filenamep, int in_file_count, phdr->presence_flags = phdr->presence_flags | WTAP_HAS_INTERFACE_ID; } if (!wtap_dump(pdh, wtap_phdr(in_file->wth), - wtap_buf_ptr(in_file->wth), &write_err)) { + wtap_buf_ptr(in_file->wth), &write_err, &write_err_info)) { got_write_error = TRUE; break; } @@ -1599,6 +1599,36 @@ cf_merge_files(char **out_filenamep, int in_file_count, g_free(display_basename); 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. + */ + display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN"); + simple_error_message_box( + "Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.", + in_file ? in_file->packet_num : 0, display_basename, + wtap_file_type_subtype_string(file_type)); + g_free(display_basename); + 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 frame number and file type/subtype. + */ + display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN"); + simple_error_message_box( + "Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)", + in_file ? in_file->packet_num : 0, display_basename, + wtap_file_type_subtype_string(file_type), + write_err_info); + g_free(write_err_info); + g_free(display_basename); + break; + default: display_basename = g_filename_display_basename(out_filename); simple_error_message_box( @@ -4098,6 +4128,7 @@ save_record(capture_file *cf, frame_data *fdata, save_callback_args_t *args = (save_callback_args_t *)argsp; struct wtap_pkthdr hdr; int err; + gchar *err_info; gchar *display_basename; const char *pkt_comment; @@ -4145,7 +4176,7 @@ save_record(capture_file *cf, frame_data *fdata, hdr.pack_flags = /* XXX - 0 for now (any value for "we don't have it"?) */ #endif /* and save the packet */ - if (!wtap_dump(args->pdh, &hdr, pd, &err)) { + if (!wtap_dump(args->pdh, &hdr, pd, &err, &err_info)) { if (err < 0) { /* Wiretap error. */ switch (err) { @@ -4172,6 +4203,30 @@ save_record(capture_file *cf, frame_data *fdata, fdata->num, wtap_file_type_subtype_string(args->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. + */ + simple_error_message_box( + "Record %u has a record type that can't be saved in a \"%s\" file.", + fdata->num, wtap_file_type_subtype_string(args->file_type)); + break; + + case WTAP_ERR_UNWRITABLE_REC_DATA: + /* + * This is a problem with the particular frame we're writing and + * the file type and subtype we're writing; note that, and report + * the frame number and file type/subtype. + */ + simple_error_message_box( + "Record %u has data that can't be saved in a \"%s\" file.\n(%s)", + fdata->num, wtap_file_type_subtype_string(args->file_type), + err_info); + g_free(err_info); + break; + default: display_basename = g_filename_display_basename(args->fname); simple_error_message_box( diff --git a/mergecap.c b/mergecap.c index b85f1f04e8..433d44584d 100644 --- a/mergecap.c +++ b/mergecap.c @@ -254,7 +254,7 @@ main(int argc, char *argv[]) struct wtap_pkthdr *phdr, snap_phdr; wtap_dumper *pdh; int open_err, read_err = 0, write_err, close_err; - gchar *err_info; + gchar *err_info, *write_err_info; int err_fileno; char *out_filename = NULL; gboolean got_read_error = FALSE, got_write_error = FALSE; @@ -379,6 +379,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -515,7 +516,7 @@ main(int argc, char *argv[]) phdr = &snap_phdr; } - if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), &write_err)) { + if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), &write_err, &write_err_info)) { got_write_error = TRUE; break; } @@ -548,6 +549,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -576,11 +578,35 @@ main(int argc, char *argv[]) * the file type and subtype we're wwriting; note that, and * report the frame number and file type/subtype. */ - fprintf(stderr, "mergecap: Frame %u of \"%s\" is too large for a \"%s\" file\n.", + fprintf(stderr, "mergecap: Frame %u of \"%s\" is too large for a \"%s\" file.\n", in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", wtap_file_type_subtype_string(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 wwriting; note that, and + * report the record number and file type/subtype. + */ + fprintf(stderr, "mergecap: Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.\n", + in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", + wtap_file_type_subtype_string(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 wwriting; note that, and + * report the record number and file type/subtype. + */ + fprintf(stderr, "mergecap: Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)\n", + in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", + wtap_file_type_subtype_string(file_type), + write_err_info); + g_free(write_err_info); + break; + default: fprintf(stderr, "mergecap: Error writing to outfile: %s\n", wtap_strerror(write_err)); diff --git a/randpkt.c b/randpkt.c index c08109ddea..1ec7d18baa 100644 --- a/randpkt.c +++ b/randpkt.c @@ -498,6 +498,7 @@ main(int argc, char **argv) struct wtap_pkthdr pkthdr; union wtap_pseudo_header *ps_header = &pkthdr.pseudo_header; int i, j, len_this_pkt, len_random, err; + gchar *err_info; guint8 buffer[65536]; int opt; @@ -619,7 +620,18 @@ main(int argc, char **argv) } } - wtap_dump(dump, &pkthdr, &buffer[0], &err); + /* XXX - report errors! */ + if (!wtap_dump(dump, &pkthdr, &buffer[0], &err, &err_info)) { + switch (err) { + + case WTAP_ERR_UNWRITABLE_REC_DATA: + g_free(err_info); + break; + + default: + break; + } + } } wtap_dump_close(dump, &err); diff --git a/reordercap.c b/reordercap.c index 014c839951..72099cf467 100644 --- a/reordercap.c +++ b/reordercap.c @@ -126,6 +126,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -140,9 +141,20 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, phdr->ts = frame->time; /* Dump frame to outfile */ - if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err)) { - fprintf(stderr, "reordercap: Error (%s) writing frame to outfile\n", - wtap_strerror(err)); + if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) { + switch (err) { + + case WTAP_ERR_UNWRITABLE_REC_DATA: + fprintf(stderr, "reordercap: Error (%s) writing frame to outfile (%s)\n", + wtap_strerror(err), err_info); + g_free(err_info); + break; + + default: + fprintf(stderr, "reordercap: Error (%s) writing frame to outfile\n", + wtap_strerror(err)); + break; + } exit(1); } } @@ -288,6 +300,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -345,6 +358,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/tshark.c b/tshark.c index a3b4e9188a..617ab1b8d8 100644 --- a/tshark.c +++ b/tshark.c @@ -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; diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index d7e41d6839..2b9b64e113 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -46,6 +46,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co exp_pdu_t *exp_pdu_tap_data = (exp_pdu_t *)tapdata; struct wtap_pkthdr pkthdr; int err; + gchar *err_info; int buffer_len; guint8 *packet_buf; @@ -71,8 +72,18 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS; /* XXX: should the pkthdr.pseudo_header be set to the pinfo's pseudo-header? */ + /* XXX: report errors! */ + if (!wtap_dump(exp_pdu_tap_data->wdh, &pkthdr, packet_buf, &err, &err_info)) { + switch (err) { - wtap_dump(exp_pdu_tap_data->wdh, &pkthdr, packet_buf, &err); + case WTAP_ERR_UNWRITABLE_REC_DATA: + g_free(err_info); + break; + + default: + break; + } + } g_free(packet_buf); g_free(pkthdr.opt_comment); diff --git a/ui/text_import.c b/ui/text_import.c index a645f05de1..dc103d75e6 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -523,6 +523,7 @@ write_current_packet (void) /* Write the packet */ struct wtap_pkthdr pkthdr; int err; + gchar *err_info; memset(&pkthdr, 0, sizeof(struct wtap_pkthdr)); @@ -535,7 +536,18 @@ write_current_packet (void) pkthdr.pack_flags |= direction; pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS; - wtap_dump(wdh, &pkthdr, packet_buf, &err); + /* XXX - report errors! */ + if (!wtap_dump(wdh, &pkthdr, packet_buf, &err, &err_info)) { + switch (err) { + + case WTAP_ERR_UNWRITABLE_REC_DATA: + g_free(err_info); + break; + + default: + break; + } + } } } diff --git a/wiretap/5views.c b/wiretap/5views.c index aa5dd9afa9..67de759c1d 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -106,7 +106,7 @@ static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, struct wtap_pkthdr *phdr, int *err, gchar **err_info); -static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err); +static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err, gchar **err_info); static gboolean _5views_dump_close(wtap_dumper *wdh, int *err); @@ -351,7 +351,7 @@ gboolean _5views_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv; t_5VW_TimeStamped_Header HeaderFrame; diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index af10c3c86d..ee6231e3b2 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -281,10 +281,10 @@ static guint8 btsnoop_lookup_flags(guint8 hci_type, gboolean sent, guint8 *flags return FALSE; } -static gboolean btsnoop_dump_partial_rec_hdr(wtap_dumper *wdh _U_, +static gboolean btsnoop_format_partial_rec_hdr( const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, - const guint8 *pd, int *err, + const guint8 *pd, int *err, gchar **err_info, struct btsnooprec_hdr *rec_hdr) { gint64 ts_usec; @@ -292,7 +292,10 @@ static gboolean btsnoop_dump_partial_rec_hdr(wtap_dumper *wdh _U_, guint8 flags = 0; if (!btsnoop_lookup_flags(*pd, pseudo_header->p2p.sent, &flags)) { - *err = WTAP_ERR_UNSUPPORTED; + *err = WTAP_ERR_UNWRITABLE_REC_DATA; + *err_info = g_strdup_printf("btsnoop: hci_type 0x%02x for %s data isn't supported", + *pd, + pseudo_header->p2p.sent ? "sent" : "received"); return FALSE; } @@ -310,7 +313,7 @@ static gboolean btsnoop_dump_partial_rec_hdr(wtap_dumper *wdh _U_, /* FIXME: How do we support multiple backends?*/ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct btsnooprec_hdr rec_hdr; @@ -330,7 +333,8 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, return FALSE; } - if (!btsnoop_dump_partial_rec_hdr(wdh, phdr, pseudo_header, pd, err, &rec_hdr)) + if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info, + &rec_hdr)) return FALSE; rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen-1); @@ -354,7 +358,7 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, static gboolean btsnoop_dump_h4(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct btsnooprec_hdr rec_hdr; @@ -371,7 +375,8 @@ static gboolean btsnoop_dump_h4(wtap_dumper *wdh, return FALSE; } - if (!btsnoop_dump_partial_rec_hdr(wdh, phdr, pseudo_header, pd, err, &rec_hdr)) + if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info, + &rec_hdr)) return FALSE; rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen); diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 28c60093b0..59ed3958df 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -111,7 +111,7 @@ static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, static void catapult_dct2000_close(wtap *wth); static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); /************************************************************/ @@ -586,7 +586,7 @@ catapult_dct2000_dump_can_write_encap(int encap) static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; guint32 n; diff --git a/wiretap/commview.c b/wiretap/commview.c index c82fdbb51a..6c410f950e 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -86,7 +86,7 @@ static gboolean commview_seek_read(wtap *wth, gint64 seek_off, static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err, gchar **err_info); static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info) { @@ -314,7 +314,7 @@ gboolean commview_dump_open(wtap_dumper *wdh, int *err _U_) * Returns TRUE on success, FALSE on failure. */ static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { commview_header_t cv_hdr; struct tm *tm; diff --git a/wiretap/erf.c b/wiretap/erf.c index b6a984a82e..acf06057f6 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -592,7 +592,8 @@ static gboolean erf_dump( wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, - int *err) + int *err, + gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; union wtap_pseudo_header other_phdr; diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 83daf82186..25e046edd6 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -356,7 +356,7 @@ esc_write(wtap_dumper *wdh, const guint8 *buf, int len, int *err) static gboolean eyesdn_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err) { @@ -393,7 +393,7 @@ int eyesdn_dump_can_write_encap(int encap) * Returns TRUE on success, FALSE on failure. */ static gboolean eyesdn_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { static const guint8 start_flag = 0xff; const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 018045cf61..c475ffd6a6 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -2316,9 +2316,9 @@ wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compress gboolean wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info) { - return (wdh->subtype_write)(wdh, phdr, pd, err); + return (wdh->subtype_write)(wdh, phdr, pd, err, err_info); } void diff --git a/wiretap/k12.c b/wiretap/k12.c index 934e8d4ec5..af1f4d84ca 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -1249,7 +1249,7 @@ static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) { } static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) { + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; k12_dump_t *k12 = (k12_dump_t *)wdh->priv; guint32 len; diff --git a/wiretap/k12text.l b/wiretap/k12text.l index f203fa7edb..f5192cadd0 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -369,7 +369,7 @@ static const struct { int e; const char* s; } encaps[] = { static gboolean k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) { + const guint8 *pd, int *err, gchar **err_info _U_) { #define K12BUF_SIZE 196808 char *buf; size_t left = K12BUF_SIZE; diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index bac54fa204..26655cdb12 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -625,7 +625,7 @@ static void my_timersub(const struct timeval *a, *---------------------------------------------------*/ static gboolean lanalyzer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { double x; int i; diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index c6141cd1db..0aebcc30c7 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -67,7 +67,7 @@ static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off, static gboolean libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info, struct pcaprec_ss990915_hdr *hdr); @@ -889,7 +889,7 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct pcaprec_ss990915_hdr rec_hdr; diff --git a/wiretap/logcat.c b/wiretap/logcat.c index a10cc7544e..de11a42958 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -312,7 +312,7 @@ int logcat_dump_can_write_encap(int encap) static gboolean logcat_binary_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { int caplen; diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c index 96ec2cb656..c7bad0d7cf 100644 --- a/wiretap/logcat_text.c +++ b/wiretap/logcat_text.c @@ -404,7 +404,7 @@ int logcat_text_long_dump_can_write_encap(int encap) { static gboolean logcat_text_dump_text(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info) { gchar *buf; gint length; @@ -474,7 +474,9 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh, msg_pre_skip = 1 + (gint) strlen(tag) + 1; msg_begin = msg_payload + msg_pre_skip; } else { - *err = WTAP_ERR_UNSUPPORTED; + *err = WTAP_ERR_UNWRITABLE_REC_DATA; + *err_info = g_strdup_printf("logcat: version %d isn't supported", + logcat_version); return FALSE; } diff --git a/wiretap/netmon.c b/wiretap/netmon.c index e9f50ce204..a8648493da 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -183,7 +183,7 @@ static gboolean netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); static void netmon_sequential_close(wtap *wth); static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean netmon_dump_close(wtap_dumper *wdh, int *err); wtap_open_return_val netmon_open(wtap *wth, int *err, gchar **err_info) @@ -993,7 +993,7 @@ gboolean netmon_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv; diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index 7d3fb9da6b..e8a0eb5ae5 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -640,7 +640,7 @@ static gboolean nstrace_set_start_time(wtap *wth); static guint64 ns_hrtime2nsec(guint32 tm); static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); /* @@ -1784,7 +1784,7 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv; diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 88d42e6e8f..cb885661f9 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -183,7 +183,7 @@ static gboolean nettl_seek_read(wtap *wth, gint64 seek_off, static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); wtap_open_return_val nettl_open(wtap *wth, int *err, gchar **err_info) { @@ -682,7 +682,7 @@ gboolean nettl_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct nettlrec_hdr rec_hdr; diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 7eb647b575..bf96b30cf8 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -108,7 +108,7 @@ static int read_packet_data(FILE_T fh, int offset_to_frame, int current_offset_f static gboolean skip_to_next_packet(wtap *wth, int offset_to_next_packet, int current_offset_from_packet_header, int *err, char **err_info); static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gint observer_to_wtap_encap(int observer_encap); static gint wtap_to_observer_encap(int wtap_encap); @@ -668,7 +668,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, - int *err) + int *err, gchar **err_info _U_) { observer_dump_private_state * private_state = NULL; packet_entry_header packet_header; diff --git a/wiretap/netxray.c b/wiretap/netxray.c index fa047ccaca..69136373e0 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -412,11 +412,11 @@ static void netxray_guess_atm_type(wtap *wth, struct wtap_pkthdr *phdr, Buffer *buf); static gboolean netxray_dump_1_1(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err); static gboolean netxray_dump_2_0(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err); wtap_open_return_val @@ -1728,7 +1728,7 @@ netxray_dump_open_1_1(wtap_dumper *wdh, int *err) static gboolean netxray_dump_1_1(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv; guint64 timestamp; @@ -1906,7 +1906,7 @@ netxray_dump_open_2_0(wtap_dumper *wdh, int *err) static gboolean netxray_dump_2_0(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv; diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 06ba78468b..60ad2e113e 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -528,7 +528,7 @@ static int fix_pseudo_header(int encap, Buffer *buf, int len, static void ngsniffer_sequential_close(wtap *wth); static void ngsniffer_close(wtap *wth); static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err); static int SnifferDecompress( unsigned char * inbuf, size_t inlen, unsigned char * outbuf, size_t outlen, int *err, gchar **err_info ); @@ -1993,7 +1993,7 @@ ngsniffer_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->priv; diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 41edb34007..5ad679091a 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -3694,7 +3694,7 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err) static gboolean pcapng_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; #ifdef HAVE_PLUGINS diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 88aecaf7a8..67816b438c 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -96,7 +96,7 @@ static gboolean snoop_read_shomiti_wireless_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info, int *header_size); static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); /* * See @@ -813,7 +813,7 @@ gboolean snoop_dump_open(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct snooprec_hdr rec_hdr; diff --git a/wiretap/visual.c b/wiretap/visual.c index 02acaf711b..01b353446b 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -165,7 +165,7 @@ static gboolean visual_seek_read(wtap *wth, gint64 seek_off, static gboolean visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err); + const guint8 *pd, int *err, gchar **err_info); static gboolean visual_dump_close(wtap_dumper *wdh, int *err); static void visual_dump_free(wtap_dumper *wdh); @@ -642,7 +642,7 @@ gboolean visual_dump_open(wtap_dumper *wdh, int *err) /* Write a packet to a Visual dump file. Returns TRUE on success, FALSE on failure. */ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, - const guint8 *pd, int *err) + const guint8 *pd, int *err, gchar **err_info _U_) { const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct visual_write_info * visual = (struct visual_write_info *)wdh->priv; diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index c550502b81..6f63cfe939 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -95,7 +95,7 @@ typedef void *WFILE_T; typedef gboolean (*subtype_write_func)(struct wtap_dumper*, const struct wtap_pkthdr*, - const guint8*, int*); + const guint8*, int*, gchar**); typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*); struct wtap_dumper { diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 74cab0901c..40cabd0821 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -883,7 +883,10 @@ static const char *wtap_errlist[] = { NULL, /* WTAP_ERR_REC_TYPE_UNSUPPORTED */ - "That record type cannot be written in that format" + "That record type cannot be written in that format", + + /* WTAP_ERR_UNWRITABLE_REC_DATA */ + "That record can't be written in that format" }; #define WTAP_ERRLIST_SIZE (sizeof wtap_errlist / sizeof wtap_errlist[0]) diff --git a/wiretap/wtap.h b/wiretap/wtap.h index e7d80da355..5e707a24db 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1562,7 +1562,8 @@ wtap_dumper* wtap_dump_fdopen_ng(int fd, int filetype, int encap, int snaplen, WS_DLL_PUBLIC -gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *, const guint8 *, int *err); +gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *, const guint8 *, + int *err, gchar **err_info); WS_DLL_PUBLIC void wtap_dump_flush(wtap_dumper *); WS_DLL_PUBLIC @@ -1738,6 +1739,9 @@ int wtap_register_encap_type(const char* name, const char* short_name); #define WTAP_ERR_REC_TYPE_UNSUPPORTED -24 /** Specified record type can't be written to that file type */ +#define WTAP_ERR_UNWRITABLE_REC_DATA -25 + /** Something in the record data can't be written to that file type */ + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.1