2003-04-16 17:34:34 +04:00
|
|
|
.\" $NetBSD: pcap.3,v 1.19 2003/04/16 13:35:12 wiz Exp $
|
1995-03-06 14:37:58 +03:00
|
|
|
.\"
|
1997-10-03 19:53:00 +04:00
|
|
|
.\" Copyright (c) 1994, 1996, 1997
|
1995-03-06 14:32:59 +03:00
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that: (1) source code distributions
|
|
|
|
.\" retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
.\" distributions including binary code include the above copyright notice and
|
|
|
|
.\" this paragraph in its entirety in the documentation or other materials
|
|
|
|
.\" provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
.\" features or use of this software display the following acknowledgement:
|
|
|
|
.\" ``This product includes software developed by the University of California,
|
|
|
|
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
.\" the University nor the names of its contributors may be used to endorse
|
|
|
|
.\" or promote products derived from this software without specific prior
|
|
|
|
.\" written permission.
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
.\"
|
2002-09-25 04:30:24 +04:00
|
|
|
.Dd September 25, 2002
|
2001-10-04 00:58:31 +04:00
|
|
|
.Os
|
|
|
|
.Dt PCAP 3
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pcap
|
|
|
|
.Nd packet capture library
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libpcap
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In pcap.h
|
2001-10-04 00:58:31 +04:00
|
|
|
.Ft pcap_t *
|
|
|
|
.Fn pcap_open_live "char *device" "int snaplen" "int promisc" \
|
|
|
|
"int to_ms" "char *ebuf"
|
|
|
|
.Ft pcap_t *
|
|
|
|
.Fn pcap_open_offline "char *fname" "char *ebuf"
|
|
|
|
.Ft pcap_dumper_t *
|
|
|
|
.Fn pcap_dump_open "pcap_t *p" "char *fname"
|
|
|
|
.Ft char
|
2001-10-04 01:57:58 +04:00
|
|
|
.Dv errbuf[PCAP_ERRBUF_SIZE];
|
2001-10-04 00:58:31 +04:00
|
|
|
.Ft char *
|
|
|
|
.Fn pcap_lookupdev "char *errbuf"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_lookupnet "char *device" "bpf_u_int32 *netp" \
|
2003-01-03 15:50:44 +03:00
|
|
|
"bpf_u_int32 *maskp" "char *errbuf"
|
2001-10-04 00:58:31 +04:00
|
|
|
.Ft int
|
|
|
|
.Fn pcap_dispatch "pcap_t *p" "int cnt" \
|
|
|
|
"pcap_handler callback" "u_char *user"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_loop "pcap_t *p" "int cnt" \
|
|
|
|
"pcap_handler callback" "u_char *user"
|
|
|
|
.Ft void
|
|
|
|
.Fn pcap_dump "u_char *user" "struct pcap_pkthdr *h" \
|
|
|
|
"u_char *sp"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_compile "pcap_t *p" "struct bpf_program *fp" \
|
|
|
|
"char *str" "int optimize" "bpf_u_int32 netmask"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_compile_nopcap "int snaplen" "int linktype" \
|
|
|
|
"struct bpf_program *fp" "char *str" "int optimize" \
|
|
|
|
"bpf_uint32 netmask" "char *errbuf"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_setfilter "pcap_t *p" "struct bpf_program *fp"
|
2002-09-22 20:13:01 +04:00
|
|
|
.Ft int
|
|
|
|
.Fn pcap_set_datalink "pcap_t *p" "int dlt"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_list_datalinks "pcap_t *p" "int **dlt_buf"
|
2003-01-02 18:43:15 +03:00
|
|
|
.Ft const u_char *
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_next "pcap_t *p" "struct pcap_pkthdr *h"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_datalink "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_snapshot "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_is_swapped "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_major_version "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_minor_version "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_stats "pcap_t *p" "struct pcap_stat *ps"
|
|
|
|
.Ft FILE *
|
|
|
|
.Fn pcap_file "pcap_t *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn pcap_fileno "pcap_t *p"
|
|
|
|
.Ft void
|
|
|
|
.Fn pcap_perror "pcap_t *p" "char *prefix"
|
|
|
|
.Ft char *
|
|
|
|
.Fn pcap_geterr "pcap_t *p"
|
|
|
|
.Ft char *
|
|
|
|
.Fn pcap_strerror "int error"
|
|
|
|
.Ft void
|
|
|
|
.Fn pcap_close "pcap_t *p"
|
|
|
|
.Ft void
|
|
|
|
.Fn pcap_dump_close "pcap_dumper_t *p"
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
library provides a high level interface to packet capture systems.
|
|
|
|
All packets on the network, even those destined for other hosts, are
|
|
|
|
accessible through this mechanism.
|
|
|
|
.Sh ROUTINES
|
|
|
|
.Fn pcap_open_live
|
|
|
|
is used to obtain a packet capture descriptor to look at packets on
|
|
|
|
the network.
|
|
|
|
.Fa device
|
1995-03-06 14:32:59 +03:00
|
|
|
is a string that specifies the network device to open.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa snaplen
|
1995-03-06 14:32:59 +03:00
|
|
|
specifies the maximum number of bytes to capture.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa promisc
|
2002-10-01 23:26:58 +04:00
|
|
|
specifies if the interface is to be put into promiscuous mode.
|
|
|
|
(Note that even if this parameter is false, the interface could well be in
|
2001-10-04 00:58:31 +04:00
|
|
|
promiscuous mode for some other reason.)
|
|
|
|
.Fa to_ms
|
1995-03-06 14:32:59 +03:00
|
|
|
specifies the read timeout in milliseconds.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa ebuf
|
1995-03-06 14:32:59 +03:00
|
|
|
is used to return error text and is only set when
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_live
|
1995-03-06 14:32:59 +03:00
|
|
|
fails and returns
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em NULL .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_open_offline
|
2001-10-04 01:57:58 +04:00
|
|
|
is called to open a
|
|
|
|
.Dq savefile
|
|
|
|
for reading.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa fname
|
2002-10-01 23:26:58 +04:00
|
|
|
specifies the name of the file to open.
|
|
|
|
The file has the same format as those used by
|
2001-10-04 00:58:31 +04:00
|
|
|
.Xr tcpdump 8 .
|
2001-10-04 01:57:58 +04:00
|
|
|
The name
|
|
|
|
.Dq \&-
|
|
|
|
is a synonym for
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em stdin .
|
|
|
|
.Fa ebuf
|
1995-03-06 14:32:59 +03:00
|
|
|
is used to return error text and is only set when
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_offline
|
1995-03-06 14:32:59 +03:00
|
|
|
fails and returns
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em NULL .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_dump_open
|
2001-10-04 01:57:58 +04:00
|
|
|
is called to open a
|
|
|
|
.Dq savefile
|
2002-10-01 23:26:58 +04:00
|
|
|
for writing.
|
|
|
|
The name
|
2001-10-04 01:57:58 +04:00
|
|
|
.Dq \&-
|
|
|
|
is a synonym
|
1995-03-06 14:32:59 +03:00
|
|
|
for
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em stdout .
|
|
|
|
.Em NULL
|
1995-03-06 14:32:59 +03:00
|
|
|
is returned on failure.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa p
|
1995-03-06 14:32:59 +03:00
|
|
|
is a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa pcap
|
1995-03-06 14:32:59 +03:00
|
|
|
struct as returned by
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_offline
|
1995-03-06 14:32:59 +03:00
|
|
|
or
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_live .
|
|
|
|
.Fa fname
|
1995-03-06 14:32:59 +03:00
|
|
|
specifies the name of the file to open.
|
|
|
|
If
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em NULL
|
1995-03-06 14:32:59 +03:00
|
|
|
is returned,
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_geterr
|
1995-03-06 14:32:59 +03:00
|
|
|
can be used to get the error text.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_lookupdev
|
1995-03-06 14:32:59 +03:00
|
|
|
returns a pointer to a network device suitable for use with
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_live
|
1995-03-06 14:32:59 +03:00
|
|
|
and
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_lookupnet .
|
1995-03-06 14:32:59 +03:00
|
|
|
If there is an error,
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em NULL
|
1995-03-06 14:32:59 +03:00
|
|
|
is returned and
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa errbuf
|
2001-10-04 01:57:58 +04:00
|
|
|
is filled in with an appropriate error message.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_lookupnet
|
1995-03-06 14:32:59 +03:00
|
|
|
is used to determine the network number and mask
|
|
|
|
associated with the network device
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em device .
|
1995-03-06 14:32:59 +03:00
|
|
|
Both
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa netp
|
1995-03-06 14:32:59 +03:00
|
|
|
and
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa maskp
|
1995-03-06 14:32:59 +03:00
|
|
|
are
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa bpf_u_int32
|
1995-03-06 14:32:59 +03:00
|
|
|
pointers.
|
|
|
|
A return of -1 indicates an error in which case
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa errbuf
|
2001-10-04 01:57:58 +04:00
|
|
|
is filled in with an appropriate error message.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_dispatch
|
1995-03-06 14:32:59 +03:00
|
|
|
is used to collect and process packets.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa cnt
|
2002-10-01 23:26:58 +04:00
|
|
|
specifies the maximum number of packets to process before returning.
|
|
|
|
A
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa cnt
|
2002-10-01 23:26:58 +04:00
|
|
|
of -1 processes all the packets received in one buffer.
|
|
|
|
A
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa cnt
|
1995-03-06 14:32:59 +03:00
|
|
|
of 0 processes all packets until an error occurs (or
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em EOF
|
1995-03-06 14:32:59 +03:00
|
|
|
is reached).
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa callback
|
1995-03-06 14:32:59 +03:00
|
|
|
specifies a routine to be called with three arguments:
|
|
|
|
a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa u_char
|
1995-03-06 14:32:59 +03:00
|
|
|
pointer which is passed in from
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_dispatch ,
|
1995-03-06 14:32:59 +03:00
|
|
|
a pointer to the
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa pcap_pkthdr
|
1995-03-06 14:32:59 +03:00
|
|
|
struct (which precede the actual network headers and data),
|
1997-10-03 19:53:00 +04:00
|
|
|
and a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa u_char
|
2002-10-01 23:26:58 +04:00
|
|
|
pointer to the packet data.
|
|
|
|
The number of packets read is returned.
|
1995-03-06 14:32:59 +03:00
|
|
|
Zero is returned when
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em EOF
|
2001-10-04 01:57:58 +04:00
|
|
|
is reached in a
|
|
|
|
.Dq savefile .
|
|
|
|
A return of -1 indicates an error in which case
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_perror
|
1995-03-06 14:32:59 +03:00
|
|
|
or
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_geterr
|
1995-03-06 14:32:59 +03:00
|
|
|
may be used to display the error text.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_dump
|
2001-10-04 01:57:58 +04:00
|
|
|
outputs a packet to the
|
|
|
|
.Dq savefile
|
|
|
|
opened with
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_dump_open .
|
1995-03-06 14:32:59 +03:00
|
|
|
Note that its calling arguments are suitable for use with
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_dispatch .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_compile
|
1995-03-06 14:32:59 +03:00
|
|
|
is used to compile the string
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa str
|
1995-03-06 14:32:59 +03:00
|
|
|
into a filter program.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa program
|
1995-03-06 14:32:59 +03:00
|
|
|
is a pointer to a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa bpf_program
|
1995-03-06 14:32:59 +03:00
|
|
|
struct and is filled in by
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_compile .
|
|
|
|
.Fa optimize
|
1995-03-06 14:32:59 +03:00
|
|
|
controls whether optimization on the resulting code is performed.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa netmask
|
1995-03-06 14:32:59 +03:00
|
|
|
specifies the netmask of the local net.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_compile_nopcap
|
2000-10-06 20:39:24 +04:00
|
|
|
is similar to
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_compile
|
2000-10-06 20:39:24 +04:00
|
|
|
except that instead of passing a pcap descriptor, one passes the
|
|
|
|
snaplen, linktype, and error buffer (which must be
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em PCAP_ERRBUF_SIZE
|
2002-10-01 23:26:58 +04:00
|
|
|
in length) explicitly.
|
|
|
|
It is intended to be used for compiling filters for direct
|
|
|
|
bpf usage, without necessarily having called
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_setfilter
|
1997-10-03 19:53:00 +04:00
|
|
|
is used to specify a filter program.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa fp
|
1995-03-06 14:32:59 +03:00
|
|
|
is a pointer to an array of
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa bpf_program
|
1995-03-06 14:32:59 +03:00
|
|
|
struct, usually the result of a call to
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_compile .
|
|
|
|
.Em \-1
|
1997-10-03 19:53:00 +04:00
|
|
|
is returned on failure;
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em 0
|
1997-10-03 19:53:00 +04:00
|
|
|
is returned on success.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
2002-09-22 20:13:01 +04:00
|
|
|
.Fn pcap_set_datalink
|
|
|
|
is used to set the current data link type of the pcap descriptor
|
|
|
|
to the type specified by
|
|
|
|
.Fa dlt .
|
|
|
|
This operation is supported only of the interface associated with
|
|
|
|
the pcap descriptor supports multiple data link types.
|
|
|
|
.Em \-1
|
2002-09-25 04:30:24 +04:00
|
|
|
is return on failure;
|
2002-09-22 20:13:01 +04:00
|
|
|
.Em 0
|
|
|
|
is returned on success.
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_list_datalinks
|
|
|
|
is used to get a list of the support data link types of the interface
|
2002-09-25 04:30:24 +04:00
|
|
|
associated with the pcap descriptor.
|
2002-09-22 20:13:01 +04:00
|
|
|
.Fn pcap_list_datalinks
|
|
|
|
allocates an array to hold the list and sets
|
|
|
|
.Fa *dlt_buf .
|
|
|
|
The caller is responsible for freeing the array.
|
|
|
|
.Em \-1
|
|
|
|
is returned on failure;
|
|
|
|
otherwise, the number of data link types in the array is returned.
|
|
|
|
.Pp
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_loop
|
1995-03-06 14:32:59 +03:00
|
|
|
is similar to
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_dispatch
|
1995-03-06 14:32:59 +03:00
|
|
|
except it keeps reading packets until
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa cnt
|
1995-03-06 14:32:59 +03:00
|
|
|
packets are processed or an error occurs.
|
|
|
|
A negative
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa cnt
|
1995-03-06 14:32:59 +03:00
|
|
|
causes
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_loop
|
1995-03-06 14:32:59 +03:00
|
|
|
to loop forever (or at least until an error occurs).
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_next
|
1995-03-06 14:32:59 +03:00
|
|
|
returns a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa u_char
|
1995-03-06 14:32:59 +03:00
|
|
|
pointer to the next packet.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_datalink
|
1995-03-06 14:32:59 +03:00
|
|
|
returns the link layer type, e.g.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em DLT_EN10MB .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_snapshot
|
1995-03-06 14:32:59 +03:00
|
|
|
returns the snapshot length specified when
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_open_live
|
1995-03-06 14:32:59 +03:00
|
|
|
was called.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_is_swapped
|
2001-10-04 01:57:58 +04:00
|
|
|
returns true if the current
|
|
|
|
.Dq savefile
|
|
|
|
uses a different byte order than the current system.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_major_version
|
1995-03-06 14:32:59 +03:00
|
|
|
returns the major number of the version of the pcap used to write the
|
|
|
|
savefile.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_minor_version
|
1998-06-24 23:07:00 +04:00
|
|
|
returns the minor number of the version of the pcap used to write the
|
1995-03-06 14:32:59 +03:00
|
|
|
savefile.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_file
|
2003-01-07 19:51:20 +03:00
|
|
|
returns the standard I/O stream of the
|
|
|
|
.Dq savefile ,
|
|
|
|
if a
|
|
|
|
.Dq savefile
|
|
|
|
was opened with
|
|
|
|
.Fn pcap_open_offline ,
|
|
|
|
or NULL, if a network device was opened with
|
|
|
|
.Fn pcap_open_live .
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_stats
|
1995-03-06 14:32:59 +03:00
|
|
|
returns 0 and fills in a
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa pcap_stat
|
2002-10-01 23:26:58 +04:00
|
|
|
struct.
|
|
|
|
The values represent packet statistics from the start of the
|
|
|
|
run to the time of the call.
|
|
|
|
If there is an error or the under lying
|
1995-03-06 14:32:59 +03:00
|
|
|
packet capture doesn't support packet statistics, -1 is returned and
|
|
|
|
the error text can be obtained with
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_perror
|
1995-03-06 14:32:59 +03:00
|
|
|
or
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fn pcap_geterr .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_fileno
|
2003-01-07 19:51:20 +03:00
|
|
|
returns the file descriptor number from which captured packets are read
|
|
|
|
if a network device was opened with
|
|
|
|
.Fn pcap_open_live ,
|
|
|
|
or \-1, if a
|
|
|
|
.Dq savefile
|
|
|
|
was opened with
|
|
|
|
.Fn pcap_open_offline .
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_perror
|
1995-03-06 14:32:59 +03:00
|
|
|
prints the text of the last pcap library error on
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em stderr ,
|
1995-03-06 14:32:59 +03:00
|
|
|
prefixed by
|
2001-10-04 00:58:31 +04:00
|
|
|
.Em prefix .
|
|
|
|
.Pp
|
|
|
|
.Fn pcap_geterr
|
1995-03-06 14:32:59 +03:00
|
|
|
returns the error text pertaining to the last pcap library error.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_strerror
|
1995-03-06 14:32:59 +03:00
|
|
|
is provided in case
|
2001-10-04 01:39:04 +04:00
|
|
|
.Xr strerror 3
|
1995-03-06 14:32:59 +03:00
|
|
|
isn't available.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_close
|
1995-03-06 14:32:59 +03:00
|
|
|
closes the files associated with
|
2001-10-04 00:58:31 +04:00
|
|
|
.Fa p
|
1995-03-06 14:32:59 +03:00
|
|
|
and deallocates resources.
|
2001-10-04 00:58:31 +04:00
|
|
|
.Pp
|
|
|
|
.Fn pcap_dump_close
|
2001-10-04 01:57:58 +04:00
|
|
|
closes the
|
|
|
|
.Dq savefile .
|
2001-10-04 00:58:31 +04:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr tcpdump 8
|
|
|
|
.Sh AUTHORS
|
2000-10-06 20:39:24 +04:00
|
|
|
The original authors are:
|
2001-10-04 00:58:31 +04:00
|
|
|
.Lp
|
1997-10-03 19:53:00 +04:00
|
|
|
Van Jacobson,
|
|
|
|
Craig Leres and
|
|
|
|
Steven McCanne, all of the
|
|
|
|
Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
|
2001-10-04 00:58:31 +04:00
|
|
|
.\" .Lp
|
|
|
|
.\" The current version is available from "The Tcpdump Group"'s Web site at
|
|
|
|
.\" .Lp
|
|
|
|
.\" .RS
|
|
|
|
.\" .Em http://www.tcpdump.org/
|
|
|
|
.\" .RE
|
|
|
|
.\" .Sh BUGS
|
|
|
|
.\" Please send problems, bugs, questions, desirable enhancements, etc. to:
|
2001-10-04 01:39:04 +04:00
|
|
|
.\" .Lp
|
2001-10-04 00:58:31 +04:00
|
|
|
.\" .RS
|
|
|
|
.\" tcpdump-workers@tcpdump.org
|
2001-10-04 01:39:04 +04:00
|
|
|
.\" .RE
|
2001-10-04 00:58:31 +04:00
|
|
|
.\" .Lp
|
|
|
|
.\" Please send source code contributions, etc. to:
|
|
|
|
.\" .Lp
|
|
|
|
.\" .RS
|
|
|
|
.\" patches@tcpdump.org
|
|
|
|
.\" .RE
|