📄 apr_network_io.h
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */#ifndef APR_NETWORK_IO_H#define APR_NETWORK_IO_H/** * @package APR Network library */#include "apr.h"#include "apr_pools.h"#include "apr_file_io.h"#include "apr_errno.h"#if APR_HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef __cplusplusextern "C" {#endif /* __cplusplus */#ifndef MAX_SECS_TO_LINGER#define MAX_SECS_TO_LINGER 30#endif#ifndef APRMAXHOSTLEN#define APRMAXHOSTLEN 256#endif#ifndef APR_ANYADDR#define APR_ANYADDR "0.0.0.0"#endif/* Socket option definitions */#define APR_SO_LINGER 1#define APR_SO_KEEPALIVE 2#define APR_SO_DEBUG 4#define APR_SO_NONBLOCK 8#define APR_SO_REUSEADDR 16#define APR_SO_TIMEOUT 32#define APR_SO_SNDBUF 64#define APR_SO_RCVBUF 128#define APR_SO_DISCONNECTED 256#define APR_TCP_NODELAY 512#define APR_TCP_NOPUSH 1024#define APR_RESET_NODELAY 2048 /* This flag is ONLY set internally * when we set APR_TCP_NOPUSH with * APR_TCP_NODELAY set to tell us that * APR_TCP_NODELAY should be turned on * again when NOPUSH is turned off */#define APR_POLLIN 0x001 #define APR_POLLPRI 0x002#define APR_POLLOUT 0x004#define APR_POLLERR 0x010#define APR_POLLHUP 0x020#define APR_POLLNVAL 0x040typedef enum {APR_SHUTDOWN_READ, APR_SHUTDOWN_WRITE, APR_SHUTDOWN_READWRITE} apr_shutdown_how_e;/* We need to make sure we always have an in_addr type, so APR will just * define it ourselves, if the platform doesn't provide it. */#if (!APR_HAVE_IN_ADDR)struct in_addr { apr_uint32_t s_addr;}#endif/* Not all platforms have these defined, so we'll define them here * The default values come from FreeBSD 4.1.1 */#define APR_INET AF_INET#ifdef AF_UNSPEC#define APR_UNSPEC AF_UNSPEC#else#define APR_UNSPEC 0#endif#if APR_HAVE_IPV6#define APR_INET6 AF_INET6#endif/* Enum to tell us if we're interested in remote or local socket */typedef enum { APR_LOCAL, APR_REMOTE} apr_interface_e;/* I guess not everybody uses inet_addr. This defines apr_inet_addr * appropriately. */#if APR_HAVE_INET_ADDR#define apr_inet_addr inet_addr#elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know *//* not generally safe... inet_network() and inet_addr() perform * different functions */#define apr_inet_addr inet_network#endiftypedef struct apr_socket_t apr_socket_t;typedef struct apr_pollfd_t apr_pollfd_t;typedef struct apr_hdtr_t apr_hdtr_t;typedef struct in_addr apr_in_addr_t;/* use apr_uint16_t just in case some system has a short that isn't 16 bits... */typedef apr_uint16_t apr_port_t;/* It's defined here as I think it should all be platform safe... */typedef struct apr_sockaddr_t apr_sockaddr_t;/** * APRs socket address type, used to ensure protocol independence */struct apr_sockaddr_t { /** The pool to use... */ apr_pool_t *pool; /** The hostname */ char *hostname; /** Either a string of the port number or the service name for the port */ char *servname; /** The numeric port */ apr_port_t port; union { /** IPv4 sockaddr structure */ struct sockaddr_in sin;#if APR_HAVE_IPV6 /** IPv6 sockaddr structure */ struct sockaddr_in6 sin6;#endif } sa; /** How big is the sockaddr we're using? */ apr_socklen_t salen; /** How big is the ip address structure we're using? */ int ipaddr_len; /** How big should the address buffer be? 16 for v4 or 46 for v6 * used in inet_ntop... */ int addr_str_len; /** This points to the IP address structure within the appropriate * sockaddr structure. */ void *ipaddr_ptr; /** If multiple addresses were found by apr_sockaddr_info_get(), this * points to a representation of the next address. */ apr_sockaddr_t *next;};#if APR_HAS_SENDFILE/* Define flags passed in on apr_sendfile() */#define APR_SENDFILE_DISCONNECT_SOCKET 1#endif/** A structure to encapsulate headers and trailers for apr_sendfile */struct apr_hdtr_t { /** An iovec to store the headers sent before the file. * @defvar iovec *headers */ struct iovec* headers; /** number of headers in the iovec */ int numheaders; /** An iovec to store the trailers sent before the file. * @defvar iovec *trailers */ struct iovec* trailers; /** number of trailers in the iovec */ int numtrailers;};/** A structure to represent an IP subnet */typedef struct apr_ipsubnet_t apr_ipsubnet_t;struct apr_ipsubnet_t { int family;#if APR_HAVE_IPV6 apr_uint32_t sub[4]; /* big enough for IPv4 and IPv6 addresses */ apr_uint32_t mask[4];#else apr_uint32_t sub[1]; apr_uint32_t mask[1];#endif};/* function definitions *//** * Create a socket. * @param new_sock The new socket that has been set up. * @param family The address family of the socket (e.g., APR_INET). * @param type The type of the socket (e.g., SOCK_STREAM). * @param cont The pool to use * @deffunc apr_status_t apr_socket_create(apr_socket_t **new_sock, int family, int type, apr_pool_t *cont) */APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, int family, int type, apr_pool_t *cont);/** * Shutdown either reading, writing, or both sides of a tcp socket. * @param thesocket The socket to close * @param how How to shutdown the socket. One of: * <PRE> * APR_SHUTDOWN_READ no longer allow read requests * APR_SHUTDOWN_WRITE no longer allow write requests * APR_SHUTDOWN_READWRITE no longer allow read or write requests * </PRE> * @deffunc apr_status_t apr_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how) * @tip This does not actually close the socket descriptor, it just * controls which calls are still valid on the socket. */APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how);/** * Close a tcp socket. * @param thesocket The socket to close
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -