socket-default: Add options to disable address families

This commit is contained in:
Tobias Brunner 2013-07-03 17:57:24 +02:00
parent bf92887af1
commit 598bec78fa
2 changed files with 31 additions and 0 deletions

View File

@ -632,6 +632,12 @@ have a high priority according to the order defined in interface-order(5).
.BR charon.plugins.socket-default.set_source " [yes]"
Set source address on outbound packets, if possible.
.TP
.BR charon.plugins.socket-default.use_ipv4 " [yes]"
Listen on IPv4, if possible.
.TP
.BR charon.plugins.socket-default.use_ipv6 " [yes]"
Listen on IPv6, if possible.
.TP
.BR charon.plugins.sql.database
Database URI for charons SQL plugin
.TP

View File

@ -630,12 +630,37 @@ static int open_socket(private_socket_default_socket_t *this,
return skt;
}
/**
* Check if we should use the given family
*/
static bool use_family(int family)
{
switch (family)
{
case AF_INET:
return lib->settings->get_bool(lib->settings,
"%s.plugins.socket-default.use_ipv4", TRUE, charon->name);
case AF_INET6:
return lib->settings->get_bool(lib->settings,
"%s.plugins.socket-default.use_ipv6", TRUE, charon->name);
default:
return FALSE;
}
}
/**
* Open a socket pair (normal and NAT traversal) for a given address family
*/
static void open_socketpair(private_socket_default_socket_t *this, int family,
int *skt, int *skt_natt, char *label)
{
if (!use_family(family))
{
*skt = -1;
*skt_natt = -1;
return;
}
*skt = open_socket(this, family, &this->port);
if (*skt == -1)
{