From 9fa3c0ae5bcdc5297a130843cff21c0926642819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=A8=81?= Date: Wed, 5 Aug 2020 11:53:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9B=9E=E6=94=BE=E5=8C=85?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BB=85=E5=BD=93=E4=BD=BF=E7=94=A8?= =?UTF-8?q?marsio=E7=BC=96=E8=AF=91=E4=B8=94=E4=BD=BF=E7=94=A8marsio?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=9B=9E=E6=94=BE=E6=B5=81=E9=87=8F=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=90=AF=E7=94=A8marsio=5Fthread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 21 +++++++++++++ src/tcpreplay.c | 81 ++++++++++++++++++++++--------------------------- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index e111edb..5ba55dd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,24 @@ tcpburst GPATH GRTAGS GTAGS +*.o +*.Po +*.a +Makefile +test/config +src/tcprewrite +src/tcpreplay-edit +src/tcpprep +src/tcpreplay +src/tcpbridge +src/stamp-h1 +src/defines.h +src/config.h +libopts/.libs/libopts.la +libopts/.deps/libopts_la-libopts.Plo +libopts/libopts.la +libopts/libopts_la-libopts.lo +libtool +doxygen.cfg +config.status +config.log diff --git a/src/tcpreplay.c b/src/tcpreplay.c index 000e631..c4e1c0e 100644 --- a/src/tcpreplay.c +++ b/src/tcpreplay.c @@ -1639,7 +1639,7 @@ static void *replay_files_thread(void *arg) marsio_thread_init(tcpburst_marsio4_instance); if(0 == loop){ - loop = 1; /* 至少一次 */ + while(1)replay_file(0); } for(i = 0; i < loop; i++){ replay_file(0); @@ -1748,50 +1748,43 @@ main(int argc, char *argv[]) if (gettimeofday(&begin, NULL) < 0) errx(-1, "gettimeofday() failed: %s", strerror(errno)); - /* main loop for non-bridge mode */ - if (options.loop > 0) { - while (options.loop--) { /* limited loop */ - /* process each pcap file in order */ - for (i = 0; i < argc; i++) { - /* reset cache markers for each iteration */ - cache_byte = 0; - cache_bit = 0; -#ifdef MARSIO - if(12 == send_pkt_driver_mode){ - pthread_t pid; - pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop); - pthread_join(pid, NULL); - }else{ - replay_file(i); - } -#else - replay_file(i); -#endif - } - } - } - else { - /* loop forever */ - while (1) { - for (i = 0; i < argc; i++) { - /* reset cache markers for each iteration */ - cache_byte = 0; - cache_bit = 0; -#ifdef MARSIO - if(12 == send_pkt_driver_mode){ - pthread_t pid; - pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop); - pthread_join(pid, NULL); - }else{ - replay_file(i); - } -#else - replay_file(i); -#endif - } - } - } + if (12 == send_pkt_driver_mode) + { +#ifdef MARSIO + pthread_t pid; + pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop); + pthread_join(pid, NULL); +#else + errx(-1, "send_pkt_driver_mode == %s, but tcp_burst did not compiled with %s", "MARSIO", "MARSIO"); +#endif + } + else + { + /* main loop for non-bridge mode */ + if (options.loop > 0) { + while (options.loop--) { /* limited loop */ + /* process each pcap file in order */ + for (i = 0; i < argc; i++) { + /* reset cache markers for each iteration */ + cache_byte = 0; + cache_bit = 0; + replay_file(i); + } + } + } + else { + /* loop forever */ + while (1) { + for (i = 0; i < argc; i++) { + /* reset cache markers for each iteration */ + cache_byte = 0; + cache_bit = 0; + replay_file(i); + } + } + } + } if (bytes_sent > 0) { if (gettimeofday(&end, NULL) < 0) errx(-1, "Unable to gettimeofday(): %s", strerror(errno));