• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Included from lib/private-lib-core.h if LWS_PLAT_FREERTOS
25  */
26 
27 #define SOMAXCONN 3
28 
29 #if defined(LWS_AMAZON_RTOS)
30  int
31  open(const char *path, int oflag, ...);
32 #else
33  #include <fcntl.h>
34 #endif
35 
36  #include <strings.h>
37  #include <unistd.h>
38  #include <sys/stat.h>
39  #include <sys/types.h>
40  #include <sys/time.h>
41  #include <netdb.h>
42 
43  #ifndef __cplusplus
44   #include <errno.h>
45  #endif
46  #include <netdb.h>
47  #include <signal.h>
48 #if defined(LWS_AMAZON_RTOS)
49 const char *
50 gai_strerror(int);
51 #else
52  #include <sys/socket.h>
53 #endif
54 
55 #if defined(LWS_AMAZON_RTOS)
56  #include "FreeRTOS.h"
57 #if defined(LWS_WITH_SYS_ASYNC_DNS)
58  #include "FreeRTOS_IP.h"
59 #endif
60  #include "timers.h"
61  #include <esp_attr.h>
62 #else
63  #include "freertos/timers.h"
64  #include <esp_attr.h>
65  #include <esp_system.h>
66  #include <esp_task_wdt.h>
67 #endif
68 
69 #if defined(LWS_WITH_ESP32)
70 #include "lwip/apps/sntp.h"
71 #endif
72 
73 #include <lwip/sockets.h>
74 
75  #if defined(LWS_BUILTIN_GETIFADDRS)
76   #include "./misc/getifaddrs.h"
77  #endif
78 
79  #define LWS_ERRNO errno
80  #define LWS_EAGAIN EAGAIN
81  #define LWS_EALREADY EALREADY
82  #define LWS_EINPROGRESS EINPROGRESS
83  #define LWS_EINTR EINTR
84  #define LWS_EISCONN EISCONN
85  #define LWS_ENOTCONN ENOTCONN
86  #define LWS_EWOULDBLOCK EWOULDBLOCK
87  #define LWS_EADDRINUSE EADDRINUSE
88 
89  #define lws_set_blocking_send(wsi)
90 
91  #ifndef LWS_NO_FORK
92   #ifdef LWS_HAVE_SYS_PRCTL_H
93    #include <sys/prctl.h>
94   #endif
95  #endif
96 
97 #if !defined(MSG_NOSIGNAL)
98 #define MSG_NOSIGNAL 0
99 #endif
100 
101 #define compatible_close(x) close(x)
102 #define lws_plat_socket_offset() LWIP_SOCKET_OFFSET
103 #define wsi_from_fd(A,B)  A->lws_lookup[B - lws_plat_socket_offset()]
104 
105 struct lws_context;
106 struct lws;
107 
108 int
109 insert_wsi(const struct lws_context *context, struct lws *wsi);
110 
111 #define delete_from_fd(A,B) A->lws_lookup[B - lws_plat_socket_offset()] = 0
112 
113