From 5bce46bd7561ae1857c7e17614133f01f984ae78 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 5 Mar 2020 21:23:21 +1100 Subject: Removed winpcap and cleaned up network module selection. (nw) The pcap.h header itself has the problematic original BSD license, including the obnoxious advertising clause. Using tap/tun networking on Windows provides a much better experience, so the extra setup is worth it. This patch also allows you to enable pcap on platforms where it's disabled by default with USE_PCAP=1 if you really want to use it. --- 3rdparty/winpcap/docs/html/group__wpcap__tut1.html | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 3rdparty/winpcap/docs/html/group__wpcap__tut1.html (limited to '3rdparty/winpcap/docs/html/group__wpcap__tut1.html') diff --git a/3rdparty/winpcap/docs/html/group__wpcap__tut1.html b/3rdparty/winpcap/docs/html/group__wpcap__tut1.html deleted file mode 100644 index 3c14d337163..00000000000 --- a/3rdparty/winpcap/docs/html/group__wpcap__tut1.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - -WinPcap: Obtaining the device list - - - - - - -
-

Obtaining the device list

-
-

Typically, the first thing that a WinPcap-based application does is get a list of attached network adapters. Both libpcap and WinPcap provide the pcap_findalldevs_ex() function for this purpose: this function returns a linked list of pcap_if structures, each of which contains comprehensive information about an attached adapter. In particular, the fields name and description contain the name and a human readable description, respectively, of the corresponding device.

-

The following code retrieves the adapter list and shows it on the screen, printing an error if no adapters are found.

-
#include "pcap.h"
-
-main()
-{
-    pcap_if_t *alldevs;
-    pcap_if_t *d;
-    int i=0;
-    char errbuf[PCAP_ERRBUF_SIZE];
-    
-    /* Retrieve the device list from the local machine */
-    if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
-    {
-        fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
-        exit(1);
-    }
-    
-    /* Print the list */
-    for(d= alldevs; d != NULL; d= d->next)
-    {
-        printf("%d. %s", ++i, d->name);
-        if (d->description)
-            printf(" (%s)\n", d->description);
-        else
-            printf(" (No description available)\n");
-    }
-    
-    if (i == 0)
-    {
-        printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
-        return;
-    }
-
-    /* We don't need any more the device list. Free it */
-    pcap_freealldevs(alldevs);
-}
-

Some comments about this code.

-

First of all, pcap_findalldevs_ex(), like other libpcap functions, has an errbuf parameter. This parameter points to a string filled by libpcap with a description of the error if something goes wrong.

-

Second, remember that not all the OSes supported by libpcap provide a description of the network interfaces, therefore if we want to write a portable application, we must consider the case in which description is null: we print the string "No description available" in that situation.

-

Note finally that we free the list with pcap_freealldevs() once when we have finished with it.

-

Let's try to compile and run the code of this first sample. In order to compile it under Unix or Cygwin, simply type:

-
-  gcc -o testprog testprog.c -lpcap
-

On Windows, you will need to create a project, following the instructions in the Using WinPcap in your programs section of this manual. However, we suggest that you use the WinPcap developer's pack (available at the WinPcap website, http://www.winpcap.org ), since it provides many examples already configured as projects including all the code presented in this tutorial and the includes and libraries needed to compile and run the examples.

-

Assuming we have compiled the program, let's try to run it. On a particular WinXP workstation, the result we optained is

-
-   1. \Device\NPF_{4E273621-5161-46C8-895A-48D0E52A0B83} (Realtek RTL8029(AS) Ethernet Adapter)
-   2. \Device\NPF_{5D24AE04-C486-4A96-83FB-8B5EC6C7F430} (3Com EtherLink PCI) 
-

As you can see, the name of the network adapters (that will be passed to libpcap when opening the devices) under Windows are quite unreadable, so the parenthetical descriptions can be very helpful.

-

<<< Previous Next >>>

-
- -
-

-documentation. Copyright (c) 2002-2005 Politecnico di Torino. Copyright (c) 2005-2009 -CACE Technologies. All rights reserved.

-- cgit v1.2.3-70-g09d2