summaryrefslogtreecommitdiffstats
path: root/src/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.c')
-rw-r--r--src/options.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/src/options.c b/src/options.c
index 0817ed7..fef7cc1 100644
--- a/src/options.c
+++ b/src/options.c
@@ -48,7 +48,7 @@ static void print_usage(const char *options, const char *message) {
puts(message);
}
-static void usage(fastd_context_t *ctx UNUSED) {
+static void usage(void) {
puts("fastd (Fast and Secure Tunnelling Daemon) " FASTD_VERSION " usage:\n");
#define OR ", "
@@ -64,49 +64,49 @@ static void usage(fastd_context_t *ctx UNUSED) {
exit(0);
}
-static void version(fastd_context_t *ctx UNUSED) {
+static void version(void) {
puts("fastd " FASTD_VERSION);
exit(0);
}
-static void option_daemon(fastd_context_t *ctx UNUSED) {
+static void option_daemon(void) {
conf.daemon = true;
}
-static void option_pid_file(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_pid_file(const char *arg) {
free(conf.pid_file);
conf.pid_file = strdup(arg);
}
-static void option_config(fastd_context_t *ctx, const char *arg) {
+static void option_config(const char *arg) {
if (!strcmp(arg, "-"))
arg = NULL;
- if (!fastd_read_config(ctx, arg, false, 0))
+ if (!fastd_read_config(arg, false, 0))
exit(1);
}
-static void option_config_peer(fastd_context_t *ctx, const char *arg) {
- fastd_peer_config_new(ctx);
+static void option_config_peer(const char *arg) {
+ fastd_peer_config_new();
- if(!fastd_read_config(ctx, arg, true, 0))
+ if(!fastd_read_config(arg, true, 0))
exit(1);
}
-static void option_config_peer_dir(fastd_context_t *ctx, const char *arg) {
- fastd_add_peer_dir(ctx, arg);
+static void option_config_peer_dir(const char *arg) {
+ fastd_add_peer_dir(arg);
}
#ifdef WITH_CMDLINE_USER
-static void option_user(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_user(const char *arg) {
free(conf.user);
conf.user = strdup(arg);
}
-static void option_group(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_group(const char *arg) {
free(conf.group);
conf.group = strdup(arg);
}
@@ -115,7 +115,7 @@ static void option_group(fastd_context_t *ctx UNUSED, const char *arg) {
#ifdef WITH_CMDLINE_LOGGING
-static int parse_log_level(fastd_context_t *ctx, const char *arg) {
+static int parse_log_level(const char *arg) {
if (!strcmp(arg, "fatal"))
return LL_FATAL;
else if (!strcmp(arg, "error"))
@@ -131,27 +131,27 @@ static int parse_log_level(fastd_context_t *ctx, const char *arg) {
else if (!strcmp(arg, "debug2"))
return LL_DEBUG2;
else
- exit_error(ctx, "invalid log level `%s'", arg);
+ exit_error("invalid log level `%s'", arg);
}
-static void option_log_level(fastd_context_t *ctx, const char *arg) {
- conf.log_stderr_level = parse_log_level(ctx, arg);
+static void option_log_level(const char *arg) {
+ conf.log_stderr_level = parse_log_level(arg);
}
-static void option_syslog_level(fastd_context_t *ctx, const char *arg) {
- conf.log_syslog_level = parse_log_level(ctx, arg);
+static void option_syslog_level(const char *arg) {
+ conf.log_syslog_level = parse_log_level(arg);
}
-static void option_syslog_ident(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_syslog_ident(const char *arg) {
free(conf.log_syslog_ident);
conf.log_syslog_ident = strdup(arg);
}
-static void option_hide_ip_addresses(fastd_context_t *ctx UNUSED) {
+static void option_hide_ip_addresses(void) {
conf.hide_ip_addresses = true;
}
-static void option_hide_mac_addresses(fastd_context_t *ctx UNUSED) {
+static void option_hide_mac_addresses(void) {
conf.hide_mac_addresses = true;
}
@@ -159,31 +159,31 @@ static void option_hide_mac_addresses(fastd_context_t *ctx UNUSED) {
#ifdef WITH_CMDLINE_OPERATION
-static void option_mode(fastd_context_t *ctx, const char *arg) {
+static void option_mode(const char *arg) {
if (!strcmp(arg, "tap"))
conf.mode = MODE_TAP;
else if (!strcmp(arg, "tun"))
conf.mode = MODE_TUN;
else
- exit_error(ctx, "invalid mode `%s'", arg);
+ exit_error("invalid mode `%s'", arg);
}
-static void option_interface(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_interface(const char *arg) {
free(conf.ifname);
conf.ifname = strdup(arg);
}
-static void option_mtu(fastd_context_t *ctx, const char *arg) {
+static void option_mtu(const char *arg) {
char *endptr;
long mtu = strtol(arg, &endptr, 10);
if (*endptr || mtu < 576 || mtu > 65535)
- exit_error(ctx, "invalid mtu `%s'", arg);
+ exit_error("invalid mtu `%s'", arg);
conf.mtu = mtu;
}
-static void option_bind(fastd_context_t *ctx, const char *arg) {
+static void option_bind(const char *arg) {
long l;
char *charptr;
char *endptr;
@@ -193,7 +193,7 @@ static void option_bind(fastd_context_t *ctx, const char *arg) {
if (arg[0] == '[') {
charptr = strrchr(arg, ']');
if (!charptr || (charptr[1] != ':' && charptr[1] != '\0'))
- exit_error(ctx, "invalid bind address `%s'", arg);
+ exit_error("invalid bind address `%s'", arg);
addrstr = strndup(arg+1, charptr-arg-1);
@@ -215,7 +215,7 @@ static void option_bind(fastd_context_t *ctx, const char *arg) {
if (charptr) {
l = strtol(charptr+1, &endptr, 10);
if (*endptr || l < 1 || l > 65535)
- exit_error(ctx, "invalid bind port `%s'", charptr+1);
+ exit_error("invalid bind port `%s'", charptr+1);
}
else {
l = 0;
@@ -234,7 +234,7 @@ static void option_bind(fastd_context_t *ctx, const char *arg) {
}
if (inet_pton(AF_INET6, addrstr, &addr.in6.sin6_addr) != 1)
- exit_error(ctx, "invalid bind address `[%s]'", addrstr);
+ exit_error("invalid bind address `[%s]'", addrstr);
}
else if (strcmp(addrstr, "any") == 0) {
addr.in.sin_family = AF_UNSPEC;
@@ -245,23 +245,23 @@ static void option_bind(fastd_context_t *ctx, const char *arg) {
addr.in.sin_port = htons(l);
if (inet_pton(AF_INET, addrstr, &addr.in.sin_addr) != 1)
- exit_error(ctx, "invalid bind address `%s'", addrstr);
+ exit_error("invalid bind address `%s'", addrstr);
}
free(addrstr);
- fastd_config_bind_address(ctx, &addr, ifname, false, false);
+ fastd_config_bind_address(&addr, ifname, false, false);
}
-static void option_protocol(fastd_context_t *ctx, const char *arg) {
- fastd_config_protocol(ctx, arg);
+static void option_protocol(const char *arg) {
+ fastd_config_protocol(arg);
}
-static void option_method(fastd_context_t *ctx, const char *arg) {
- fastd_config_method(ctx, arg);
+static void option_method(const char *arg) {
+ fastd_config_method(arg);
}
-static void option_forward(fastd_context_t *ctx UNUSED) {
+static void option_forward(void) {
conf.forward = true;
}
@@ -269,55 +269,55 @@ static void option_forward(fastd_context_t *ctx UNUSED) {
#ifdef WITH_CMDLINE_COMMANDS
-static void option_on_pre_up(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_pre_up(const char *arg) {
fastd_shell_command_set(&conf.on_pre_up, arg, true);
}
-static void option_on_up(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_up(const char *arg) {
fastd_shell_command_set(&conf.on_up, arg, true);
}
-static void option_on_down(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_down(const char *arg) {
fastd_shell_command_set(&conf.on_down, arg, true);
}
-static void option_on_post_down(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_post_down(const char *arg) {
fastd_shell_command_set(&conf.on_post_down, arg, true);
}
-static void option_on_connect(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_connect(const char *arg) {
fastd_shell_command_set(&conf.on_connect, arg, false);
}
-static void option_on_establish(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_establish(const char *arg) {
fastd_shell_command_set(&conf.on_establish, arg, false);
}
-static void option_on_disestablish(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_disestablish(const char *arg) {
fastd_shell_command_set(&conf.on_disestablish, arg, false);
}
-static void option_on_verify(fastd_context_t *ctx UNUSED, const char *arg) {
+static void option_on_verify(const char *arg) {
fastd_shell_command_set(&conf.on_verify, arg, false);
}
#endif
-static void option_verify_config(fastd_context_t *ctx UNUSED) {
+static void option_verify_config(void) {
conf.verify_config = true;
}
-static void option_generate_key(fastd_context_t *ctx UNUSED) {
+static void option_generate_key(void) {
conf.generate_key = true;
conf.show_key = false;
}
-static void option_show_key(fastd_context_t *ctx UNUSED) {
+static void option_show_key(void) {
conf.generate_key = false;
conf.show_key = true;
}
-static void option_machine_readable(fastd_context_t *ctx UNUSED) {
+static void option_machine_readable(void) {
conf.machine_readable = true;
}
@@ -341,7 +341,7 @@ static bool config_match(const char *opt, ...) {
return match;
}
-void fastd_config_handle_options(fastd_context_t *ctx, int argc, char *const argv[]) {
+void fastd_config_handle_options(int argc, char *const argv[]) {
int i = 1;
while (i < argc) {
@@ -351,7 +351,7 @@ void fastd_config_handle_options(fastd_context_t *ctx, int argc, char *const arg
({ \
if(config_match(argv[i], options, NULL)) { \
i++; \
- func(ctx); \
+ func(); \
continue; \
} \
})
@@ -360,8 +360,8 @@ void fastd_config_handle_options(fastd_context_t *ctx, int argc, char *const arg
if(config_match(argv[i], options, NULL)) { \
i+=2; \
if (i > argc) \
- exit_error(ctx, "command line error: option `%s' needs an argument; see --help for usage", argv[i-2]); \
- func(ctx, argv[i-1]); \
+ exit_error("command line error: option `%s' needs an argument; see --help for usage", argv[i-2]); \
+ func(argv[i-1]); \
continue; \
} \
})
@@ -371,6 +371,6 @@ void fastd_config_handle_options(fastd_context_t *ctx, int argc, char *const arg
#undef OPTION
#undef OPTION_ARG
- exit_error(ctx, "command line error: unknown option `%s'; see --help for usage", argv[i]);
+ exit_error("command line error: unknown option `%s'; see --help for usage", argv[i]);
}
}