mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ipv6 use lws_plat_ to avoid win naming collision
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
5266f66f50
commit
1cd3ba6fdc
3 changed files with 17 additions and 8 deletions
|
@ -50,6 +50,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms);
|
|||
int lws_plat_init_fd_tables(struct libwebsocket_context *context);
|
||||
void lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
|
||||
unsigned long long time_in_microseconds(void);
|
||||
const char *lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt);
|
||||
|
||||
#ifdef LWS_USE_LIBEV
|
||||
#define _LWS_EV_TAG " libev"
|
||||
|
@ -503,15 +504,14 @@ libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
|
|||
goto bail;
|
||||
}
|
||||
|
||||
if (inet_ntop(AF_INET6, &sin6.sin6_addr, rip, rip_len) == NULL) {
|
||||
perror("inet_ntop");
|
||||
if (!lws_plat_inet_ntop(AF_INET6, &sin6.sin6_addr, rip, rip_len)) {
|
||||
lwsl_err("inet_ntop", strerror(LWS_ERRNO));
|
||||
goto bail;
|
||||
}
|
||||
|
||||
// Strip off the IPv4 to IPv6 header if one exists
|
||||
if (strncmp(rip, "::ffff:", 7) == 0) {
|
||||
if (strncmp(rip, "::ffff:", 7) == 0)
|
||||
memmove(rip, rip + 7, strlen(rip) - 6);
|
||||
}
|
||||
|
||||
getnameinfo((struct sockaddr *)&sin6,
|
||||
sizeof(struct sockaddr_in6), name,
|
||||
|
|
|
@ -476,4 +476,11 @@ lws_plat_open_file(const char* filename, unsigned long* filelen)
|
|||
fstat(ret, &stat_buf);
|
||||
*filelen = stat_buf.st_size;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#ifdef LWS_USE_IPV6
|
||||
LWS_VISIBLE const char *
|
||||
lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
|
||||
{
|
||||
return inet_ntop(af, src, dst, cnt);
|
||||
}
|
||||
#endif
|
|
@ -310,14 +310,15 @@ lws_plat_open_file(const char* filename, unsigned long* filelen)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef LWS_USE_IPV6
|
||||
/*
|
||||
* Windows doesn't have an "inet_top"
|
||||
* This came from http://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/
|
||||
* suggested by Joakim Soderberg
|
||||
*/
|
||||
|
||||
LWS_VISIBLE
|
||||
const char *inet_ntop(int af, const void *src, char *dst, int cnt)
|
||||
LWS_VISIBLE const char *
|
||||
lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
|
||||
{
|
||||
struct sockaddr_in srcaddr;
|
||||
DWORD rv;
|
||||
|
@ -334,4 +335,5 @@ const char *inet_ntop(int af, const void *src, char *dst, int cnt)
|
|||
lwsl_err("WSAAddressToString() : %d\n",rv);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Add table
Reference in a new issue