blob: cd54ec8ee0ff63ff07eb39e7593f9164a265a10b [file] [log] [blame]
Willy Tarreaudd815982007-10-16 12:25:14 +02001/*
2 include/proto/protocols.h
3 This file declares generic protocol primitives.
4
5 Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _PROTO_PROTOCOLS_H
23#define _PROTO_PROTOCOLS_H
24
25#include <types/protocols.h>
26
Willy Tarreaudabf2e22007-10-28 21:59:24 +010027/* This function adds the specified listener's file descriptor to the polling
28 * lists if it is in the LI_LISTEN state. The listener enters LI_READY or
29 * LI_FULL state depending on its number of connections.
30 */
31void enable_listener(struct listener *listener);
32
33/* This function removes the specified listener's file descriptor from the
34 * polling lists if it is in the LI_READY or in the LI_FULL state. The listener
35 * enters LI_LISTEN.
36 */
37void disable_listener(struct listener *listener);
38
39/* This function adds all of the protocol's listener's file descriptors to the
40 * polling lists when they are in the LI_LISTEN state. It is intended to be
41 * used as a protocol's generic enable_all() primitive, for use after the
42 * fork(). It puts the listeners into LI_READY or LI_FULL states depending on
43 * their number of connections. It always returns ERR_NONE.
44 */
45int enable_all_listeners(struct protocol *proto);
46
47/* This function removes all of the protocol's listener's file descriptors from
48 * the polling lists when they are in the LI_READY or LI_FULL states. It is
49 * intended to be used as a protocol's generic disable_all() primitive. It puts
50 * the listeners into LI_LISTEN, and always returns ERR_NONE.
51 */
52int disable_all_listeners(struct protocol *proto);
53
Willy Tarreaub648d632007-10-28 22:13:50 +010054/* This function closes the listening socket for the specified listener,
55 * provided that it's already in a listening state. The listener enters the
56 * LI_ASSIGNED state. It always returns ERR_NONE. This function is intended
57 * to be used as a generic function for standard protocols.
58 */
59int unbind_listener(struct listener *listener);
60
Willy Tarreau3acf8c32007-10-28 22:35:41 +010061/* This function closes all listening sockets bound to the protocol <proto>,
62 * and the listeners end in LI_ASSIGNED state if they were higher. It does not
63 * detach them from the protocol. It always returns ERR_NONE.
64 */
65int unbind_all_listeners(struct protocol *proto);
66
Willy Tarreau1a64d162007-10-28 22:26:05 +010067/* Delete a listener from its protocol's list of listeners. The listener's
68 * state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's
69 * number of listeners is updated. Note that the listener must have previously
70 * been unbound. This is the generic function to use to remove a listener.
71 */
72void delete_listener(struct listener *listener);
73
Willy Tarreaudd815982007-10-16 12:25:14 +020074/* Registers the protocol <proto> */
75void protocol_register(struct protocol *proto);
76
77/* Unregisters the protocol <proto>. Note that all listeners must have
78 * previously been unbound.
79 */
80void protocol_unregister(struct protocol *proto);
81
82/* binds all listeneres of all registered protocols. Returns a composition
83 * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
84 */
85int protocol_bind_all(void);
86
87/* unbinds all listeners of all registered protocols. They are also closed.
88 * This must be performed before calling exit() in order to get a chance to
89 * remove file-system based sockets and pipes.
90 * Returns a composition of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
91 */
92int protocol_unbind_all(void);
93
94/* enables all listeners of all registered protocols. This is intended to be
95 * used after a fork() to enable reading on all file descriptors. Returns a
96 * composition of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
97 */
98int protocol_enable_all(void);
99
100
101#endif /* _PROTO_PROTOCOLS_H */
102
103/*
104 * Local variables:
105 * c-indent-level: 8
106 * c-basic-offset: 8
107 * End:
108 */