Update to zlib-1.2.5.
[dragonfly.git] / contrib / libpcap / pcap_next_ex.3pcap
1 .\" @(#) $Header: /tcpdump/master/libpcap/pcap_next_ex.3pcap,v 1.1.2.3 2008-04-06 03:21:56 guy Exp $
2 .\"
3 .\" Copyright (c) 1994, 1996, 1997
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that: (1) source code distributions
8 .\" retain the above copyright notice and this paragraph in its entirety, (2)
9 .\" distributions including binary code include the above copyright notice and
10 .\" this paragraph in its entirety in the documentation or other materials
11 .\" provided with the distribution, and (3) all advertising materials mentioning
12 .\" features or use of this software display the following acknowledgement:
13 .\" ``This product includes software developed by the University of California,
14 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 .\" the University nor the names of its contributors may be used to endorse
16 .\" or promote products derived from this software without specific prior
17 .\" written permission.
18 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 .\"
22 .TH PCAP_NEXT_EX 3PCAP "5 April 2008"
23 .SH NAME
24 pcap_next_ex, pcap_next \- read the next packet from a pcap_t
25 .SH SYNOPSIS
26 .nf
27 .ft B
28 #include <pcap/pcap.h>
29 .ft
30 .LP
31 .ft B
32 int pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
33 .ti +8
34 const u_char **pkt_data);
35 const u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h);
36 .ft
37 .fi
38 .SH DESCRIPTION
39 .B pcap_next_ex()
40 reads the next packet and returns a success/failure indication.
41 If the packet was read without problems, the pointer pointed to by the
42 .I pkt_header
43 argument is set to point to the
44 .I pcap_pkthdr
45 struct for the packet, and the
46 pointer pointed to by the
47 .I pkt_data
48 argument is set to point to the data in the packet.
49 .PP
50 .B pcap_next()
51 reads the next packet (by calling
52 .B pcap_dispatch()
53 with a
54 .I cnt
55 of 1) and returns a
56 .I u_char
57 pointer to the data in that packet.
58 The
59 .I pcap_pkthdr
60 structure pointed to by
61 .I h
62 is filled in with the appropriate values for the packet.
63 .SH RETURN VALUE
64 .B pcap_next_ex()
65 returns 1 if the packet was read without problems, 0
66 if packets are being read from a live capture, and the timeout expired,
67 \-1 if an error occurred while reading the packet, and \-2 if
68 packets are being read from a ``savefile'', and there are no more
69 packets to read from the savefile.
70 If \-1 is returned,
71 .B pcap_geterr()
72 or
73 .B pcap_perror()
74 may be called with
75 .I p
76 as an argument to fetch or display the error text.
77 .PP
78 .B pcap_next()
79 returns a pointer to the packet data on success, and returns
80 .B NULL
81 if an error occured, or if no packets were read from a live
82 capture (if, for example, they were discarded because they didn't pass
83 the packet filter, or if, on platforms that support a read timeout that
84 starts before any packets arrive, the timeout expires before any packets
85 arrive, or if the file descriptor for the capture device is in
86 non-blocking mode and no packets were available to be read), or if no
87 more packets are available in a ``savefile.''  Unfortunately, there is
88 no way to determine whether an error occured or not.
89 .SH SEE ALSO
90 pcap(3PCAP), pcap_geterr(3PCAP), pcap_dispatch(3PCAP)