添加依赖库googletest.
This commit is contained in:
@@ -56,11 +56,11 @@ static int jump_check_ipv4_pkt(const struct ip *ip4hdr, int expect_tot_len, unsi
|
||||
return -1;
|
||||
}
|
||||
if(ip4hdr->ip_hl*4 < 20){
|
||||
printf("\033[1;31;40mMESA_net_jump_to_layer(): ipv4 header check header length error!\033[0m\n");
|
||||
printf("\033[1;31;40mMESA_net_jump_to_layer(): ipv4 header check header length error, iphdr less than 20Byte!\033[0m\n");
|
||||
return -1;
|
||||
}
|
||||
if(ntohs(ip4hdr->ip_len) != expect_tot_len){
|
||||
printf("\033[1;31;40mMESA_net_jump_to_layer(): ipv4 header check length error!\033[0m\n");
|
||||
printf("\033[1;31;40mMESA_net_jump_to_layer(): ipv4 header check length error, ip len is:%d, but expect:%d!\033[0m\n", ntohs(ip4hdr->ip_len), expect_tot_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,6 @@ static int jmp_file_md5_checksum(const char *filename, const char *expect_md5sum
|
||||
static void jump_layer_eth_ipv4_tcp(u_char *result_val, const struct pcap_pkthdr *hdr, const u_char *data)
|
||||
{
|
||||
int ret;
|
||||
int tot_pkt_len;
|
||||
const void *eth_header, *ipv4_header, *tcp_header;
|
||||
const void *next_header;
|
||||
|
||||
@@ -219,7 +218,7 @@ static void jump_layer_eth_ipv4_tcp(u_char *result_val, const struct pcap_pkthdr
|
||||
}
|
||||
|
||||
const struct ip* ip4hdr = (struct ip*)ipv4_header;
|
||||
jump_check_ipv4_pkt(ip4hdr, tot_pkt_len-sizeof(struct ethhdr), IPPROTO_TCP, "192.168.10.250", "192.168.10.234");
|
||||
jump_check_ipv4_pkt(ip4hdr, 60, IPPROTO_TCP, "192.168.10.250", "192.168.10.234");
|
||||
|
||||
tcp_header = MESA_net_jump_to_layer((void *)ipv4_header, ADDR_TYPE_IPV4, ADDR_TYPE_TCP);
|
||||
if(NULL == tcp_header){
|
||||
@@ -254,7 +253,8 @@ static void jump_layer_eth_ipv4_tcp(u_char *result_val, const struct pcap_pkthdr
|
||||
|
||||
TEST(jump_layer, eth_ipv4_tcp)
|
||||
{
|
||||
int fun_ret, chk_res = -1;
|
||||
int fun_ret;
|
||||
u_char chk_res = -1;
|
||||
|
||||
fun_ret = jmp_file_md5_checksum("./sample_pcap/tcp_simple.pcap", "eb4b176720c698e86c1acbacf2f30ede");
|
||||
ASSERT_EQ(fun_ret, 0);
|
||||
|
||||
Reference in New Issue
Block a user