ipv6 started pushing bits

ulab-next
Jay Sorg 12 years ago
parent 2d89ae1f38
commit cae3b1b0f1

@ -1,7 +1,7 @@
/** /**
* xrdp: A Remote Desktop Protocol server. * xrdp: A Remote Desktop Protocol server.
* *
* Copyright (C) Jay Sorg 2004-2012 * Copyright (C) Jay Sorg 2004-2013
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -427,29 +427,42 @@ g_tcp_set_keepalive(int sck)
/*****************************************************************************/ /*****************************************************************************/
/* returns a newly created socket or -1 on error */ /* returns a newly created socket or -1 on error */
/* in win32 a socket is an unsigned int, in linux, its an int */
int APP_CC int APP_CC
g_tcp_socket(void) g_tcp_socket(void)
{ {
#if defined(_WIN32)
int rv; int rv;
int option_value; int option_value;
#if defined(_WIN32)
int option_len; int option_len;
#else #else
int rv;
int option_value;
unsigned int option_len; unsigned int option_len;
#endif #endif
/* in win32 a socket is an unsigned int, in linux, its an int */ #if defined(XRDP_ENABLE_IPv6)
rv = (int)socket(PF_INET, SOCK_STREAM, 0); rv = (int)socket(AF_INET6, SOCK_STREAM, 0);
#else
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
#endif
if (rv < 0) if (rv < 0)
{ {
return -1; return -1;
} }
#if defined(XRDP_ENABLE_IPv6)
option_len = sizeof(option_value);
if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
&option_len) == 0)
{
if (option_value != 0)
{
option_value = 0;
option_len = sizeof(option_value);
setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
option_len);
}
}
#endif
option_len = sizeof(option_value); option_len = sizeof(option_value);
if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value, if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value,
&option_len) == 0) &option_len) == 0)
{ {
@ -495,16 +508,17 @@ void APP_CC
g_tcp_close(int sck) g_tcp_close(int sck)
{ {
char ip[256]; char ip[256];
if (sck == 0) if (sck == 0)
{ {
return; return;
} }
#if defined(_WIN32) #if defined(_WIN32)
closesocket(sck); closesocket(sck);
#else #else
g_write_ip_address(sck, ip, 255); g_write_ip_address(sck, ip, 255);
log_message(LOG_LEVEL_INFO,"An established connection closed to endpoint: %s", ip); log_message(LOG_LEVEL_INFO, "An established connection closed to "
"endpoint: %s", ip);
close(sck); close(sck);
#endif #endif
} }

Loading…
Cancel
Save