修复ip分片跳转BUG.
This commit is contained in:
14
net_common.c
14
net_common.c
@@ -156,6 +156,12 @@ static int ipv4_jump_to_layer(const char *raw_data, int raw_layer_type, int exp
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* IP<49><50>Ƭ<EFBFBD><C6AC><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD>ת */
|
||||||
|
unsigned short *iphdr_off = (unsigned short *)&p_ip_hdr->ip_off[0];
|
||||||
|
if((htons(*iphdr_off) & IP_MF) || (htons(*iphdr_off) & IP_OFFMASK)){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
switch(p_ip_hdr->ip_p){
|
switch(p_ip_hdr->ip_p){
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
if(ADDR_TYPE_TCP == expect_layer_type){
|
if(ADDR_TYPE_TCP == expect_layer_type){
|
||||||
@@ -263,7 +269,8 @@ static int ipv6_jump_to_layer(const char *raw_data, int raw_layer_type, int exp
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 44:///NEXTHDR_FRAGMENT:
|
case 44:///NEXTHDR_FRAGMENT:
|
||||||
offset_to_ip6 = 8; // 8 == sizeof(struct ipv6_frag_hdr);
|
/* IP<49><50>Ƭ<EFBFBD><C6AC><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD>ת */
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 50://NEXTHDR_ESP:
|
case 50://NEXTHDR_ESP:
|
||||||
@@ -642,6 +649,11 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty
|
|||||||
case __ADDR_TYPE_IP_PAIR_V4:
|
case __ADDR_TYPE_IP_PAIR_V4:
|
||||||
{
|
{
|
||||||
const struct mesa_ip4_hdr *ip4hdr = (const struct mesa_ip4_hdr *)expect_layer;
|
const struct mesa_ip4_hdr *ip4hdr = (const struct mesa_ip4_hdr *)expect_layer;
|
||||||
|
if((ntohs(ip4hdr->ip_off) & IP_MF ) || (ntohs(ip4hdr->ip_off) & IP_OFFMASK)){
|
||||||
|
/* IP<49><50>Ƭ<EFBFBD><C6AC><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ת */
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if(IPPROTO_UDP == ip4hdr->ip_p){
|
if(IPPROTO_UDP == ip4hdr->ip_p){
|
||||||
new_next_layer_data = (char *)expect_layer + ip4hdr->ip_hl * 4;
|
new_next_layer_data = (char *)expect_layer + ip4hdr->ip_hl * 4;
|
||||||
new_raw_layer_type = ADDR_TYPE_UDP; /* IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ƫ<EFBFBD><C6AB>, ֻ֧<D6BB><D6A7>UDP, IPIP, GRE, L2TPv3. */
|
new_raw_layer_type = ADDR_TYPE_UDP; /* IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ƫ<EFBFBD><C6AB>, ֻ֧<D6BB><D6A7>UDP, IPIP, GRE, L2TPv3. */
|
||||||
|
|||||||
@@ -138,18 +138,6 @@ ether_print(netdissect_options *ndo,
|
|||||||
|
|
||||||
ep = (const struct ether_header *)p;
|
ep = (const struct ether_header *)p;
|
||||||
|
|
||||||
/* 2017-01-06 lijia add, <20>dz<EFBFBD><C7B3><EFBFBD>Ethernet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ */
|
|
||||||
switch(ntohs(ep->ether_length_type)){
|
|
||||||
case ETHERTYPE_IP:
|
|
||||||
case ETHERTYPE_IPV6:
|
|
||||||
case ETHERTYPE_8021Q:
|
|
||||||
case ETHERTYPE_ARP:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (caplen < ETHER_HDRLEN) {
|
if (caplen < ETHER_HDRLEN) {
|
||||||
ND_PRINT((ndo, "[|ether]"));
|
ND_PRINT((ndo, "[|ether]"));
|
||||||
return (caplen);
|
return (caplen);
|
||||||
|
|||||||
@@ -2177,8 +2177,11 @@ main(int argc, char **argv)
|
|||||||
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0){
|
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0){
|
||||||
error("%s", pcap_geterr(pd));
|
error("%s", pcap_geterr(pd));
|
||||||
}else{
|
}else{
|
||||||
|
/* <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>bpf filter, <20>˴<EFBFBD><CBB4>ж<EFBFBD>һ<EFBFBD><D2BB> */
|
||||||
|
if(cmdbuf){
|
||||||
has_bpf_filter_flag = 1;
|
has_bpf_filter_flag = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
bpf_dump(&fcode, dflag);
|
bpf_dump(&fcode, dflag);
|
||||||
|
|||||||
Reference in New Issue
Block a user