i am using pcap_findalldevs to get the device list in the computer. I get it successfully, with the name of the device, and description, but I don't know why, I get Netmask 0.0.0.0 and the ip address also 0.0.0.0. here is my code to generate the list:
/* get the devices list */
if (pcap_findalldevs(&devList, errbuf) == -1)
{
fprintf(stderr, "There is a problem with pcap_findalldevs: %s\n", errbuf);
return -1;
}
/* scan the list for a suitable device to capture from */
for (dev = devList; dev != NULL; dev = dev->next)
{
pcap_addr_t *dev_addr; //interface address that used by pcap_findalldevs()
/* check if the device captureble*/
if ((dev_addr = dev->addresses) != NULL && dev_addr->addr->sa_family == AF_INET && dev_addr->addr && dev_addr->netmask) {
printf("Found a device %s on address %s with netmask %s\n", dev->name, iptos(((struct sockaddr_in *)dev_addr->addr)->sin_addr.s_addr), iptos(((struct sockaddr_in *)dev_addr->netmask)->sin_addr.s_addr));
break;
}
}