blob: 1842faf167bb5145d035ad4d40479c735f6b5422 [file] [log] [blame]
Willy Tarreaud1d54542012-09-12 22:58:11 +02001/*
2 * include/proto/protocol.h
3 * This file declares generic protocol management primitives.
4 *
5 * Copyright (C) 2000-2012 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_PROTOCOL_H
23#define _PROTO_PROTOCOL_H
24
25#include <types/protocol.h>
26
27/* Registers the protocol <proto> */
28void protocol_register(struct protocol *proto);
29
30/* Unregisters the protocol <proto>. Note that all listeners must have
31 * previously been unbound.
32 */
33void protocol_unregister(struct protocol *proto);
34
35/* binds all listeneres of all registered protocols. Returns a composition
36 * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
37 */
38int protocol_bind_all(char *errmsg, int errlen);
39
40/* unbinds all listeners of all registered protocols. They are also closed.
41 * This must be performed before calling exit() in order to get a chance to
42 * remove file-system based sockets and pipes.
43 * Returns a composition of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
44 */
45int protocol_unbind_all(void);
46
47/* enables all listeners of all registered protocols. This is intended to be
48 * used after a fork() to enable reading on all file descriptors. Returns a
49 * composition of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
50 */
51int protocol_enable_all(void);
52
53/* returns the protocol associated to family <family> or NULL if not found */
54struct protocol *protocol_by_family(int family);
55
56#endif /* _PROTO_PROTOCOL_H */
57
58/*
59 * Local variables:
60 * c-indent-level: 8
61 * c-basic-offset: 8
62 * End:
63 */