]> granicus.if.org Git - apache/blob - include/ap_listen.h
update transformation
[apache] / include / ap_listen.h
1 /* Copyright 1999-2004 The Apache Software Foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef AP_LISTEN_H
17 #define AP_LISTEN_H
18
19 #include "apr_network_io.h"
20 #include "httpd.h"
21 #include "http_config.h"
22
23 /**
24  * @package Apache Listeners Library
25  */
26
27 typedef struct ap_listen_rec ap_listen_rec;
28 typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
29
30 /**
31  * Apache's listeners record.  These are used in the Multi-Processing Modules
32  * to setup all of the sockets for the MPM to listen to and accept on.
33  */
34 struct ap_listen_rec {
35     /**
36      * The next listener in the list
37      */
38     ap_listen_rec *next;
39     /**
40      * The actual socket 
41      */
42     apr_socket_t *sd;
43     /**
44      * The sockaddr the socket should bind to
45      */
46     apr_sockaddr_t *bind_addr;
47     /**
48      * The accept function for this socket
49      */
50     accept_function accept_func;
51     /**
52      * Is this socket currently active 
53      */
54     int active;
55 /* more stuff here, like which protocol is bound to the port */
56 };
57
58 /**
59  * The global list of ap_listen_rec structures
60  */
61 AP_DECLARE_DATA extern ap_listen_rec *ap_listeners;
62
63 /**
64  * Setup all of the defaults for the listener list
65  */
66 void ap_listen_pre_config(void);
67 #if !defined(SPMT_OS2_MPM)
68 /**
69  * Loop through the global ap_listen_rec list and create all of the required
70  * sockets.  This executes the listen and bind on the sockets.
71  * @param s The global server_rec
72  * @return The number of open sockets.
73  * @warning This function is not available to Windows platforms, or the
74  * Prefork or SPMT_OS2 MPMs.
75  */ 
76 int ap_setup_listeners(server_rec *s);
77 #endif
78 /* Split into two #if's to make the exports scripts easier.
79  */
80 #if defined(SPMT_OS2_MPM)
81 /**
82  * Create and open a socket on the specified port.  This includes listening
83  * and binding the socket.
84  * @param process The process record for the currently running server
85  * @param port The port to open a socket on.
86  * @return The number of open sockets
87  * @warning This function is only available to Windows platforms, or the
88  * Prefork or SPMT_OS2 MPMs.
89  */
90 int ap_listen_open(process_rec *process, apr_port_t port);
91 #endif
92
93 /* Although these functions are exported from libmain, they are not really
94  * public functions.  These functions are actually called while parsing the
95  * config file, when one of the LISTEN_COMMANDS directives is read.  These
96  * should not ever be called by external modules.  ALL MPMs should include
97  * LISTEN_COMMANDS in their command_rec table so that these functions are
98  * called.
99  */ 
100 const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
101 const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
102 const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
103                                     const char *arg);
104
105 #define LISTEN_COMMANDS \
106 AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
107   "Maximum length of the queue of pending connections, as used by listen(2)"), \
108 AP_INIT_TAKE1("Listen", ap_set_listener, NULL, RSRC_CONF, \
109   "A port number or a numeric IP address and a port number"), \
110 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
111   "Send buffer size in bytes")
112
113 #endif