Support further address families in the future

This commit is contained in:
Pierre Pronchery 2018-08-06 17:29:04 +02:00
parent 3a8e01adea
commit 13dee2cdd8
4 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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 */

View File

@ -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);
}
}