1 /* $NetBSD: pcap-win32.c,v 1.3 2015/03/31 21:39:42 christos Exp $ */
4 * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
5 * Copyright (c) 2005 - 2008 CACE Technologies, Davis (California)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Politecnico di Torino, CACE Technologies
18 * nor the names of its contributors may be used to endorse or promote
19 * products derived from this software without specific prior written
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 #include <ddk/ntddndis.h>
44 #endif /*__MINGW64__*/
47 #endif /*__MINGW32__*/
51 #endif /* HAVE_DAG_API */
54 #define errno (*_errno())
55 #endif /* __MINGW32__ */
57 static int pcap_setfilter_win32_npf(pcap_t
*, struct bpf_program
*);
58 static int pcap_setfilter_win32_dag(pcap_t
*, struct bpf_program
*);
59 static int pcap_getnonblock_win32(pcap_t
*, char *);
60 static int pcap_setnonblock_win32(pcap_t
*, int, char *);
62 /*dimension of the buffer in the pcap_t structure*/
63 #define WIN32_DEFAULT_USER_BUFFER_SIZE 256000
65 /*dimension of the buffer in the kernel driver NPF */
66 #define WIN32_DEFAULT_KERNEL_BUFFER_SIZE 1000000
68 /* Equivalent to ntohs(), but a lot faster under Windows */
69 #define SWAPS(_X) ((_X & 0xff) << 8) | (_X >> 8)
72 * Private data for capturing on WinPcap devices.
77 int filtering_in_kernel
; /* using kernel filter */
80 int dag_fcs_bits
; /* Number of checksum bits from link layer */
85 * Header that the WinPcap driver associates to the packets.
89 struct timeval bh_tstamp
; /* time stamp */
90 bpf_u_int32 bh_caplen
; /* length of captured portion */
91 bpf_u_int32 bh_datalen
; /* original length of packet */
92 u_short bh_hdrlen
; /* length of bpf header (this struct
93 plus alignment padding) */
96 CRITICAL_SECTION g_PcapCompileCriticalSection
;
104 if (dwReason
== DLL_PROCESS_ATTACH
)
106 InitializeCriticalSection(&g_PcapCompileCriticalSection
);
116 WORD wVersionRequested
;
124 wVersionRequested
= MAKEWORD( 1, 1);
125 err
= WSAStartup( wVersionRequested
, &wsaData
);
126 atexit ((void(*)(void))WSACleanup
);
127 InitializeCriticalSection(&g_PcapCompileCriticalSection
);
141 pcap_stats_win32(pcap_t
*p
, struct pcap_stat
*ps
)
144 if(PacketGetStats(p
->adapter
, (struct bpf_stat
*)ps
) != TRUE
){
145 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "PacketGetStats error: %s", pcap_win32strerror());
152 /* Set the dimension of the kernel-level capture buffer */
154 pcap_setbuff_win32(pcap_t
*p
, int dim
)
156 if(PacketSetBuff(p
->adapter
,dim
)==FALSE
)
158 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "driver error: not enough memory to allocate the kernel buffer");
164 /* Set the driver working mode */
166 pcap_setmode_win32(pcap_t
*p
, int mode
)
168 if(PacketSetMode(p
->adapter
,mode
)==FALSE
)
170 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "driver error: working mode not recognized");
177 /*set the minimum amount of data that will release a read call*/
179 pcap_setmintocopy_win32(pcap_t
*p
, int size
)
181 if(PacketSetMinToCopy(p
->adapter
, size
)==FALSE
)
183 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "driver error: unable to set the requested mintocopy size");
189 /*return the Adapter for a pcap_t*/
191 pcap_getadapter_win32(pcap_t
*p
)
197 pcap_read_win32_npf(pcap_t
*p
, int cnt
, pcap_handler callback
, u_char
*user
)
201 register u_char
*bp
, *ep
;
203 struct pcap_win
*pw
= p
->priv
;
208 * Has "pcap_breakloop()" been called?
212 * Yes - clear the flag that indicates that it
213 * has, and return PCAP_ERROR_BREAK to indicate
214 * that we were told to break out of the loop.
217 return (PCAP_ERROR_BREAK
);
220 /* capture the packets */
221 if(PacketReceivePacket(p
->adapter
,p
->Packet
,TRUE
)==FALSE
){
222 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "read error: PacketReceivePacket failed");
226 cc
= p
->Packet
->ulBytesReceived
;
228 bp
= p
->Packet
->Buffer
;
234 * Loop through each packet.
236 #define bhp ((struct bpf_hdr *)bp)
239 register int caplen
, hdrlen
;
242 * Has "pcap_breakloop()" been called?
243 * If so, return immediately - if we haven't read any
244 * packets, clear the flag and return PCAP_ERROR_BREAK
245 * to indicate that we were told to break out of the loop,
246 * otherwise leave the flag set, so that the *next* call
247 * will break out of the loop without having read any
248 * packets, and return the number of packets we've
254 return (PCAP_ERROR_BREAK
);
264 caplen
= bhp
->bh_caplen
;
265 hdrlen
= bhp
->bh_hdrlen
;
269 * Short-circuit evaluation: if using BPF filter
270 * in kernel, no need to do it now - we already know
271 * the packet passed the filter.
273 * XXX - bpf_filter() should always return TRUE if
274 * handed a null pointer for the program, but it might
275 * just try to "run" the filter, so we check here.
277 if (pw
->filtering_in_kernel
||
278 p
->fcode
.bf_insns
== NULL
||
279 bpf_filter(p
->fcode
.bf_insns
, datap
, bhp
->bh_datalen
, caplen
)) {
281 * XXX A bpf_hdr matches a pcap_pkthdr.
283 (*callback
)(user
, (struct pcap_pkthdr
*)bp
, datap
);
284 bp
+= Packet_WORDALIGN(caplen
+ hdrlen
);
285 if (++n
>= cnt
&& !PACKET_COUNT_IS_UNLIMITED(cnt
)) {
294 bp
+= Packet_WORDALIGN(caplen
+ hdrlen
);
304 pcap_read_win32_dag(pcap_t
*p
, int cnt
, pcap_handler callback
, u_char
*user
)
306 struct pcap_win
*pw
= p
->priv
;
308 int packet_len
= 0, caplen
= 0;
309 struct pcap_pkthdr pcap_header
;
312 dag_record_t
*header
;
313 unsigned erf_record_len
;
317 unsigned dfp
= p
->adapter
->DagFastProcess
;
320 if (cc
== 0) /* Get new packets only if we have processed all the ones of the previous read */
322 /* Get new packets from the network */
323 if(PacketReceivePacket(p
->adapter
, p
->Packet
, TRUE
)==FALSE
){
324 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "read error: PacketReceivePacket failed");
328 cc
= p
->Packet
->ulBytesReceived
;
330 /* The timeout has expired but we no packets arrived */
332 header
= (dag_record_t
*)p
->adapter
->DagBuffer
;
335 header
= (dag_record_t
*)p
->bp
;
337 endofbuf
= (char*)header
+ cc
;
340 * Cycle through the packets
344 erf_record_len
= SWAPS(header
->rlen
);
345 if((char*)header
+ erf_record_len
> endofbuf
)
348 /* Increase the number of captured packets */
351 /* Find the beginning of the packet */
352 dp
= ((u_char
*)header
) + dag_record_size
;
354 /* Determine actual packet len */
358 packet_len
= ATM_SNAPLEN
;
359 caplen
= ATM_SNAPLEN
;
365 swt
= SWAPS(header
->wlen
);
366 packet_len
= swt
- (pw
->dag_fcs_bits
);
367 caplen
= erf_record_len
- dag_record_size
- 2;
368 if (caplen
> packet_len
)
377 swt
= SWAPS(header
->wlen
);
378 packet_len
= swt
- (pw
->dag_fcs_bits
);
379 caplen
= erf_record_len
- dag_record_size
;
380 if (caplen
> packet_len
)
388 if(caplen
> p
->snapshot
)
389 caplen
= p
->snapshot
;
392 * Has "pcap_breakloop()" been called?
393 * If so, return immediately - if we haven't read any
394 * packets, clear the flag and return -2 to indicate
395 * that we were told to break out of the loop, otherwise
396 * leave the flag set, so that the *next* call will break
397 * out of the loop without having read any packets, and
398 * return the number of packets we've processed so far.
409 p
->bp
= (char*)header
;
410 p
->cc
= endofbuf
- (char*)header
;
417 /* convert between timestamp formats */
419 pcap_header
.ts
.tv_sec
= (int)(ts
>> 32);
420 ts
= (ts
& 0xffffffffi
64) * 1000000;
421 ts
+= 0x80000000; /* rounding */
422 pcap_header
.ts
.tv_usec
= (int)(ts
>> 32);
423 if (pcap_header
.ts
.tv_usec
>= 1000000) {
424 pcap_header
.ts
.tv_usec
-= 1000000;
425 pcap_header
.ts
.tv_sec
++;
429 /* No underlaying filtering system. We need to filter on our own */
430 if (p
->fcode
.bf_insns
)
432 if (bpf_filter(p
->fcode
.bf_insns
, dp
, packet_len
, caplen
) == 0)
434 /* Move to next packet */
435 header
= (dag_record_t
*)((char*)header
+ erf_record_len
);
440 /* Fill the header for the user suppplied callback function */
441 pcap_header
.caplen
= caplen
;
442 pcap_header
.len
= packet_len
;
444 /* Call the callback function */
445 (*callback
)(user
, &pcap_header
, dp
);
447 /* Move to next packet */
448 header
= (dag_record_t
*)((char*)header
+ erf_record_len
);
450 /* Stop if the number of packets requested by user has been reached*/
451 if (++n
>= cnt
&& !PACKET_COUNT_IS_UNLIMITED(cnt
))
453 p
->bp
= (char*)header
;
454 p
->cc
= endofbuf
- (char*)header
;
458 while((u_char
*)header
< endofbuf
);
462 #endif /* HAVE_DAG_API */
464 /* Send a packet to the network */
466 pcap_inject_win32(pcap_t
*p
, const void *buf
, size_t size
){
467 LPPACKET PacketToSend
;
469 PacketToSend
=PacketAllocatePacket();
471 if (PacketToSend
== NULL
)
473 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "send error: PacketAllocatePacket failed");
477 PacketInitPacket(PacketToSend
,(PVOID
)buf
,size
);
478 if(PacketSendPacket(p
->adapter
,PacketToSend
,TRUE
) == FALSE
){
479 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "send error: PacketSendPacket failed");
480 PacketFreePacket(PacketToSend
);
484 PacketFreePacket(PacketToSend
);
487 * We assume it all got sent if "PacketSendPacket()" succeeded.
488 * "pcap_inject()" is expected to return the number of bytes
495 pcap_cleanup_win32(pcap_t
*p
)
497 if (p
->adapter
!= NULL
) {
498 PacketCloseAdapter(p
->adapter
);
502 PacketFreePacket(p
->Packet
);
505 pcap_cleanup_live_common(p
);
509 pcap_activate_win32(pcap_t
*p
)
511 struct pcap_win
*pw
= p
->priv
;
516 * No monitor mode on Windows. It could be done on
517 * Vista with drivers that support the native 802.11
518 * mechanism and monitor mode.
520 return (PCAP_ERROR_RFMON_NOTSUP
);
526 p
->adapter
= PacketOpenAdapter(p
->opt
.source
);
528 if (p
->adapter
== NULL
)
530 /* Adapter detected but we are not able to open it. Return failure. */
531 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "Error opening adapter: %s", pcap_win32strerror());
536 if(PacketGetNetType (p
->adapter
,&type
) == FALSE
)
538 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "Cannot determine the network type: %s", pcap_win32strerror());
543 switch (type
.LinkType
)
546 p
->linktype
= DLT_EN10MB
;
549 case NdisMedium802_3
:
550 p
->linktype
= DLT_EN10MB
;
552 * This is (presumably) a real Ethernet capture; give it a
553 * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
554 * that an application can let you choose it, in case you're
555 * capturing DOCSIS traffic that a Cisco Cable Modem
556 * Termination System is putting out onto an Ethernet (it
557 * doesn't put an Ethernet header onto the wire, it puts raw
558 * DOCSIS frames out on the wire inside the low-level
561 p
->dlt_list
= (u_int
*) malloc(sizeof(u_int
) * 2);
563 * If that fails, just leave the list empty.
565 if (p
->dlt_list
!= NULL
) {
566 p
->dlt_list
[0] = DLT_EN10MB
;
567 p
->dlt_list
[1] = DLT_DOCSIS
;
573 p
->linktype
= DLT_FDDI
;
576 case NdisMedium802_5
:
577 p
->linktype
= DLT_IEEE802
;
580 case NdisMediumArcnetRaw
:
581 p
->linktype
= DLT_ARCNET
;
584 case NdisMediumArcnet878_2
:
585 p
->linktype
= DLT_ARCNET
;
589 p
->linktype
= DLT_ATM_RFC1483
;
592 case NdisMediumCHDLC
:
593 p
->linktype
= DLT_CHDLC
;
596 case NdisMediumPPPSerial
:
597 p
->linktype
= DLT_PPP_SERIAL
;
601 p
->linktype
= DLT_NULL
;
604 case NdisMediumBare80211
:
605 p
->linktype
= DLT_IEEE802_11
;
608 case NdisMediumRadio80211
:
609 p
->linktype
= DLT_IEEE802_11_RADIO
;
613 p
->linktype
= DLT_PPI
;
617 p
->linktype
= DLT_EN10MB
; /*an unknown adapter is assumed to be ethernet*/
621 /* Set promiscuous mode */
625 if (PacketSetHwFilter(p
->adapter
,NDIS_PACKET_TYPE_PROMISCUOUS
) == FALSE
)
627 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "failed to set hardware filter to promiscuous mode");
633 if (PacketSetHwFilter(p
->adapter
,NDIS_PACKET_TYPE_ALL_LOCAL
) == FALSE
)
635 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "failed to set hardware filter to non-promiscuous mode");
640 /* Set the buffer size */
641 p
->bufsize
= WIN32_DEFAULT_USER_BUFFER_SIZE
;
643 /* allocate Packet structure used during the capture */
644 if((p
->Packet
= PacketAllocatePacket())==NULL
)
646 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "failed to allocate the PACKET structure");
650 if(!(p
->adapter
->Flags
& INFO_FLAG_DAG_CARD
))
653 * Traditional Adapter
656 * If the buffer size wasn't explicitly set, default to
657 * WIN32_DEFAULT_USER_BUFFER_SIZE.
659 if (p
->opt
.buffer_size
== 0)
660 p
->opt
.buffer_size
= WIN32_DEFAULT_KERNEL_BUFFER_SIZE
;
662 if(PacketSetBuff(p
->adapter
,p
->opt
.buffer_size
)==FALSE
)
664 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "driver error: not enough memory to allocate the kernel buffer");
668 p
->buffer
= (u_char
*)malloc(p
->bufsize
);
669 if (p
->buffer
== NULL
)
671 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
, "malloc: %s", pcap_strerror(errno
));
675 PacketInitPacket(p
->Packet
,(BYTE
*)p
->buffer
,p
->bufsize
);
677 if (p
->opt
.immediate
)
679 /* tell the driver to copy the buffer as soon as data arrives */
680 if(PacketSetMinToCopy(p
->adapter
,0)==FALSE
)
682 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
,"Error calling PacketSetMinToCopy: %s", pcap_win32strerror());
688 /* tell the driver to copy the buffer only if it contains at least 16K */
689 if(PacketSetMinToCopy(p
->adapter
,16000)==FALSE
)
691 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
,"Error calling PacketSetMinToCopy: %s", pcap_win32strerror());
709 snprintf(keyname
, sizeof(keyname
), "%s\\CardParams\\%s",
710 "SYSTEM\\CurrentControlSet\\Services\\DAG",
711 strstr(_strlwr(p
->opt
.source
), "dag"));
714 status
= RegOpenKeyEx(HKEY_LOCAL_MACHINE
, keyname
, 0, KEY_READ
, &dagkey
);
715 if(status
!= ERROR_SUCCESS
)
718 status
= RegQueryValueEx(dagkey
,
725 if(status
!= ERROR_SUCCESS
)
735 p
->snapshot
= PacketSetSnapLen(p
->adapter
, snaplen
);
737 /* Set the length of the FCS associated to any packet. This value
738 * will be subtracted to the packet length */
739 pw
->dag_fcs_bits
= p
->adapter
->DagFcsLen
;
743 #endif /* HAVE_DAG_API */
745 PacketSetReadTimeout(p
->adapter
, p
->opt
.timeout
);
748 if(p
->adapter
->Flags
& INFO_FLAG_DAG_CARD
)
750 /* install dag specific handlers for read and setfilter */
751 p
->read_op
= pcap_read_win32_dag
;
752 p
->setfilter_op
= pcap_setfilter_win32_dag
;
756 #endif /* HAVE_DAG_API */
757 /* install traditional npf handlers for read and setfilter */
758 p
->read_op
= pcap_read_win32_npf
;
759 p
->setfilter_op
= pcap_setfilter_win32_npf
;
762 #endif /* HAVE_DAG_API */
763 p
->setdirection_op
= NULL
; /* Not implemented. */
764 /* XXX - can this be implemented on some versions of Windows? */
765 p
->inject_op
= pcap_inject_win32
;
766 p
->set_datalink_op
= NULL
; /* can't change data link type */
767 p
->getnonblock_op
= pcap_getnonblock_win32
;
768 p
->setnonblock_op
= pcap_setnonblock_win32
;
769 p
->stats_op
= pcap_stats_win32
;
770 p
->setbuff_op
= pcap_setbuff_win32
;
771 p
->setmode_op
= pcap_setmode_win32
;
772 p
->setmintocopy_op
= pcap_setmintocopy_win32
;
773 p
->getadapter_op
= pcap_getadapter_win32
;
774 p
->cleanup_op
= pcap_cleanup_win32
;
778 pcap_cleanup_win32(p
);
783 pcap_create_interface(const char *device
, char *ebuf
)
787 if (strlen(device
) == 1)
790 * It's probably a unicode string
791 * Convert to ascii and pass it to pcap_create_common
793 * This wonderful hack is needed because pcap_lookupdev still returns
794 * unicode strings, and it's used by windump when no device is specified
795 * in the command line
800 length
= wcslen((wchar_t*)device
);
802 deviceAscii
= (char*)malloc(length
+ 1);
804 if (deviceAscii
== NULL
)
806 snprintf(ebuf
, PCAP_ERRBUF_SIZE
, "Malloc failed");
810 snprintf(deviceAscii
, length
+ 1, "%ws", (wchar_t*)device
);
811 p
= pcap_create_common(deviceAscii
, ebuf
, sizeof (struct pcap_win
));
816 p
= pcap_create_common(device
, ebuf
, sizeof (struct pcap_win
));
822 p
->activate_op
= pcap_activate_win32
;
827 pcap_setfilter_win32_npf(pcap_t
*p
, struct bpf_program
*fp
)
829 struct pcap_win
*pw
= p
->priv
;
831 if(PacketSetBpf(p
->adapter
,fp
)==FALSE
){
833 * Kernel filter not installed.
835 * XXX - we don't know whether this failed because:
837 * the kernel rejected the filter program as invalid,
838 * in which case we should fall back on userland
841 * the kernel rejected the filter program as too big,
842 * in which case we should again fall back on
843 * userland filtering;
845 * there was some other problem, in which case we
846 * should probably report an error.
848 * For NPF devices, the Win32 status will be
849 * STATUS_INVALID_DEVICE_REQUEST for invalid
850 * filters, but I don't know what it'd be for
851 * other problems, and for some other devices
852 * it might not be set at all.
854 * So we just fall back on userland filtering in
859 * install_bpf_program() validates the program.
861 * XXX - what if we already have a filter in the kernel?
863 if (install_bpf_program(p
, fp
) < 0)
865 pw
->filtering_in_kernel
= 0; /* filtering in userland */
872 pw
->filtering_in_kernel
= 1; /* filtering in the kernel */
875 * Discard any previously-received packets, as they might have
876 * passed whatever filter was formerly in effect, but might
877 * not pass this filter (BIOCSETF discards packets buffered
878 * in the kernel, so you can lose packets in any case).
885 * We filter at user level, since the kernel driver does't process the packets
888 pcap_setfilter_win32_dag(pcap_t
*p
, struct bpf_program
*fp
) {
892 strncpy(p
->errbuf
, "setfilter: No filter specified", sizeof(p
->errbuf
));
896 /* Install a user level filter */
897 if (install_bpf_program(p
, fp
) < 0)
899 snprintf(p
->errbuf
, sizeof(p
->errbuf
),
900 "setfilter, unable to install the filter: %s", pcap_strerror(errno
));
908 pcap_getnonblock_win32(pcap_t
*p
, char *errbuf
)
910 struct pcap_win
*pw
= p
->priv
;
913 * XXX - if there were a PacketGetReadTimeout() call, we
914 * would use it, and return 1 if the timeout is -1
917 return (pw
->nonblock
);
921 pcap_setnonblock_win32(pcap_t
*p
, int nonblock
, char *errbuf
)
923 struct pcap_win
*pw
= p
->priv
;
928 * Set the read timeout to -1 for non-blocking mode.
933 * Restore the timeout set when the device was opened.
934 * (Note that this may be -1, in which case we're not
935 * really leaving non-blocking mode.)
937 newtimeout
= p
->opt
.timeout
;
939 if (!PacketSetReadTimeout(p
->adapter
, newtimeout
)) {
940 snprintf(errbuf
, PCAP_ERRBUF_SIZE
,
941 "PacketSetReadTimeout: %s", pcap_win32strerror());
944 pw
->nonblock
= (newtimeout
== -1);
948 /*platform-dependent routine to add devices other than NDIS interfaces*/
950 pcap_platform_finddevs(pcap_if_t
**alldevsp
, char *errbuf
)