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 whether the interface is to be put into promiscuous
26 mode. If promisc is non-zero, promiscuous mode will be set, otherwise
27 it will not be set.
28
29 to_ms specifies the packet buffer timeout, as a non-negative value, in
30 milliseconds. (See pcap(3PCAP) for an explanation of the packet buffer
31 timeout.)
32
34 pcap_open_live() returns a pcap_t * on success and NULL on failure. If
35 NULL is returned, errbuf is filled in with an appropriate error mes‐
36 sage. errbuf may also be set to warning text when pcap_open_live()
37 succeeds; to detect this case the caller should store a zero-length
38 string in errbuf before calling pcap_open_live() and display the warn‐
39 ing to the user if errbuf is no longer a zero-length string. errbuf is
40 assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
41
43 pcap_create(3PCAP), pcap_activate(3PCAP)
44
45
46
47 6 December 2017 PCAP_OPEN_LIVE(3PCAP)