Make keepalive an option (and not a flag)
This commit is contained in:
37
src/main.c
37
src/main.c
@@ -626,7 +626,6 @@ int main (int argc, char **argv)
|
||||
long buffer_size = GT_BUFFER_SIZE;
|
||||
int delay = 0;
|
||||
int multiqueue = 0;
|
||||
int keepalive = 0;
|
||||
long ka_count = -1;
|
||||
long ka_idle = -1;
|
||||
long ka_interval = -1;
|
||||
@@ -640,22 +639,26 @@ int main (int argc, char **argv)
|
||||
} tcpinfo = {0};
|
||||
#endif
|
||||
|
||||
struct option ka_opts[] = {
|
||||
{ "count", &ka_count, option_long },
|
||||
{ "idle", &ka_idle, option_long },
|
||||
{ "interval", &ka_interval, option_long },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
struct option opts[] = {
|
||||
{ "listener", &listener, option_flag },
|
||||
{ "host", &host, option_str },
|
||||
{ "port", &port, option_str },
|
||||
{ "dev", &dev, option_str },
|
||||
{ "keyfile", &keyfile, option_str },
|
||||
{ "congestion", &congestion, option_str },
|
||||
{ "delay", &delay, option_flag },
|
||||
{ "multiqueue", &multiqueue, option_flag },
|
||||
{ "keepalive", &keepalive, option_flag },
|
||||
{ "ka-count", &ka_count, option_long },
|
||||
{ "ka-idle", &ka_idle, option_long },
|
||||
{ "ka-interval", &ka_interval, option_long },
|
||||
{ "buffer-size", &buffer_size, option_long },
|
||||
{ "debug", &debug, option_flag },
|
||||
{ "version", &version, option_flag },
|
||||
{ "listener", &listener, option_flag },
|
||||
{ "host", &host, option_str },
|
||||
{ "port", &port, option_str },
|
||||
{ "dev", &dev, option_str },
|
||||
{ "keyfile", &keyfile, option_str },
|
||||
{ "congestion", &congestion, option_str },
|
||||
{ "delay", &delay, option_flag },
|
||||
{ "multiqueue", &multiqueue, option_flag },
|
||||
{ "keepalive", ka_opts, option_option },
|
||||
{ "buffer-size", &buffer_size, option_long },
|
||||
{ "debug", &debug, option_flag },
|
||||
{ "version", &version, option_flag },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
@@ -667,6 +670,8 @@ int main (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int keepalive = option_is_set(opts, "keepalive");
|
||||
|
||||
if (buffer_size < 2048) {
|
||||
buffer_size = 2048;
|
||||
gt_log("buffer size must be greater than 2048!\n");
|
||||
|
||||
12
src/option.c
12
src/option.c
@@ -46,6 +46,18 @@ int option_long (void *data, int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int option_is_set (struct option *opts, const char *name)
|
||||
{
|
||||
for (int k=0; opts[k].name; k++) {
|
||||
if (str_cmp(opts[k].name, name))
|
||||
continue;
|
||||
|
||||
return opts[k].set;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int option_option (void *data, int argc, char **argv)
|
||||
{
|
||||
struct option *opts = (struct option *)data;
|
||||
|
||||
@@ -12,4 +12,5 @@ int option_str (void *, int, char **);
|
||||
int option_long (void *, int, char **);
|
||||
int option_option (void *, int, char **);
|
||||
|
||||
int option (struct option *, int, char **);
|
||||
int option_is_set (struct option *, const char *);
|
||||
int option (struct option *, int, char **);
|
||||
|
||||
Reference in New Issue
Block a user