1PCAP_OPEN_LIVE(3PCAP) PCAP_OPEN_LIVE(3PCAP)
2
3
4
6 pcap_open_live - open a device for capturing
7
9 #include <pcap/pcap.h>
10
11 char errbuf[PCAP_ERRBUF_SIZE];
12
13 pcap_t *pcap_open_live(const char *device, int snaplen,
14 int promisc, int to_ms, char *errbuf);
15
17 pcap_open_live() is used to obtain a packet capture handle to look at
18 packets on the network. device is a string that specifies the network
19 device to open; on Linux systems with 2.2 or later kernels, a device
20 argument of "any" or NULL can be used to capture packets from all
21 interfaces.
22
23 snaplen specifies the snapshot length to be set on the handle.
24
25 promisc specifies if the interface is to be put into promiscuous mode.
26
27 to_ms specifies the read timeout in milliseconds.
28
30 pcap_open_live() returns a pcap_t * on success and NULL on failure. If
31 NULL is returned, errbuf is filled in with an appropriate error mes‐
32 sage. errbuf may also be set to warning text when pcap_open_live()
33 succeeds; to detect this case the caller should store a zero-length
34 string in errbuf before calling pcap_open_live() and display the warn‐
35 ing to the user if errbuf is no longer a zero-length string. errbuf is
36 assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
37
39 pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
40
41
42
43 5 April 2008 PCAP_OPEN_LIVE(3PCAP)