diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-11-19 20:18:01 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-11-19 20:18:01 +0000 |
commit | 2929c93ea276766076aed8bf617befba65d32eb4 (patch) | |
tree | 23f6e64eaa570e79fd24e3dd413e77eed56f9737 /merge.c | |
parent | 4b2aa811e14412e3731714e4e54c344e967173c1 (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 'merge.c')
-rw-r--r-- | merge.c | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -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]; } |