1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef NETWORK_IO_H 18#define NETWORK_IO_H 19 20#include "apr.h" 21#include "apr_private.h" 22#include "apr_network_io.h" 23#include "apr_errno.h" 24#include "apr_general.h" 25#include "apr_lib.h" 26#ifndef WAITIO_USES_POLL 27#include "apr_poll.h" 28#endif 29 30/* System headers the network I/O library needs */ 31#if APR_HAVE_SYS_TYPES_H 32#include <sys/types.h> 33#endif 34#if APR_HAVE_SYS_UIO_H 35#include <sys/uio.h> 36#endif 37#ifdef HAVE_SYS_SELECT_H 38#include <sys/select.h> 39#endif 40#if APR_HAVE_ERRNO_H 41#include <errno.h> 42#endif 43#if APR_HAVE_SYS_TIME_H 44#include <sys/time.h> 45#endif 46#if APR_HAVE_UNISTD_H 47#include <unistd.h> 48#endif 49#if APR_HAVE_STRING_H 50#include <string.h> 51#endif 52#if APR_HAVE_NETINET_TCP_H 53#include <netinet/tcp.h> 54#endif 55#if APR_HAVE_NETINET_SCTP_UIO_H 56#include <netinet/sctp_uio.h> 57#endif 58#if APR_HAVE_NETINET_SCTP_H 59#include <netinet/sctp.h> 60#endif 61#if APR_HAVE_NETINET_IN_H 62#include <netinet/in.h> 63#endif 64#if APR_HAVE_ARPA_INET_H 65#include <arpa/inet.h> 66#endif 67#if APR_HAVE_SYS_SOCKET_H 68#include <sys/socket.h> 69#endif 70#if APR_HAVE_SYS_SOCKIO_H 71#include <sys/sockio.h> 72#endif 73#if APR_HAVE_NETDB_H 74#include <netdb.h> 75#endif 76#if APR_HAVE_FCNTL_H 77#include <fcntl.h> 78#endif 79#if APR_HAVE_SYS_SENDFILE_H 80#include <sys/sendfile.h> 81#endif 82#if APR_HAVE_SYS_IOCTL_H 83#include <sys/ioctl.h> 84#endif 85/* End System Headers */ 86 87#ifndef HAVE_POLLIN 88#define POLLIN 1 89#define POLLPRI 2 90#define POLLOUT 4 91#define POLLERR 8 92#define POLLHUP 16 93#define POLLNVAL 32 94#endif 95 96typedef struct sock_userdata_t sock_userdata_t; 97struct sock_userdata_t { 98 sock_userdata_t *next; 99 const char *key; 100 void *data; 101}; 102 103struct apr_socket_t { 104 apr_pool_t *pool; 105 int socketdes; 106 int type; 107 int protocol; 108 apr_sockaddr_t *local_addr; 109 apr_sockaddr_t *remote_addr; 110 apr_interval_time_t timeout; 111#ifndef HAVE_POLL 112 int connected; 113#endif 114 int local_port_unknown; 115 int local_interface_unknown; 116 int remote_addr_unknown; 117 apr_int32_t options; 118 apr_int32_t inherit; 119 sock_userdata_t *userdata; 120#ifndef WAITIO_USES_POLL 121 /* if there is a timeout set, then this pollset is used */ 122 apr_pollset_t *pollset; 123#endif 124}; 125 126const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); 127int apr_inet_pton(int af, const char *src, void *dst); 128void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); 129 130#define apr_is_option_set(skt, option) \ 131 (((skt)->options & (option)) == (option)) 132 133#define apr_set_option(skt, option, on) \ 134 do { \ 135 if (on) \ 136 (skt)->options |= (option); \ 137 else \ 138 (skt)->options &= ~(option); \ 139 } while (0) 140 141#endif /* ! NETWORK_IO_H */ 142 143