为什么size_ip会出现0?

时间:2017-12-18 21:07:00

标签: libpcap

ethernet = (struct sniff_ethernet*) (packet);
const u_int16_t type = ethernet->ether_type;
switch (ntohs(type))
{
    case ETHERTYPE_IP:
        printf("Sniffed IPv4 packet\n");
        break;
    case ETHERTYPE_IPV6:
        printf("Sniffed IPv6 packet\n");
        break;
}

ip = (struct sniff_ip*) (packet + SIZE_ETHERNET);
size_ip = IP_HL(ip) * 4;
if (size_ip < 20)
{
    printf("Packet Capture, Invalid IP header length: %u bytes\n", size_ip);
    return;
}

IPv4的size_ip始终是正确的。但是对于IPv6情况,我总是将size_ip设为0。我试图转储被嗅探到文件中的IPv6数据包,看起来没问题。任何人都知道为什么size_ip会出现0?

0 个答案:

没有答案