PPP协议也封装了,发送不出去。问题不在这。
发现了一个问题,winpcap可以枚举到一个设备,但是从设备结构体中遍历地址时发现都是0,不知道是这么回事
代码片段:
int Result = pcap_findalldevs(&NetwokDevice, WinpcapError);
if (Result == - 1)
{
printf("pcap_findalldevs Error");
return 0;
}
for (Device = NetwokDevice, i = 0; Device && i < 10; Device = Device->next, i++)
{
printf("Number %d:", i);
printf("%s:", Device->name);
printf("%s\n", Device->description);
sprintf(DeviceName[i], "%s", Device->name);
}
for (;;)
{
printf("Please Choose the Device Number:(0-%d)", i - 1);
scanf("%d", &DeviceIndex);
if (DeviceIndex > i - 1 || DeviceIndex < 0)
{
printf("Device Number Error\n");
continue;
}
else
break;
}
for (Device = NetwokDevice, i=0; i<DeviceIndex; i++)
{
Device = Device->next;
}
DWORD dwHostIP;
pcap_addr* adds = Device->addresses;
while (adds)
{
if (adds->addr/* && ((sockaddr_in *)(adds->addr))->sin_family == AF_INET*/)
{
dwHostIP = ((sockaddr_in *)(adds->addr))->sin_addr.S_un.S_addr;
printf("IP: %x\n", dwHostIP);
if (dwHostIP!=0)
{
struct in_addr stInAddr;
unsigned int iTemp = dwHostIP;
stInAddr.s_addr=iTemp;
char *pIp=inet_ntoa(stInAddr);
printf("host ip %s\n", pIp); //此处打出来的地址都是0
}
}
adds = adds->next;
}