Skip to content

Commit d13af41

Browse files
author
=
committed
fixed systemd issue
1 parent b5e22b6 commit d13af41

1 file changed

Lines changed: 63 additions & 34 deletions

File tree

hcxdumptool.c

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,7 +3216,7 @@ return;
32163216
/*===========================================================================*/
32173217
/*===========================================================================*/
32183218
/*SCAN LOOPs */
3219-
static bool nl_scanloop(void)
3219+
static bool nl_scanloop(intmax_t tottime)
32203220
{
32213221
static ssize_t i;
32223222
static int fd_epoll = 0;
@@ -3256,16 +3256,19 @@ if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer1, &ev) < 0)
32563256
}
32573257
epi++;
32583258

3259-
ev.data.fd = fd_timer2;
3260-
ev.events = EPOLLIN;
3261-
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0)
3259+
if(tottime > 0)
32623260
{
3263-
#ifdef HCXDEBUG
3264-
fprintf(fh_debug, "epoll_ctl timer 2 failed: %s\n", strerror(errno));
3265-
#endif
3266-
return false;
3267-
}
3268-
epi++;
3261+
ev.data.fd = fd_timer2;
3262+
ev.events = EPOLLIN;
3263+
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0)
3264+
{
3265+
#ifdef HCXDEBUG
3266+
fprintf(fh_debug, "epoll_ctl timer 2 failed: %s\n", strerror(errno));
3267+
#endif
3268+
return false;
3269+
}
3270+
epi++;
3271+
}
32693272

32703273
if(nl_set_frequency() == false) errorcount++;
32713274
while(!wanteventflag)
@@ -3328,7 +3331,7 @@ while(!wanteventflag)
33283331
return true;
33293332
}
33303333
/*---------------------------------------------------------------------------*/
3331-
static bool nl_scanloop_rds(void)
3334+
static bool nl_scanloop_rds(intmax_t tottime)
33323335
{
33333336
static ssize_t i;
33343337
static int fd_epoll = 0;
@@ -3350,10 +3353,19 @@ ev.events = EPOLLIN;
33503353
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer1, &ev) < 0) return false;
33513354
epi++;
33523355

3353-
ev.data.fd = fd_timer2;
3354-
ev.events = EPOLLIN;
3355-
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0) return false;
3356-
epi++;
3356+
if(tottime > 0)
3357+
{
3358+
ev.data.fd = fd_timer2;
3359+
ev.events = EPOLLIN;
3360+
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0)
3361+
{
3362+
#ifdef HCXDEBUG
3363+
fprintf(fh_debug, "epoll_ctl timer 2 failed: %s\n", strerror(errno));
3364+
#endif
3365+
return false;
3366+
}
3367+
epi++;
3368+
}
33573369

33583370
if(nl_set_frequency() == false) errorcount++;
33593371
while(!wanteventflag)
@@ -3429,7 +3441,7 @@ while(!wanteventflag)
34293441
return true;
34303442
}
34313443
/*---------------------------------------------------------------------------*/
3432-
static bool nl_scanloop_waterfall(void)
3444+
static bool nl_scanloop_waterfall(intmax_t tottime)
34333445
{
34343446
static ssize_t i;
34353447
static int fd_epoll = 0;
@@ -3451,10 +3463,19 @@ ev.events = EPOLLIN;
34513463
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer1, &ev) < 0) return false;
34523464
epi++;
34533465

3454-
ev.data.fd = fd_timer2;
3455-
ev.events = EPOLLIN;
3456-
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0) return false;
3457-
epi++;
3466+
if(tottime > 0)
3467+
{
3468+
ev.data.fd = fd_timer2;
3469+
ev.events = EPOLLIN;
3470+
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0)
3471+
{
3472+
#ifdef HCXDEBUG
3473+
fprintf(fh_debug, "epoll_ctl timer 2 failed: %s\n", strerror(errno));
3474+
#endif
3475+
return false;
3476+
}
3477+
epi++;
3478+
}
34583479

34593480
if(nl_set_frequency() == false) errorcount++;
34603481
while(!wanteventflag)
@@ -3517,7 +3538,7 @@ while(!wanteventflag)
35173538
return true;
35183539
}
35193540
/*---------------------------------------------------------------------------*/
3520-
static bool nl_scanloop_rcascan(void)
3541+
static bool nl_scanloop_rcascan(intmax_t tottime)
35213542
{
35223543
static ssize_t i;
35233544
static int fd_epoll = 0;
@@ -3539,10 +3560,19 @@ ev.events = EPOLLIN;
35393560
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer1, &ev) < 0) return false;
35403561
epi++;
35413562

