|
From: <asf...@us...> - 2014-11-16 02:41:56
|
Revision: 60242
http://sourceforge.net/p/firebird/code/60242
Author: asfernandes
Date: 2014-11-16 02:41:47 +0000 (Sun, 16 Nov 2014)
Log Message:
-----------
Misc.
Modified Paths:
--------------
firebird/trunk/doc/README.IPv6
firebird/trunk/src/common/isc_file.cpp
firebird/trunk/src/remote/SockAddr.h
firebird/trunk/src/remote/inet.cpp
Modified: firebird/trunk/doc/README.IPv6
===================================================================
--- firebird/trunk/doc/README.IPv6 2014-11-15 10:16:48 UTC (rev 60241)
+++ firebird/trunk/doc/README.IPv6 2014-11-16 02:41:47 UTC (rev 60242)
@@ -39,4 +39,3 @@
the RemoteBindAddress, RemoteServicePort and RemoteServiceName directives as
the listening socket is set up by (x)inetd. Listening address and/or port need
to be set in (x)inetd configuration in this mode.
-
Modified: firebird/trunk/src/common/isc_file.cpp
===================================================================
--- firebird/trunk/src/common/isc_file.cpp 2014-11-15 10:16:48 UTC (rev 60241)
+++ firebird/trunk/src/common/isc_file.cpp 2014-11-16 02:41:47 UTC (rev 60242)
@@ -417,9 +417,8 @@
p = file_name.find(INET_FLAG, p + 1);
}
else
- {
p = file_name.find(INET_FLAG);
- }
+
if (p == npos || p == 0 || p == file_name.length() - 1)
return false;
Modified: firebird/trunk/src/remote/SockAddr.h
===================================================================
--- firebird/trunk/src/remote/SockAddr.h 2014-11-15 10:16:48 UTC (rev 60241)
+++ firebird/trunk/src/remote/SockAddr.h 2014-11-16 02:41:47 UTC (rev 60242)
@@ -31,9 +31,8 @@
#ifndef WIN_NT
#include <netinet/in.h>
-#endif
+#else
-#ifdef WIN_NT
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <Wspiapi.h>
@@ -47,7 +46,8 @@
#include "../remote/remote.h"
-class SockAddr {
+class SockAddr
+{
private:
static const unsigned maxLen = sizeof(struct sockaddr_in6);
char data[maxLen];
@@ -173,18 +173,22 @@
inline bool SockAddr::isLocalhost() const
{
const struct sockaddr* sa = (const struct sockaddr*) data;
- switch(sa->sa_family) {
- case AF_INET:
+
+ switch(sa->sa_family)
+ {
+ case AF_INET:
{
const struct sockaddr_in* sa4 = (const struct sockaddr_in*) data;
return ((ntohl(sa4->sin_addr.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET);
}
- case AF_INET6:
+
+ case AF_INET6:
{
const struct sockaddr_in6* sa6 = (const struct sockaddr_in6*) data;
return (memcmp(&sa6->sin6_addr, &in6addr_loopback, sizeof(in6_addr)) == 0);
}
}
+
return 0; // exception?
}
@@ -197,8 +201,8 @@
const struct sockaddr_in6* sa6 = (const struct sockaddr_in6*) data;
// IPv6 mapped IPv4 addresses are ::ffff:0:0/32
- static const unsigned char v4mapped_pfx[12]
- = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+ static const unsigned char v4mapped_pfx[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
+
if (memcmp(sa6->sin6_addr.s6_addr, v4mapped_pfx, sizeof(v4mapped_pfx)) != 0)
return;
Modified: firebird/trunk/src/remote/inet.cpp
===================================================================
--- firebird/trunk/src/remote/inet.cpp 2014-11-15 10:16:48 UTC (rev 60241)
+++ firebird/trunk/src/remote/inet.cpp 2014-11-16 02:41:47 UTC (rev 60242)
@@ -734,15 +734,17 @@
{
host = name;
const FB_SIZE_T pos = host.find("/");
+
if (pos != string::npos)
{
protocol = host.substr(pos + 1);
host = host.substr(0, pos);
}
- if (host.hasData() && host[0] == '[' && host[host.length()-1] == ']')
+
+ if (host.hasData() && host[0] == '[' && host[host.length() - 1] == ']')
{
// host name or address is in brackets, remove them
- host.erase(host.length()-1);
+ host.erase(host.length() - 1);
host.erase(0, 1);
}
}
@@ -775,22 +777,26 @@
memset(&gai_hints, 0, sizeof(gai_hints));
gai_hints.ai_family = (packet ? AF_UNSPEC : AF_INET6);
gai_hints.ai_socktype = SOCK_STREAM;
+
#ifndef WIN_NT
gai_hints.ai_protocol = SOL_TCP;
#else
gai_hints.ai_protocol = IPPROTO_TCP;
#endif
+
gai_hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | (packet ? 0 : AI_PASSIVE);
const char* host_str = (host.hasData() ? host.c_str() : NULL);
struct addrinfo* gai_result;
int n = getaddrinfo(host_str, protocol.c_str(), &gai_hints, &gai_result);
+
if (n && (protocol == FB_SERVICE_NAME))
{
// Try hard-wired translation of "gds_db" to "3050"
protocol.printf("%hu", FB_SERVICE_PORT);
n = getaddrinfo(host_str, protocol.c_str(), &gai_hints, &gai_result);
}
+
if (n)
{
gds__log("INET/INET_connect: getaddrinfo(%s,%s) failed: %s",
@@ -802,6 +808,7 @@
{
// Allocate a port block and initialize a socket for communications
port->port_handle = socket(pai->ai_family, pai->ai_socktype, pai->ai_protocol);
+
if (port->port_handle == INVALID_SOCKET)
{
gds__log("socket: error creating socket (family %d, socktype %d, protocol %d",
@@ -830,7 +837,9 @@
{
goto exit_free;
}
- } else {
+ }
+ else
+ {
// server
INET_server_socket(port, flag, pai);
goto exit_free;
@@ -842,11 +851,9 @@
// all attempts failed
if (packet)
- {
inet_error(true, port, "connect", isc_net_connect_err, 0);
- } else {
+ else
inet_error(true, port, "listen", isc_net_connect_listen_err, 0);
- }
exit_free:
freeaddrinfo(gai_result);
@@ -867,15 +874,13 @@
*
**************************************/
- int n;
int ipv6_v6only = port->getPortConfig()->getIPv6V6Only() ? 1 : 0;
- n = setsockopt(port->port_handle, IPPROTO_IPV6, IPV6_V6ONLY,
+ int n = setsockopt(port->port_handle, IPPROTO_IPV6, IPV6_V6ONLY,
(SCHAR*) &ipv6_v6only, sizeof(ipv6_v6only));
+
if (n == -1)
- {
gds__log("setsockopt: error setting IPV6_V6ONLY to %d", ipv6_v6only);
- }
if (flag & SRVR_multi_client)
{
@@ -924,12 +929,12 @@
// On Linux platform, when the server dies the system holds a port
// for some time (we don't set SO_REUSEADDR for standalone server).
int retry = -1;
- do {
+ do
+ {
if (++retry)
sleep(10);
n = bind(port->port_handle, pai->ai_addr, pai->ai_addrlen);
- }
- while (n == -1 && INET_ERRNO == INET_ADDR_IN_USE && retry < INET_RETRY_CALL);
+ } while (n == -1 && INET_ERRNO == INET_ADDR_IN_USE && retry < INET_RETRY_CALL);
if (n == -1)
{
@@ -1169,12 +1174,12 @@
{
address.unmapV4(); // convert mapped IPv4 to regular IPv4
char host[40]; // 32 digits, 7 colons, 1 trailing null byte
- int R = getnameinfo(address.ptr(), address.length(), host, sizeof(host),
+ int nameinfo = getnameinfo(address.ptr(), address.length(), host, sizeof(host),
NULL, 0, NI_NUMERICHOST);
- if (!R)
- {
+
+ if (!nameinfo)
port->port_address = host;
- }
+
if (address.family() == AF_INET6)
port->port_protocol_id = "TCPv6";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|