mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ipv6 integration fixes
Disable for build using -DLWS_IPV6= on the cmake line
This commit is contained in:
parent
3f13ea2264
commit
055f2979ec
6 changed files with 23 additions and 25 deletions
|
@ -40,7 +40,6 @@ option(LWS_USE_CYASSL "Use CyaSSL replacement for OpenSSL. When settings this, y
|
|||
option(LWS_WITHOUT_BUILTIN_GETIFADDRS "Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist." OFF)
|
||||
option(LWS_WITHOUT_CLIENT "Don't build the client part of the library" OFF)
|
||||
option(LWS_WITHOUT_SERVER "Don't build the server part of the library" OFF)
|
||||
#option(LWS_WITH_LIBCRYPTO "Use libcrypto MD5 and SHA1 implementations" ON)
|
||||
option(LWS_LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF)
|
||||
option(LWS_WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
|
||||
option(LWS_WITHOUT_TEST_SERVER "Don't build the test server" OFF)
|
||||
|
@ -53,7 +52,7 @@ option(LWS_WITHOUT_EXTENSIONS "Don't compile with extensions" OFF)
|
|||
option(LWS_WITH_LATENCY "Build latency measuring code into the library" OFF)
|
||||
option(LWS_WITHOUT_DAEMONIZE "Don't build the daemonization api" OFF)
|
||||
option(LWS_WITH_LIBEV "Compile with support for libev" OFF)
|
||||
option(LWS_WITHOUT_IPV6 "Compile without support for ipv6" OFF)
|
||||
option(LWS_IPV6 "Compile with support for ipv6" ON)
|
||||
|
||||
# Allow the user to override installation directories.
|
||||
set(LWS_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
|
||||
|
@ -122,9 +121,8 @@ if (LWS_WITH_LIBEV)
|
|||
set(LWS_NO_EXTERNAL_POLL 1)
|
||||
endif()
|
||||
|
||||
if (LWS_WITHOUT_IPV6)
|
||||
else()
|
||||
set(LWS_WITH_IPV6 1)
|
||||
if (LWS_IPV6)
|
||||
set(LWS_USE_IPV6 1)
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
|
@ -883,7 +881,7 @@ message(" LWS_WITHOUT_EXTENSIONS = ${LWS_WITHOUT_EXTENSIONS}")
|
|||
message(" LWS_WITH_LATENCY = ${LWS_WITH_LATENCY}")
|
||||
message(" LWS_WITHOUT_DAEMONIZE = ${LWS_WITHOUT_DAEMONIZE}")
|
||||
message(" LWS_USE_LIBEV = ${LWS_USE_LIBEV}")
|
||||
message(" LWS_WITH_IPV6 = ${LWS_WITH_IPV6}")
|
||||
message(" LWS_USE_IPV6 = ${LWS_USE_IPV6}")
|
||||
message("---------------------------------------------------------------------")
|
||||
|
||||
# These will be available to parent projects including libwebsockets using add_subdirectory()
|
||||
|
|
|
@ -45,7 +45,7 @@ use it, you must also set the LWS_SERVER_OPTION_LIBEV flag on the context
|
|||
creation info struct options member.
|
||||
|
||||
IPV6 is supported and enabled by default, you can disable the support at
|
||||
build-time by giving -DLWS_WITHOUT_IPV6, and disable use of it even if
|
||||
build-time by giving -DLWS_IPV6=, and disable use of it even if
|
||||
compiled in by making sure the flag LWS_SERVER_OPTION_DISABLE_IPV6 is set on
|
||||
the context creation info struct options member.
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#cmakedefine LWS_USE_LIBEV
|
||||
|
||||
/* Build with support for ipv6 */
|
||||
#cmakedefine LWS_WITH_IPV6
|
||||
#cmakedefine LWS_USE_IPV6
|
||||
|
||||
/* Turn on latency measuring code */
|
||||
#cmakedefine LWS_LATENCY
|
||||
|
|
|
@ -5,7 +5,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
struct libwebsocket *wsi
|
||||
) {
|
||||
struct pollfd pfd;
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
struct sockaddr_in6 server_addr6;
|
||||
struct sockaddr_in6 client_addr6;
|
||||
struct addrinfo hints, *result;
|
||||
|
@ -35,7 +35,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
wsi->u.hdr.ah->c_port);
|
||||
ads = context->http_proxy_address;
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context))
|
||||
server_addr6.sin6_port = htons(context->http_proxy_port);
|
||||
else
|
||||
|
@ -57,7 +57,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
*/
|
||||
lwsl_client("libwebsocket_client_connect_2: address %s\n", ads);
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
n = getaddrinfo(ads, NULL, &hints, &result);
|
||||
|
@ -106,7 +106,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
|
||||
if (wsi->sock < 0) {
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context))
|
||||
wsi->sock = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
else
|
||||
|
@ -131,7 +131,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
libwebsocket_set_timeout(wsi,
|
||||
PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE,
|
||||
AWAITING_TIMEOUT);
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
v = (struct sockaddr *)&client_addr6;
|
||||
n = sizeof(client_addr6);
|
||||
|
@ -164,7 +164,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
v = (struct sockaddr *)&server_addr6;
|
||||
n = sizeof(struct sockaddr_in6);
|
||||
|
|
|
@ -576,7 +576,7 @@ libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
|
|||
char *rip, int rip_len)
|
||||
{
|
||||
socklen_t len;
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
struct sockaddr_in6 sin6;
|
||||
#endif
|
||||
struct sockaddr_in sin4;
|
||||
|
@ -595,7 +595,7 @@ libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
|
|||
|
||||
lws_latency_pre(context, wsi);
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
|
||||
len = sizeof(sin6);
|
||||
|
@ -2083,7 +2083,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
|
|||
#ifndef LWS_NO_SERVER
|
||||
int opt = 1;
|
||||
struct libwebsocket *wsi;
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
struct sockaddr_in6 serv_addr6;
|
||||
#endif
|
||||
struct sockaddr_in serv_addr4;
|
||||
|
@ -2104,7 +2104,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
|
|||
|
||||
lwsl_notice("Initial logging level %d\n", log_level);
|
||||
lwsl_notice("Library version: %s\n", library_version);
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (!(info->options & LWS_SERVER_OPTION_DISABLE_IPV6))
|
||||
lwsl_notice("IPV6 compiled in and enabled\n");
|
||||
else
|
||||
|
@ -2580,7 +2580,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
|
|||
if (info->port != CONTEXT_PORT_NO_LISTEN) {
|
||||
int sockfd;
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context))
|
||||
sockfd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
else
|
||||
|
@ -2610,7 +2610,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
|
|||
fcntl(sockfd, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
v = (struct sockaddr *)&serv_addr6;
|
||||
n = sizeof(struct sockaddr_in6);
|
||||
|
@ -2935,7 +2935,7 @@ interface_to_sa(struct libwebsocket_context *context,
|
|||
#else
|
||||
struct ifaddrs *ifr;
|
||||
struct ifaddrs *ifc;
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
|
||||
#endif
|
||||
|
||||
|
@ -2951,7 +2951,7 @@ interface_to_sa(struct libwebsocket_context *context,
|
|||
|
||||
switch (ifc->ifa_addr->sa_family) {
|
||||
case AF_INET:
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
/* map IPv4 to IPv6 */
|
||||
bzero((char *)&addr6->sin6_addr,
|
||||
|
@ -2967,7 +2967,7 @@ interface_to_sa(struct libwebsocket_context *context,
|
|||
(struct sockaddr_in *)ifc->ifa_addr,
|
||||
sizeof(struct sockaddr_in));
|
||||
break;
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#ifdef LWS_USE_IPV6
|
||||
case AF_INET6:
|
||||
if (rc >= 0)
|
||||
break;
|
||||
|
|
|
@ -354,8 +354,8 @@ struct libwebsocket_context {
|
|||
#define LWS_LIBEV_ENABLED(context) (0)
|
||||
#endif
|
||||
|
||||
#ifdef LWS_WITH_IPV6
|
||||
#define LWS_IPV6_ENABLED(context) (context->options & LWS_SERVER_OPTION_DISABLE_IPV6)
|
||||
#ifdef LWS_USE_IPV6
|
||||
#define LWS_IPV6_ENABLED(context) (!(context->options & LWS_SERVER_OPTION_DISABLE_IPV6))
|
||||
#else
|
||||
#define LWS_IPV6_ENABLED(context) (0)
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue