diff options
author | Martin Willi <martin@strongswan.org> | 2007-02-28 14:04:36 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2007-02-28 14:04:36 +0000 |
commit | c60c7694d2d8925c5d93ff33d132f561ad89e071 (patch) | |
tree | 9c7957b0749139c5e7c9b008c927e79d69f8e500 /src/libstrongswan/utils/host.c | |
parent | a7a5e834e318d0582b6db979b63a5739c0a8244f (diff) | |
download | strongswan-c60c7694d2d8925c5d93ff33d132f561ad89e071.tar.bz2 strongswan-c60c7694d2d8925c5d93ff33d132f561ad89e071.tar.xz |
merged tasking branch into trunk
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; +} |