Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1e57d6f8 | ||
|
|
c75c00a185 | ||
|
|
810624b7a0 |
@@ -13,18 +13,45 @@ extern "C" {
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
CHN : <20><><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7>ƫ<EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>.
|
||||
|
||||
<09><><EFBFBD><EFBFBD>:
|
||||
raw_data: <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ָ<EFBFBD><D6B8>;
|
||||
raw_layer_type: <20><>ǰ<EFBFBD><C7B0><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>: enum addr_type_t ;
|
||||
expect_layer_type: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>: enum addr_type_t ;
|
||||
|
||||
<09><><EFBFBD><EFBFBD>ֵ:
|
||||
NULL: <20>˵<DEB4>ַ;
|
||||
NON-NULL: <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ַ.
|
||||
|
||||
<09><><EFBFBD><EFBFBD>:
|
||||
<09><><EFBFBD>赱ǰ<E8B5B1><C7B0>ΪEthernet, <20><>ʼ<EFBFBD><CABC>ͷ<EFBFBD><CDB7>ַΪthis_layer_hdr, <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>IPv6<76><36>ͷ<EFBFBD><CDB7>:
|
||||
struct ip6_hdr *ip6_header;
|
||||
ip6_header = MESA_net_jump_to_layer(this_layer_hdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
|
||||
*/
|
||||
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
/*
|
||||
MESA_jump_layer_greedy<64><79>MESA_jump_layer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>˵,
|
||||
MESA_jump_layer<65><72>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>expect_layer_type;
|
||||
MESA_jump_layer_greedy<64><79>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>expect_layer_type;
|
||||
*/
|
||||
const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
|
||||
|
||||
/* <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ľӿ<C4BD><D3BF><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> */
|
||||
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 char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len );
|
||||
|
||||
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len );
|
||||
const char *MESA_jump_layer_ipv6_ntop(const struct ip6_hdr *ip6_hdr, char *out_buf, int buf_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -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{
|
||||
/* <20><><EFBFBD><EFBFBD>UDP<44><50><EFBFBD>Ͳ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת */
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1332,16 +1332,21 @@ const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, in
|
||||
return ((const char *)raw_data + ret);
|
||||
}
|
||||
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
return MESA_jump_layer(raw_data, raw_layer_type, expect_layer_type);
|
||||
}
|
||||
|
||||
/*
|
||||
<09><>MESA_net_jump_to_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
MESA_net_jump_to_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿪ʼ, <20>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>˳<EFBFBD>;
|
||||
MESA_net_jump_to_layer_greedy()<29><>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Э<EFBFBD><D0AD>ͷ, <20>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>ģʽ.
|
||||
<09><>MESA_jump_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
MESA_jump_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿪ʼ, <20>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>˳<EFBFBD>;
|
||||
MESA_jump_layer_greedy()<29><>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Э<EFBFBD><D0AD>ͷ, <20>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>ģʽ.
|
||||
|
||||
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 +1374,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,17 +1419,22 @@ 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:
|
||||
return success_layer;
|
||||
}
|
||||
|
||||
const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
return MESA_jump_layer_greedy(raw_data, raw_layer_type, expect_layer_type);
|
||||
}
|
||||
|
||||
/* ģ<><C4A3>tcpdump<6D><70>ʽ: 192.168.40.137.22 > 192.168.36.40.49429 */
|
||||
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len )
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user