diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-01-23 22:56:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-23 22:56:47 +0100 |
commit | 83c60c9f0c7581b607dc5c0f84582978894e3d4a (patch) | |
tree | 9c6dc95ae4ca7e64ffc674cb45561dd52dcaa10f /socket-util.c | |
parent | 542563babda739f7aee468c3eaaab6315ffa4224 (diff) |
implement proper binding on ports
Diffstat (limited to 'socket-util.c')
-rw-r--r-- | socket-util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/socket-util.c b/socket-util.c index 525c33474d..1024ecbed3 100644 --- a/socket-util.c +++ b/socket-util.c @@ -115,13 +115,13 @@ int socket_address_parse(SocketAddress *a, const char *s) { idx = if_nametoindex(n); free(n); - if (n == 0) + if (idx == 0) return -EINVAL; a->sockaddr.in6.sin6_family = AF_INET6; a->sockaddr.in6.sin6_port = htons((uint16_t) u); a->sockaddr.in6.sin6_scope_id = idx; - memcpy(&a->sockaddr.in6.sin6_addr, &in6addr_any, INET6_ADDRSTRLEN); + a->sockaddr.in6.sin6_addr = in6addr_any; a->size = sizeof(struct sockaddr_in6); } } else { @@ -135,7 +135,7 @@ int socket_address_parse(SocketAddress *a, const char *s) { a->sockaddr.in6.sin6_family = AF_INET6; a->sockaddr.in6.sin6_port = htons((uint16_t) u); - memcpy(&a->sockaddr.in6.sin6_addr, &in6addr_any, INET6_ADDRSTRLEN); + a->sockaddr.in6.sin6_addr = in6addr_any; a->size = sizeof(struct sockaddr_in6); } } @@ -274,9 +274,10 @@ int socket_address_print(const SocketAddress *a, char **p) { } } -int socket_address_listen(const SocketAddress *a, int backlog, SocketAddressBindIPv6Only only) { +int socket_address_listen(const SocketAddress *a, int backlog, SocketAddressBindIPv6Only only, int *ret) { int r, fd; assert(a); + assert(ret); if ((r = socket_address_verify(a)) < 0) return r; @@ -304,5 +305,6 @@ int socket_address_listen(const SocketAddress *a, int backlog, SocketAddressBind return -errno; } + *ret = fd; return 0; } |