/* Get a list of all capture sources that are up and that we can open. Returns -1 on error, 0 otherwise. The list, as returned through "alldevsp", may be null if no interfaces were up and could be opened.  */
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
/* Get a list of all capture sources that are up and that we can open. Returns -1 on error, 0 otherwise. The list, as returned through "alldevsp", may be null if no interfaces were up and could be opened.  */
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
{
	size_t i;
	pcap_if_list_t devlist;
	devlist.beginning = NULL;
	if (pcap_platform_finddevs(&devlist, errbuf) == -1) {
		if (devlist.beginning != NULL)
			pcap_freealldevs(devlist.beginning);
		*alldevsp = NULL;
		return (-1);
	}
	for (i = 0; capture_source_types[i].findalldevs_op != NULL; i++) {
		if (capture_source_types[i].findalldevs_op(&devlist, errbuf) == -1) {
			if (devlist.beginning != NULL)
				pcap_freealldevs(devlist.beginning);
			*alldevsp = NULL;
			return (-1);
		}
	}
	*alldevsp = devlist.beginning;
	return (0);
}