ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] wtap_dump_file_seek() and _tell()

From: Ed Beroset <beroset@xxxxxxxxxxxxxx>
Date: Sat, 16 Mar 2013 10:38:10 -0400
Guy Harris wrote:

On Mar 3, 2013, at 11:10 AM, Ed Beroset <beroset@xxxxxxxxxxxxxx>
wrote:

According to svn, version 36318 (March 2011) added, among other
things, the following lines to the wiretap/wtap-int.h file:

extern gint64 wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset,
int whence, int *err); extern gint64
wtap_dump_file_tell(wtap_dumper *wdh);

However, unlike most of the corresponding functions which are
implemented in wiretap/file_access.c these two have no
implementations.
[...]
but these places in the code are doing it anyway.  How should we
best resolve this? Should I implement the functions?

Might as well.  They'd belong with the others in file_access.c, and
should fail if wdh->compressed is set.  (We already have
wtap_dump_can_compress(), which checks whether writing the file
format requires a seek, so no Wireshark code should be trying to
write out a compressed file in any of those formats.)

We should probably define a new WTAP_ERR_CANT_SEEK_COMPRESSED value
and return it as the error value if a seek is attempted on a
compressed stream.

file_tell() should probably also have an "int *err" argument, as
ftell() can fail.

Done, and submitted as a patch to Bug 8416: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416. I haven't compiled this under Windows yet, but will later today.

Ed