新增MAX_BURST_PKTLEN和MIN_BURST_PKTLEN两个环境变量控制放大包的长度范围
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
tcpburst
|
tcpburst
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
GPATH
|
||||||
|
GRTAGS
|
||||||
|
GTAGS
|
||||||
|
|||||||
2
clean.sh
2
clean.sh
@@ -1,3 +1,3 @@
|
|||||||
make clean
|
make clean
|
||||||
make distclean
|
make distclean
|
||||||
rm tcpburst clean
|
rm clean
|
||||||
|
|||||||
@@ -1565,7 +1565,7 @@ static const u_char *find_iphdr(const u_char *pkt, size_t pktlen, const u_char *
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pktlen > TCP_BURST_MTU){
|
if(pktlen > TCP_BURST_MTU || pktlen > options.max_burst_pkt_len || pktlen < options.min_burst_pkt_len){
|
||||||
//fprintf(stderr, "Tcpburst error! Packet too long:%d, current MTU is:%d\n", pktlen, TCP_BURST_MTU);
|
//fprintf(stderr, "Tcpburst error! Packet too long:%d, current MTU is:%d\n", pktlen, TCP_BURST_MTU);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1960,10 +1960,28 @@ init(void)
|
|||||||
options.pkt_distance = 0;
|
options.pkt_distance = 0;
|
||||||
options.driver_mode = "pcap"; /* default mode is pcap */
|
options.driver_mode = "pcap"; /* default mode is pcap */
|
||||||
options.encap_cfg_file = NULL;
|
options.encap_cfg_file = NULL;
|
||||||
|
char *env_var = getenv("MAX_BURST_PKTLEN");
|
||||||
|
if(env_var != NULL)
|
||||||
|
{
|
||||||
|
options.max_burst_pkt_len = atoi(env_var);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.max_burst_pkt_len = TCP_BURST_MTU;
|
||||||
|
}
|
||||||
|
env_var = getenv("MIN_BURST_PKTLEN");
|
||||||
|
if(env_var != NULL)
|
||||||
|
{
|
||||||
|
options.min_burst_pkt_len = atoi(env_var);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.min_burst_pkt_len = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fcntl(STDERR_FILENO, F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(STDERR_FILENO, F_SETFL, O_NONBLOCK) < 0)
|
||||||
warnx("Unable to set STDERR to non-blocking: %s", strerror(errno));
|
warnx("Unable to set STDERR to non-blocking: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ struct tcpreplay_opt_s {
|
|||||||
long cpu_mask;
|
long cpu_mask;
|
||||||
|
|
||||||
char *encap_cfg_file; /* <20>ײ<EFBFBD><D7B2><EFBFBD>װģʽ */
|
char *encap_cfg_file; /* <20>ײ<EFBFBD><D7B2><EFBFBD>װģʽ */
|
||||||
|
int max_burst_pkt_len;
|
||||||
|
int min_burst_pkt_len;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user