libwebsockets
Lightweight C library for HTML5 websockets
lws-adopt.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010-2018 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 
33 
47 LWS_VISIBLE LWS_EXTERN struct lws *
48 lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd);
62 LWS_VISIBLE LWS_EXTERN struct lws *
63 lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd);
64 
65 typedef enum {
66  LWS_ADOPT_RAW_FILE_DESC = 0, /* convenience constant */
67  LWS_ADOPT_HTTP = 1, /* flag: absent implies RAW */
68  LWS_ADOPT_SOCKET = 2, /* flag: absent implies file descr */
69  LWS_ADOPT_ALLOW_SSL = 4, /* flag: if set requires LWS_ADOPT_SOCKET */
70  LWS_ADOPT_FLAG_UDP = 16, /* flag: socket is UDP */
71  LWS_ADOPT_FLAG_RAW_PROXY = 32, /* flag: raw proxy */
72 
73  LWS_ADOPT_RAW_SOCKET_UDP = LWS_ADOPT_SOCKET | LWS_ADOPT_FLAG_UDP,
74 } lws_adoption_type;
75 
76 typedef union {
77  lws_sockfd_type sockfd;
78  lws_filefd_type filefd;
80 
81 #if !defined(LWS_WITH_ESP32) && !defined(LWS_PLAT_OPTEE)
82 struct lws_udp {
83  struct sockaddr sa;
84  socklen_t salen;
85 
86  struct sockaddr sa_pending;
87  socklen_t salen_pending;
88 };
89 #endif
90 
110 LWS_VISIBLE LWS_EXTERN struct lws *
111 lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
112  lws_sock_file_fd_type fd, const char *vh_prot_name,
113  struct lws *parent);
114 
138 LWS_VISIBLE LWS_EXTERN struct lws *
139 lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
140  const char *readbuf, size_t len);
163 LWS_VISIBLE LWS_EXTERN struct lws *
164 lws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost,
165  lws_sockfd_type accept_fd, const char *readbuf,
166  size_t len);
167 
168 #define LWS_CAUDP_BIND 1
169 
182 LWS_VISIBLE LWS_EXTERN struct lws *
183 lws_create_adopt_udp(struct lws_vhost *vhost, int port, int flags,
184  const char *protocol_name, struct lws *parent_wsi);
LWS_VISIBLE LWS_EXTERN struct lws * lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd)
LWS_VISIBLE LWS_EXTERN struct lws * lws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost, lws_sockfd_type accept_fd, const char *readbuf, size_t len)
LWS_VISIBLE LWS_EXTERN struct lws * lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, const char *readbuf, size_t len)
LWS_VISIBLE LWS_EXTERN struct lws * lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
LWS_VISIBLE LWS_EXTERN struct lws * lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type, lws_sock_file_fd_type fd, const char *vh_prot_name, struct lws *parent)
LWS_VISIBLE LWS_EXTERN struct lws * lws_create_adopt_udp(struct lws_vhost *vhost, int port, int flags, const char *protocol_name, struct lws *parent_wsi)
Definition: lws-adopt.h:82
Definition: lws-adopt.h:76