3542-
ev.data.fd = fd_timer2;
3543-
ev.events = EPOLLIN;
3544-
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0) return false;
3545-
epi++;
3563+
if(tottime > 0)
3564+
{
3565+
ev.data.fd = fd_timer2;
3566+
ev.events = EPOLLIN;
3567+
if(epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_timer2, &ev) < 0)
3568+
{
3569+
#ifdef HCXDEBUG
3570+
fprintf(fh_debug, "epoll_ctl timer 2 failed: %s\n", strerror(errno));
3571+
#endif
3572+
return false;
3573+
}
3574+
epi++;
3575+
}
35463576

35473577
if(nl_set_frequency() == false) errorcount++;
35483578
if(rcascanmode == RCASCAN_ACTIVE)
@@ -4887,12 +4917,12 @@ if(timerfd_settime(fd_timer1, 0, &tval1, NULL) == -1) return false;
48874917
return true;
48884918
}
48894919
/*---------------------------------------------------------------------------*/
4890-
static bool set_timer2(time_t tottime)
4920+
static bool set_timer2(intmax_t tottime)
48914921
{
48924922
static struct itimerspec tval2;
48934923

48944924
if((fd_timer2 = timerfd_create(CLOCK_BOOTTIME, 0)) < 0) return false;
4895-
tval2.it_value.tv_sec = tottime * 60;
4925+
tval2.it_value.tv_sec = tottime;
48964926
tval2.it_value.tv_nsec = 0;
48974927
tval2.it_interval.tv_sec = 0;
48984928
tval2.it_interval.tv_nsec = 0;
@@ -5580,7 +5610,7 @@ static u8 exitwatchdogflag = 0;
55805610
static u8 exiterrorflag = 0;
55815611
static struct timespec tspecifo, tspeciforem;
55825612
static struct tpacket_stats lStats = { 0 };
5583-
static time_t tottime = 0;
5613+
static intmax_t tottime = 0;
55845614
static socklen_t lStatsLength = sizeof(lStats);
55855615
static char *bpfname = NULL;
55865616
#ifdef HCXWANTLIBPCAP
@@ -5730,7 +5760,7 @@ while((auswahl = getopt_long(argc, argv, short_options, long_options, &index)) !
57305760
fprintf(stderr, "time out timer must be > 0 minutes\n");
57315761
exit(EXIT_FAILURE);
57325762
}
5733-
if(set_timer2(tottime) == false)
5763+
if(set_timer2(tottime * 60) == false)
57345764
{
57355765
fprintf(stderr, "failed to set time out timer\n");
57365766
exit(EXIT_FAILURE);
@@ -6053,7 +6083,6 @@ if(set_timer() == false)
60536083
fprintf(stderr, "failed to initialize timer\n");
60546084
goto byebye;
60556085
}
6056-
60576086
if(daemon == true)
60586087
{
60596088
if((hcxpid = fork()) < 0)
@@ -6091,31 +6120,31 @@ else fprintf(stdout, "starting...\033[?25l\n");
60916120
nanosleep(&tspecifo, &tspeciforem);
60926121
if(rcascanmode > 0)
60936122
{
6094-
if(nl_scanloop_rcascan() == false)
6123+
if(nl_scanloop_rcascan(tottime) == false)
60956124
{
60966125
errorcount++;
60976126
fprintf(stderr, "failed to initialize rcascan scan loop\n");
60986127
}
60996128
}
61006129
else if(rds == 0)
61016130
{
6102-
if(nl_scanloop() == false)
6131+
if(nl_scanloop(tottime) == false)
61036132
{
61046133
errorcount++;
61056134
fprintf(stderr, "failed to initialize main scan loop\n");
61066135
}
61076136
}
61086137
else if(rds == 4)
61096138
{
6110-
if(nl_scanloop_waterfall() == false)
6139+
if(nl_scanloop_waterfall(tottime) == false)
61116140
{
61126141
errorcount++;
61136142
fprintf(stderr, "failed to initialize main scan loop\n");
61146143
}
61156144
}
61166145
else
61176146
{
6118-
if(nl_scanloop_rds() == false)
6147+
if(nl_scanloop_rds(tottime) == false)
61196148
{
61206149
errorcount++;
61216150
fprintf(stderr, "failed to initialize main scan loop\n");

0 commit comments

Comments
 (0)