1PCAP_INIT(3PCAP) PCAP_INIT(3PCAP)
2
3
4
6 pcap_init - initialize the library
7
9 #include <pcap/pcap.h>
10
11 char errbuf[PCAP_ERRBUF_SIZE];
12
13 int pcap_init(unsigned int opts, char *errbuf);
14
16 pcap_init() is used to initialize the Packet Capture library. opts
17 specifies options for the library; currently, the options are:
18
19 PCAP_CHAR_ENC_LOCAL
20 Treat all strings supplied as arguments, and return all strings
21 to the caller, as being in the local character encoding.
22
23 PCAP_CHAR_ENC_UTF_8
24 Treat all strings supplied as arguments, and return all strings
25 to the caller, as being in UTF-8.
26
27 On UNIX-like systems, the local character encoding is assumed to be
28 UTF-8, so no character encoding transformations are done.
29
30 On Windows, the local character encoding is the local ANSI code page.
31
32 If pcap_init() is not called, strings are treated as being in the local
33 ANSI code page on Windows, pcap_lookupdev(3PCAP) will succeed if there
34 is a device on which to capture, and pcap_create(3PCAP) makes an at‐
35 tempt to check whether the string passed as an argument is a UTF-16LE
36 string - note that this attempt is unsafe, as it may run past the end
37 of the string - to handle pcap_lookupdev() returning a UTF-16LE string.
38 Programs that don't call pcap_init() should, on Windows, call
39 pcap_wsockinit() to initialize Winsock; this is not necessary if
40 pcap_init() is called, as pcap_init() will initialize Winsock itself on
41 Windows.
42
44 pcap_init() returns 0 on success and PCAP_ERROR on failure. If
45 PCAP_ERROR is returned, errbuf is filled in with an appropriate error
46 message. errbuf is assumed to be able to hold at least PCAP_ER‐
47 RBUF_SIZE chars.
48
50 This function became available in libpcap release 1.9.0. In previous
51 releases, on Windows, all strings supplied as arguments, and all
52 strings returned to the caller, are in the local character encoding.
53
55 pcap(3PCAP)
56
57
58
59 4 May 2022 PCAP_INIT(3PCAP)