diff options
author | Martin Willi <martin@strongswan.org> | 2006-02-16 16:24:50 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-02-16 16:24:50 +0000 |
commit | 0a373aec33c977b061c57b72a3bc909ef5971b56 (patch) | |
tree | 99d9c1b185161f324a3393261bdfd5dcbad2938b /Source/charon/network/host.c | |
parent | 30b5b412da849251d6000c2dc52731af3e5409b8 (diff) | |
download | strongswan-0a373aec33c977b061c57b72a3bc909ef5971b56.tar.bz2 strongswan-0a373aec33c977b061c57b72a3bc909ef5971b56.tar.xz |
- fixed socket code, so we know on which address we receive traffic
- AH/ESP setup in kernel is working now!!! :-)))
Diffstat (limited to 'Source/charon/network/host.c')
-rw-r--r-- | Source/charon/network/host.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/charon/network/host.c b/Source/charon/network/host.c index a8fab245d..7d120886e 100644 --- a/Source/charon/network/host.c +++ b/Source/charon/network/host.c @@ -319,3 +319,26 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port) allocator_free(this); return NULL; } + +/* + * Described in header. + */ +host_t *host_create_from_sockaddr(sockaddr_t *sockaddr) +{ + chunk_t address; + + switch (sockaddr->sa_family) + { + /* IPv4 */ + case AF_INET: + { + struct sockaddr_in *sin = (struct sockaddr_in *)sockaddr; + address.ptr = (void*)&(sin->sin_addr.s_addr); + address.len = 4; + return host_create_from_chunk(AF_INET, address, ntohs(sin->sin_port)); + } + default: + return NULL; + } +} + |