summaryrefslogtreecommitdiff
path: root/network_io/os2
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2002-04-01 14:18:22 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2002-04-01 14:18:22 +0000
commit910da4cb602df8f3d3004e2d9435239298fcc3b7 (patch)
treede27796faa2808009e25a3df85d9b14af4e2eed4 /network_io/os2
parent2c8ea0ae2b128d21de318d408eaa51991e8644bb (diff)
downloadlibapr-910da4cb602df8f3d3004e2d9435239298fcc3b7.tar.gz
simplify sockaddr manipulation code a little bit
point out some possible bugs (see "XXX" comments) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63211 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/os2')
-rw-r--r--network_io/os2/sockets.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/network_io/os2/sockets.c b/network_io/os2/sockets.c
index aab2d2edc..96eb1cef0 100644
--- a/network_io/os2/sockets.c
+++ b/network_io/os2/sockets.c
@@ -87,35 +87,8 @@ static apr_status_t socket_cleanup(void *sock)
static void set_socket_vars(apr_socket_t *sock, int family, int type)
{
sock->type = type;
- sock->local_addr->family = family;
- sock->local_addr->sa.sin.sin_family = family;
- sock->remote_addr->family = family;
- sock->remote_addr->sa.sin.sin_family = family;
-
- if (family == AF_INET) {
- sock->local_addr->salen = sizeof(struct sockaddr_in);
- sock->local_addr->addr_str_len = 16;
- sock->local_addr->ipaddr_ptr = &(sock->local_addr->sa.sin.sin_addr);
- sock->local_addr->ipaddr_len = sizeof(struct in_addr);
-
- sock->remote_addr->salen = sizeof(struct sockaddr_in);
- sock->remote_addr->addr_str_len = 16;
- sock->remote_addr->ipaddr_ptr = &(sock->remote_addr->sa.sin.sin_addr);
- sock->remote_addr->ipaddr_len = sizeof(struct in_addr);
- }
-#if APR_HAVE_IPV6
- else if (family == AF_INET6) {
- sock->local_addr->salen = sizeof(struct sockaddr_in6);
- sock->local_addr->addr_str_len = 46;
- sock->local_addr->ipaddr_ptr = &(sock->local_addr->sa.sin6.sin6_addr);
- sock->local_addr->ipaddr_len = sizeof(struct in6_addr);
-
- sock->remote_addr->salen = sizeof(struct sockaddr_in6);
- sock->remote_addr->addr_str_len = 46;
- sock->remote_addr->ipaddr_ptr = &(sock->remote_addr->sa.sin6.sin6_addr);
- sock->remote_addr->ipaddr_len = sizeof(struct in6_addr);
- }
-#endif
+ apr_sockaddr_vars_set(sock->local_addr, family, 0);
+ apr_sockaddr_vars_set(sock->remote_addr, family, 0);
}
static void alloc_socket(apr_socket_t **new, apr_pool_t *p)
@@ -223,6 +196,8 @@ APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new, apr_socket_t *sock, apr
if ((*new)->socketdes < 0) {
return APR_OS2_STATUS(sock_errno());
}
+ /* XXX fix up any pointers which are no longer valid (or just call
+ * apr_sockaddr_vars_set() to do it */
(*new)->remote_addr->port = ntohs((*new)->remote_addr->sa.sin.sin_port);
apr_pool_cleanup_register((*new)->cntxt, (void *)(*new),
socket_cleanup, apr_pool_cleanup_null);