1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>WinPcap: Exported functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Exported functions<br/>
<small>
[<a class="el" href="group__wpcap.html">WinPcap user's manual</a>]</small>
</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Unix-compatible Functions</h2></td></tr>
<tr><td colspan="2"><p><a class="anchor" id="amgrp66235da55168274536ca96ecc6470bf6"></a> These functions are part of the libpcap library, and therefore work both on Windows and on Linux. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>errbuf in <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845" title="Create a pcap_t structure without starting a capture.">pcap_open_dead()</a>, <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#ga3f212141c80b59aad8ac535bb0178275" title="Switch between blocking and nonblocking mode.">pcap_setnonblock()</a>, <a class="el" href="group__wpcapfunc.html#gab25dc0bfe06545b86be4103bf010708e" title="Get the "non-blocking" state of an interface.">pcap_getnonblock()</a>, <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, <a class="el" href="group__wpcapfunc.html#gaed295fc9fd86434372e8a8316f1270b1" title="Return the first valid device in the system.">pcap_lookupdev()</a>, and <a class="el" href="group__wpcapfunc.html#gaa35276d0fa530c51a455f298fa1ec453" title="Return the subnet and netmask of an interface.">pcap_lookupnet()</a> is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars. </dd></dl>
<br/><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void(* </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a> )(u_char *user, const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *pkt_header, const u_char *pkt_data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Prototype of the callback function that receives the packets. <a href="#gabcba231c099919ecd9300d7160b19878"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8">pcap_open_live</a> (const char *device, int snaplen, int promisc, int to_ms, char *ebuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Open a live capture from the network. <a href="#gaae6abe06e15c87b803f69773822beca8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845">pcap_open_dead</a> (int linktype, int snaplen)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a pcap_t structure without starting a capture. <a href="#ga6445eeb76f2757b9fa088b276eea2845"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69">pcap_open_offline</a> (const char *fname, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Open a savefile in the tcpdump/libpcap format to read packets. <a href="#ga91078168a13de8848df2b7b83d1f5b69"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c">pcap_dump_open</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, const char *fname)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Open a file to write packets. <a href="#ga9506c33d580fdb5e5c288dba0f8a085c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga3f212141c80b59aad8ac535bb0178275">pcap_setnonblock</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int nonblock, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Switch between blocking and nonblocking mode. <a href="#ga3f212141c80b59aad8ac535bb0178275"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gab25dc0bfe06545b86be4103bf010708e">pcap_getnonblock</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the "non-blocking" state of an interface. <a href="#gab25dc0bfe06545b86be4103bf010708e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d">pcap_findalldevs</a> (<a class="el" href="structpcap__if.html">pcap_if_t</a> **alldevsp, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a list of network devices that can be opened with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>. <a href="#ga7b128eaeef627b408f6a6e2a2f5eb45d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga346b4b0b7fd1cda4abb9a39f767dbeb1">pcap_freealldevs</a> (<a class="el" href="structpcap__if.html">pcap_if_t</a> *alldevsp)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Free an interface list returned by <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>. <a href="#ga346b4b0b7fd1cda4abb9a39f767dbeb1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaed295fc9fd86434372e8a8316f1270b1">pcap_lookupdev</a> (char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the first valid device in the system. <a href="#gaed295fc9fd86434372e8a8316f1270b1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaa35276d0fa530c51a455f298fa1ec453">pcap_lookupnet</a> (const char *device, <a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> *netp, <a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> *maskp, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the subnet and netmask of an interface. <a href="#gaa35276d0fa530c51a455f298fa1ec453"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c">pcap_dispatch</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int cnt, <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a> callback, u_char *user)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Collect a group of packets. <a href="#ga60ce104cdf28420d3361cd36d15be44c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de">pcap_loop</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int cnt, <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a> callback, u_char *user)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Collect a group of packets. <a href="#ga6bcb7c5c59d76ec16b8a699da136b5de"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u_char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3">pcap_next</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *h)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the next available packet. <a href="#gadf60257f650aaf869671e0a163611fc3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga439439c2eae61161dc1efb1e03a81133">pcap_next_ex</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> **pkt_header, const u_char **pkt_data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Read a packet from an interface or from an offline capture. <a href="#ga439439c2eae61161dc1efb1e03a81133"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33">pcap_breakloop</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">set a flag that will force <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> to return rather than looping. <a href="#gae0dc50910fabbd375fab8a1352a6cf33"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga51dbda0f1ab9da2cfe49d657486d50b2">pcap_sendpacket</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, u_char *buf, int size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Send a raw packet. <a href="#ga51dbda0f1ab9da2cfe49d657486d50b2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437">pcap_dump</a> (u_char *user, const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *h, const u_char *sp)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Save a packet to disk. <a href="#ga659439bf5aa3988b5a92d31990fbf437"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">long </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga50de34b8b3298f76c66c82b7ca3f84de">pcap_dump_ftell</a> (<a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the file position for a "savefile". <a href="#ga50de34b8b3298f76c66c82b7ca3f84de"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c">pcap_compile</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, struct bpf_program *fp, char *str, int optimize, <a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> netmask)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Compile a packet filter, converting an high level filtering expression (see <a class="el" href="group__language.html">Filtering expression syntax</a>) in a program that can be interpreted by the kernel-level filtering engine. <a href="#ga363bdc6f6b39b4979ddcf15ecb830c5c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e">pcap_compile_nopcap</a> (int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, <a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> mask)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Compile a packet filter without the need of opening an adapter. This function converts an high level filtering expression (see <a class="el" href="group__language.html">Filtering expression syntax</a>) in a program that can be interpreted by the kernel-level filtering engine. <a href="#ga8325b202dad14a00609db8372722ae4e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61">pcap_setfilter</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, struct bpf_program *fp)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Associate a filter to a capture. <a href="#gaf5f9cfe85dad0967ff607e5159b1ba61"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga9e0a5aad1a5dc79d85f1edfcebe0ac13">pcap_freecode</a> (struct bpf_program *fp)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Free a filter. <a href="#ga9e0a5aad1a5dc79d85f1edfcebe0ac13"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga64c019f851f7da6892d51cca15f12ace">pcap_datalink</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the link layer of an adapter. <a href="#ga64c019f851f7da6892d51cca15f12ace"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga64e482360b0ed7d65fce1db23d56b921">pcap_list_datalinks</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int **dlt_buf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">list datalinks <a href="#ga64e482360b0ed7d65fce1db23d56b921"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga9588b99ac118cf827873d9e941eb6c77">pcap_set_datalink</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int dlt)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the current data link type of the pcap descriptor to the type specified by dlt. -1 is returned on failure. <a href="#ga9588b99ac118cf827873d9e941eb6c77"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga440b2f0757acd4804588933324909207">pcap_datalink_name_to_val</a> (const char *name)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Translates a data link type name, which is a DLT_ name with the DLT_ removed, to the corresponding data link type value. The translation is case-insensitive. -1 is returned on failure. <a href="#ga440b2f0757acd4804588933324909207"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gad45c16d494577f1886704af8f31ed442">pcap_datalink_val_to_name</a> (int dlt)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Translates a data link type value to the corresponding data link type name. NULL is returned on failure. <a href="#gad45c16d494577f1886704af8f31ed442"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga3f142cd0694b49357e4a73371db71411">pcap_datalink_val_to_description</a> (int dlt)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Translates a data link type value to a short description of that data link type. NULL is returned on failure. <a href="#ga3f142cd0694b49357e4a73371db71411"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gae5c6e9768e89a6b82f9d720f37e6ab97">pcap_snapshot</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the dimension of the packet portion (in bytes) that is delivered to the application. <a href="#gae5c6e9768e89a6b82f9d720f37e6ab97"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaba4941e09e5e03ba39841de4b1d5d6a4">pcap_is_swapped</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">returns true if the current savefile uses a different byte order than the current system. <a href="#gaba4941e09e5e03ba39841de4b1d5d6a4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga39dfb05149b443cc25b8febc455ca753">pcap_major_version</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">return the major version number of the pcap library used to write the savefile. <a href="#ga39dfb05149b443cc25b8febc455ca753"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gac7a9dd9cd040ee500221cf35dfb49248">pcap_minor_version</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">return the minor version number of the pcap library used to write the savefile. <a href="#gac7a9dd9cd040ee500221cf35dfb49248"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">FILE * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga4c9f5690b99fb2af1f8904403f7da06b">pcap_file</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the standard stream of an offline capture. <a href="#ga4c9f5690b99fb2af1f8904403f7da06b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gabbd74d8c3ce1bcbccc76129ac38f4549">pcap_stats</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, struct <a class="el" href="structpcap__stat.html">pcap_stat</a> *ps)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return statistics on current capture. <a href="#gabbd74d8c3ce1bcbccc76129ac38f4549"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e">pcap_perror</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, char *prefix)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">print the text of the last pcap library error on stderr, prefixed by prefix. <a href="#gac3b6784c6c2623b93b22f6f219bd470e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a">pcap_geterr</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">return the error text pertaining to the last pcap library error. <a href="#ga81305cb154e4497e95bbb9b708631a3a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gafac2067e8f66f5a5a87f19f5e2b5ad4f">pcap_strerror</a> (int error)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Provided in case strerror() isn't available. <a href="#gafac2067e8f66f5a5a87f19f5e2b5ad4f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga2d92cec9ff55906b5b6fb883e4bd72f4">pcap_lib_version</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns a pointer to a string giving information about the version of the libpcap library being used; note that it contains more information than just a version number. <a href="#ga2d92cec9ff55906b5b6fb883e4bd72f4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560">pcap_close</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">close the files associated with p and deallocates resources. <a href="#gaa45a5e1a4ba9925bb3586dcbeec78560"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">FILE * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga8dac02f297422ff2ab5983d1e30c58b6">pcap_dump_file</a> (<a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">return the standard I/O stream of the 'savefile' opened by <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>. <a href="#ga8dac02f297422ff2ab5983d1e30c58b6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga90404ae3dcffcd3bbe78f8b187a88984">pcap_dump_flush</a> (<a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Flushes the output buffer to the ``savefile,'' so that any packets written with <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> but not yet written to the ``savefile'' will be written. -1 is returned on error, 0 on success. <a href="#ga90404ae3dcffcd3bbe78f8b187a88984"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga3897795c1e9fb10571092febae964ef0">pcap_dump_close</a> (<a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Closes a savefile. <a href="#ga3897795c1e9fb10571092febae964ef0"></a><br/></td></tr>
<tr><td colspan="2"><h2>Windows-specific Extensions</h2></td></tr>
<tr><td colspan="2"><p><a class="anchor" id="amgrp06003dbc75790df77036476ed55327c8"></a> The functions in this section extend libpcap to offer advanced functionalities (like remote packet capture, packet buffer size variation or high-precision packet injection). Howerver, at the moment they can be used only in Windows. </p>
<br/><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="Win32-Extensions_8h.html#aadfdcc0e37082d8f6b28a43ec9a0bccf">PAirpcapHandle</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga4c8f8d1b9238c74faa156494a6b98670">pcap_get_airpcap_handle</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the AirPcap handler associated with an adapter. This handler can be used to change the wireless-related settings of the CACE Technologies AirPcap wireless capture adapters. <a href="#ga4c8f8d1b9238c74faa156494a6b98670"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gae92f11bfb001c19b2d0fbcd6821d222a">pcap_offline_filter</a> (struct bpf_program *prog, const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *header, const u_char *pkt_data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns if a given filter applies to an offline packet. <a href="#gae92f11bfb001c19b2d0fbcd6821d222a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d">pcap_live_dump</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, char *filename, int maxsize, int maxpacks)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Save a capture to file. <a href="#gaedef54159d918b22a7de8e75b8a3ef4d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gafe8a334f3a7ae2dc7f52e96523da39be">pcap_live_dump_ended</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int sync)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the status of the kernel dump process, i.e. tells if one of the limits defined with <a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> has been reached. <a href="#gafe8a334f3a7ae2dc7f52e96523da39be"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structpcap__stat.html">pcap_stat</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga8050f7829956aabd243cc32b3cfabbd6">pcap_stats_ex</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int *pcap_stat_size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return statistics on current capture. <a href="#ga8050f7829956aabd243cc32b3cfabbd6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga124bde25ccd9e39017ff2abec2dda623">pcap_setbuff</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int dim)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the size of the kernel buffer associated with an adapter. <a href="#ga124bde25ccd9e39017ff2abec2dda623"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaef07ef49d3c75644f3fd34518e2fe720">pcap_setmode</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the working mode of the interface p to mode. <a href="#gaef07ef49d3c75644f3fd34518e2fe720"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gab14ceacbf1c2f63026416dd73f80dc0d">pcap_setmintocopy</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, int size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the minumum amount of data received by the kernel in a single call. <a href="#gab14ceacbf1c2f63026416dd73f80dc0d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">HANDLE </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga2c415e9192c7b18a81a02300ae6f2c02">pcap_getevent</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the handle of the event associated with the interface p. <a href="#ga2c415e9192c7b18a81a02300ae6f2c02"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gab940e69631b7cc7f2232a69ea02b86d9">pcap_sendqueue_alloc</a> (u_int memsize)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocate a send queue. <a href="#gab940e69631b7cc7f2232a69ea02b86d9"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga72624f7a9932cc2124abf661001e0aa4">pcap_sendqueue_destroy</a> (<a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> *queue)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy a send queue. <a href="#ga72624f7a9932cc2124abf661001e0aa4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297">pcap_sendqueue_queue</a> (<a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> *queue, const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *pkt_header, const u_char *pkt_data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Add a packet to a send queue. <a href="#ga4c57ea320d71dbfe55c5665af9db1297"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u_int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaa4d55eb047a1cccc0e28397ce04ee097">pcap_sendqueue_transmit</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p, <a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> *queue, int sync)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Send a queue of raw packets to the network. <a href="#gaa4d55eb047a1cccc0e28397ce04ee097"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e">pcap_findalldevs_ex</a> (char *source, struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> *auth, <a class="el" href="structpcap__if.html">pcap_if_t</a> **alldevs, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a list of network devices that can be opened with <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>. <a href="#ga98f36e62c95c6ad81eaa8b2bbeb8f16e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#gaa3111e10f930a9772a32a922b26948b0">pcap_createsrcstr</a> (char *source, int type, const char *<a class="el" href="wpcap__remote_8htm.html#a3c46d79c790748a5942fb43baa6b3073">host</a>, const char *port, const char *name, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Accept a set of strings (host name, port, ...), and it returns the complete source string according to the new format (e.g. 'rpcap://1.2.3.4/eth0'). <a href="#gaa3111e10f930a9772a32a922b26948b0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga090e0afd3f463b4b60a64c47eddc1ba2">pcap_parsesrcstr</a> (const char *source, int *type, char *<a class="el" href="wpcap__remote_8htm.html#a3c46d79c790748a5942fb43baa6b3073">host</a>, char *port, char *name, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Parse the source string and returns the pieces in which the source can be split. <a href="#ga090e0afd3f463b4b60a64c47eddc1ba2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791">pcap_open</a> (const char *source, int snaplen, int flags, int read_timeout, struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> *auth, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Open a generic source in order to capture / send (WinPcap only) traffic. <a href="#ga2b64c7b6490090d1d37088794f1f1791"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structpcap__samp.html">pcap_samp</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga84c7d55f5b0e7d545b38d6b8e7bde005">pcap_setsampling</a> (<a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> *p)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Define a sampling method for packet capture. <a href="#ga84c7d55f5b0e7d545b38d6b8e7bde005"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">SOCKET </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga5495943cc8262db57f726e2a23f837dd">pcap_remoteact_accept</a> (const char *address, const char *port, const char *hostlist, char *connectinghost, struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> *auth, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Block until a network connection is accepted (active mode only). <a href="#ga5495943cc8262db57f726e2a23f837dd"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga6a84e03497f946d61c440696e57e2c95">pcap_remoteact_close</a> (const char *<a class="el" href="wpcap__remote_8htm.html#a3c46d79c790748a5942fb43baa6b3073">host</a>, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Drop an active connection (active mode only). <a href="#ga6a84e03497f946d61c440696e57e2c95"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga7b022e0a67f5ff62fd13df5c688d6d82">pcap_remoteact_cleanup</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Clean the socket that is currently used in waiting active connections. <a href="#ga7b022e0a67f5ff62fd13df5c688d6d82"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__wpcapfunc.html#ga7ee8f666bff537aa457b7c05651cf815">pcap_remoteact_list</a> (char *hostlist, char sep, int size, char *errbuf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the hostname of the host that have an active connection with us (active mode only). <a href="#ga7ee8f666bff537aa457b7c05651cf815"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>Functions exported by wpcap.dll </p>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="gabcba231c099919ecd9300d7160b19878"></a><!-- doxytag: member="funcs/pcap.h::pcap_handler" ref="gabcba231c099919ecd9300d7160b19878" args=")(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void(* <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a>)(u_char *user, const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> *pkt_header, const u_char *pkt_data)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Prototype of the callback function that receives the packets. </p>
<p>When <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> are called by the user, the packets are passed to the application by means of this callback. user is a user-defined parameter that contains the state of the capture session, it corresponds to the <em>user</em> parameter of <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> and <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>. pkt_header is the header associated by the capture driver to the packet. It is NOT a protocol header. pkt_data points to the data of the packet, including the protocol headers. </p>
<p>Definition at line <a class="el" href="funcs_2pcap_8h_source.html#l00027">27</a> of file <a class="el" href="funcs_2pcap_8h_source.html">funcs/pcap.h</a>.</p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gae0dc50910fabbd375fab8a1352a6cf33"></a><!-- doxytag: member="funcs/pcap.h::pcap_breakloop" ref="gae0dc50910fabbd375fab8a1352a6cf33" args="(pcap_t *)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_breakloop </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>set a flag that will force <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> to return rather than looping. </p>
<p>They will return the number of packets that have been processed so far, or -2 if no packets have been processed so far. This routine is safe to use inside a signal handler on UNIX or a console control handler on Windows, as it merely sets a flag that is checked within the loop. The flag is checked in loops reading packets from the OS - a signal by itself will not necessarily terminate those loops - as well as in loops processing a set of packets returned by the OS. Note that if you are catching signals on UNIX systems that support restarting system calls after a signal, and calling <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a> in the signal handler, you must specify, when catching those signals, that system calls should NOT be restarted by that signal. Otherwise, if the signal interrupted a call reading packets in a live capture, when your signal handler returns after calling <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a>, the call will be restarted, and the loop will not terminate until more packets arrive and the call completes. </p>
<dl class="note"><dt><b>Note:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a> will, on some platforms, loop reading packets from the OS; that loop will not necessarily be terminated by a signal, so <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a> should be used to terminate packet processing even if <a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a> is being used. <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a> does not guarantee that no further packets will be processed by <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> after it is called; at most one more packet might be processed. If -2 is returned from <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>, the flag is cleared, so a subsequent call will resume reading packets. If a positive number is returned, the flag is not cleared, so a subsequent call will return -2 and clear the flag. </dd></dl>
</div>
</div>
<a class="anchor" id="gaa45a5e1a4ba9925bb3586dcbeec78560"></a><!-- doxytag: member="funcs/pcap.h::pcap_close" ref="gaa45a5e1a4ba9925bb3586dcbeec78560" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_close </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>close the files associated with p and deallocates resources. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845" title="Create a pcap_t structure without starting a capture.">pcap_open_dead()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga363bdc6f6b39b4979ddcf15ecb830c5c"></a><!-- doxytag: member="funcs/pcap.h::pcap_compile" ref="ga363bdc6f6b39b4979ddcf15ecb830c5c" args="(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_compile </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct bpf_program * </td>
<td class="paramname"> <em>fp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>str</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>optimize</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> </td>
<td class="paramname"> <em>netmask</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Compile a packet filter, converting an high level filtering expression (see <a class="el" href="group__language.html">Filtering expression syntax</a>) in a program that can be interpreted by the kernel-level filtering engine. </p>
<p><a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a> is used to compile the string str into a filter program. program is a pointer to a bpf_program struct and is filled in by <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>. optimize controls whether optimization on the resulting code is performed. netmask specifies the IPv4 netmask of the network on which packets are being captured; it is used only when checking for IPv4 broadcast addresses in the filter program. If the netmask of the network on which packets are being captured isn't known to the program, or if packets are being captured on the Linux "any" pseudo-interface that can capture on more than one network, a value of 0 can be supplied; tests for IPv4 broadcast addreses won't be done correctly, but all other tests in the filter program will be OK. A return of -1 indicates an error in which case <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> may be used to display the error text.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61" title="Associate a filter to a capture.">pcap_setfilter()</a>, <a class="el" href="group__wpcapfunc.html#ga9e0a5aad1a5dc79d85f1edfcebe0ac13" title="Free a filter.">pcap_freecode()</a>, <a class="el" href="group__wpcapfunc.html#gae5c6e9768e89a6b82f9d720f37e6ab97" title="Return the dimension of the packet portion (in bytes) that is delivered to the application...">pcap_snapshot()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga8325b202dad14a00609db8372722ae4e"></a><!-- doxytag: member="funcs/pcap.h::pcap_compile_nopcap" ref="ga8325b202dad14a00609db8372722ae4e" args="(int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_compile_nopcap </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>snaplen_arg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>linktype_arg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct bpf_program * </td>
<td class="paramname"> <em>program</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>optimize</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> </td>
<td class="paramname"> <em>mask</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Compile a packet filter without the need of opening an adapter. This function converts an high level filtering expression (see <a class="el" href="group__language.html">Filtering expression syntax</a>) in a program that can be interpreted by the kernel-level filtering engine. </p>
<p><a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> is similar to <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a> except that instead of passing a pcap structure, one passes the snaplen and linktype explicitly. It is intended to be used for compiling filters for direct BPF usage, without necessarily having called <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>. A return of -1 indicates an error; the error text is unavailable. (<a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> is a wrapper around <a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845" title="Create a pcap_t structure without starting a capture.">pcap_open_dead()</a>, <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>, and <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a>; the latter three routines can be used directly in order to get the error text for a compilation error.)</p>
<p>Look at the <a class="el" href="group__language.html">Filtering expression syntax</a> section for details on the str parameter.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61" title="Associate a filter to a capture.">pcap_setfilter()</a>, <a class="el" href="group__wpcapfunc.html#ga9e0a5aad1a5dc79d85f1edfcebe0ac13" title="Free a filter.">pcap_freecode()</a>, <a class="el" href="group__wpcapfunc.html#gae5c6e9768e89a6b82f9d720f37e6ab97" title="Return the dimension of the packet portion (in bytes) that is delivered to the application...">pcap_snapshot()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaa3111e10f930a9772a32a922b26948b0"></a><!-- doxytag: member="funcs/pcap.h::pcap_createsrcstr" ref="gaa3111e10f930a9772a32a922b26948b0" args="(char *source, int type, const char *host, const char *port, const char *name, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_createsrcstr </td>
<td>(</td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>source</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>type</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>host</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>port</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Accept a set of strings (host name, port, ...), and it returns the complete source string according to the new format (e.g. 'rpcap://1.2.3.4/eth0'). </p>
<p>This function is provided in order to help the user creating the source string according to the new format. An unique source string is used in order to make easy for old applications to use the remote facilities. Think about tcpdump, for example, which has only one way to specify the interface on which the capture has to be started. However, GUI-based programs can find more useful to specify hostname, port and interface name separately. In that case, they can use this function to create the source string before passing it to the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> function.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>source,:</em> </td><td>a user-allocated buffer that will contain the complete source string wen the function returns.<br/>
The source will start with an identifier according to the new <a class="el" href="group__remote__source__string.html">Source Specification Syntax </a>.<br/>
This function assumes that the allocated buffer is at least PCAP_BUF_SIZE bytes.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>type,:</em> </td><td>its value tells the type of the source we want to create. It can assume the values defined in the <a class="el" href="group__remote__source__ID.html">Source identification Codes </a>.<br/>
</td></tr>
<tr><td valign="top"></td><td valign="top"><em>host,:</em> </td><td>an user-allocated buffer that keeps the host (e.g. "foo.bar.com") we want to connect to. It can be NULL in case we want to open an interface on a local host.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>port,:</em> </td><td>an user-allocated buffer that keeps the network port (e.g. "2002") we want to use for the RPCAP protocol. It can be NULL in case we want to open an interface on a local host.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>name,:</em> </td><td>an user-allocated buffer that keeps the interface name we want to use (e.g. "eth0"). It can be NULL in case the return string (i.e. 'source') has to be used with the <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e" title="Create a list of network devices that can be opened with pcap_open().">pcap_findalldevs_ex()</a>, which does not require the interface name.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one).</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>'0' if everything is fine, '-1' if some errors occurred. The string containing the complete source is returned in the 'source' variable.</dd></dl>
<dl class="warning"><dt><b>Warning:</b></dt><dd>If the source is longer than PCAP_BUF_SIZE, the excess characters are truncated. </dd></dl>
</div>
</div>
<a class="anchor" id="ga64c019f851f7da6892d51cca15f12ace"></a><!-- doxytag: member="funcs/pcap.h::pcap_datalink" ref="ga64c019f851f7da6892d51cca15f12ace" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_datalink </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the link layer of an adapter. </p>
<p>returns the link layer type; link layer types it can return include:</p>
<ul>
<li>DLT_NULL BSD loopback encapsulation; the link layer header is a 4-byte field, in host byte order, containing a PF_ value from socket.h for the network-layer protocol of the packet. Note that ``host byte order'' is the byte order of the machine on which the packets are captured, and the PF_ values are for the OS of the machine on which the packets are captured; if a live capture is being done, ``host byte order'' is the byte order of the machine capturing the packets, and the PF_ values are those of the OS of the machine capturing the packets, but if a ``savefile'' is being read, the byte order and PF_ values are not necessarily those of the machine reading the capture file.</li>
<li>DLT_EN10MB Ethernet (10Mb, 100Mb, 1000Mb, and up)</li>
<li>DLT_IEEE802: IEEE 802.5 Token Ring</li>
<li>DLT_ARCNET: ARCNET</li>
<li>DLT_SLIP: SLIP; the link layer header contains, in order:<ol type="a">
<li>a 1-byte flag, which is 0 for packets received by the machine and 1 for packets sent by the machine;</li>
<li>a 1-byte field, the upper 4 bits of which indicate the type of packet, as per RFC 1144:<ul>
<li>0x40: an unmodified IP datagram (TYPE_IP);</li>
<li>0x70: an uncompressed-TCP IP datagram (UNCOMPRESSED_TCP), with that byte being the first byte of the raw IP header on the wire, containing the connection number in the protocol field;</li>
<li>0x80: a compressed-TCP IP datagram (COMPRESSED_TCP), with that byte being the first byte of the compressed TCP/IP datagram header;</li>
</ul>
</li>
<li>for UNCOMPRESSED_TCP, the rest of the modified IP header, and for COMPRESSED_TCP, the compressed TCP/IP datagram header;</li>
<li>for a total of 16 bytes; the uncompressed IP datagram follows the header.</li>
</ol>
</li>
</ul>
<ul>
<li>DLT_PPP: PPP; if the first 2 bytes are 0xff and 0x03, it's PPP in HDLC-like framing, with the PPP header following those two bytes, otherwise it's PPP without framing, and the packet begins with the PPP header.</li>
<li>DLT_FDDI: FDDI</li>
<li>DLT_ATM_RFC1483: RFC 1483 LLC/SNAP-encapsulated ATM; the packet begins with an IEEE 802.2 LLC header.</li>
<li>DLT_RAW: raw IP; the packet begins with an IP header.</li>
<li>DLT_PPP_SERIAL: PPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547; the first byte will be 0xFF for PPP in HDLC-like framing, and will be 0x0F or 0x8F for Cisco PPP with HDLC framing.</li>
<li>DLT_PPP_ETHER: PPPoE; the packet begins with a PPPoE header, as per RFC 2516.</li>
<li>DLT_C_HDLC: Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547.</li>
<li>DLT_IEEE802_11: IEEE 802.11 wireless LAN</li>
<li>DLT_FRELAY: Frame Relay</li>
<li>DLT_LOOP: OpenBSD loopback encapsulation; the link layer header is a 4-byte field, in network byte order, containing a PF_ value from OpenBSD's socket.h for the network-layer protocol of the packet. Note that, if a ``savefile'' is being read, those PF_ values are not necessarily those of the machine reading the capture file.</li>
<li>DLT_LINUX_SLL: Linux "cooked" capture encapsulation; the link layer header contains, in order:<ul>
<li>a 2-byte "packet type", in network byte order, which is one of:<ol type="i">
<li>packet was sent to us by somebody else</li>
<li>packet was broadcast by somebody else</li>
<li>packet was multicast, but not broadcast, by somebody else</li>
<li>packet was sent by somebody else to somebody else</li>
<li>packet was sent by us</li>
</ol>
</li>
<li>a 2-byte field, in network byte order, containing a Linux ARPHRD_ value for the link layer device type;</li>
<li>a 2-byte field, in network byte order, containing the length of the link layer address of the sender of the packet (which could be 0);</li>
<li>an 8-byte field containing that number of bytes of the link layer header (if there are more than 8 bytes, only the first 8 are present);</li>
<li>2-byte field containing an Ethernet protocol type, in network byte order, or containing 1 for Novell 802.3 frames without an 802.2 LLC header or 4 for frames beginning with an 802.2 LLC header.</li>
</ul>
</li>
<li>DLT_LTALK: Apple LocalTalk; the packet begins with an AppleTalk LLAP header.</li>
<li>DLT_PFLOG: OpenBSD pflog; the link layer header contains, in order:<ul>
<li>a 4-byte PF_ value, in network byte order;</li>
<li>a 16-character interface name;</li>
<li>a 2-byte rule number, in network byte order;</li>
<li>a 2-byte reason code, in network byte order, which is one of:<ol type="i">
<li>match</li>
<li>bad offset</li>
<li>fragment</li>
<li>short</li>
<li>normalize</li>
<li>memory -a 2-byte action code, in network byte order, which is one of:</li>
<li>passed</li>
<li>dropped</li>
<li>scrubbed</li>
</ol>
</li>
<li>a 2-byte direction, in network byte order, which is one of:<ol type="i">
<li>incoming or outgoing</li>
<li>incoming</li>
<li>outgoing</li>
</ol>
</li>
</ul>
</li>
<li>DLT_PRISM_HEADER: Prism monitor mode information followed by an 802.11 header.</li>
<li>DLT_IP_OVER_FC: RFC 2625 IP-over-Fibre Channel, with the link-layer header being the Network_Header as described in that RFC.</li>
<li>DLT_SUNATM: SunATM devices; the link layer header contains, in order:<ul>
<li>a 1-byte flag field, containing a direction flag in the uppermost bit, which is set for packets transmitted by the machine and clear for packets received by the machine, and a 4-byte traffic type in the low-order 4 bits, which is one of:<ol type="i">
<li>raw traffic</li>
<li>LANE traffic</li>
<li>LLC-encapsulated traffic</li>
<li>MARS traffic</li>
<li>IFMP traffic</li>
<li>ILMI traffic</li>
<li>Q.2931 traffic</li>
</ol>
</li>
<li>a 1-byte VPI value;</li>
<li>a 2-byte VCI field, in network byte order.</li>
</ul>
</li>
<li>DLT_IEEE802_11_RADIO: link-layer information followed by an 802.11 header - see <a href="http://www.radiotap.org/">http://www.radiotap.org/</a> for a description of the link-layer information.</li>
<li>DLT_ARCNET_LINUX: ARCNET, with no exception frames, reassembled packets rather than raw frames, and an extra 16-bit offset field between the destination host and type bytes.</li>
<li>DLT_LINUX_IRDA: Linux-IrDA packets, with a DLT_LINUX_SLL header followed by the IrLAP header.</li>
</ul>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga64e482360b0ed7d65fce1db23d56b921" title="list datalinks">pcap_list_datalinks()</a>, <a class="el" href="group__wpcapfunc.html#ga9588b99ac118cf827873d9e941eb6c77" title="Set the current data link type of the pcap descriptor to the type specified by dlt...">pcap_set_datalink()</a>, <a class="el" href="group__wpcapfunc.html#ga440b2f0757acd4804588933324909207" title="Translates a data link type name, which is a DLT_ name with the DLT_ removed, to...">pcap_datalink_name_to_val()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga440b2f0757acd4804588933324909207"></a><!-- doxytag: member="funcs/pcap.h::pcap_datalink_name_to_val" ref="ga440b2f0757acd4804588933324909207" args="(const char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_datalink_name_to_val </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>name</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Translates a data link type name, which is a DLT_ name with the DLT_ removed, to the corresponding data link type value. The translation is case-insensitive. -1 is returned on failure. </p>
</div>
</div>
<a class="anchor" id="ga3f142cd0694b49357e4a73371db71411"></a><!-- doxytag: member="funcs/pcap.h::pcap_datalink_val_to_description" ref="ga3f142cd0694b49357e4a73371db71411" args="(int dlt)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char* pcap_datalink_val_to_description </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>dlt</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Translates a data link type value to a short description of that data link type. NULL is returned on failure. </p>
</div>
</div>
<a class="anchor" id="gad45c16d494577f1886704af8f31ed442"></a><!-- doxytag: member="funcs/pcap.h::pcap_datalink_val_to_name" ref="gad45c16d494577f1886704af8f31ed442" args="(int dlt)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char* pcap_datalink_val_to_name </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>dlt</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Translates a data link type value to the corresponding data link type name. NULL is returned on failure. </p>
</div>
</div>
<a class="anchor" id="ga60ce104cdf28420d3361cd36d15be44c"></a><!-- doxytag: member="funcs/pcap.h::pcap_dispatch" ref="ga60ce104cdf28420d3361cd36d15be44c" args="(pcap_t *p, int cnt, pcap_handler callback, u_char *user)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_dispatch </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>cnt</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a> </td>
<td class="paramname"> <em>callback</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u_char * </td>
<td class="paramname"> <em>user</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Collect a group of packets. </p>
<p><a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a>, a const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> pointer, and a const u_char pointer to the first caplen (as given in the struct <a class="el" href="structpcap__pkthdr.html" title="Header of a packet in the dump file.">pcap_pkthdr</a> a pointer to which is passed to the callback routine) bytes of data from the packet (which won't necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> that is sufficiently large to get all of the packet's data - a value of 65535 should be sufficient on most if not all networks).</p>
<p>The number of packets read is returned. 0 is returned if no packets were read from a live capture (if, for example, they were discarded because they didn't pass the packet filter, or if, on platforms that support a read timeout that starts before any packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode and no packets were available to be read) or if no more packets are available in a ``savefile.'' A return of -1 indicates an error in which case <a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e" title="print the text of the last pcap library error on stderr, prefixed by prefix.">pcap_perror()</a> or <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> may be used to display the error text. A return of -2 indicates that the loop terminated due to a call to <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a> before any packets were processed. If your application uses <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a>, make sure that you explicitly check for -1 and -2, rather than just checking for a return value < 0.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>when reading a live capture, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to ``poll'' for user input periodically, as there's no guarantee that <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> will return after the timeout expires.</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>, <a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878" title="Prototype of the callback function that receives the packets.">pcap_handler</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga659439bf5aa3988b5a92d31990fbf437"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump" ref="ga659439bf5aa3988b5a92d31990fbf437" args="(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_dump </td>
<td>(</td>
<td class="paramtype">u_char * </td>
<td class="paramname"> <em>user</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> * </td>
<td class="paramname"> <em>h</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const u_char * </td>
<td class="paramname"> <em>sp</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Save a packet to disk. </p>
<p><a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> outputs a packet to the "savefile" opened with <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>. Note that its calling arguments are suitable for use with <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> or <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>. If called directly, the user parameter is of type pcap_dumper_t as returned by <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>, <a class="el" href="group__wpcapfunc.html#ga3897795c1e9fb10571092febae964ef0" title="Closes a savefile.">pcap_dump_close()</a>, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a>, <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga3897795c1e9fb10571092febae964ef0"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump_close" ref="ga3897795c1e9fb10571092febae964ef0" args="(pcap_dumper_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_dump_close </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Closes a savefile. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>, <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga8dac02f297422ff2ab5983d1e30c58b6"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump_file" ref="ga8dac02f297422ff2ab5983d1e30c58b6" args="(pcap_dumper_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">FILE* pcap_dump_file </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>return the standard I/O stream of the 'savefile' opened by <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>. </p>
</div>
</div>
<a class="anchor" id="ga90404ae3dcffcd3bbe78f8b187a88984"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump_flush" ref="ga90404ae3dcffcd3bbe78f8b187a88984" args="(pcap_dumper_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_dump_flush </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Flushes the output buffer to the ``savefile,'' so that any packets written with <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> but not yet written to the ``savefile'' will be written. -1 is returned on error, 0 on success. </p>
</div>
</div>
<a class="anchor" id="ga50de34b8b3298f76c66c82b7ca3f84de"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump_ftell" ref="ga50de34b8b3298f76c66c82b7ca3f84de" args="(pcap_dumper_t *)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">long pcap_dump_ftell </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a> * </td>
<td class="paramname"></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the file position for a "savefile". </p>
<p><a class="el" href="group__wpcapfunc.html#ga50de34b8b3298f76c66c82b7ca3f84de" title="Return the file position for a "savefile".">pcap_dump_ftell()</a> returns the current file position for the "savefile", representing the number of bytes written by <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a> and <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> . -1 is returned on error.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>, <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga9506c33d580fdb5e5c288dba0f8a085c"></a><!-- doxytag: member="funcs/pcap.h::pcap_dump_open" ref="ga9506c33d580fdb5e5c288dba0f8a085c" args="(pcap_t *p, const char *fname)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__wpcap__def.html#gab8c7858aa3a7e3158d9d58cb113a2ae8">pcap_dumper_t</a>* pcap_dump_open </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>fname</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Open a file to write packets. </p>
<p><a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a> is called to open a "savefile" for writing. The name "-" in a synonym for stdout. NULL is returned on failure. p is a pcap struct as returned by <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a> or <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>. fname specifies the name of the file to open. Alternatively, you may call pcap_dump_fopen() to write data to an existing open stream fp. Note that on Windows, that stream should be opened in binary mode. If NULL is returned, <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> can be used to get the error text.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga3897795c1e9fb10571092febae964ef0" title="Closes a savefile.">pcap_dump_close()</a>, <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga4c9f5690b99fb2af1f8904403f7da06b"></a><!-- doxytag: member="funcs/pcap.h::pcap_file" ref="ga4c9f5690b99fb2af1f8904403f7da06b" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">FILE* pcap_file </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the standard stream of an offline capture. </p>
<p><a class="el" href="group__wpcapfunc.html#ga4c9f5690b99fb2af1f8904403f7da06b" title="Return the standard stream of an offline capture.">pcap_file()</a> returns the standard I/O stream of the "savefile", if a "savefile" was opened with <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, or NULL, if a network device was opened with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>. </p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000003">Deprecated:</a></b></dt><dd>Due to incompatibilities between the C Runtime (CRT) used to compile WinPcap and the one used by WinPcap-based applications, this function may return an invalid FILE pointer, i.e. a descriptor that causes all the standard I/O stream functions (ftell, fseek, fclose...) to fail. The function is still available for backwards binary compatibility, only.</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga7b128eaeef627b408f6a6e2a2f5eb45d"></a><!-- doxytag: member="funcs/pcap.h::pcap_findalldevs" ref="ga7b128eaeef627b408f6a6e2a2f5eb45d" args="(pcap_if_t **alldevsp, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_findalldevs </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structpcap__if.html">pcap_if_t</a> ** </td>
<td class="paramname"> <em>alldevsp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Construct a list of network devices that can be opened with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>that there may be network devices that cannot be opened with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> by the process calling <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, because, for example, that process might not have sufficient privileges to open them for capturing; if so, those devices will not appear on the list.) alldevsp is set to point to the first element of the list; each element of the list is of type <a class="el" href="group__wpcap__def.html#ga3a6e7cbf8d9752da3add4676c7cd4c58">pcap_if_t</a>,</dd></dl>
<p>-1 is returned on failure, in which case errbuf is filled in with an appropriate error message; 0 is returned on success.</p>
<dl class="see"><dt><b>See also:</b></dt><dd>struct <a class="el" href="structpcap__if.html" title="Item in a list of interfaces, used by pcap_findalldevs().">pcap_if</a>, <a class="el" href="group__wpcapfunc.html#ga346b4b0b7fd1cda4abb9a39f767dbeb1" title="Free an interface list returned by pcap_findalldevs().">pcap_freealldevs()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#gaed295fc9fd86434372e8a8316f1270b1" title="Return the first valid device in the system.">pcap_lookupdev()</a>, <a class="el" href="group__wpcapfunc.html#gaa35276d0fa530c51a455f298fa1ec453" title="Return the subnet and netmask of an interface.">pcap_lookupnet()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga98f36e62c95c6ad81eaa8b2bbeb8f16e"></a><!-- doxytag: member="funcs/pcap.h::pcap_findalldevs_ex" ref="ga98f36e62c95c6ad81eaa8b2bbeb8f16e" args="(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_findalldevs_ex </td>
<td>(</td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>source</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> * </td>
<td class="paramname"> <em>auth</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structpcap__if.html">pcap_if_t</a> ** </td>
<td class="paramname"> <em>alldevs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Create a list of network devices that can be opened with <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>. </p>
<p>This function is a superset of the old 'pcap_findalldevs()', which allows listing only the devices present on the local machine. Vice versa, <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e" title="Create a list of network devices that can be opened with pcap_open().">pcap_findalldevs_ex()</a> allows listing the devices present on a remote machine as well. Additionally, it can list all the pcap files available into a given folder. Moreover, <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e" title="Create a list of network devices that can be opened with pcap_open().">pcap_findalldevs_ex()</a> is platform independent, since it relies on the standard <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a> to get addresses on the local machine.</p>
<p>In case the function has to list the interfaces on a remote machine, it opens a new control connection toward that machine, it retrieves the interfaces, and it drops the connection. However, if this function detects that the remote machine is in 'active' mode, the connection is not dropped and the existing socket is used.</p>
<p>The 'source' is a parameter that tells the function where the lookup has to be done and it uses the same syntax of the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>.</p>
<p>Differently from the <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, the interface names (pointed by the alldevs->name and the other ones in the linked list) are already ready to be used in the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> call. Vice versa, the output that comes from <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a> must be formatted with the new <a class="el" href="group__wpcapfunc.html#gaa3111e10f930a9772a32a922b26948b0" title="Accept a set of strings (host name, port, ...), and it returns the complete source...">pcap_createsrcstr()</a> before passing the source identifier to the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>source,:</em> </td><td>a char* buffer that keeps the 'source localtion', according to the new WinPcap syntax. This source will be examined looking for adapters (local or remote) (e.g. source can be 'rpcap://' for local adapters or 'rpcap://host:port' for adapters on a remote host) or pcap files (e.g. source can be 'file://c:/myfolder/').<br/>
The strings that must be prepended to the 'source' in order to define if we want local/remote adapters or files is defined in the new <a class="el" href="group__remote__source__string.html">Source Specification Syntax </a>.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>auth,:</em> </td><td>a pointer to a <a class="el" href="structpcap__rmtauth.html" title="This structure keeps the information needed to autheticate the user on a remote machine...">pcap_rmtauth</a> structure. This pointer keeps the information required to authenticate the RPCAP connection to the remote host. This parameter is not meaningful in case of a query to the local host: in that case it can be NULL.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>alldevs,:</em> </td><td>a 'struct pcap_if_t' pointer, which will be properly allocated inside this function. When the function returns, it is set to point to the first element of the interface list; each element of the list is of type 'struct pcap_if_t'.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one).</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>'0' if everything is fine, '-1' if some errors occurred. The list of the devices is returned in the 'alldevs' variable. When the function returns correctly, 'alldevs' cannot be NULL. In other words, this function returns '-1' also in case the system does not have any interface to list.</dd></dl>
<p>The error message is returned in the 'errbuf' variable. An error could be due to several reasons:</p>
<ul>
<li>libpcap/WinPcap was not installed on the local/remote host</li>
<li>the user does not have enough privileges to list the devices / files</li>
<li>a network problem</li>
<li>the RPCAP version negotiation failed</li>
<li>other errors (not enough memory and others).</li>
</ul>
<dl class="warning"><dt><b>Warning:</b></dt><dd>There may be network devices that cannot be opened with <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> by the process calling <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, because, for example, that process might not have sufficient privileges to open them for capturing; if so, those devices will not appear on the list.</dd>
<dd>
The interface list must be deallocated manually by using the <a class="el" href="group__wpcapfunc.html#ga346b4b0b7fd1cda4abb9a39f767dbeb1" title="Free an interface list returned by pcap_findalldevs().">pcap_freealldevs()</a>. </dd></dl>
</div>
</div>
<a class="anchor" id="ga346b4b0b7fd1cda4abb9a39f767dbeb1"></a><!-- doxytag: member="funcs/pcap.h::pcap_freealldevs" ref="ga346b4b0b7fd1cda4abb9a39f767dbeb1" args="(pcap_if_t *alldevsp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_freealldevs </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structpcap__if.html">pcap_if_t</a> * </td>
<td class="paramname"> <em>alldevsp</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Free an interface list returned by <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>. </p>
<p><a class="el" href="group__wpcapfunc.html#ga346b4b0b7fd1cda4abb9a39f767dbeb1" title="Free an interface list returned by pcap_findalldevs().">pcap_freealldevs()</a> is used to free a list allocated by <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga9e0a5aad1a5dc79d85f1edfcebe0ac13"></a><!-- doxytag: member="funcs/pcap.h::pcap_freecode" ref="ga9e0a5aad1a5dc79d85f1edfcebe0ac13" args="(struct bpf_program *fp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_freecode </td>
<td>(</td>
<td class="paramtype">struct bpf_program * </td>
<td class="paramname"> <em>fp</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Free a filter. </p>
<p><a class="el" href="group__wpcapfunc.html#ga9e0a5aad1a5dc79d85f1edfcebe0ac13" title="Free a filter.">pcap_freecode()</a> is used to free up allocated memory pointed to by a bpf_program struct generated by <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a> when that BPF program is no longer needed, for example after it has been made the filter program for a pcap structure by a call to <a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61" title="Associate a filter to a capture.">pcap_setfilter()</a>.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>, <a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga4c8f8d1b9238c74faa156494a6b98670"></a><!-- doxytag: member="funcs/pcap.h::pcap_get_airpcap_handle" ref="ga4c8f8d1b9238c74faa156494a6b98670" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="Win32-Extensions_8h.html#aadfdcc0e37082d8f6b28a43ec9a0bccf">PAirpcapHandle</a> pcap_get_airpcap_handle </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the AirPcap handler associated with an adapter. This handler can be used to change the wireless-related settings of the CACE Technologies AirPcap wireless capture adapters. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>THIS FUNCTION SHOULD BE CONSIDERED PROVISIONAL, AND MAY BE REPLACED IN THE FUTURE BY A MORE COMPLETE SET OF FUNCTIONS FOR WIRELESS SUPPORT.</dd></dl>
<p><a class="el" href="group__wpcapfunc.html#ga4c8f8d1b9238c74faa156494a6b98670" title="Returns the AirPcap handler associated with an adapter. This handler can be used...">pcap_get_airpcap_handle()</a> allows to obtain the airpcap handle of an open adapter. This handle can be used with the AirPcap API functions to perform wireless-releated operations, e.g. changing the channel or enabling WEP decryption. For more details about the AirPcap wireless capture adapters, see <a href="http://www.cacetech.com/products/airpcap.htm">http://www.cacetech.com/products/airpcap.htm</a></p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>p,:</em> </td><td>handle to an open libpcap adapter</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>a pointer to an open AirPcap handle, used internally by the libpcap open adapter. NULL if the libpcap adapter doesn't have wireless support through AirPcap. </dd></dl>
</div>
</div>
<a class="anchor" id="ga81305cb154e4497e95bbb9b708631a3a"></a><!-- doxytag: member="funcs/pcap.h::pcap_geterr" ref="ga81305cb154e4497e95bbb9b708631a3a" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char* pcap_geterr </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>return the error text pertaining to the last pcap library error. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>the pointer Return will no longer point to a valid error message string after the pcap_t passed to it is closed; you must use or copy the string before closing the pcap_t.</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e" title="print the text of the last pcap library error on stderr, prefixed by prefix.">pcap_perror()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga2c415e9192c7b18a81a02300ae6f2c02"></a><!-- doxytag: member="funcs/pcap.h::pcap_getevent" ref="ga2c415e9192c7b18a81a02300ae6f2c02" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">HANDLE pcap_getevent </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the handle of the event associated with the interface p. </p>
<p>This event can be passed to functions like WaitForSingleObject() or WaitForMultipleObjects() to wait until the driver's buffer contains some data without performing a read.</p>
<p>We disourage the use of this function because it is not portable.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gab25dc0bfe06545b86be4103bf010708e"></a><!-- doxytag: member="funcs/pcap.h::pcap_getnonblock" ref="gab25dc0bfe06545b86be4103bf010708e" args="(pcap_t *p, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_getnonblock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Get the "non-blocking" state of an interface. </p>
<p><a class="el" href="group__wpcapfunc.html#gab25dc0bfe06545b86be4103bf010708e" title="Get the "non-blocking" state of an interface.">pcap_getnonblock()</a> returns the current "non-blocking" state of the capture descriptor; it always returns 0 on "savefiles". If there is an error, -1 is returned and errbuf is filled in with an appropriate error message.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga3f212141c80b59aad8ac535bb0178275" title="Switch between blocking and nonblocking mode.">pcap_setnonblock()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaba4941e09e5e03ba39841de4b1d5d6a4"></a><!-- doxytag: member="funcs/pcap.h::pcap_is_swapped" ref="gaba4941e09e5e03ba39841de4b1d5d6a4" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_is_swapped </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>returns true if the current savefile uses a different byte order than the current system. </p>
</div>
</div>
<a class="anchor" id="ga2d92cec9ff55906b5b6fb883e4bd72f4"></a><!-- doxytag: member="funcs/pcap.h::pcap_lib_version" ref="ga2d92cec9ff55906b5b6fb883e4bd72f4" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char* pcap_lib_version </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns a pointer to a string giving information about the version of the libpcap library being used; note that it contains more information than just a version number. </p>
</div>
</div>
<a class="anchor" id="ga64e482360b0ed7d65fce1db23d56b921"></a><!-- doxytag: member="funcs/pcap.h::pcap_list_datalinks" ref="ga64e482360b0ed7d65fce1db23d56b921" args="(pcap_t *p, int **dlt_buf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_list_datalinks </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int ** </td>
<td class="paramname"> <em>dlt_buf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>list datalinks </p>
<p><a class="el" href="group__wpcapfunc.html#ga64e482360b0ed7d65fce1db23d56b921" title="list datalinks">pcap_list_datalinks()</a> is used to get a list of the supported data link types of the interface associated with the pcap descriptor. <a class="el" href="group__wpcapfunc.html#ga64e482360b0ed7d65fce1db23d56b921" title="list datalinks">pcap_list_datalinks()</a> allocates an array to hold the list and sets *dlt_buf. The caller is responsible for freeing the array. -1 is returned on failure; otherwise, the number of data link types in the array is returned.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga64c019f851f7da6892d51cca15f12ace" title="Return the link layer of an adapter.">pcap_datalink()</a>, <a class="el" href="group__wpcapfunc.html#ga9588b99ac118cf827873d9e941eb6c77" title="Set the current data link type of the pcap descriptor to the type specified by dlt...">pcap_set_datalink()</a>, <a class="el" href="group__wpcapfunc.html#ga440b2f0757acd4804588933324909207" title="Translates a data link type name, which is a DLT_ name with the DLT_ removed, to...">pcap_datalink_name_to_val()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaedef54159d918b22a7de8e75b8a3ef4d"></a><!-- doxytag: member="funcs/pcap.h::pcap_live_dump" ref="gaedef54159d918b22a7de8e75b8a3ef4d" args="(pcap_t *p, char *filename, int maxsize, int maxpacks)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_live_dump </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>filename</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>maxsize</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>maxpacks</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Save a capture to file. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>: this function does not work in current version of WinPcap.</dd></dl>
<p><a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> dumps the network traffic from an interface to a file. Using this function the dump is performed at kernel level, therefore it is more efficient than using <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a>.</p>
<p>The parameters of this function are an interface descriptor (obtained with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>), a string with the name of the dump file, the maximum size of the file (in bytes) and the maximum number of packets that the file will contain. Setting maxsize or maxpacks to 0 means no limit. When maxsize or maxpacks are reached, the dump ends.</p>
<p><a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> is non-blocking, threfore Return immediately. <a class="el" href="group__wpcapfunc.html#gafe8a334f3a7ae2dc7f52e96523da39be" title="Return the status of the kernel dump process, i.e. tells if one of the limits defined...">pcap_live_dump_ended()</a> can be used to check the status of the dump process or to wait until it is finished. <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a> can instead be used to end the dump process.</p>
<p>Note that when one of the two limits is reached, the dump is stopped, but the file remains opened. In order to correctly flush the data and put the file in a consistent state, the adapter must be closed with <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a>.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gafe8a334f3a7ae2dc7f52e96523da39be" title="Return the status of the kernel dump process, i.e. tells if one of the limits defined...">pcap_live_dump_ended()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a>, <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>, <a class="el" href="group__wpcapfunc.html#ga659439bf5aa3988b5a92d31990fbf437" title="Save a packet to disk.">pcap_dump()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gafe8a334f3a7ae2dc7f52e96523da39be"></a><!-- doxytag: member="funcs/pcap.h::pcap_live_dump_ended" ref="gafe8a334f3a7ae2dc7f52e96523da39be" args="(pcap_t *p, int sync)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_live_dump_ended </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>sync</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the status of the kernel dump process, i.e. tells if one of the limits defined with <a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> has been reached. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>: this function does not work in current version of WinPcap.</dd></dl>
<p><a class="el" href="group__wpcapfunc.html#gafe8a334f3a7ae2dc7f52e96523da39be" title="Return the status of the kernel dump process, i.e. tells if one of the limits defined...">pcap_live_dump_ended()</a> informs the user about the limits that were set with a previous call to <a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> on the interface pointed by p: if the return value is nonzero, one of the limits has been reched and the dump process is currently stopped.</p>
<p>If sync is nonzero, the function blocks until the dump is finished, otherwise Return immediately.</p>
<dl class="warning"><dt><b>Warning:</b></dt><dd>if the dump process has no limits (i.e. if the maxsize and maxpacks arguments of <a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> were both 0), the dump process will never stop, therefore setting sync to TRUE will block the application on this call forever.</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaedef54159d918b22a7de8e75b8a3ef4d" title="Save a capture to file.">pcap_live_dump()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaed295fc9fd86434372e8a8316f1270b1"></a><!-- doxytag: member="funcs/pcap.h::pcap_lookupdev" ref="gaed295fc9fd86434372e8a8316f1270b1" args="(char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char* pcap_lookupdev </td>
<td>(</td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the first valid device in the system. </p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd>Use <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d">pcap_findalldevs()</a> or <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e">pcap_findalldevs_ex()</a> instead.</dd></dl>
<p><a class="el" href="group__wpcapfunc.html#gaed295fc9fd86434372e8a8316f1270b1" title="Return the first valid device in the system.">pcap_lookupdev()</a> returns a pointer to a network device suitable for use with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> and <a class="el" href="group__wpcapfunc.html#gaa35276d0fa530c51a455f298fa1ec453" title="Return the subnet and netmask of an interface.">pcap_lookupnet()</a>. If there is an error, NULL is returned and errbuf is filled in with an appropriate error message.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaa35276d0fa530c51a455f298fa1ec453"></a><!-- doxytag: member="funcs/pcap.h::pcap_lookupnet" ref="gaa35276d0fa530c51a455f298fa1ec453" args="(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_lookupnet </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>device</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> * </td>
<td class="paramname"> <em>netp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga37fdbc8313e90fb2041203a2e40cd482">bpf_u_int32</a> * </td>
<td class="paramname"> <em>maskp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the subnet and netmask of an interface. </p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000002">Deprecated:</a></b></dt><dd>Use <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d">pcap_findalldevs()</a> or <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e">pcap_findalldevs_ex()</a> instead.</dd></dl>
<p><a class="el" href="group__wpcapfunc.html#gaa35276d0fa530c51a455f298fa1ec453" title="Return the subnet and netmask of an interface.">pcap_lookupnet()</a> is used to determine the network number and mask associated with the network device device. Both netp and maskp are bpf_u_int32 pointers. A return of -1 indicates an error in which case errbuf is filled in with an appropriate error message.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga6bcb7c5c59d76ec16b8a699da136b5de"></a><!-- doxytag: member="funcs/pcap.h::pcap_loop" ref="ga6bcb7c5c59d76ec16b8a699da136b5de" args="(pcap_t *p, int cnt, pcap_handler callback, u_char *user)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_loop </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>cnt</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878">pcap_handler</a> </td>
<td class="paramname"> <em>callback</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u_char * </td>
<td class="paramname"> <em>user</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Collect a group of packets. </p>
<p><a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> is similar to <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> except it keeps reading packets until cnt packets are processed or an error occurs. It does not return when live read timeouts occur. Rather, specifying a non-zero read timeout to <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> and then calling <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> allows the reception and processing of any packets that arrive when the timeout occurs. A negative cnt causes <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> to loop forever (or at least until an error occurs). -1 is returned on an error; 0 is returned if cnt is exhausted; -2 is returned if the loop terminated due to a call to <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a> before any packets were processed. If your application uses <a class="el" href="group__wpcapfunc.html#gae0dc50910fabbd375fab8a1352a6cf33" title="set a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping...">pcap_breakloop()</a>, make sure that you explicitly check for -1 and -2, rather than just checking for a return value < 0.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a>, <a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878" title="Prototype of the callback function that receives the packets.">pcap_handler</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga39dfb05149b443cc25b8febc455ca753"></a><!-- doxytag: member="funcs/pcap.h::pcap_major_version" ref="ga39dfb05149b443cc25b8febc455ca753" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_major_version </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>return the major version number of the pcap library used to write the savefile. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gac7a9dd9cd040ee500221cf35dfb49248" title="return the minor version number of the pcap library used to write the savefile.">pcap_minor_version()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gac7a9dd9cd040ee500221cf35dfb49248"></a><!-- doxytag: member="funcs/pcap.h::pcap_minor_version" ref="gac7a9dd9cd040ee500221cf35dfb49248" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_minor_version </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>return the minor version number of the pcap library used to write the savefile. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga39dfb05149b443cc25b8febc455ca753" title="return the major version number of the pcap library used to write the savefile.">pcap_major_version()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gadf60257f650aaf869671e0a163611fc3"></a><!-- doxytag: member="funcs/pcap.h::pcap_next" ref="gadf60257f650aaf869671e0a163611fc3" args="(pcap_t *p, struct pcap_pkthdr *h)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">u_char* pcap_next </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> * </td>
<td class="paramname"> <em>h</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the next available packet. </p>
<p><a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a> reads the next packet (by calling <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> with a cnt of 1) and returns a u_char pointer to the data in that packet. (The <a class="el" href="structpcap__pkthdr.html" title="Header of a packet in the dump file.">pcap_pkthdr</a> struct for that packet is not supplied.) NULL is returned if an error occured, or if no packets were read from a live capture (if, for example, they were discarded because they didn't pass the packet filter, or if, on platforms that support a read timeout that starts before any packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode and no packets were available to be read), or if no more packets are available in a ``savefile.'' Unfortunately, there is no way to determine whether an error occured or not. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a>, <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga439439c2eae61161dc1efb1e03a81133"></a><!-- doxytag: member="funcs/pcap.h::pcap_next_ex" ref="ga439439c2eae61161dc1efb1e03a81133" args="(pcap_t *p, struct pcap_pkthdr **pkt_header, const u_char **pkt_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_next_ex </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> ** </td>
<td class="paramname"> <em>pkt_header</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const u_char ** </td>
<td class="paramname"> <em>pkt_data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Read a packet from an interface or from an offline capture. </p>
<p>This function is used to retrieve the next available packet, bypassing the callback method traditionally provided by libpcap.</p>
<p>pcap_next_ex fills the pkt_header and pkt_data parameters (see <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878" title="Prototype of the callback function that receives the packets.">pcap_handler()</a>) with the pointers to the header and to the data of the next captured packet.</p>
<p>The return value can be:</p>
<ul>
<li>1 if the packet has been read without problems</li>
<li>0 if the timeout set with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> has elapsed. In this case pkt_header and pkt_data don't point to a valid packet</li>
<li>-1 if an error occurred</li>
<li>-2 if EOF was reached reading from an offline capture</li>
</ul>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a>, <a class="el" href="group__wpcapfunc.html#gabcba231c099919ecd9300d7160b19878" title="Prototype of the callback function that receives the packets.">pcap_handler()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gae92f11bfb001c19b2d0fbcd6821d222a"></a><!-- doxytag: member="funcs/pcap.h::pcap_offline_filter" ref="gae92f11bfb001c19b2d0fbcd6821d222a" args="(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_offline_filter </td>
<td>(</td>
<td class="paramtype">struct bpf_program * </td>
<td class="paramname"> <em>prog</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> * </td>
<td class="paramname"> <em>header</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const u_char * </td>
<td class="paramname"> <em>pkt_data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns if a given filter applies to an offline packet. </p>
<p>This function is used to apply a filter to a packet that is currently in memory. This process does not need to open an adapter; we need just to create the proper filter (by settings parameters like the snapshot length, or the link-layer type) by means of the <a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a>.</p>
<p>The current API of libpcap does not allow to receive a packet and to filter the packet after it has been received. However, this can be useful in case you want to filter packets in the application, instead of into the receiving process. This function allows you to do the job.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>prog,:</em> </td><td>bpf program (created with the <a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> ) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>header,:</em> </td><td>header of the packet that has to be filtered </td></tr>
<tr><td valign="top"></td><td valign="top"><em>pkt_data,:</em> </td><td>buffer containing the packet, in network-byte order.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the length of the bytes that are currently available into the packet if the packet satisfies the filter, 0 otherwise. </dd></dl>
</div>
</div>
<a class="anchor" id="ga2b64c7b6490090d1d37088794f1f1791"></a><!-- doxytag: member="funcs/pcap.h::pcap_open" ref="ga2b64c7b6490090d1d37088794f1f1791" args="(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a>* pcap_open </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>source</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>snaplen</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>flags</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>read_timeout</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> * </td>
<td class="paramname"> <em>auth</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Open a generic source in order to capture / send (WinPcap only) traffic. </p>
<p>The <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> replaces all the pcap_open_xxx() functions with a single call.</p>
<p>This function hides the differences between the different pcap_open_xxx() functions so that the programmer does not have to manage different opening function. In this way, the 'true' open function is decided according to the source type, which is included into the source string (in the form of source prefix).</p>
<p>This function can rely on the <a class="el" href="group__wpcapfunc.html#gaa3111e10f930a9772a32a922b26948b0" title="Accept a set of strings (host name, port, ...), and it returns the complete source...">pcap_createsrcstr()</a> to create the string that keeps the capture device according to the new syntax, and the <a class="el" href="group__wpcapfunc.html#ga090e0afd3f463b4b60a64c47eddc1ba2" title="Parse the source string and returns the pieces in which the source can be split.">pcap_parsesrcstr()</a> for the other way round.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>source,:</em> </td><td>zero-terminated string containing the source name to open. The source name has to include the format prefix according to the new <a class="el" href="group__remote__source__string.html">Source Specification Syntax</a> and it cannot be NULL.<br/>
On on Linux systems with 2.2 or later kernels, a device argument of "any" (i.e. rpcap://any) can be used to capture packets from all interfaces. <br/>
In order to makes the source syntax easier, please remember that:</p>
<ul>
<li>the adapters returned by the <a class="el" href="group__wpcapfunc.html#ga98f36e62c95c6ad81eaa8b2bbeb8f16e" title="Create a list of network devices that can be opened with pcap_open().">pcap_findalldevs_ex()</a> can be used immediately by the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a></li>
<li>in case the user wants to pass its own source string to the <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a>, the <a class="el" href="group__wpcapfunc.html#gaa3111e10f930a9772a32a922b26948b0" title="Accept a set of strings (host name, port, ...), and it returns the complete source...">pcap_createsrcstr()</a> helps in creating the correct source identifier.</li>
</ul>
</td></tr>
<tr><td valign="top"></td><td valign="top"><em>snaplen,:</em> </td><td>length of the packet that has to be retained. For each packet received by the filter, only the first 'snaplen' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>flags,:</em> </td><td>keeps several flags that can be needed for capturing packets. The allowed flags are defined in the <a class="el" href="group__remote__open__flags.html">pcap_open() flags </a>.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>read_timeout,:</em> </td><td>read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>auth,:</em> </td><td>a pointer to a 'struct pcap_rmtauth' that keeps the information required to authenticate the user on a remote machine. In case this is not a remote capture, this pointer can be set to NULL.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer which will contain the error in case this function fails. The <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> and findalldevs() are the only two functions which have this parameter, since they do not have (yet) a pointer to a pcap_t structure, which reserves space for the error string. Since these functions do not have (yet) a pcap_t pointer (the pcap_t pointer is NULL in case of errors), they need an explicit 'errbuf' variable. 'errbuf' may also be set to warning text when <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> succeds; to detect this case the caller should store a zero-length string in 'errbuf' before calling <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> and display the warning to the user if 'errbuf' is no longer a zero-length string.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A pointer to a 'pcap_t' which can be used as a parameter to the following calls (<a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a> and so on) and that specifies an opened WinPcap session. In case of problems, it returns NULL and the 'errbuf' variable keeps the error message.</dd></dl>
<dl class="warning"><dt><b>Warning:</b></dt><dd>The source cannot be larger than PCAP_BUF_SIZE.</dd>
<dd>
The following formats are not allowed as 'source' strings:<ul>
<li>rpcap:// [to open the first local adapter]</li>
<li>rpcap://hostname/ [to open the first remote adapter] </li>
</ul>
</dd></dl>
</div>
</div>
<a class="anchor" id="ga6445eeb76f2757b9fa088b276eea2845"></a><!-- doxytag: member="funcs/pcap.h::pcap_open_dead" ref="ga6445eeb76f2757b9fa088b276eea2845" args="(int linktype, int snaplen)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a>* pcap_open_dead </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>linktype</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>snaplen</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Create a pcap_t structure without starting a capture. </p>
<p><a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845" title="Create a pcap_t structure without starting a capture.">pcap_open_dead()</a> is used for creating a pcap_t structure to use when calling the other functions in libpcap. It is typically used when just using libpcap for compiling BPF code.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>, <a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61" title="Associate a filter to a capture.">pcap_setfilter()</a>, <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaae6abe06e15c87b803f69773822beca8"></a><!-- doxytag: member="funcs/pcap.h::pcap_open_live" ref="gaae6abe06e15c87b803f69773822beca8" args="(const char *device, int snaplen, int promisc, int to_ms, char *ebuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a>* pcap_open_live </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>device</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>snaplen</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>promisc</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>to_ms</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>ebuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Open a live capture from the network. </p>
<p><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> is used to obtain a packet capture descriptor to look at packets on the network. device is a string that specifies the network device to open; on Linux systems with 2.2 or later kernels, a device argument of "any" or NULL can be used to capture packets from all interfaces. snaplen specifies the maximum number of bytes to capture. If this value is less than the size of a packet that is captured, only the first snaplen bytes of that packet will be captured and provided as packet data. A value of 65535 should be sufficient, on most if not all networks, to capture all the data available from the packet. promisc 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 promiscuous mode for some other reason.) For now, this doesn't work on the "any" device; if an argument of "any" or NULL is supplied, the promisc flag is ignored. to_ms specifies the read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it wait for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored. A zero value for to_ms, on platforms that support a read timeout, will cause a read to wait forever to allow enough packets to arrive, with no timeout. errbuf is used to return error or warning text. It will be set to error text when <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> fails and returns NULL. errbuf may also be set to warning text when <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> succeds; to detect this case the caller should store a zero-length string in errbuf before calling <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> and display the warning to the user if errbuf is no longer a zero-length string.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a>, <a class="el" href="group__wpcapfunc.html#ga6445eeb76f2757b9fa088b276eea2845" title="Create a pcap_t structure without starting a capture.">pcap_open_dead()</a>, <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga91078168a13de8848df2b7b83d1f5b69"></a><!-- doxytag: member="funcs/pcap.h::pcap_open_offline" ref="ga91078168a13de8848df2b7b83d1f5b69" args="(const char *fname, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a>* pcap_open_offline </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>fname</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Open a savefile in the tcpdump/libpcap format to read packets. </p>
<p><a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a> is called to open a "savefile" for reading. fname specifies the name of the file to open. The file has the same format as those used by tcpdump(1) and tcpslice(1). The name "-" in a synonym for stdin. Alternatively, you may call pcap_fopen_offline() to read dumped data from an existing open stream fp. Note that on Windows, that stream should be opened in binary mode. errbuf is used to return error text and is only set when <a class="el" href="group__wpcapfunc.html#ga91078168a13de8848df2b7b83d1f5b69" title="Open a savefile in the tcpdump/libpcap format to read packets.">pcap_open_offline()</a> or pcap_fopen_offline() fails and returns NULL.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga9506c33d580fdb5e5c288dba0f8a085c" title="Open a file to write packets.">pcap_dump_open()</a>, <a class="el" href="group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d" title="Construct a list of network devices that can be opened with pcap_open_live().">pcap_findalldevs()</a>, <a class="el" href="group__wpcapfunc.html#gaa45a5e1a4ba9925bb3586dcbeec78560" title="close the files associated with p and deallocates resources.">pcap_close()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga090e0afd3f463b4b60a64c47eddc1ba2"></a><!-- doxytag: member="funcs/pcap.h::pcap_parsesrcstr" ref="ga090e0afd3f463b4b60a64c47eddc1ba2" args="(const char *source, int *type, char *host, char *port, char *name, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_parsesrcstr </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>source</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"> <em>type</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>host</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>port</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Parse the source string and returns the pieces in which the source can be split. </p>
<p>This call is the other way round of <a class="el" href="group__wpcapfunc.html#gaa3111e10f930a9772a32a922b26948b0" title="Accept a set of strings (host name, port, ...), and it returns the complete source...">pcap_createsrcstr()</a>. It accepts a null-terminated string and it returns the parameters related to the source. This includes:</p>
<ul>
<li>the type of the source (file, winpcap on a remote adapter, winpcap on local adapter), which is determined by the source prefix (PCAP_SRC_IF_STRING and so on)</li>
<li>the host on which the capture has to be started (only for remote captures)</li>
<li>the 'raw' name of the source (file name, name of the remote adapter, name of the local adapter), without the source prefix. The string returned does not include the type of the source itself (i.e. the string returned does not include "file://" or rpcap:// or such).</li>
</ul>
<p>The user can omit some parameters in case it is not interested in them.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>source,:</em> </td><td>a null-terminated string containing the WinPcap source. This source starts with an identifier according to the new <a class="el" href="group__remote__source__string.html">Source Specification Syntax </a>.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>type,:</em> </td><td>pointer to an integer, which is used to return the code corrisponding to the selected source. The code will be one defined in the <a class="el" href="group__remote__source__ID.html">Source identification Codes </a>.<br/>
In case the source string does not exists (i.e. 'source == NULL') or it is empty ('*source == NULL'), it returns PCAP_SRC_IF_LOCAL (i.e. you are ready to call <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> ). This behavior is kept only for compatibility with older applications (e.g. tcpdump); therefore we suggest to move to the new syntax for sources.<br/>
This parameter can be NULL in case the user is not interested in that.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>host,:</em> </td><td>user-allocated buffer (of size PCAP_BUF_SIZE) that is used to return the host name on which the capture has to be started. This value is meaningful only in case of remote capture; otherwise, the returned string will be empty (""). This parameter can be NULL in case the user is not interested in that.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>port,:</em> </td><td>user-allocated buffer (of size PCAP_BUF_SIZE) that is used to return the port that has to be used by the RPCAP protocol to contact the other host. This value is meaningful only in case of remote capture and if the user wants to use a non-standard port; otherwise, the returned string will be empty (""). In case of remote capture, an emply string means "use the standard RPCAP port". This parameter can be NULL in case the user is not interested in that.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>name,:</em> </td><td>user-allocated buffer (of size PCAP_BUF_SIZE) that is used to return the source name, without the source prefix. If the name does not exist (for example because source contains 'rpcap://' that means 'default local adapter'), it returns NULL. This parameter can be NULL in case the user is not interested in that.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one). This parameter can be NULL in case the user is not interested in that.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>'0' if everything is fine, '-1' if some errors occurred. The requested values (host name, network port, type of the source) are returned into the proper variables passed by reference. </dd></dl>
</div>
</div>
<a class="anchor" id="gac3b6784c6c2623b93b22f6f219bd470e"></a><!-- doxytag: member="funcs/pcap.h::pcap_perror" ref="gac3b6784c6c2623b93b22f6f219bd470e" args="(pcap_t *p, char *prefix)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_perror </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>prefix</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>print the text of the last pcap library error on stderr, prefixed by prefix. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga5495943cc8262db57f726e2a23f837dd"></a><!-- doxytag: member="funcs/pcap.h::pcap_remoteact_accept" ref="ga5495943cc8262db57f726e2a23f837dd" args="(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SOCKET pcap_remoteact_accept </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>port</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>hostlist</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>connectinghost</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__rmtauth.html">pcap_rmtauth</a> * </td>
<td class="paramname"> <em>auth</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Block until a network connection is accepted (active mode only). </p>
<p>This function has been defined to allow the client dealing with the 'active mode'. In other words, in the 'active mode' the server opens the connection toward the client, so that the client has to open a socket in order to wait for connections. When a new connection is accepted, the RPCAP protocol starts as usual; the only difference is that the connection is initiated by the server.</p>
<p>This function accepts only ONE connection, then it closes the waiting socket. This means that if some error occurs, the application has to call it again in order to accept another connection.</p>
<p>This function returns when a new connection (coming from a valid host 'connectinghost') is accepted; it returns error otherwise.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>address,:</em> </td><td>a string that keeps the network address we have to bind to; usually it is NULL (it means 'bind on all local addresses').</td></tr>
<tr><td valign="top"></td><td valign="top"><em>port,:</em> </td><td>a string that keeps the network port on which we have to bind to; usually it is NULL (it means 'bind on the predefined port', i.e. RPCAP_DEFAULT_NETPORT_ACTIVE).</td></tr>
<tr><td valign="top"></td><td valign="top"><em>hostlist,:</em> </td><td>a string that keeps the host name of the host from whom we are expecting a connection; it can be NULL (it means 'accept connection from everyone'). Host names are separated by a whatever character in the RPCAP_HOSTLIST_SEP list.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>connectinghost,:</em> </td><td>a user-allocated buffer that will contain the name of the host is trying to connect to us. This variable must be at least RPCAP_HOSTLIST_SIZE bytes..</td></tr>
<tr><td valign="top"></td><td valign="top"><em>auth,:</em> </td><td>a pointer to a <a class="el" href="structpcap__rmtauth.html" title="This structure keeps the information needed to autheticate the user on a remote machine...">pcap_rmtauth</a> structure. This pointer keeps the information required to authenticate the RPCAP connection to the remote host.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one).</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The SOCKET identifier of the new control connection if everything is fine, a negative number if some errors occurred. The error message is returned into the errbuf variable. In case it returns '-1', this means 'everything is fine', but the host cannot be admitted. In case it returns '-2', in means 'unrecoverable error' (for example it is not able to bind the socket, or something like that). In case it returns '-3', it means 'authentication failed'. The authentication check is performed only if the connecting host is among the ones that are allowed to connect to this host.</dd></dl>
<p>The host that is connecting to us is returned into the hostlist variable, which ust be allocated by the user. This variable contains the host name both in case the host is allowed, and in case the connection is refused.</p>
<dl class="warning"><dt><b>Warning:</b></dt><dd>Although this function returns the socket established by the new control connection, this value should not be used. This value will be stored into some libpcap internal variables and it will be managed automatically by the library. In other words, all the following calls to findalldevs() and <a class="el" href="group__wpcapfunc.html#ga2b64c7b6490090d1d37088794f1f1791" title="Open a generic source in order to capture / send (WinPcap only) traffic.">pcap_open()</a> will check if the host is among one that already has a control connection in place; if so, that one will be used.</dd>
<dd>
This function has several problems if used inside a thread, which is stopped when this call is blocked into the accept(). In this case, the socket on which we accept connections is not freed (thread termination is a very dirty job), so that we are no longer able to accept other connections until the program (i.e. the process) stops. In order to solve the problem, call the <a class="el" href="group__wpcapfunc.html#ga7b022e0a67f5ff62fd13df5c688d6d82" title="Clean the socket that is currently used in waiting active connections.">pcap_remoteact_cleanup()</a>. </dd></dl>
</div>
</div>
<a class="anchor" id="ga7b022e0a67f5ff62fd13df5c688d6d82"></a><!-- doxytag: member="funcs/pcap.h::pcap_remoteact_cleanup" ref="ga7b022e0a67f5ff62fd13df5c688d6d82" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_remoteact_cleanup </td>
<td>(</td>
<td class="paramname"></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Clean the socket that is currently used in waiting active connections. </p>
<p>This function does a very dirty job. The fact is that is the waiting socket is not freed if the pcap_remoteaccept() is killed inside a new thread. This function is able to clean the socket in order to allow the next calls to <a class="el" href="group__wpcapfunc.html#ga5495943cc8262db57f726e2a23f837dd" title="Block until a network connection is accepted (active mode only).">pcap_remoteact_accept()</a> to work.</p>
<p>This function is useful *only* if you launch <a class="el" href="group__wpcapfunc.html#ga5495943cc8262db57f726e2a23f837dd" title="Block until a network connection is accepted (active mode only).">pcap_remoteact_accept()</a> inside a new thread, and you stops (not very gracefully) the thread (for example because the user changed idea, and it does no longer want to wait for an active connection). So, basically, the flow should be the following:</p>
<ul>
<li>launch a new thread</li>
<li>call the pcap_remoteact_accept</li>
<li>if this new thread is killed, call <a class="el" href="group__wpcapfunc.html#ga7b022e0a67f5ff62fd13df5c688d6d82" title="Clean the socket that is currently used in waiting active connections.">pcap_remoteact_cleanup()</a>.</li>
</ul>
<p>This function has no effects in other cases.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>None. </dd></dl>
</div>
</div>
<a class="anchor" id="ga6a84e03497f946d61c440696e57e2c95"></a><!-- doxytag: member="funcs/pcap.h::pcap_remoteact_close" ref="ga6a84e03497f946d61c440696e57e2c95" args="(const char *host, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_remoteact_close </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>host</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Drop an active connection (active mode only). </p>
<p>This function has been defined to allow the client dealing with the 'active mode'. This function closes an active connection that is still in place and it purges the host name from the 'activeHost' list. From this point on, the client will not have any connection with that host in place.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>host,:</em> </td><td>a string that keeps the host name of the host for which we want to close the active connection.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one).</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>'0' if everything is fine, '-1' if some errors occurred. The error message is returned into the errbuf variable. </dd></dl>
</div>
</div>
<a class="anchor" id="ga7ee8f666bff537aa457b7c05651cf815"></a><!-- doxytag: member="funcs/pcap.h::pcap_remoteact_list" ref="ga7ee8f666bff537aa457b7c05651cf815" args="(char *hostlist, char sep, int size, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_remoteact_list </td>
<td>(</td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>hostlist</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char </td>
<td class="paramname"> <em>sep</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the hostname of the host that have an active connection with us (active mode only). </p>
<p>This function has been defined to allow the client dealing with the 'active mode'. This function returns the list of hosts that are currently having an active connection with us. This function is useful in order to delete an active connection that is still in place.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>hostlist,:</em> </td><td>a user-allocated string that will keep the list of host that are currently connected with us.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>sep,:</em> </td><td>the character that has to be sued as a separator between the hosts (',' for example).</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size,:</em> </td><td>size of the hostlist buffer.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>errbuf,:</em> </td><td>a pointer to a user-allocated buffer (of size PCAP_ERRBUF_SIZE) that will contain the error message (in case there is one).</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>'0' if everything is fine, '-1' if some errors occurred. The error message is returned into the errbuf variable. </dd></dl>
</div>
</div>
<a class="anchor" id="ga51dbda0f1ab9da2cfe49d657486d50b2"></a><!-- doxytag: member="funcs/pcap.h::pcap_sendpacket" ref="ga51dbda0f1ab9da2cfe49d657486d50b2" args="(pcap_t *p, u_char *buf, int size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_sendpacket </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u_char * </td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>size</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Send a raw packet. </p>
<p>This function allows to send a raw packet to the network. p is the interface that will be used to send the packet, buf contains the data of the packet to send (including the various protocol headers), size is the dimension of the buffer pointed by buf, i.e. the size of the packet to send. The MAC CRC doesn't need to be included, because it is transparently calculated and added by the network interface driver. The return value is 0 if the packet is succesfully sent, -1 otherwise.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gab940e69631b7cc7f2232a69ea02b86d9"></a><!-- doxytag: member="funcs/pcap.h::pcap_sendqueue_alloc" ref="gab940e69631b7cc7f2232a69ea02b86d9" args="(u_int memsize)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structpcap__send__queue.html">pcap_send_queue</a>* pcap_sendqueue_alloc </td>
<td>(</td>
<td class="paramtype">u_int </td>
<td class="paramname"> <em>memsize</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocate a send queue. </p>
<p>This function allocates a send queue, i.e. a buffer containing a set of raw packets that will be transimtted on the network with <a class="el" href="group__wpcapfunc.html#gaa4d55eb047a1cccc0e28397ce04ee097" title="Send a queue of raw packets to the network.">pcap_sendqueue_transmit()</a>.</p>
<p>memsize is the size, in bytes, of the queue, therefore it determines the maximum amount of data that the queue will contain.</p>
<p>Use <a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a> to insert packets in the queue.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a>, <a class="el" href="group__wpcapfunc.html#gaa4d55eb047a1cccc0e28397ce04ee097" title="Send a queue of raw packets to the network.">pcap_sendqueue_transmit()</a>, <a class="el" href="group__wpcapfunc.html#ga72624f7a9932cc2124abf661001e0aa4" title="Destroy a send queue.">pcap_sendqueue_destroy()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga72624f7a9932cc2124abf661001e0aa4"></a><!-- doxytag: member="funcs/pcap.h::pcap_sendqueue_destroy" ref="ga72624f7a9932cc2124abf661001e0aa4" args="(pcap_send_queue *queue)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pcap_sendqueue_destroy </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> * </td>
<td class="paramname"> <em>queue</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Destroy a send queue. </p>
<p>Deletes a send queue and frees all the memory associated with it.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gab940e69631b7cc7f2232a69ea02b86d9" title="Allocate a send queue.">pcap_sendqueue_alloc()</a>, <a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a>, <a class="el" href="group__wpcapfunc.html#gaa4d55eb047a1cccc0e28397ce04ee097" title="Send a queue of raw packets to the network.">pcap_sendqueue_transmit()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga4c57ea320d71dbfe55c5665af9db1297"></a><!-- doxytag: member="funcs/pcap.h::pcap_sendqueue_queue" ref="ga4c57ea320d71dbfe55c5665af9db1297" args="(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_sendqueue_queue </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> * </td>
<td class="paramname"> <em>queue</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct <a class="el" href="structpcap__pkthdr.html">pcap_pkthdr</a> * </td>
<td class="paramname"> <em>pkt_header</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const u_char * </td>
<td class="paramname"> <em>pkt_data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Add a packet to a send queue. </p>
<p><a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a> adds a packet at the end of the send queue pointed by the queue parameter. pkt_header points to a <a class="el" href="structpcap__pkthdr.html" title="Header of a packet in the dump file.">pcap_pkthdr</a> structure with the timestamp and the length of the packet, pkt_data points to a buffer with the data of the packet.</p>
<p>The <a class="el" href="structpcap__pkthdr.html" title="Header of a packet in the dump file.">pcap_pkthdr</a> structure is the same used by WinPcap and libpcap to store the packets in a file, therefore sending a capture file is straightforward. 'Raw packet' means that the sending application will have to include the protocol headers, since every packet is sent to the network 'as is'. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gab940e69631b7cc7f2232a69ea02b86d9" title="Allocate a send queue.">pcap_sendqueue_alloc()</a>, <a class="el" href="group__wpcapfunc.html#gaa4d55eb047a1cccc0e28397ce04ee097" title="Send a queue of raw packets to the network.">pcap_sendqueue_transmit()</a>, <a class="el" href="group__wpcapfunc.html#ga72624f7a9932cc2124abf661001e0aa4" title="Destroy a send queue.">pcap_sendqueue_destroy()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaa4d55eb047a1cccc0e28397ce04ee097"></a><!-- doxytag: member="funcs/pcap.h::pcap_sendqueue_transmit" ref="gaa4d55eb047a1cccc0e28397ce04ee097" args="(pcap_t *p, pcap_send_queue *queue, int sync)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">u_int pcap_sendqueue_transmit </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structpcap__send__queue.html">pcap_send_queue</a> * </td>
<td class="paramname"> <em>queue</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>sync</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Send a queue of raw packets to the network. </p>
<p>This function transmits the content of a queue to the wire. p is a pointer to the adapter on which the packets will be sent, queue points to a <a class="el" href="structpcap__send__queue.html" title="A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit()...">pcap_send_queue</a> structure containing the packets to send (see <a class="el" href="group__wpcapfunc.html#gab940e69631b7cc7f2232a69ea02b86d9" title="Allocate a send queue.">pcap_sendqueue_alloc()</a> and <a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a>), sync determines if the send operation must be synchronized: if it is non-zero, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible.</p>
<p>The return value is the amount of bytes actually sent. If it is smaller than the size parameter, an error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send queue.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Using this function is more efficient than issuing a series of <a class="el" href="group__wpcapfunc.html#ga51dbda0f1ab9da2cfe49d657486d50b2" title="Send a raw packet.">pcap_sendpacket()</a>, because the packets are buffered in the kernel driver, so the number of context switches is reduced. Therefore, expect a better throughput when using pcap_sendqueue_transmit.</dd>
<dd>
When Sync is set to TRUE, the packets are synchronized in the kernel with a high precision timestamp. This requires a non-negligible amount of CPU, but allows normally to send the packets with a precision of some microseconds (depending on the accuracy of the performance counter of the machine). Such a precision cannot be reached sending the packets with <a class="el" href="group__wpcapfunc.html#ga51dbda0f1ab9da2cfe49d657486d50b2" title="Send a raw packet.">pcap_sendpacket()</a>.</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gab940e69631b7cc7f2232a69ea02b86d9" title="Allocate a send queue.">pcap_sendqueue_alloc()</a>, <a class="el" href="group__wpcapfunc.html#ga4c57ea320d71dbfe55c5665af9db1297" title="Add a packet to a send queue.">pcap_sendqueue_queue()</a>, <a class="el" href="group__wpcapfunc.html#ga72624f7a9932cc2124abf661001e0aa4" title="Destroy a send queue.">pcap_sendqueue_destroy()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga9588b99ac118cf827873d9e941eb6c77"></a><!-- doxytag: member="funcs/pcap.h::pcap_set_datalink" ref="ga9588b99ac118cf827873d9e941eb6c77" args="(pcap_t *p, int dlt)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_set_datalink </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>dlt</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the current data link type of the pcap descriptor to the type specified by dlt. -1 is returned on failure. </p>
</div>
</div>
<a class="anchor" id="ga124bde25ccd9e39017ff2abec2dda623"></a><!-- doxytag: member="funcs/pcap.h::pcap_setbuff" ref="ga124bde25ccd9e39017ff2abec2dda623" args="(pcap_t *p, int dim)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_setbuff </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>dim</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the size of the kernel buffer associated with an adapter. </p>
<p><em>dim</em> specifies the size of the buffer in bytes. The return value is 0 when the call succeeds, -1 otherwise. If an old buffer was already created with a previous call to <a class="el" href="group__wpcapfunc.html#ga124bde25ccd9e39017ff2abec2dda623" title="Set the size of the kernel buffer associated with an adapter.">pcap_setbuff()</a>, it is deleted and its content is discarded. <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> creates a 1 MByte buffer by default.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaf5f9cfe85dad0967ff607e5159b1ba61"></a><!-- doxytag: member="funcs/pcap.h::pcap_setfilter" ref="gaf5f9cfe85dad0967ff607e5159b1ba61" args="(pcap_t *p, struct bpf_program *fp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_setfilter </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct bpf_program * </td>
<td class="paramname"> <em>fp</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Associate a filter to a capture. </p>
<p><a class="el" href="group__wpcapfunc.html#gaf5f9cfe85dad0967ff607e5159b1ba61" title="Associate a filter to a capture.">pcap_setfilter()</a> is used to specify a filter program. fp is a pointer to a bpf_program struct, usually the result of a call to <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>. -1 is returned on failure, in which case <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> may be used to display the error text; 0 is returned on success.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>, <a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gab14ceacbf1c2f63026416dd73f80dc0d"></a><!-- doxytag: member="funcs/pcap.h::pcap_setmintocopy" ref="gab14ceacbf1c2f63026416dd73f80dc0d" args="(pcap_t *p, int size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_setmintocopy </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>size</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the minumum amount of data received by the kernel in a single call. </p>
<p><a class="el" href="group__wpcapfunc.html#gab14ceacbf1c2f63026416dd73f80dc0d" title="Set the minumum amount of data received by the kernel in a single call.">pcap_setmintocopy()</a> changes the minimum amount of data in the kernel buffer that causes a read from the application to return (unless the timeout expires). If the value of <em>size</em> is large, the kernel is forced to wait the arrival of several packets before copying the data to the user. This guarantees a low number of system calls, i.e. low processor usage, and is a good setting for applications like packet-sniffers and protocol analyzers. Vice versa, in presence of a small value for this variable, the kernel will copy the packets as soon as the application is ready to receive them. This is useful for real time applications that need the best responsiveness from the kernel. <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> sets a default mintocopy value of 16000 bytes.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a>, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaef07ef49d3c75644f3fd34518e2fe720"></a><!-- doxytag: member="funcs/pcap.h::pcap_setmode" ref="gaef07ef49d3c75644f3fd34518e2fe720" args="(pcap_t *p, int mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_setmode </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>mode</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the working mode of the interface p to mode. </p>
<p>Valid values for mode are MODE_CAPT (default capture mode) and MODE_STAT (statistical mode). See the tutorial "\ref wpcap_tut9" for details about statistical mode. </p>
</div>
</div>
<a class="anchor" id="ga3f212141c80b59aad8ac535bb0178275"></a><!-- doxytag: member="funcs/pcap.h::pcap_setnonblock" ref="ga3f212141c80b59aad8ac535bb0178275" args="(pcap_t *p, int nonblock, char *errbuf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_setnonblock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>nonblock</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>errbuf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Switch between blocking and nonblocking mode. </p>
<p><a class="el" href="group__wpcapfunc.html#ga3f212141c80b59aad8ac535bb0178275" title="Switch between blocking and nonblocking mode.">pcap_setnonblock()</a> puts a capture descriptor, opened with <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, into "non-blocking" mode, or takes it out of "non-blocking" mode, depending on whether the nonblock argument is non-zero or zero. It has no effect on "savefiles". If there is an error, -1 is returned and errbuf is filled in with an appropriate error message; otherwise, 0 is returned. In "non-blocking" mode, an attempt to read from the capture descriptor with <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> will, if no packets are currently available to be read, return 0 immediately rather than blocking waiting for packets to arrive. <a class="el" href="group__wpcapfunc.html#ga6bcb7c5c59d76ec16b8a699da136b5de" title="Collect a group of packets.">pcap_loop()</a> and <a class="el" href="group__wpcapfunc.html#gadf60257f650aaf869671e0a163611fc3" title="Return the next available packet.">pcap_next()</a> will not work in "non-blocking" mode.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gab25dc0bfe06545b86be4103bf010708e" title="Get the "non-blocking" state of an interface.">pcap_getnonblock()</a>, <a class="el" href="group__wpcapfunc.html#ga60ce104cdf28420d3361cd36d15be44c" title="Collect a group of packets.">pcap_dispatch()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga84c7d55f5b0e7d545b38d6b8e7bde005"></a><!-- doxytag: member="funcs/pcap.h::pcap_setsampling" ref="ga84c7d55f5b0e7d545b38d6b8e7bde005" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="structpcap__samp.html">pcap_samp</a>* pcap_setsampling </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Define a sampling method for packet capture. </p>
<p>This function allows applying a sampling method to the packet capture process. The currently sampling methods (and the way to set them) are described into the struct <a class="el" href="structpcap__samp.html" title="This structure defines the information related to sampling.">pcap_samp</a>. In other words, the user must set the appropriate parameters into it; these will be applied as soon as the capture starts.</p>
<dl class="warning"><dt><b>Warning:</b></dt><dd>Sampling parameters <b>cannot</b> be changed when a capture is active. These parameters must be applied <b>before</b> starting the capture. If they are applied when the capture is in progress, the new settings are ignored.</dd>
<dd>
Sampling works only when capturing data on Win32 or reading from a file. It has not been implemented on other platforms. Sampling works on remote machines provided that the probe (i.e. the capturing device) is a Win32 workstation. </dd></dl>
</div>
</div>
<a class="anchor" id="gae5c6e9768e89a6b82f9d720f37e6ab97"></a><!-- doxytag: member="funcs/pcap.h::pcap_snapshot" ref="gae5c6e9768e89a6b82f9d720f37e6ab97" args="(pcap_t *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_snapshot </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the dimension of the packet portion (in bytes) that is delivered to the application. </p>
<p><a class="el" href="group__wpcapfunc.html#gae5c6e9768e89a6b82f9d720f37e6ab97" title="Return the dimension of the packet portion (in bytes) that is delivered to the application...">pcap_snapshot()</a> returns the snapshot length specified when pcap_open_live was called.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a>, <a class="el" href="group__wpcapfunc.html#ga363bdc6f6b39b4979ddcf15ecb830c5c" title="Compile a packet filter, converting an high level filtering expression (see Filtering...">pcap_compile()</a>, <a class="el" href="group__wpcapfunc.html#ga8325b202dad14a00609db8372722ae4e" title="Compile a packet filter without the need of opening an adapter. This function converts...">pcap_compile_nopcap()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gabbd74d8c3ce1bcbccc76129ac38f4549"></a><!-- doxytag: member="funcs/pcap.h::pcap_stats" ref="gabbd74d8c3ce1bcbccc76129ac38f4549" args="(pcap_t *p, struct pcap_stat *ps)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pcap_stats </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="structpcap__stat.html">pcap_stat</a> * </td>
<td class="paramname"> <em>ps</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return statistics on current capture. </p>
<p><a class="el" href="group__wpcapfunc.html#gabbd74d8c3ce1bcbccc76129ac38f4549" title="Return statistics on current capture.">pcap_stats()</a> returns 0 and fills in a <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> 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 underlying packet capture doesn't support packet statistics, -1 is returned and the error text can be obtained with <a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e" title="print the text of the last pcap library error on stderr, prefixed by prefix.">pcap_perror()</a> or <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a>. <a class="el" href="group__wpcapfunc.html#gabbd74d8c3ce1bcbccc76129ac38f4549" title="Return statistics on current capture.">pcap_stats()</a> is supported only on live captures, not on "savefiles"; no statistics are stored in "savefiles", so no statistics are available when reading from a "savefile".</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga8050f7829956aabd243cc32b3cfabbd6" title="Return statistics on current capture.">pcap_stats_ex()</a>, <a class="el" href="group__wpcapfunc.html#gaae6abe06e15c87b803f69773822beca8" title="Open a live capture from the network.">pcap_open_live()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga8050f7829956aabd243cc32b3cfabbd6"></a><!-- doxytag: member="funcs/pcap.h::pcap_stats_ex" ref="ga8050f7829956aabd243cc32b3cfabbd6" args="(pcap_t *p, int *pcap_stat_size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="structpcap__stat.html">pcap_stat</a>* pcap_stats_ex </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__wpcap__def.html#ga4711d025f83503ce692efa5e45ec60a7">pcap_t</a> * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"> <em>pcap_stat_size</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return statistics on current capture. </p>
<p><a class="el" href="group__wpcapfunc.html#ga8050f7829956aabd243cc32b3cfabbd6" title="Return statistics on current capture.">pcap_stats_ex()</a> extends the <a class="el" href="group__wpcapfunc.html#gabbd74d8c3ce1bcbccc76129ac38f4549" title="Return statistics on current capture.">pcap_stats()</a> allowing to return more statistical parameters than the old call. One of the advantages of this new call is that the <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> structure is not allocated by the user; instead, it is returned back by the system. This allow to extend the <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> structure without affecting backward compatibility on older applications. These will simply check at the values of the members at the beginning of the structure, while only newest applications are able to read new statistical values, which are appended in tail.</p>
<p>To be sure not to read a piece of mamory which has not been allocated by the system, the variable pcap_stat_size will return back the size of the structure <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> allocated by the system.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>p,:</em> </td><td>pointer to the pcap_t currently in use. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>pcap_stat_size,:</em> </td><td>pointer to an integer that will contain (when the function returns back) the size of the structure <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> as it has been allocated by the system.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>: a pointer to a <a class="el" href="structpcap__stat.html" title="Structure that keeps statistical values on an interface.">pcap_stat</a> structure, that will contain the statistics related to the current device. The return value is NULL in case of errors, and the error text can be obtained with <a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e" title="print the text of the last pcap library error on stderr, prefixed by prefix.">pcap_perror()</a> or <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a>.</dd></dl>
<dl class="warning"><dt><b>Warning:</b></dt><dd><a class="el" href="group__wpcapfunc.html#ga8050f7829956aabd243cc32b3cfabbd6" title="Return statistics on current capture.">pcap_stats_ex()</a> is supported only on live captures, not on "savefiles"; no statistics are stored in "savefiles", so no statistics are available when reading from a "savefile".</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gabbd74d8c3ce1bcbccc76129ac38f4549" title="Return statistics on current capture.">pcap_stats()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gafac2067e8f66f5a5a87f19f5e2b5ad4f"></a><!-- doxytag: member="funcs/pcap.h::pcap_strerror" ref="gafac2067e8f66f5a5a87f19f5e2b5ad4f" args="(int error)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char* pcap_strerror </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>error</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Provided in case strerror() isn't available. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__wpcapfunc.html#gac3b6784c6c2623b93b22f6f219bd470e" title="print the text of the last pcap library error on stderr, prefixed by prefix.">pcap_perror()</a>, <a class="el" href="group__wpcapfunc.html#ga81305cb154e4497e95bbb9b708631a3a" title="return the error text pertaining to the last pcap library error.">pcap_geterr()</a> </dd></dl>
</div>
</div>
</div>
<hr>
<p align="right"><img border="0" src="winpcap_small.gif" align="absbottom" width="91" height="27">
documentation. Copyright (c) 2002-2005 Politecnico di Torino. Copyright (c) 2005-2009
CACE Technologies. All rights reserved.</p>
|