1 /* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "apr_network_io.h"
22 #include "http_config.h"
25 * @package Apache Listeners Library
28 typedef struct ap_listen_rec ap_listen_rec;
29 typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
32 * Apache's listeners record. These are used in the Multi-Processing Modules
33 * to setup all of the sockets for the MPM to listen to and accept on.
35 struct ap_listen_rec {
37 * The next listener in the list
45 * The sockaddr the socket should bind to
47 apr_sockaddr_t *bind_addr;
49 * The accept function for this socket
51 accept_function accept_func;
53 * Is this socket currently active
57 * The default protocol for this listening socket.
63 * The global list of ap_listen_rec structures
65 AP_DECLARE_DATA extern ap_listen_rec *ap_listeners;
68 * Setup all of the defaults for the listener list
70 AP_DECLARE(void) ap_listen_pre_config(void);
73 * Loop through the global ap_listen_rec list and create all of the required
74 * sockets. This executes the listen and bind on the sockets.
75 * @param s The global server_rec
76 * @return The number of open sockets.
78 AP_DECLARE(int) ap_setup_listeners(server_rec *s);
81 * Loop through the global ap_listen_rec list and close each of the sockets.
83 AP_DECLARE_NONSTD(void) ap_close_listeners();
85 /* Although these functions are exported from libmain, they are not really
86 * public functions. These functions are actually called while parsing the
87 * config file, when one of the LISTEN_COMMANDS directives is read. These
88 * should not ever be called by external modules. ALL MPMs should include
89 * LISTEN_COMMANDS in their command_rec table so that these functions are
92 AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
93 AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
94 int argc, char *const argv[]);
95 AP_DECLARE_NONSTD(const char *) ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
97 AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
101 #define LISTEN_COMMANDS \
102 AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
103 "Maximum length of the queue of pending connections, as used by listen(2)"), \
104 AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \
105 "A port number or a numeric IP address and a port number, and an optional protocol"), \
106 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
107 "Send buffer size in bytes"), \
108 AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
109 RSRC_CONF, "Receive buffer size in bytes")