On Mon, Dec 10, 2018 at 08:03:23AM +0100, Jan Stary wrote:
> pcap_dump() is described in pcap.3 as follows:
> 
>   pcap_dump() outputs a packet to the savefile opened with pcap_dump_open().
>   Note that its calling arguments are suitable for use with pcap_dispatch().
> 
> That formulation is imho not entirely clear,
> as the arguments mention no "savefile".
> 
> (Looking at the source, it just treats the 'user' argument as a FILE*
> which is what a pcap_dumper_t* returned by pcap_dump_open() really is,
> and fwrite()s the header and packet data there.)
> 
> It would be clearer if the manpage said that the 'user' is the savefile,
> and that it is to be passed as the last argument to pcap_dispatch()
> when using pcap_dump() as a callback function.
> 
>       Jan
> 

hi. i committed the diff below, as adjusted by djm.
jmc

Index: pcap.3
===================================================================
RCS file: /cvs/src/lib/libpcap/pcap.3,v
retrieving revision 1.49
diff -u -r1.49 pcap.3
--- pcap.3      12 Dec 2018 20:12:03 -0000      1.49
+++ pcap.3      13 Dec 2018 06:45:40 -0000
@@ -353,9 +353,17 @@
 may be used to display the error text.
 .Pp
 .Fn pcap_dump
-outputs a packet to the savefile opened with
-.Fn pcap_dump_open .
-Note that its calling arguments are suitable for use with
+outputs a packet to a save file previously opened using
+.Fn pcap_dump_open
+or
+.Fn pcap_dump_fopen .
+Note that the
+.Fa user
+argument contains the handle to the save file and should be of type
+.Ft "pcap_dumper_t *" .
+This makes
+.Fn pcap_dump
+a suitable callback function for use as an argument to
 .Fn pcap_dispatch .
 .Pp
 .Fn pcap_inject

> 
> Index: pcap.3
> ===================================================================
> RCS file: /cvs/src/lib/libpcap/pcap.3,v
> retrieving revision 1.48
> diff -u -p -r1.48 pcap.3
> --- pcap.3    3 Jun 2018 10:45:15 -0000       1.48
> +++ pcap.3    10 Dec 2018 07:01:13 -0000
> @@ -353,9 +353,17 @@ or
>  may be used to display the error text.
>  .Pp
>  .Fn pcap_dump
> -outputs a packet to the savefile opened with
> -.Fn pcap_dump_open .
> -Note that its calling arguments are suitable for use with
> +outputs a packet to a previously opened savefile,
> +if the pointer obtained with
> +.Fn pcap_dump_open
> +is passed as the
> +.Fa user
> +argument.
> +This makes
> +.Fn pcap_dump
> +a suitable
> +.Fa callback
> +to use with
>  .Fn pcap_dispatch .
>  .Pp
>  .Fn pcap_inject
> 

Reply via email to