diff options
Diffstat (limited to 'src/libstrongswan/utils/host.c')
-rw-r--r-- | src/libstrongswan/utils/host.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c index f9be454fa..8cbfd6ab8 100644 --- a/src/libstrongswan/utils/host.c +++ b/src/libstrongswan/utils/host.c @@ -6,7 +6,8 @@ */ /* - * Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger + * Copyright (C) 2006-2007 Tobias Brunner + * Copyright (C) 2006 Daniel Roethlisberger * Copyright (C) 2005-2006 Martin Willi * Copyright (C) 2005 Jan Hutter * Hochschule fuer Technik Rapperswil @@ -45,7 +46,7 @@ struct private_host_t { union { /** generic type */ struct sockaddr address; - /** maximux sockaddr size */ + /** maximum sockaddr size */ struct sockaddr_storage address_max; /** IPv4 address */ struct sockaddr_in address4; @@ -495,3 +496,31 @@ host_t *host_create_from_sockaddr(sockaddr_t *sockaddr) free(this); return NULL; } + +/* + * Described in header. + */ +host_t *host_create_any(int family) +{ + private_host_t *this = host_create_empty(); + + memset(&this->address_max, 0, sizeof(struct sockaddr_storage)); + this->address.sa_family = family; + + switch (family) + { + case AF_INET: + { + this->socklen = sizeof(struct sockaddr_in); + return &(this->public); + } + case AF_INET6: + { + this->socklen = sizeof(struct sockaddr_in6); + return &this->public; + } + default: + break; + } + return NULL; +} |