From 13dee2cdd8efb46d362ca6428321c75203656451 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 6 Aug 2018 17:29:04 +0200 Subject: [PATCH] Support further address families in the future --- server/config_init.c | 2 +- server/fwknopd.c | 4 ++-- server/fwknopd_common.h | 2 +- server/pcap_capture.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/config_init.c b/server/config_init.c index 78f1677c..225290aa 100644 --- a/server/config_init.c +++ b/server/config_init.c @@ -1373,7 +1373,7 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) set_config_entry(opts, CONF_PCAP_INTF, optarg); break; case '6': - opts->ipv6 = 1; + opts->family = AF_INET6; break; case FIREWD_DISABLE_CHECK_SUPPORT: opts->firewd_disable_check_support = 1; diff --git a/server/fwknopd.c b/server/fwknopd.c index aed5dc52..e475a5e8 100644 --- a/server/fwknopd.c +++ b/server/fwknopd.c @@ -259,7 +259,7 @@ main(int argc, char **argv) if(opts.enable_udp_server || strncasecmp(opts.config[CONF_ENABLE_UDP_SERVER], "Y", 1) == 0) { - if(run_udp_server(&opts, opts.ipv6 ? AF_INET6 : AF_INET) < 0) + if(run_udp_server(&opts, (opts.family != AF_UNSPEC) ? opts.family : AF_INET) < 0) { log_msg(LOG_ERR, "Fatal run_udp_server() error"); clean_exit(&opts, FW_CLEANUP, EXIT_FAILURE); @@ -280,7 +280,7 @@ main(int argc, char **argv) */ if(strncasecmp(opts.config[CONF_ENABLE_TCP_SERVER], "Y", 1) == 0) { - if(run_tcp_server(&opts, opts.ipv6 ? AF_INET6 : AF_INET) < 0) + if(run_tcp_server(&opts, (opts.family != AF_UNSPEC) ? opts.family : AF_INET) < 0) { log_msg(LOG_ERR, "Fatal run_tcp_server() error"); clean_exit(&opts, FW_CLEANUP, EXIT_FAILURE); diff --git a/server/fwknopd_common.h b/server/fwknopd_common.h index 387d5290..85c85612 100644 --- a/server/fwknopd_common.h +++ b/server/fwknopd_common.h @@ -688,7 +688,7 @@ typedef struct fko_srv_options unsigned char enable_nfq_capture; /* Enable Netfilter Queue capture mode */ unsigned char enable_fw; /* Command modes by themselves don't need firewall support. */ - unsigned char ipv6; /* Enable IPv6 mode (TCP/UDP) */ + int family; /* Family restriction (TCP/UDP) */ unsigned char firewd_disable_check_support; /* Don't use firewall-cmd ... -C */ unsigned char ipt_disable_check_support; /* Don't use iptables -C */ diff --git a/server/pcap_capture.c b/server/pcap_capture.c index f32aeca8..6d616956 100644 --- a/server/pcap_capture.c +++ b/server/pcap_capture.c @@ -211,7 +211,7 @@ pcap_capture(fko_srv_options_t *opts) /* Attempt to restart tcp server ? */ usleep(1000000); - run_tcp_server(opts, opts->ipv6 ? AF_INET6 : AF_INET); + run_tcp_server(opts, (opts->family != AF_UNSPEC) ? opts->family : AF_INET); } }