diff --git a/inc/MESA_jump_layer.h b/inc/MESA_jump_layer.h index 5356f6a..d15578b 100644 --- a/inc/MESA_jump_layer.h +++ b/inc/MESA_jump_layer.h @@ -16,9 +16,9 @@ const char *MESA_jump_layer_get_last_error(void); /* The raw_layer_type and expect_layer_type refer to sapp_base.h->enum addr_type_t */ -const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type); +const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type); -const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type); +const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type); const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len ); diff --git a/src/MESA_jump_layer.cpp b/src/MESA_jump_layer.cpp index 0641498..ebbf164 100644 --- a/src/MESA_jump_layer.cpp +++ b/src/MESA_jump_layer.cpp @@ -500,7 +500,7 @@ static int udp_jump_to_layer(const char *raw_data, int raw_layer_type, int expe skip_len = l2tp_jump_to_layer(raw_data+sizeof(struct mesa_udp_hdr), ADDR_TYPE_UDP, expect_layer_type); }else{ /* 其他UDP类型不支持再跳转 */ - snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer_greedy() not support layer type:%d", expect_layer_type); + snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer_greedy() not support layer type:%d", expect_layer_type); return -1; } if(skip_len < 0){ @@ -1244,7 +1244,7 @@ extern "C" { Non-NULL: the pointer to expect layer; NULL: not found expect layer. */ -const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type) +const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type) { int ret; @@ -1321,7 +1321,7 @@ const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, in break; default: - snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer(): unsupport raw_layer_type:%d in MESA_net_jump_to_layer()!", raw_layer_type); + snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer(): unsupport raw_layer_type:%d in MESA_jump_layer()!", raw_layer_type); return NULL; } @@ -1333,15 +1333,15 @@ const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, in } /* - 与MESA_net_jump_to_layer()的区别: - MESA_net_jump_to_layer()从最外层开始, 找到第一个符合条件的层就退出; - MESA_net_jump_to_layer_greedy()会一直尝试找最内层协议头, 适合隧道模式. + 与MESA_jump_layer()的区别: + MESA_jump_layer()从最外层开始, 找到第一个符合条件的层就退出; + MESA_jump_layer_greedy()会一直尝试找最内层协议头, 适合隧道模式. return value: Non-NULL: the pointer to expect layer; NULL: not found expect layer. */ -const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type) +const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type) { int skip_len; const void *expect_layer; @@ -1369,7 +1369,7 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty expect_layer_type = __ADDR_TYPE_IP_PAIR_V6; } - expect_layer = MESA_net_jump_to_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type); + expect_layer = MESA_jump_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type); while(expect_layer){ success_layer = expect_layer; @@ -1414,11 +1414,11 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty break; default: - snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer_greedy() not support layer type:%d\n", expect_layer_type); + snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer_greedy() not support layer type:%d\n", expect_layer_type); goto done; } - expect_layer = MESA_net_jump_to_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type); + expect_layer = MESA_jump_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type); } done: diff --git a/src/mesa_net.h b/src/mesa_net.h index f0319f8..96610a7 100644 --- a/src/mesa_net.h +++ b/src/mesa_net.h @@ -870,8 +870,8 @@ UINT16 net_layer_to_ethernet_protocol_by_stream(const struct streaminfo *pstream enum addr_type_t ethernet_protocol_to_net_layer(UINT16 ether_type_host); int net_common_build_send_mac(unsigned char *buf, const struct mesa_ethernet_hdr *raw_eth_hdr, int addr_type, int dir_reverse, int net_topology_mode); int net_common_adjust_forward_mac(struct mesa_ethernet_hdr *raw_eth_hdr,int net_topology_mode); -const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type); -const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type); +const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type); +const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type); char MESA_ascii_to_hex(char ascii); const char *sapp_raw_ipv4_ntop(const struct mesa_ip4_hdr *ip4_hdr, char *out_buf, int buf_len ); const char *sapp_raw_ipv6_ntop(const struct mesa_ip6_hdr *ip6_hdr, char *out_buf, int buf_len); diff --git a/test/test_jump_layer.c b/test/test_jump_layer.c index 0cd518d..3cdd4fe 100644 --- a/test/test_jump_layer.c +++ b/test/test_jump_layer.c @@ -66,8 +66,8 @@ static void _pcap_pkt_handle(u_char *user, const struct pcap_pkthdr *hdr, const int offset_to_eth; static int pkt_index = 0; - ip4_hdr = MESA_net_jump_to_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV4); - ip6_h = MESA_net_jump_to_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV6); + ip4_hdr = MESA_jump_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV4); + ip6_h = MESA_jump_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV6); printf("-----------------------------packet index:%d------------------------------------------\n", pkt_index++); if(ip4_hdr){