rbb 99/09/03 17:21:16
Modified: src/lib/apr/include apr_errno.h apr_network_io.h
src/lib/apr/network_io/unix sockets.c sockopt.c
Log:
A couple of new features for APR. And a few doc changes for APR.
Revision Changes Path
1.2 +8 -0 apache-2.0/src/lib/apr/include/apr_errno.h
Index: apr_errno.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_errno.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apr_errno.h 1999/08/17 15:59:37 1.1
+++ apr_errno.h 1999/09/04 00:21:15 1.2
@@ -413,6 +413,14 @@
#define APR_BADARG 5013
#define APR_EOF 5014
#define APR_NOTFOUND 5015
+#define APR_EINIT 5016 /* A simple value to be used to initialze a
+ * status variable.
+ */
+#define APR_ENOTIMPL 5017 /* Not implemented either because we
haven't
+ * gotten to it yet, or because it is not
+ * possible to do correctly.
+ */
+
#ifdef __cplusplus
}
#endif
1.4 +6 -0 apache-2.0/src/lib/apr/include/apr_network_io.h
Index: apr_network_io.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- apr_network_io.h 1999/09/03 14:20:22 1.3
+++ apr_network_io.h 1999/09/04 00:21:15 1.4
@@ -76,6 +76,10 @@
#define APRMAXHOSTLEN 256
#endif
+#ifndef APR_ANYADDR
+#define APR_ANYADDR "ANY_IPADDR"
+#endif
+
/* Socket option definitions */
#define APR_SO_LINGER 1
#define APR_SO_KEEPALIVE 2
@@ -83,6 +87,7 @@
#define APR_SO_NONBLOCK 8
#define APR_SO_REUSEADDR 16
#define APR_SO_TIMEOUT 32
+#define APR_SO_SNDBUF 64
#define APR_POLLIN 0x001
#define APR_POLLPRI 0x002
@@ -120,6 +125,7 @@
ap_status_t ap_setport(ap_socket_t *, ap_uint32_t);
ap_status_t ap_setipaddr(ap_socket_t *, const char *);
ap_status_t ap_getport(ap_socket_t *, ap_uint32_t *);
+ap_status_t ap_getipaddr(ap_socket_t *, char **);
ap_status_t ap_setup_poll(ap_context_t *, ap_int32_t, ap_pollfd_t **);
ap_status_t ap_poll(ap_pollfd_t *, ap_int32_t *, ap_int32_t);
1.4 +21 -2 apache-2.0/src/lib/apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sockets.c 1999/09/03 14:33:11 1.3
+++ sockets.c 1999/09/04 00:21:16 1.4
@@ -63,6 +63,7 @@
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <netdb.h>
ap_status_t socket_cleanup(void *sock)
@@ -174,18 +175,36 @@
}
/* ***APRDOC********************************************************
- * ap_status_t ap_setipaddr(ap_socket_t *, apr_uint32_t addr)
+ * ap_status_t ap_setipaddr(ap_socket_t *, cont char *addr)
* Assocaite a socket addr with an apr socket.
* arg 1) The socket to use
* arg 2) The IP address to attach to the socket.
+ * Use APR_ANYADDR to use any IP addr on the machine.
* NOTE: This does not bind the two together, it is just telling apr
* that this socket is going to use this address if possible.
*/
ap_status_t ap_setipaddr(struct socket_t *sock, const char *addr)
{
- if (inet_aton(addr, &sock->addr->sin_addr.s_addr) == 0) {
+ if (!strcmp(addr, APR_ANYADDR)) {
+ sock->addr->sin_addr.s_addr = htonl(INADDR_ANY);
+ return APR_SUCCESS;
+ }
+ if (inet_aton(addr, &sock->addr->sin_addr) == 0) {
return errno;
}
+ return APR_SUCCESS;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_getipaddr(ap_socket_t *, char *addr)
+ * Return the IP address associated with an apr socket.
+ * arg 1) The socket to use
+ * arg 2) The IP address associated with the socket.
+ */
+ap_status_t ap_getipaddr(struct socket_t *sock, char **addr)
+{
+ char *temp = inet_ntoa(sock->addr->sin_addr);
+ strcpy(*addr, temp);
return APR_SUCCESS;
}
1.3 +6 -0 apache-2.0/src/lib/apr/network_io/unix/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sockopt.c 1999/09/03 14:20:23 1.2
+++ sockopt.c 1999/09/04 00:21:16 1.3
@@ -120,6 +120,7 @@
* supplied to bind should allow reuse
* of local addresses.
* APR_SO_TIMEOUT -- Set the timeout value in seconds.
+ * APR_SO_SNDBUF -- Set the SendBufferSize
* arg 3) Are we turning the option on or off.
*/
ap_status_t ap_setsocketopt(struct socket_t *sock, ap_int32_t opt,
ap_int32_t on)
@@ -145,6 +146,11 @@
}
if (opt & APR_SO_REUSEADDR) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void
*)&one, sizeof(int)) == -1) {
+ return errno;
+ }
+ }
+ if (opt & APR_SO_SNDBUF) {
+ if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on,
sizeof(int)) == -1) {
return errno;
}
}