diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-07-03 17:32:40 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-07-05 09:48:01 +0200 |
commit | eafd7ee7e1164cd21fa7f9a2d828a0bb5f51ef0b (patch) | |
tree | 9e0f17584d104aa8f74e84294d5b5e97dfbffcb2 /src/libcharon/plugins | |
parent | ef1348069906e4ebac5e5b7e9409f157df391bef (diff) | |
download | strongswan-eafd7ee7e1164cd21fa7f9a2d828a0bb5f51ef0b.tar.bz2 strongswan-eafd7ee7e1164cd21fa7f9a2d828a0bb5f51ef0b.tar.xz |
net: Socket implementations report the address families they support
Diffstat (limited to 'src/libcharon/plugins')
-rw-r--r-- | src/libcharon/plugins/socket_default/socket_default_socket.c | 19 | ||||
-rw-r--r-- | src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c | 11 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/libcharon/plugins/socket_default/socket_default_socket.c b/src/libcharon/plugins/socket_default/socket_default_socket.c index 494bf57b1..c1ed22ecb 100644 --- a/src/libcharon/plugins/socket_default/socket_default_socket.c +++ b/src/libcharon/plugins/socket_default/socket_default_socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2012 Tobias Brunner + * Copyright (C) 2006-2013 Tobias Brunner * Copyright (C) 2006 Daniel Roethlisberger * Copyright (C) 2005-2010 Martin Willi * Copyright (C) 2005 Jan Hutter @@ -501,6 +501,22 @@ METHOD(socket_t, get_port, u_int16_t, return nat_t ? this->natt : this->port; } +METHOD(socket_t, supported_families, socket_family_t, + private_socket_default_socket_t *this) +{ + socket_family_t families = SOCKET_FAMILY_NONE; + + if (this->ipv4 != -1 || this->ipv4_natt != -1) + { + families |= SOCKET_FAMILY_IPV4; + } + if (this->ipv6 != -1 || this->ipv6_natt != -1) + { + families |= SOCKET_FAMILY_IPV6; + } + return families; +} + /** * open a socket to send and receive packets */ @@ -671,6 +687,7 @@ socket_default_socket_t *socket_default_socket_create() .send = _sender, .receive = _receiver, .get_port = _get_port, + .supported_families = _supported_families, .destroy = _destroy, }, }, diff --git a/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c b/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c index b7c73945d..aecbd5226 100644 --- a/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c +++ b/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2012 Tobias Brunner + * Copyright (C) 2006-2013 Tobias Brunner * Copyright (C) 2006 Daniel Roethlisberger * Copyright (C) 2005-2010 Martin Willi * Copyright (C) 2005 Jan Hutter @@ -620,6 +620,14 @@ METHOD(socket_t, get_port, u_int16_t, return 0; } +METHOD(socket_t, supported_families, socket_family_t, + private_socket_dynamic_socket_t *this) +{ + /* we could return only the families of the opened sockets, but it could + * be that both families are supported even if no socket is yet open */ + return SOCKET_FAMILY_BOTH; +} + METHOD(socket_t, destroy, void, private_socket_dynamic_socket_t *this) { @@ -654,6 +662,7 @@ socket_dynamic_socket_t *socket_dynamic_socket_create() .send = _sender, .receive = _receiver, .get_port = _get_port, + .supported_families = _supported_families, .destroy = _destroy, }, }, |