Imported Upstream version 3.2
[platform/upstream/libwebsockets.git] / include / libwebsockets / abstract / transports.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010-2019 Andy Green <andy@warmcat.com>
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public
8  *  License as published by the Free Software Foundation:
9  *  version 2.1 of the License.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  *  MA  02110-1301  USA
20  *
21  * included from libwebsockets.h
22  */
23
24 /*
25  * Abstract transport ops
26  */
27
28 typedef struct lws_abs_transport {
29         const char *name;
30         int alloc;
31
32         int (*create)(struct lws_abs *abs);
33         void (*destroy)(lws_abs_transport_inst_t **d);
34
35         /* events the abstract protocol invokes (handled by transport) */
36
37         int (*tx)(lws_abs_transport_inst_t *d, uint8_t *buf, size_t len);
38         int (*client_conn)(const lws_abs_t *abs);
39         int (*close)(lws_abs_transport_inst_t *d);
40         int (*ask_for_writeable)(lws_abs_transport_inst_t *d);
41         int (*set_timeout)(lws_abs_transport_inst_t *d, int reason, int secs);
42         int (*state)(lws_abs_transport_inst_t *d);
43 } lws_abs_transport_t;
44
45 /**
46  * lws_abs_protocol_get_by_name() - returns a pointer to the named protocol ops
47  *
48  * \param name: the name of the abstract protocol
49  *
50  * Returns a pointer to the named protocol ops struct if available, otherwise
51  * NULL.
52  */
53 LWS_VISIBLE LWS_EXTERN const lws_abs_transport_t *
54 lws_abs_transport_get_by_name(const char *name);
55
56 /*
57  * bring in public api pieces from transports
58  */
59
60 #include <libwebsockets/abstract/transports/raw-skt.h>
61 #include <libwebsockets/abstract/transports/unit-test.h>