1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25/*
26 * Information about how this protocol handles multiple use of connections.
27 *
28 * .flags of 0 indicates each connection must start with a fresh transport.
29 *
30 * Flags can be used to indicate the protocol itself supports different
31 * kinds of multiple use. However the actual use or not of these may depend on
32 * negotiation with the remote peer.
33 *
34 * LWS_AP_FLAG_PIPELINE_TRANSACTIONS: other instances can be queued on one
35 * with an existing connection and get a
36 * chance to "hot take over" the existing
37 * transport in turn, like h1 keepalive
38 * pipelining
39 *
40 * LWS_AP_FLAG_MUXABLE_STREAM: an existing connection can absorb more child
41 * connections and mux them as separate child
42 * streams ongoing, like h2
43 */
44
45enum {
46 LWS_AP_FLAG_PIPELINE_TRANSACTIONS = (1 << 0),
47 LWS_AP_FLAG_MUXABLE_STREAM = (1 << 1),
48};
49
50typedef struct lws_abs_protocol {
51 const char *name;
52 int alloc;
53 int flags;
54
55 int (*create)(const struct lws_abs *ai);
56 void (*destroy)(lws_abs_protocol_inst_t **d);
57 int (*compare)(lws_abs_t *abs1, lws_abs_t *abs2);
58
59 /* events the transport invokes (handled by abstract protocol) */
60
61 int (*accept)(lws_abs_protocol_inst_t *d);
62 int (*rx)(lws_abs_protocol_inst_t *d, const uint8_t *b, size_t l);
63 int (*writeable)(lws_abs_protocol_inst_t *d, size_t budget);
64 int (*closed)(lws_abs_protocol_inst_t *d);
65 int (*heartbeat)(lws_abs_protocol_inst_t *d);
66
67 /* as parent, we get a notification a new child / queue entry
68 * bound to us... this is the parent lws_abs_t as arg */
69 int (*child_bind)(lws_abs_t *abs);
70} lws_abs_protocol_t;
71
72/**
73 * lws_abs_protocol_get_by_name() - returns a pointer to the named protocol ops
74 *
75 * \param name: the name of the abstract protocol
76 *
77 * Returns a pointer to the named protocol ops struct if available, otherwise
78 * NULL.
79 */
80LWS_VISIBLE LWS_EXTERN const lws_abs_protocol_t *
81lws_abs_protocol_get_by_name(const char *name);
82
83/*
84 * bring in public api pieces from protocols
85 */
86
87#include <libwebsockets/abstract/protocols/smtp.h>
88
89