Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

Problems with libpcap - segmentation fault

$
0
0

I'm having problems with the libpcap function "pcap_findalldevs". The problem is when I run the code is gives a "segmentation fault". The code is:

int listDevices()
{
    int res = -1;
    int count = 1;
    pcap_if_t *device;
    pcap_if_t **alldev;
    char e_buffer[PCAP_ERRBUF_SIZE];

    res = pcap_findalldevs(alldev, e_buffer); //Gives "segmentation fault" here

    if (res == 0)
    {
        printf("Error reading list of devices: %s\n", e_buffer);
        return res;
    }

    if (alldev == NULL)
    {
        printf("No devices founded!");
        return 1;
    }

    device = *alldev;

    while(device != NULL)
    {       
        printf("%s\n", device->name);
        device= device->next;
    }

    pcap_freealldevs(*alldev);

    return 0;
}

Watching the variables, I can see that **alldev is giving an address of 0x0 while the others have "normal" addresses. What am I doing wrong?

Thank you in advance.


Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>