增加-g参数, 并通过控制连接传输给sapp.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
#ifndef _MESA_PKT_DUMP_H_
|
#ifndef _MESA_PKT_DUMP_H_
|
||||||
#define _MESA_PKT_DUMP_H_ 1
|
#define _MESA_PKT_DUMP_H_ 1
|
||||||
|
|
||||||
|
#define MESA_PKT_DUM_H_VER (20181115)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<09><><EFBFBD><EFBFBD>DPDK-3.0, PFRINGģʽ<C4A3><CABD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ʱ, ͨ<><CDA8>ƽ̨ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>.
|
<09><><EFBFBD><EFBFBD>DPDK-3.0, PFRINGģʽ<C4A3><CABD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ʱ, ͨ<><CDA8>ƽ̨ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>.
|
||||||
*/
|
*/
|
||||||
@@ -14,6 +17,7 @@ enum pkt_dump_opt_t{
|
|||||||
PKT_DUMP_OPT_THREAD_INDEX,
|
PKT_DUMP_OPT_THREAD_INDEX,
|
||||||
PKT_DUMP_OPT_ACK, /* sapp<70><70><EFBFBD>ظ<EFBFBD>tcpdump_mesa<73><61>ack<63><6B> */
|
PKT_DUMP_OPT_ACK, /* sapp<70><70><EFBFBD>ظ<EFBFBD>tcpdump_mesa<73><61>ack<63><6B> */
|
||||||
PKT_DUMP_OPT_PERCEPTIVE, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, <20><><EFBFBD>Է<EFBFBD><D4B7>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
PKT_DUMP_OPT_PERCEPTIVE, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, <20><><EFBFBD>Է<EFBFBD><D4B7>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
PKT_DUMP_OPT_GREEDY_SEEK, /* ƫ<>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>ڲ<EFBFBD>IP, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>²<EFBFBD><C2B2><EFBFBD>BUG */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ARM, PowerPC, MIPS<50><53><EFBFBD><EFBFBD>ֲ */
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ARM, PowerPC, MIPS<50><53><EFBFBD><EFBFBD>ֲ */
|
||||||
|
|||||||
30
tcpdump.c
30
tcpdump.c
@@ -959,7 +959,11 @@ static int pkt_dump_recv_ack(int connfd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
static void *detect_sapp_thread(void *arg)
|
/*
|
||||||
|
<09><><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD>sapp<70>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>sapp<70>˳<EFBFBD><CBB3><EFBFBD>,
|
||||||
|
tcpdump_mesaҲӦ<D2B2><D3A6><EFBFBD>˳<EFBFBD>.
|
||||||
|
*/
|
||||||
|
static void *detect_sapp_alive_thread(void *arg)
|
||||||
{
|
{
|
||||||
int tcp_cmd_fd = (int)arg;
|
int tcp_cmd_fd = (int)arg;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1020,9 +1024,17 @@ static int MESA_dump_start(unsigned short udp_rcv_port, unsigned short sapp_cmd_
|
|||||||
opt_num++;
|
opt_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(greedy_seek_flag != 0){
|
||||||
|
if(tcpdump_data_offset != 0){
|
||||||
|
printf("option -o and -g is exclusive, can't use at same time!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
opt_num++;
|
||||||
|
}
|
||||||
|
|
||||||
/************** pkt handshake *************/
|
/************** pkt handshake *************/
|
||||||
pkt_hdr.magic = htonl(PKT_DUMP_HDR_MAGIC);
|
pkt_hdr.magic = htonl(PKT_DUMP_HDR_MAGIC);
|
||||||
pkt_hdr.version = htonl(tcpdump_mesa_version_VERSION_20181114);
|
pkt_hdr.version = htonl(20180119); /* ֮ǰsapp<70><70>20180119<31>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>У<EFBFBD><D0A3>, <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ȹ̶<C8B9><CCB6>ô<EFBFBD>ֵ, <20>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD>sapp<70><70>, <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>汾 */
|
||||||
pkt_hdr.opt_num = htonl(opt_num);
|
pkt_hdr.opt_num = htonl(opt_num);
|
||||||
ret = write(tcp_cmd_fd, &pkt_hdr, sizeof(pkt_hdr));
|
ret = write(tcp_cmd_fd, &pkt_hdr, sizeof(pkt_hdr));
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
@@ -1106,12 +1118,24 @@ static int MESA_dump_start(unsigned short udp_rcv_port, unsigned short sapp_cmd_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************** greedy seek *************/
|
||||||
|
if(greedy_seek_flag != 0){
|
||||||
|
opt.opt_type = htons(PKT_DUMP_OPT_GREEDY_SEEK);
|
||||||
|
opt.opt_len = 0;
|
||||||
|
ret = write(tcp_cmd_fd, &opt, sizeof(opt));
|
||||||
|
if(ret < 0){
|
||||||
|
printf("connection down!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/********** after send opt, start recv sapp ACK *******/
|
||||||
if(pkt_dump_recv_ack(tcp_cmd_fd) < 0){
|
if(pkt_dump_recv_ack(tcp_cmd_fd) < 0){
|
||||||
printf("connection down!\n");
|
printf("connection down!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_create(&pid, NULL, detect_sapp_thread, (void *)tcp_cmd_fd);
|
pthread_create(&pid, NULL, detect_sapp_alive_thread, (void *)tcp_cmd_fd);
|
||||||
|
|
||||||
return tcp_cmd_fd;
|
return tcp_cmd_fd;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user