Ticket #2246: pcap.diff

File pcap.diff, 2.1 KB (added by mjw, 16 years ago)
  • libpcap/pcap-haiku.cpp

     
    250250extern "C" int
    251251pcap_platform_finddevs(pcap_if_t** _allDevices, char* errorBuffer)
    252252{
     253    // If Haiku supports a Linux-like pseudo device, it should be
     254    // added here.  See pcap-linux.c for more info.
     255    int flags;
     256
    253257    // we need a socket to talk to the networking stack
    254258    int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
    255259    if (socket < 0) {
     
    290294    }
    291295
    292296    ifreq *interface = (ifreq *)buffer;
    293     pcap_if_t* last = NULL;
    294297
    295298    for (uint32 i = 0; i < count; i++) {
    296         pcap_if_t* pcapInterface = (pcap_if_t*)malloc(sizeof(pcap_if_t));
    297         if (pcapInterface == NULL)
    298             continue;
     299        flags = 0;
    299300
    300         if (last == NULL)
    301             *_allDevices = pcapInterface;
    302         else
    303             last->next = pcapInterface;
    304 
    305         pcapInterface->next = NULL;
    306         pcapInterface->name = strdup(interface->ifr_name);
    307         pcapInterface->description = NULL;
    308         pcapInterface->addresses = NULL;
    309         pcapInterface->flags = 0;
    310 
    311301        // get interface type
    312302
    313303        int linkSocket = ::socket(AF_LINK, SOCK_DGRAM, 0);
     
    331321                    sockaddr_dl &link = *(sockaddr_dl *)&request.ifr_addr;
    332322
    333323                    if (link.sdl_type == IFT_LOOP)
    334                         pcapInterface->flags = PCAP_IF_LOOPBACK;
     324                        flags = IFF_LOOPBACK;
    335325                }
    336326            }
    337327            close(linkSocket);
    338328        }
    339329
     330        pcap_add_if(_allDevices, interface->ifr_name, flags, NULL, errorBuffer);
     331
    340332        interface = (ifreq *)((addr_t)interface + IF_NAMESIZE
    341333            + interface->ifr_addr.sa_len);
    342334    }
  • config.h

     
    192192/* #undef HAVE_PCAP_DUMP_FLUSH */
    193193
    194194/* Define to 1 if you have the `pcap_findalldevs' function. */
    195 /* #undef HAVE_PCAP_FINDALLDEVS */
     195#define HAVE_PCAP_FINDALLDEVS 1
    196196
    197197/* Define to 1 if the system has the type `pcap_if_t'. */
    198 /* #undef HAVE_PCAP_IF_T */
     198#define HAVE_PCAP_IF_T 1
    199199
    200200/* Define to 1 if you have the `pcap_lib_version' function. */
    201201/* #undef HAVE_PCAP_LIB_VERSION */