httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/network_io/beos sockaddr.c sockets.c
Date Sat, 11 Mar 2000 14:11:37 GMT
dreid       00/03/11 06:11:37

  Modified:    src/lib/apr/network_io/beos sockaddr.c sockets.c
  Log:
  Tidy up and correct a few errors in the BeOS code.  Also add Ronalds
  changes.  Add some error checking for the simple functions in
  sockaddr.c
  
  Revision  Changes    Path
  1.5       +36 -0     apache-2.0/src/lib/apr/network_io/beos/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockaddr.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- sockaddr.c	2000/03/10 00:06:24	1.4
  +++ sockaddr.c	2000/03/11 14:11:36	1.5
  @@ -57,24 +57,36 @@
   
   ap_status_t ap_set_local_port(struct socket_t *sock, ap_uint32_t port)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       sock->local_addr->sin_port = htons((short)port);
       return APR_SUCCESS;
   }
   
   ap_status_t ap_set_remote_port(struct socket_t *sock, ap_uint32_t port)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       sock->remote_addr->sin_port = htons((short)port);
       return APR_SUCCESS;
   }
   
   ap_status_t ap_get_local_port(ap_uint32_t *port, struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       *port = ntohs(sock->local_addr->sin_port);
       return APR_SUCCESS;
   }
   
   ap_status_t ap_get_remote_port(ap_uint32_t *port, struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       *port = ntohs(sock->remote_addr->sin_port);
       return APR_SUCCESS;
   }
  @@ -82,6 +94,10 @@
   ap_status_t ap_set_local_ipaddr(struct socket_t *sock, const char *addr)
   {
       u_long ipaddr;
  +
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       
       if (!strcmp(addr, APR_ANYADDR)) {
           sock->local_addr->sin_addr.s_addr = htonl(INADDR_ANY);
  @@ -101,6 +117,10 @@
   ap_status_t ap_set_remote_ipaddr(struct socket_t *sock, const char *addr)
   {
       u_long ipaddr;
  +
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
       
       if (!strcmp(addr, APR_ANYADDR)) {
           sock->remote_addr->sin_addr.s_addr = htonl(INADDR_ANY);
  @@ -119,12 +139,20 @@
   
   ap_status_t ap_get_local_ipaddr(char **addr, const struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
  +
       *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->local_addr->sin_addr));
       return APR_SUCCESS;
   }
   
   ap_status_t ap_get_remote_ipaddr(char **addr, const struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
  +
       *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->remote_addr->sin_addr));
       return APR_SUCCESS;
   }
  @@ -132,12 +160,20 @@
   
   ap_status_t ap_get_local_name(struct sockaddr_in **name, const struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
  +
       *name = sock->local_addr;
       return APR_SUCCESS;
   }
   
   ap_status_t ap_get_remote_name(struct sockaddr_in **name, const struct socket_t *sock)
   {
  +    if (!sock) {
  +        return APR_EBADF;
  +    }
  +
       *name = sock->remote_addr;
       return APR_SUCCESS;
   }
  
  
  
  1.18      +7 -8      apache-2.0/src/lib/apr/network_io/beos/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockets.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- sockets.c	2000/03/10 00:06:24	1.17
  +++ sockets.c	2000/03/11 14:11:36	1.18
  @@ -89,6 +89,7 @@
   	(*new)->remote_addr->sin_family = AF_INET; 
       (*new)->addr_len = sizeof(*(*new)->local_addr);
   	memset(&(*new)->local_addr->sin_zero, 0, sizeof((*new)->local_addr->sin_zero));
  +	memset(&(*new)->remote_addr->sin_zero, 0, sizeof((*new)->remote_addr->sin_zero));
   
       if ((*new)->socketdes < 0) {
           return errno;
  @@ -102,12 +103,7 @@
   
   ap_status_t ap_shutdown(struct socket_t *thesocket, ap_shutdown_how_e how)
   {
  -    if (shutdown(thesocket->socketdes, how) == 0) {
  -        return APR_SUCCESS;
  -    }
  -    else {
  -        return errno;
  -    }
  +    return APR_SUCCESS;
   }
   
   ap_status_t ap_close_socket(struct socket_t *thesocket)
  @@ -140,16 +136,19 @@
       (*new)->cntxt = connection_context;
       (*new)->local_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, 
                    sizeof(struct sockaddr_in));
  -    memcpy((*new)->local_addr, sock->local_addr, sizeof(struct sockaddr_in));
   
       (*new)->remote_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, 
                    sizeof(struct sockaddr_in));
       (*new)->addr_len = sizeof(struct sockaddr_in);
       (*new)->connected = 1;
       
  -    (*new)->socketdes = accept(sock->socketdes, (struct sockaddr *)(*new)->local_addr,
  +    (*new)->socketdes = accept(sock->socketdes, (struct sockaddr *)(*new)->remote_addr,
                           &(*new)->addr_len);
   
  +    if (getsockname((*new)->socketdes, (struct sockaddr *)(*new)->local_addr,
  +         &((*new)->addr_len)) < 0) {
  +        return errno;
  +    }
   	if ((*new)->socketdes <0){
   		return errno;
   	}
  
  
  

Mime
View raw message