fix jump greedy for ipv6; fix compile warnning

This commit is contained in:
lijia
2024-04-18 15:41:55 +08:00
parent 71a6040f8a
commit 10330f034e
4 changed files with 26 additions and 9 deletions

View File

@@ -11,7 +11,8 @@ include_directories(${PROJECT_SOURCE_DIR}/include/)
LINK_DIRECTORIES(/opt/MESA/lib)
add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
#add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
add_definitions(-D_DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
add_definitions(-DSAPP_V4=1)
add_definitions(-fPIC)

View File

@@ -290,9 +290,9 @@ static int gtp_jump_to_layer(const char *raw_data, int raw_layer_type, int expe
next_ip_layer_hdr = (unsigned char *)raw_data + gtp_hdr_len;
if((*next_ip_layer_hdr & 0x40) == 0x40){
if((*next_ip_layer_hdr & 0xF0) == 0x40){
skip_len = ipv4_jump_to_layer((char *)next_ip_layer_hdr, __ADDR_TYPE_IP_PAIR_V4, expect_layer_type);
}else if((*next_ip_layer_hdr & 0x60) == 0x60){
}else if((*next_ip_layer_hdr & 0xF0) == 0x60){
skip_len = ipv6_jump_to_layer((char *)next_ip_layer_hdr, __ADDR_TYPE_IP_PAIR_V6, expect_layer_type);
}else{
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "gtp_jump_to_layer() error, unsupport type in GTP, 0x%x!", (*next_ip_layer_hdr));
@@ -1427,8 +1427,23 @@ const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int
case __ADDR_TYPE_IP_PAIR_V6:
{
//TODO2,
goto done;
const struct mesa_ip6_hdr *ip6hdr = (const struct mesa_ip6_hdr *)expect_layer;
if(IPPROTO_UDP == ip6hdr->ip6_nxt_hdr){
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
new_raw_layer_type = ADDR_TYPE_UDP; /* IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ƫ<EFBFBD><C6AB> */
}else if(IPPROTO_GRE == ip6hdr->ip6_nxt_hdr){
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
new_raw_layer_type = ADDR_TYPE_GRE; /* GRE */
}else if(IPPROTO_IPIP == ip6hdr->ip6_nxt_hdr){
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
new_raw_layer_type = ADDR_TYPE_IPV4;
}else if(IPPROTO_IPIP == ip6hdr->ip6_nxt_hdr){
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
new_raw_layer_type = ADDR_TYPE_IPV6;
}else{
//TODO 2, IPIP, L2TPv3
goto done;
}
}
break;
@@ -1476,7 +1491,7 @@ const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, i
inner_thdr = (struct mesa_tcp_hdr *)((char *)ip4_hdr + ip4_hdr->ip_hl*4);
sport = ntohs(inner_thdr->th_sport);
dport = ntohs(inner_thdr->th_dport);
}else if(IPPROTO_UDP){
}else if(IPPROTO_UDP == inner_ip_proto){
inner_uhdr = (struct mesa_udp_hdr *)((char *)ip4_hdr + ip4_hdr->ip_hl*4);
sport = ntohs(inner_uhdr->uh_sport);
dport = ntohs(inner_uhdr->uh_dport);
@@ -1509,7 +1524,7 @@ const char *MESA_jump_layer_ipv6_ntop(const struct ip6_hdr *ip6_hdr, char *out_b
inner_thdr = (struct tcphdr *)((char *)ip6_hdr + sizeof(struct ip6_hdr));
sport = inner_thdr->source;
dport = inner_thdr->dest;
}else if(IPPROTO_UDP){
}else if(IPPROTO_UDP== inner_ip_proto){
inner_uhdr = (struct udphdr *)((char *)ip6_hdr + sizeof(struct ip6_hdr));
sport = inner_uhdr->source;
dport = inner_uhdr->dest;

View File

@@ -5,7 +5,8 @@ include_directories(${MESA_SDK_PREFIX}/include)
include_directories(${MESA_SDK_PREFIX}/include/MESA)
add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
# add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
add_definitions(-D_DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
add_definitions(-fPIC -std=c++11)
LINK_DIRECTORIES(/opt/MESA/lib)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)

View File

@@ -143,7 +143,7 @@ static int jump_check_udp_pkt(const struct udphdr *uhdr, unsigned short expect_u
return 0;
}
static int jump_check_vlan_pkt(const void *vlan_hdr, unsigned int expect_vlan_hex_data)
int jump_check_vlan_pkt(const void *vlan_hdr, unsigned int expect_vlan_hex_data)
{
if(memcmp(vlan_hdr, &expect_vlan_hex_data, sizeof(int)) != 0){
printf("\033[1;31;40mMESA_net_jump_to_layer(): vlan header error!\033[0m\n");