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 - 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 
33 
48 LWS_VISIBLE LWS_EXTERN struct lws *
49 lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd);
63 LWS_VISIBLE LWS_EXTERN struct lws *
64 lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd);
65 
66 typedef enum {
67  LWS_ADOPT_RAW_FILE_DESC = 0, /* convenience constant */
68  LWS_ADOPT_HTTP = 1, /* flag: absent implies RAW */
69  LWS_ADOPT_SOCKET = 2, /* flag: absent implies file descr */
70  LWS_ADOPT_ALLOW_SSL = 4, /* flag: if set requires LWS_ADOPT_SOCKET */
71  LWS_ADOPT_FLAG_UDP = 16, /* flag: socket is UDP */
72  LWS_ADOPT_FLAG_RAW_PROXY = 32, /* flag: raw proxy */
73 
74  LWS_ADOPT_RAW_SOCKET_UDP = LWS_ADOPT_SOCKET | LWS_ADOPT_FLAG_UDP,
75 } lws_adoption_type;
76 
77 typedef union {
78  lws_sockfd_type sockfd;
79  lws_filefd_type filefd;
81 
82 #if !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_OPTEE)
83 struct lws_udp {
84  struct sockaddr sa;
85  socklen_t salen;
86 
87  struct sockaddr sa_pending;
88  socklen_t salen_pending;
89 };
90 #endif
91 
111 LWS_VISIBLE LWS_EXTERN struct lws *
112 lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
113  lws_sock_file_fd_type fd, const char *vh_prot_name,
114  struct lws *parent);
115 
139 LWS_VISIBLE LWS_EXTERN struct lws *
140 lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
141  const char *readbuf, size_t len);
165 LWS_VISIBLE LWS_EXTERN struct lws *
166 lws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost,
167  lws_sockfd_type accept_fd, const char *readbuf,
168  size_t len);
169 
170 #define LWS_CAUDP_BIND 1
171 
185 LWS_VISIBLE LWS_EXTERN struct lws *
186 lws_create_adopt_udp(struct lws_vhost *vhost, const char *ads, int port,
187  int flags, const char *protocol_name,
188  struct lws *parent_wsi);
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)
Definition: lws-adopt.h:77
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(struct lws_context *context, lws_sockfd_type accept_fd)
LWS_VISIBLE LWS_EXTERN struct lws * lws_create_adopt_udp(struct lws_vhost *vhost, const char *ads, int port, int flags, const char *protocol_name, struct lws *parent_wsi)
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)
Definition: lws-adopt.h:83
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)