Update tcpdump.c:835 查找到内层为IPv6时头部地址错误的笔误

This commit is contained in:
杨威
2018-12-04 02:37:01 +08:00
parent 13e7449232
commit 5427b568de

View File

@@ -855,11 +855,14 @@ static int MESA_dump_seek_to_inner(char *pkt_buf, int pktlen)
if((char *)ip6hdr_greedy == first_ip_layer){
bpf_match_pkt_len = pktlen; /* 最内层和第一层IP一样, 说明是非常标准的ethernet->IPv6包, 且无隧道, 无需memmove操作 */
}else{
memmove(pkt_buf + sizeof(struct mesa_ethernet_hdr),
ip6hdr_greedy,
pktlen - ((char *)ip6hdr_greedy - pkt_buf));
bpf_match_pkt_len = pktlen - ((char *)ip4hdr_greedy - pkt_buf) + sizeof(struct mesa_ethernet_hdr);
ehdr->ether_type = htons(ETHERTYPE_IPv6); /* 第一层可能不是IPV6, 比如MPLS, VLAN等,需要改成IP,以便bpf过滤器能正确执行 */
if(pktlen - ((char *)ip6hdr_greedy - pkt_buf) > 0)
{
memmove(pkt_buf + sizeof(struct mesa_ethernet_hdr),
ip6hdr_greedy,
pktlen - ((char *)ip6hdr_greedy - pkt_buf));
bpf_match_pkt_len = pktlen - ((char *)ip6hdr_greedy - pkt_buf) + sizeof(struct mesa_ethernet_hdr);
ehdr->ether_type = htons(ETHERTYPE_IPv6); /* 第一层可能不是IPV6, 比如MPLS, VLAN等,需要改成IP,以便bpf过滤器能正确执行 */
}
}
if(bpf_match_pkt_len <= 0){