示例#1
0
int
main(int argc, char **argv)
{
    capdev_t interfaces[32];
    int numdev, i;

    /* Try loading the DLL. */
#ifdef _WIN32
    pcap_handle = dynld_module("wpcap.dll", pcap_imports);
#else
    pcap_handle = dynld_module("libpcap.so", pcap_imports);
#endif
    if (pcap_handle == NULL) {
#ifdef _WIN32
	fprintf(stderr, "Unable to load WinPcap DLL !\n");
#else
	fprintf(stderr, "Unable to load libpcap.so !\n");
#endif
	return(1);
    }

    /* Get the list. */
    numdev = get_devlist(interfaces);

    if (argc == 1) {
	/* No arguments, just show the list. */
	show_devs(interfaces, numdev);

	dynld_close(pcap_handle);

	return(numdev);
    }

    /* Assume argument to be the interface number to listen on. */
    i = atoi(argv[1]);
    if (i < 0 || i > numdev) {
	fprintf(stderr, "Invalid interface number %d !\n", i);

	dynld_close(pcap_handle);

	return(1);
    }

    /* Looks good, go and listen.. */
    i = start_cap(interfaces[i-1].device);

    dynld_close(pcap_handle);

    return(i);
}
示例#2
0
文件: net_pcap.c 项目: Nado15/86Box
/* Initialize the (Win)Pcap module for use. */
void
network_pcap_reset(void)
{
    /* Try loading the DLL. */
    pcap_handle = dynld_module("wpcap.dll", pcap_imports);
    return;
}
示例#3
0
文件: net_pcap.c 项目: Nado15/86Box
/* Initialize the (Win)Pcap module for use. */
int
network_pcap_init(netdev_t *list)
{
    char errbuf[PCAP_ERRBUF_SIZE];
    pcap_if_t *devlist, *dev;
    int i = 0;

    /* Local variables. */
    pcap = NULL;

    /* Try loading the DLL. */
    pcap_handle = dynld_module("wpcap.dll", pcap_imports);
    if (pcap_handle == NULL) return(-1);

    /* Retrieve the device list from the local machine */
    if (f_pcap_findalldevs(&devlist, errbuf) == -1) {
	pclog("PCAP: error in pcap_findalldevs: %s\n", errbuf);
	return(-1);
    }

    for (dev=devlist; dev!=NULL; dev=dev->next) {
	strcpy(list->device, dev->name);
	if (dev->description)
		strcpy(list->description, dev->description);
	  else
		memset(list->description, '\0', sizeof(list->description));
	list++; i++;
    }

    /* Release the memory. */
    f_pcap_freealldevs(devlist);

    return(i);
}