2 * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010 - 2018 Andy Green <andy@warmcat.com>
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.
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.
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,
21 * Included from lib/core/private.h if no explicit platform
28 #include <netinet/in.h>
29 #include <netinet/tcp.h>
30 #include <arpa/inet.h>
40 #include <sys/socket.h>
41 #include <sys/types.h>
47 #if defined(__APPLE__)
48 #include <machine/endian.h>
50 #if defined(__FreeBSD__)
51 #include <sys/endian.h>
53 #if defined(__linux__)
58 #if defined(__LITTLEENDIAN__)
59 #define BYTE_ORDER __LITTLEENDIAN__
60 #define LITTLE_ENDIAN __LITTLEENDIAN__
61 #define BIG_ENDIAN 4321 /* to show byte order (taken from gcc); for suppres warning that BIG_ENDIAN is not defined. */
63 #if defined(__BIGENDIAN__)
64 #define BYTE_ORDER __BIGENDIAN__
65 #define LITTLE_ENDIAN 1234 /* to show byte order (taken from gcc); for suppres warning that LITTLE_ENDIAN is not defined. */
66 #define BIG_ENDIAN __BIGENDIAN__
70 #if defined(__sun) && defined(__GNUC__)
72 #include <arpa/nameser_compat.h>
74 #if !defined (BYTE_ORDER)
75 #define BYTE_ORDER __BYTE_ORDER__
78 #if !defined(LITTLE_ENDIAN)
79 #define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
82 #if !defined(BIG_ENDIAN)
83 #define BIG_ENDIAN __ORDER_BIG_ENDIAN__
86 #endif /* sun + GNUC */
88 #if !defined(BYTE_ORDER)
89 #define BYTE_ORDER __BYTE_ORDER
91 #if !defined(LITTLE_ENDIAN)
92 #define LITTLE_ENDIAN __LITTLE_ENDIAN
94 #if !defined(BIG_ENDIAN)
95 #define BIG_ENDIAN __BIG_ENDIAN
98 #if defined(LWS_BUILTIN_GETIFADDRS)
99 #include "./misc/getifaddrs.h"
102 #if defined(__HAIKU__)
109 #if defined (__sun) || defined(__HAIKU__) || defined(__QNX__) || defined(__ANDROID__)
112 #if defined(__ANDROID__)
113 #include <sys/resource.h>
117 #include <sys/syslog.h>
121 # include "netinet/tcp_var.h"
122 # define TCP_KEEPINTVL TCPCTL_KEEPINTVL
123 # define TCP_KEEPIDLE TCPCTL_KEEPIDLE
124 # define TCP_KEEPCNT TCPCTL_KEEPCNT
127 #define LWS_ERRNO errno
128 #define LWS_EAGAIN EAGAIN
129 #define LWS_EALREADY EALREADY
130 #define LWS_EINPROGRESS EINPROGRESS
131 #define LWS_EINTR EINTR
132 #define LWS_EISCONN EISCONN
133 #define LWS_ENOTCONN ENOTCONN
134 #define LWS_EWOULDBLOCK EWOULDBLOCK
135 #define LWS_EADDRINUSE EADDRINUSE
136 #define lws_set_blocking_send(wsi)
137 #define LWS_SOCK_INVALID (-1)
142 wsi_from_fd(const struct lws_context *context, int fd);
145 insert_wsi(const struct lws_context *context, struct lws *wsi);
148 delete_from_fd(const struct lws_context *context, int fd);
151 #ifdef LWS_HAVE_SYS_PRCTL_H
152 #include <sys/prctl.h>
156 #define compatible_close(x) close(x)
157 #define lws_plat_socket_offset() (0)
160 * Mac OSX as well as iOS do not define the MSG_NOSIGNAL flag,
161 * but happily have something equivalent in the SO_NOSIGPIPE flag.
164 #define MSG_NOSIGNAL SO_NOSIGPIPE
168 * Solaris 11.X only supports POSIX 2001, MSG_NOSIGNAL appears in
171 #if defined(__sun) && !defined(__smartos__)
172 #define MSG_NOSIGNAL 0