http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/os/linux/src/system/tcp_socket_client.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/linux/src/system/tcp_socket_client.cpp b/modules/platforms/cpp/odbc/os/linux/src/system/tcp_socket_client.cpp new file mode 100644 index 0000000..f145361 --- /dev/null +++ b/modules/platforms/cpp/odbc/os/linux/src/system/tcp_socket_client.cpp @@ -0,0 +1,384 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/tcp.h> +#include <netdb.h> +#include <unistd.h> +#include <fcntl.h> + +#include <cstring> + +#include <sstream> + +#include "ignite/odbc/system/tcp_socket_client.h" +#include "ignite/odbc/utility.h" +#include "ignite/odbc/log.h" + +#define SOCKET_ERROR (-1) + +namespace +{ + /** + * Get last socket error message. + * @param error Error code. + * @return Last socket error message string. + */ + std::string GetSocketErrorMessage(int error) + { + std::stringstream res; + + res << "error_code=" << error; + + if (error == 0) + return res.str(); + + char buffer[1024] = ""; + + if (!strerror_r(error, buffer, sizeof(buffer))) + res << ", msg=" << buffer; + + return res.str(); + } + + /** + * Get last socket error message. + * @return Last socket error message string. + */ + std::string GetLastSocketErrorMessage() + { + int lastError = errno; + + return GetSocketErrorMessage(lastError); + } +} + +namespace ignite +{ + namespace odbc + { + namespace system + { + + TcpSocketClient::TcpSocketClient() : + socketHandle(SOCKET_ERROR), + blocking(true) + { + // No-op. + } + + TcpSocketClient::~TcpSocketClient() + { + Close(); + } + + bool TcpSocketClient::Connect(const char* hostname, uint16_t port, diagnostic::Diagnosable& diag) + { + LOG_MSG("Host: " << hostname << ", port: " << port); + + addrinfo hints; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + std::stringstream converter; + converter << port; + + // Resolve the server address and port + addrinfo *result = NULL; + int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result); + + if (res != 0) + { + LOG_MSG("Address resolving failed: " << gai_strerror(res)); + + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not resolve host address."); + + return false; + } + + // Attempt to connect to an address until one succeeds + for (addrinfo *it = result; it != NULL; it = it->ai_next) + { + LOG_MSG("Addr: " << (it->ai_addr->sa_data[2] & 0xFF) << "." + << (it->ai_addr->sa_data[3] & 0xFF) << "." + << (it->ai_addr->sa_data[4] & 0xFF) << "." + << (it->ai_addr->sa_data[5] & 0xFF)); + + // Create a SOCKET for connecting to server + socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol); + + if (socketHandle == SOCKET_ERROR) + { + LOG_MSG("Socket creation failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create new socket."); + + return false; + } + + diag.GetDiagnosticRecords().Reset(); + + TrySetOptions(diag); + + // Connect to server. + res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen)); + if (SOCKET_ERROR == res) + { + int lastError = errno; + + if (lastError != EWOULDBLOCK && lastError != EINPROGRESS) + { + LOG_MSG("Connection failed: " << GetSocketErrorMessage(lastError)); + + Close(); + + continue; + } + + res = WaitOnSocket(CONNECT_TIMEOUT, false); + + if (res < 0 || res == WaitResult::TIMEOUT) + { + LOG_MSG("Connection timeout expired: " << GetSocketErrorMessage(-res)); + + Close(); + + continue; + } + } + break; + } + + freeaddrinfo(result); + + return socketHandle != SOCKET_ERROR; + } + + void TcpSocketClient::Close() + { + if (socketHandle != SOCKET_ERROR) + { + close(socketHandle); + + socketHandle = SOCKET_ERROR; + } + } + + int TcpSocketClient::Send(const int8_t* data, size_t size, int32_t timeout) + { + if (!blocking) + { + int res = WaitOnSocket(timeout, false); + + if (res < 0 || res == WaitResult::TIMEOUT) + return res; + } + + return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0); + } + + int TcpSocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout) + { + if (!blocking) + { + int res = WaitOnSocket(timeout, true); + + if (res < 0 || res == WaitResult::TIMEOUT) + return res; + } + + return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0); + } + + bool TcpSocketClient::IsBlocking() const + { + return blocking; + } + + void TcpSocketClient::TrySetOptions(diagnostic::Diagnosable& diag) + { + int trueOpt = 1; + int bufSizeOpt = BUFFER_SIZE; + int idleOpt = KEEP_ALIVE_IDLE_TIME; + int idleRetryOpt = KEEP_ALIVE_PROBES_PERIOD; + + int res = setsockopt(socketHandle, SOL_SOCKET, SO_SNDBUF, + reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP socket send buffer size setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP socket send buffer size"); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_RCVBUF, + reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP socket receive buffer size setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP socket receive buffer size"); + } + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP no-delay mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP no-delay mode"); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_OOBINLINE, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP out-of-bound data inlining setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP out-of-bound data inlining"); + } + + blocking = false; + + int flags; + if (((flags = fcntl(socketHandle, F_GETFL, 0)) < 0) || + (fcntl(socketHandle, F_SETFL, flags | O_NONBLOCK) < 0)) + { + blocking = true; + LOG_MSG("Non-blocking mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up non-blocking mode. Timeouts are not available."); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive mode"); + + // There is no sense in configuring keep alive params if we faileed to set up keep alive mode. + return; + } + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPIDLE, + reinterpret_cast<char*>(&idleOpt), sizeof(idleOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive idle timeout setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive idle timeout"); + } + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPINTVL, + reinterpret_cast<char*>(&idleRetryOpt), sizeof(idleRetryOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive probes period setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive probes period"); + } + + } + + int TcpSocketClient::WaitOnSocket(int32_t timeout, bool rd) + { + int ready = 0; + int lastError = 0; + + fd_set fds; + + do { + struct timeval tv = { 0 }; + tv.tv_sec = timeout; + + FD_ZERO(&fds); + FD_SET(socketHandle, &fds); + + fd_set* readFds = 0; + fd_set* writeFds = 0; + + if (rd) + readFds = &fds; + else + writeFds = &fds; + + ready = select(static_cast<int>((socketHandle) + 1), + readFds, writeFds, NULL, (timeout == 0 ? NULL : &tv)); + + if (ready == SOCKET_ERROR) + lastError = GetLastSocketError(); + + } while (ready == SOCKET_ERROR && IsSocketOperationInterrupted(lastError)); + + if (ready == SOCKET_ERROR) + return -lastError; + + socklen_t size = sizeof(lastError); + int res = getsockopt(socketHandle, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&lastError), &size); + + if (res != SOCKET_ERROR && lastError != 0) + return -lastError; + + if (ready == 0) + return WaitResult::TIMEOUT; + + return WaitResult::SUCCESS; + } + + int TcpSocketClient::GetLastSocketError() + { + return errno; + } + + int TcpSocketClient::GetLastSocketError(int handle) + { + int lastError = 0; + socklen_t size = sizeof(lastError); + int res = getsockopt(handle, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&lastError), &size); + + return res == SOCKET_ERROR ? 0 : lastError; + } + + bool TcpSocketClient::IsSocketOperationInterrupted(int errorCode) + { + return errorCode == EINTR; + } + } + } +} +
http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp b/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp deleted file mode 100644 index 6f87b93..0000000 --- a/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define WIN32_LEAN_AND_MEAN -#define _WINSOCKAPI_ - -#include <windows.h> -#include <winsock2.h> -#include <ws2tcpip.h> -#include <mstcpip.h> - -#include <cstring> - -#include <sstream> - -#include "ignite/odbc/system/socket_client.h" -#include "ignite/odbc/utility.h" -#include "ignite/odbc/log.h" - -namespace -{ - /** - * Get socket error message for the error code. - * @param error Error code. - * @return Socket error message string. - */ - std::string GetSocketErrorMessage(HRESULT error) - { - std::stringstream res; - - res << "error_code=" << error; - - if (error == 0) - return res.str(); - - LPTSTR errorText = NULL; - - DWORD len = FormatMessage( - // use system message tables to retrieve error text - FORMAT_MESSAGE_FROM_SYSTEM - // allocate buffer on local heap for error text - | FORMAT_MESSAGE_ALLOCATE_BUFFER - // We're not passing insertion parameters - | FORMAT_MESSAGE_IGNORE_INSERTS, - // unused with FORMAT_MESSAGE_FROM_SYSTEM - NULL, - error, - MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - // output - reinterpret_cast<LPTSTR>(&errorText), - // minimum size for output buffer - 0, - // arguments - see note - NULL); - - if (NULL != errorText) - { - if (len != 0) - res << ", msg=" << std::string(errorText, len); - - LocalFree(errorText); - } - - return res.str(); - } - - /** - * Get last socket error message. - * @return Last socket error message string. - */ - std::string GetLastSocketErrorMessage() - { - HRESULT lastError = WSAGetLastError(); - - return GetSocketErrorMessage(lastError); - } -} - -namespace ignite -{ - namespace odbc - { - namespace tcp - { - - SocketClient::SocketClient() : - socketHandle(INVALID_SOCKET), - blocking(true) - { - // No-op. - } - - SocketClient::~SocketClient() - { - Close(); - } - - bool SocketClient::Connect(const char* hostname, uint16_t port, diagnostic::Diagnosable& diag) - { - static bool networkInited = false; - - // Initing networking if is not inited. - if (!networkInited) - { - WSADATA wsaData; - - networkInited = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0); - - if (!networkInited) - { - LOG_MSG("Networking initialisation failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not initialize Windows networking."); - - return false; - } - } - - addrinfo hints; - - LOG_MSG("Host: " << hostname << " port: " << port); - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - - std::stringstream converter; - converter << port; - - // Resolve the server address and port - addrinfo *result = NULL; - int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result); - - if (res != 0) - { - LOG_MSG("Address resolving failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not resolve host address."); - - return false; - } - - // Attempt to connect to an address until one succeeds - for (addrinfo *it = result; it != NULL; it = it->ai_next) - { - LOG_MSG("Addr: " << (it->ai_addr->sa_data[2] & 0xFF) << "." - << (it->ai_addr->sa_data[3] & 0xFF) << "." - << (it->ai_addr->sa_data[4] & 0xFF) << "." - << (it->ai_addr->sa_data[5] & 0xFF)); - - // Create a SOCKET for connecting to server - socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol); - - if (socketHandle == INVALID_SOCKET) - { - LOG_MSG("Socket creation failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create new socket."); - - return false; - } - - diag.GetDiagnosticRecords().Reset(); - - TrySetOptions(diag); - - // Connect to server. - res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen)); - if (SOCKET_ERROR == res) - { - int lastError = WSAGetLastError(); - - if (lastError != WSAEWOULDBLOCK) - { - LOG_MSG("Connection failed: " << GetSocketErrorMessage(lastError)); - - Close(); - - continue; - } - - res = WaitOnSocket(CONNECT_TIMEOUT, false); - - if (res < 0 || res == WaitResult::TIMEOUT) - { - LOG_MSG("Connection timeout expired: " << GetSocketErrorMessage(-res)); - - Close(); - - continue; - } - } - break; - } - - freeaddrinfo(result); - - return socketHandle != INVALID_SOCKET; - } - - void SocketClient::Close() - { - if (socketHandle != INVALID_SOCKET) - { - closesocket(socketHandle); - - socketHandle = INVALID_SOCKET; - } - } - - int SocketClient::Send(const int8_t* data, size_t size, int32_t timeout) - { - if (!blocking) - { - int res = WaitOnSocket(timeout, false); - - if (res < 0 || res == WaitResult::TIMEOUT) - return res; - } - - return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0); - } - - int SocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout) - { - if (!blocking) - { - int res = WaitOnSocket(timeout, true); - - if (res < 0 || res == WaitResult::TIMEOUT) - return res; - } - - return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0); - } - - void SocketClient::TrySetOptions(diagnostic::Diagnosable& diag) - { - BOOL trueOpt = TRUE; - ULONG uTrueOpt = TRUE; - int bufSizeOpt = BUFFER_SIZE; - - - int res = setsockopt(socketHandle, SOL_SOCKET, SO_SNDBUF, - reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP socket send buffer size setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP socket send buffer size"); - } - - res = setsockopt(socketHandle, SOL_SOCKET, SO_RCVBUF, - reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP socket receive buffer size setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP socket receive buffer size"); - } - - res = setsockopt(socketHandle, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP no-delay mode setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP no-delay mode"); - } - - res = setsockopt(socketHandle, SOL_SOCKET, SO_OOBINLINE, - reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP out-of-bound data inlining setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP out-of-bound data inlining"); - } - - blocking = false; - res = ioctlsocket(socketHandle, FIONBIO, &uTrueOpt); - - if (res == SOCKET_ERROR) - { - blocking = true; - LOG_MSG("Non-blocking mode setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up non-blocking mode. Timeouts are not available."); - } - - res = setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, - reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP keep-alive mode setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP keep-alive mode"); - - // There is no sense in configuring keep alive params if we faileed to set up keep alive mode. - return; - } - - // This option is available starting with Windows 10, version 1709. -#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) - DWORD idleOpt = KEEP_ALIVE_IDLE_TIME; - DWORD idleRetryOpt = KEEP_ALIVE_PROBES_PERIOD; - - res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPIDLE, - reinterpret_cast<char*>(&idleOpt), sizeof(idleOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP keep-alive idle timeout setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP keep-alive idle timeout"); - } - - res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPINTVL, - reinterpret_cast<char*>(&idleRetryOpt), sizeof(idleRetryOpt)); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP keep-alive probes period setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP keep-alive probes period"); - } -#else // use old hardcore WSAIoctl - - // WinSock structure for KeepAlive timing settings - struct tcp_keepalive settings = {0}; - settings.onoff = 1; - settings.keepalivetime = KEEP_ALIVE_IDLE_TIME * 1000; - settings.keepaliveinterval = KEEP_ALIVE_PROBES_PERIOD * 1000; - - // pointers for WinSock call - DWORD bytesReturned; - WSAOVERLAPPED overlapped; - overlapped.hEvent = NULL; - - // Set KeepAlive settings - res = WSAIoctl( - socketHandle, - SIO_KEEPALIVE_VALS, - &settings, - sizeof(struct tcp_keepalive), - NULL, - 0, - &bytesReturned, - &overlapped, - NULL - ); - - if (SOCKET_ERROR == res) - { - LOG_MSG("TCP keep-alive params setup failed: " << GetLastSocketErrorMessage()); - - diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, - "Can not set up TCP keep-alive idle timeout and probes period"); - } -#endif - } - - int SocketClient::WaitOnSocket(int32_t timeout, bool rd) - { - int ready = 0; - int lastError = 0; - - fd_set fds; - - do { - struct timeval tv = { 0 }; - tv.tv_sec = timeout; - - FD_ZERO(&fds); - FD_SET(socketHandle, &fds); - - fd_set* readFds = 0; - fd_set* writeFds = 0; - - if (rd) - readFds = &fds; - else - writeFds = &fds; - - ready = select(static_cast<int>((socketHandle) + 1), - readFds, writeFds, NULL, (timeout == 0 ? NULL : &tv)); - - if (ready == SOCKET_ERROR) - lastError = WSAGetLastError(); - - } while (ready == SOCKET_ERROR && lastError == WSAEINTR); - - if (ready == SOCKET_ERROR) - return -lastError; - - if (ready == 0) - return WaitResult::TIMEOUT; - - return WaitResult::SUCCESS; - } - } - } -} - http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/os/win/src/system/tcp_socket_client.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/win/src/system/tcp_socket_client.cpp b/modules/platforms/cpp/odbc/os/win/src/system/tcp_socket_client.cpp new file mode 100644 index 0000000..1459a17 --- /dev/null +++ b/modules/platforms/cpp/odbc/os/win/src/system/tcp_socket_client.cpp @@ -0,0 +1,462 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define WIN32_LEAN_AND_MEAN +#define _WINSOCKAPI_ + +#include <windows.h> +#include <winsock2.h> +#include <ws2tcpip.h> +#include <mstcpip.h> + +#include <cstring> + +#include <sstream> + +#include "ignite/common/concurrent.h" +#include "ignite/odbc/system/tcp_socket_client.h" +#include "ignite/odbc/utility.h" +#include "ignite/odbc/log.h" + +namespace +{ + /** + * Get socket error message for the error code. + * @param error Error code. + * @return Socket error message string. + */ + std::string GetSocketErrorMessage(HRESULT error) + { + std::stringstream res; + + res << "error_code=" << error; + + if (error == 0) + return res.str(); + + LPTSTR errorText = NULL; + + DWORD len = FormatMessage( + // use system message tables to retrieve error text + FORMAT_MESSAGE_FROM_SYSTEM + // allocate buffer on local heap for error text + | FORMAT_MESSAGE_ALLOCATE_BUFFER + // We're not passing insertion parameters + | FORMAT_MESSAGE_IGNORE_INSERTS, + // unused with FORMAT_MESSAGE_FROM_SYSTEM + NULL, + error, + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), + // output + reinterpret_cast<LPTSTR>(&errorText), + // minimum size for output buffer + 0, + // arguments - see note + NULL); + + if (NULL != errorText) + { + if (len != 0) + res << ", msg=" << std::string(errorText, len); + + LocalFree(errorText); + } + + return res.str(); + } + + /** + * Get last socket error message. + * @return Last socket error message string. + */ + std::string GetLastSocketErrorMessage() + { + HRESULT lastError = WSAGetLastError(); + + return GetSocketErrorMessage(lastError); + } +} + +namespace ignite +{ + namespace odbc + { + namespace system + { + + TcpSocketClient::TcpSocketClient() : + socketHandle(INVALID_SOCKET), + blocking(true) + { + // No-op. + } + + TcpSocketClient::~TcpSocketClient() + { + Close(); + } + + bool TcpSocketClient::Connect(const char* hostname, uint16_t port, diagnostic::Diagnosable& diag) + { + static common::concurrent::CriticalSection initCs; + static bool networkInited = false; + + // Initing networking if is not inited. + if (!networkInited) + { + common::concurrent::CsLockGuard lock(initCs); + if (!networkInited) + { + WSADATA wsaData; + + networkInited = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0); + + if (!networkInited) + { + LOG_MSG("Networking initialisation failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not initialize Windows networking."); + + return false; + } + } + } + + addrinfo hints; + + LOG_MSG("Host: " << hostname << " port: " << port); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + std::stringstream converter; + converter << port; + + // Resolve the server address and port + addrinfo *result = NULL; + int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result); + + if (res != 0) + { + LOG_MSG("Address resolving failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not resolve host address."); + + return false; + } + + // Attempt to connect to an address until one succeeds + for (addrinfo *it = result; it != NULL; it = it->ai_next) + { + LOG_MSG("Addr: " << (it->ai_addr->sa_data[2] & 0xFF) << "." + << (it->ai_addr->sa_data[3] & 0xFF) << "." + << (it->ai_addr->sa_data[4] & 0xFF) << "." + << (it->ai_addr->sa_data[5] & 0xFF)); + + // Create a SOCKET for connecting to server + socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol); + + if (socketHandle == INVALID_SOCKET) + { + LOG_MSG("Socket creation failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create new socket."); + + return false; + } + + diag.GetDiagnosticRecords().Reset(); + + TrySetOptions(diag); + + // Connect to server. + res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen)); + if (SOCKET_ERROR == res) + { + int lastError = WSAGetLastError(); + + if (lastError != WSAEWOULDBLOCK) + { + LOG_MSG("Connection failed: " << GetSocketErrorMessage(lastError)); + + Close(); + + continue; + } + + res = WaitOnSocket(CONNECT_TIMEOUT, false); + + if (res < 0 || res == WaitResult::TIMEOUT) + { + LOG_MSG("Connection timeout expired: " << GetSocketErrorMessage(-res)); + + Close(); + + continue; + } + } + break; + } + + freeaddrinfo(result); + + return socketHandle != INVALID_SOCKET; + } + + void TcpSocketClient::Close() + { + if (socketHandle != INVALID_SOCKET) + { + closesocket(socketHandle); + + socketHandle = INVALID_SOCKET; + } + } + + int TcpSocketClient::Send(const int8_t* data, size_t size, int32_t timeout) + { + if (!blocking) + { + int res = WaitOnSocket(timeout, false); + + if (res < 0 || res == WaitResult::TIMEOUT) + return res; + } + + return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0); + } + + int TcpSocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout) + { + if (!blocking) + { + int res = WaitOnSocket(timeout, true); + + if (res < 0 || res == WaitResult::TIMEOUT) + return res; + } + + return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0); + } + + bool TcpSocketClient::IsBlocking() const + { + return blocking; + } + + void TcpSocketClient::TrySetOptions(diagnostic::Diagnosable& diag) + { + BOOL trueOpt = TRUE; + ULONG uTrueOpt = TRUE; + int bufSizeOpt = BUFFER_SIZE; + + + int res = setsockopt(socketHandle, SOL_SOCKET, SO_SNDBUF, + reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP socket send buffer size setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP socket send buffer size"); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_RCVBUF, + reinterpret_cast<char*>(&bufSizeOpt), sizeof(bufSizeOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP socket receive buffer size setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP socket receive buffer size"); + } + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP no-delay mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP no-delay mode"); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_OOBINLINE, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP out-of-bound data inlining setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP out-of-bound data inlining"); + } + + blocking = false; + res = ioctlsocket(socketHandle, FIONBIO, &uTrueOpt); + + if (res == SOCKET_ERROR) + { + blocking = true; + LOG_MSG("Non-blocking mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up non-blocking mode. Timeouts are not available."); + } + + res = setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, + reinterpret_cast<char*>(&trueOpt), sizeof(trueOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive mode setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive mode"); + + // There is no sense in configuring keep alive params if we faileed to set up keep alive mode. + return; + } + + // This option is available starting with Windows 10, version 1709. +#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) + DWORD idleOpt = KEEP_ALIVE_IDLE_TIME; + DWORD idleRetryOpt = KEEP_ALIVE_PROBES_PERIOD; + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPIDLE, + reinterpret_cast<char*>(&idleOpt), sizeof(idleOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive idle timeout setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive idle timeout"); + } + + res = setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPINTVL, + reinterpret_cast<char*>(&idleRetryOpt), sizeof(idleRetryOpt)); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive probes period setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive probes period"); + } +#else // use old hardcore WSAIoctl + + // WinSock structure for KeepAlive timing settings + struct tcp_keepalive settings = {0}; + settings.onoff = 1; + settings.keepalivetime = KEEP_ALIVE_IDLE_TIME * 1000; + settings.keepaliveinterval = KEEP_ALIVE_PROBES_PERIOD * 1000; + + // pointers for WinSock call + DWORD bytesReturned; + WSAOVERLAPPED overlapped; + overlapped.hEvent = NULL; + + // Set KeepAlive settings + res = WSAIoctl( + socketHandle, + SIO_KEEPALIVE_VALS, + &settings, + sizeof(struct tcp_keepalive), + NULL, + 0, + &bytesReturned, + &overlapped, + NULL + ); + + if (SOCKET_ERROR == res) + { + LOG_MSG("TCP keep-alive params setup failed: " << GetLastSocketErrorMessage()); + + diag.AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, + "Can not set up TCP keep-alive idle timeout and probes period"); + } +#endif + } + + int TcpSocketClient::WaitOnSocket(int32_t timeout, bool rd) + { + int ready = 0; + int lastError = 0; + + fd_set fds; + + do { + struct timeval tv = { 0 }; + tv.tv_sec = timeout; + + FD_ZERO(&fds); + FD_SET(socketHandle, &fds); + + fd_set* readFds = 0; + fd_set* writeFds = 0; + + if (rd) + readFds = &fds; + else + writeFds = &fds; + + ready = select(static_cast<int>((socketHandle) + 1), + readFds, writeFds, NULL, (timeout == 0 ? NULL : &tv)); + + if (ready == SOCKET_ERROR) + lastError = GetLastSocketError(); + + } while (ready == SOCKET_ERROR && IsSocketOperationInterrupted(lastError)); + + if (ready == SOCKET_ERROR) + return -lastError; + + if (ready == 0) + return WaitResult::TIMEOUT; + + return WaitResult::SUCCESS; + } + + int TcpSocketClient::GetLastSocketError() + { + return WSAGetLastError(); + } + + int TcpSocketClient::GetLastSocketError(int handle) + { + int lastError = 0; + socklen_t size = sizeof(lastError); + int res = getsockopt(handle, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&lastError), &size); + + return res == SOCKET_ERROR ? 0 : lastError; + } + + bool TcpSocketClient::IsSocketOperationInterrupted(int errorCode) + { + return errorCode == WSAEINTR; + } + } + } +} + http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp index d5aa0db..0e742be 100644 --- a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp +++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp @@ -16,8 +16,10 @@ */ #include <Windowsx.h> +#include <Shlwapi.h> #include "ignite/odbc/log.h" +#include "ignite/odbc/ssl/ssl_mode.h" #include "ignite/odbc/system/ui/dsn_configuration_window.h" @@ -32,7 +34,7 @@ namespace ignite DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config): CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"), width(360), - height(300), + height(480), connectionSettingsGroupBox(), nameLabel(), nameEdit(), @@ -89,53 +91,56 @@ namespace ignite void DsnConfigurationWindow::OnCreate() { - int margin = 10; - int interval = 10; + int groupPosY = MARGIN; + int groupSizeY = width - 2 * MARGIN; - int labelSizeX = 80; - int labelPosX = margin + interval; + groupPosY += INTERVAL + CreateConnectionSettingsGroup(MARGIN, groupPosY, groupSizeY); + groupPosY += INTERVAL + CreateSslSettingsGroup(MARGIN, groupPosY, groupSizeY); + groupPosY += INTERVAL + CreateAdditionalSettingsGroup(MARGIN, groupPosY, groupSizeY); - int editSizeX = width - labelSizeX - 2 * margin - 3 * interval; - int editPosX = margin + labelSizeX + 2 * interval; + int cancelPosX = width - MARGIN - BUTTON_WIDTH; + int okPosX = cancelPosX - INTERVAL - BUTTON_WIDTH; - int rowSize = 20; - int rowPos = margin + 2 * interval; + okButton = CreateButton(okPosX, groupPosY, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok", ChildId::OK_BUTTON); + cancelButton = CreateButton(cancelPosX, groupPosY, BUTTON_WIDTH, BUTTON_HEIGHT, + "Cancel", ChildId::CANCEL_BUTTON); + } + + int DsnConfigurationWindow::CreateConnectionSettingsGroup(int posX, int posY, int sizeX) + { + enum { LABEL_WIDTH = 100 }; + + int labelPosX = posX + INTERVAL; - int checkBoxSize = (editSizeX - interval) / 2; + int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; + int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; - int sectionBegin = margin; + int rowPos = posY + 2 * INTERVAL; const char* val = config.GetDsn().c_str(); - nameLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "DSN name:", ChildId::NAME_LABEL); - nameEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ChildId::NAME_EDIT); + nameLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, + "Data Source Name:", ChildId::NAME_LABEL); + nameEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::NAME_EDIT); - rowPos += interval + rowSize; + rowPos += INTERVAL + ROW_HEIGHT; val = config.GetAddress().c_str(); - addressLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Address:", ChildId::ADDRESS_LABEL); - addressEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ChildId::ADDRESS_EDIT); + addressLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, + "Address:", ChildId::ADDRESS_LABEL); + addressEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::ADDRESS_EDIT); - rowPos += interval + rowSize; + rowPos += INTERVAL + ROW_HEIGHT; val = config.GetSchema().c_str(); - schemaLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Schema name:", ChildId::SCHEMA_LABEL); - schemaEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ChildId::SCHEMA_EDIT); - - rowPos += interval + rowSize; - - std::string tmp = common::LexicalCast<std::string>(config.GetPageSize()); - val = tmp.c_str(); - pageSizeLabel = CreateLabel(labelPosX, rowPos, labelSizeX, - rowSize, "Page size:", ChildId::PAGE_SIZE_LABEL); + schemaLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, + "Schema name:", ChildId::SCHEMA_LABEL); + schemaEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::SCHEMA_EDIT); - pageSizeEdit = CreateEdit(editPosX, rowPos, editSizeX, - rowSize, val, ChildId::PAGE_SIZE_EDIT, ES_NUMBER); + rowPos += INTERVAL + ROW_HEIGHT; - rowPos += interval + rowSize; - - protocolVersionLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, + protocolVersionLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "Protocol version:", ChildId::PROTOCOL_VERSION_LABEL); - protocolVersionComboBox = CreateComboBox(editPosX, rowPos, editSizeX, rowSize, + protocolVersionComboBox = CreateComboBox(editPosX, rowPos, editSizeX, ROW_HEIGHT, "Protocol version", ChildId::PROTOCOL_VERSION_COMBO_BOX); int id = 0; @@ -157,48 +162,132 @@ namespace ignite ++id; } - rowPos += interval + rowSize; + rowPos += INTERVAL + ROW_HEIGHT; + + connectionSettingsGroupBox = CreateGroupBox(posX, posY, sizeX, rowPos - posY, + "Connection settings", ChildId::CONNECTION_SETTINGS_GROUP_BOX); + + return rowPos - posY; + } + + int DsnConfigurationWindow::CreateSslSettingsGroup(int posX, int posY, int sizeX) + { + using ssl::SslMode; + + enum { LABEL_WIDTH = 120 }; + + int labelPosX = posX + INTERVAL; + + int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; + int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; + + int rowPos = posY + 2 * INTERVAL; + + const char* val = config.GetSslMode().c_str(); + SslMode::T sslMode = SslMode::FromString(val, SslMode::DISABLE); + + sslModeLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "SSL Mode:", ChildId::SSL_MODE_LABEL); + sslModeComboBox = CreateComboBox(editPosX, rowPos, editSizeX, ROW_HEIGHT, "", ChildId::SSL_MODE_COMBO_BOX); + + sslModeComboBox->AddString("disable"); + sslModeComboBox->AddString("require"); + + sslModeComboBox->SetSelection(sslMode); + + rowPos += INTERVAL + ROW_HEIGHT; + + val = config.GetSslKeyFile().c_str(); + sslKeyFileLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "SSL Private Key:", ChildId::SSL_KEY_FILE_LABEL); + sslKeyFileEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::SSL_KEY_FILE_EDIT); + + SHAutoComplete(sslKeyFileEdit->GetHandle(), SHACF_DEFAULT); + + rowPos += INTERVAL + ROW_HEIGHT; + + val = config.GetSslCertFile().c_str(); + sslCertFileLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "SSL Certificate:", ChildId::SSL_CERT_FILE_LABEL); + sslCertFileEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::SSL_CERT_FILE_EDIT); + + SHAutoComplete(sslCertFileEdit->GetHandle(), SHACF_DEFAULT); - distributedJoinsCheckBox = CreateCheckBox(editPosX, rowPos, checkBoxSize, rowSize, + rowPos += INTERVAL + ROW_HEIGHT; + + val = config.GetSslCaFile().c_str(); + sslCaFileLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "SSL Certificate Authority:", ChildId::SSL_CA_FILE_LABEL); + sslCaFileEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::SSL_CA_FILE_EDIT); + + SHAutoComplete(sslCaFileEdit->GetHandle(), SHACF_DEFAULT); + + rowPos += INTERVAL + ROW_HEIGHT; + + sslSettingsGroupBox = CreateGroupBox(posX, posY, sizeX, rowPos - posY, + "SSL settings", ChildId::SSL_SETTINGS_GROUP_BOX); + + sslKeyFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + sslCertFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + sslCaFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + + return rowPos - posY; + } + + int DsnConfigurationWindow::CreateAdditionalSettingsGroup(int posX, int posY, int sizeX) + { + enum { LABEL_WIDTH = 80 }; + + int labelPosX = posX + INTERVAL; + + int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; + int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; + + int checkBoxSize = (sizeX - 3 * INTERVAL) / 2; + + const ProtocolVersion version = config.GetProtocolVersion(); + + int rowPos = posY + 2 * INTERVAL; + + std::string tmp = common::LexicalCast<std::string>(config.GetPageSize()); + const char* val = tmp.c_str(); + pageSizeLabel = CreateLabel(labelPosX, rowPos, LABEL_WIDTH, + ROW_HEIGHT, "Page size:", ChildId::PAGE_SIZE_LABEL); + + pageSizeEdit = CreateEdit(editPosX, rowPos, editSizeX, + ROW_HEIGHT, val, ChildId::PAGE_SIZE_EDIT, ES_NUMBER); + + rowPos += INTERVAL + ROW_HEIGHT; + + distributedJoinsCheckBox = CreateCheckBox(labelPosX, rowPos, checkBoxSize, ROW_HEIGHT, "Distributed Joins", ChildId::DISTRIBUTED_JOINS_CHECK_BOX, config.IsDistributedJoins()); - enforceJoinOrderCheckBox = CreateCheckBox(editPosX + checkBoxSize + interval, rowPos, checkBoxSize, - rowSize, "Enforce Join Order", ChildId::ENFORCE_JOIN_ORDER_CHECK_BOX, config.IsEnforceJoinOrder()); + enforceJoinOrderCheckBox = CreateCheckBox(labelPosX + checkBoxSize + INTERVAL, rowPos, checkBoxSize, + ROW_HEIGHT, "Enforce Join Order", ChildId::ENFORCE_JOIN_ORDER_CHECK_BOX, config.IsEnforceJoinOrder()); - rowPos += rowSize; + rowPos += ROW_HEIGHT; - replicatedOnlyCheckBox = CreateCheckBox(editPosX, rowPos, checkBoxSize, rowSize, + replicatedOnlyCheckBox = CreateCheckBox(labelPosX, rowPos, checkBoxSize, ROW_HEIGHT, "Replicated Only", ChildId::REPLICATED_ONLY_CHECK_BOX, config.IsReplicatedOnly()); - collocatedCheckBox = CreateCheckBox(editPosX + checkBoxSize + interval, rowPos, checkBoxSize, - rowSize, "Collocated", ChildId::COLLOCATED_CHECK_BOX, config.IsCollocated()); + collocatedCheckBox = CreateCheckBox(labelPosX + checkBoxSize + INTERVAL, rowPos, checkBoxSize, + ROW_HEIGHT, "Collocated", ChildId::COLLOCATED_CHECK_BOX, config.IsCollocated()); - rowPos += rowSize; + rowPos += ROW_HEIGHT; - lazyCheckBox = CreateCheckBox(editPosX, rowPos, checkBoxSize, rowSize, + lazyCheckBox = CreateCheckBox(labelPosX, rowPos, checkBoxSize, ROW_HEIGHT, "Lazy", ChildId::LAZY_CHECK_BOX, config.IsLazy()); lazyCheckBox->SetEnabled(version >= ProtocolVersion::VERSION_2_1_5); - skipReducerOnUpdateCheckBox = CreateCheckBox(editPosX + checkBoxSize + interval, rowPos, - checkBoxSize, rowSize, "Skip reducer on update", ChildId::SKIP_REDUCER_ON_UPDATE_CHECK_BOX, + skipReducerOnUpdateCheckBox = CreateCheckBox(labelPosX + checkBoxSize + INTERVAL, rowPos, + checkBoxSize, ROW_HEIGHT, "Skip reducer on update", ChildId::SKIP_REDUCER_ON_UPDATE_CHECK_BOX, config.IsSkipReducerOnUpdate()); skipReducerOnUpdateCheckBox->SetEnabled(version >= ProtocolVersion::VERSION_2_3_0); - rowPos += interval * 2 + rowSize; - - connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin, - rowPos - interval - sectionBegin, "Connection settings", ChildId::CONNECTION_SETTINGS_GROUP_BOX); + rowPos += ROW_HEIGHT + INTERVAL; - int buttonSizeX = 80; - int cancelPosX = width - margin - buttonSizeX; - int okPosX = cancelPosX - interval - buttonSizeX; + additionalSettingsGroupBox = CreateGroupBox(posX, posY, sizeX, rowPos - posY, + "Additional settings", ChildId::ADDITIONAL_SETTINGS_GROUP_BOX); - rowSize = 25; - - okButton = CreateButton(okPosX, rowPos, buttonSizeX, rowSize, "Ok", ChildId::OK_BUTTON); - cancelButton = CreateButton(cancelPosX, rowPos, buttonSizeX, rowSize, "Cancel", ChildId::CANCEL_BUTTON); + return rowPos - posY; } bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) @@ -289,6 +378,22 @@ namespace ignite break; } + case ChildId::SSL_MODE_COMBO_BOX: + { + using ssl::SslMode; + + std::string sslModeStr; + sslModeComboBox->GetText(sslModeStr); + + SslMode::T sslMode = SslMode::FromString(sslModeStr, SslMode::DISABLE); + + sslKeyFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + sslCertFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + sslCaFileEdit->SetEnabled(sslMode != SslMode::DISABLE); + + break; + } + default: return false; } @@ -312,54 +417,32 @@ namespace ignite void DsnConfigurationWindow::RetrieveParameters(config::Configuration& cfg) const { + RetrieveConnectionParameters(cfg); + RetrieveSslParameters(cfg); + RetrieveAdditionalParameters(cfg); + } + + void DsnConfigurationWindow::RetrieveConnectionParameters(config::Configuration& cfg) const + { std::string dsn; std::string address; std::string schema; - std::string pageSizeStr; std::string version; - bool distributedJoins; - bool enforceJoinOrder; - bool replicatedOnly; - bool collocated; - bool lazy; - bool skipReducerOnUpdate; - nameEdit->GetText(dsn); addressEdit->GetText(address); schemaEdit->GetText(schema); protocolVersionComboBox->GetText(version); - pageSizeEdit->GetText(pageSizeStr); - - int32_t pageSize = common::LexicalCast<int32_t>(pageSizeStr); - - if (pageSize <= 0) - pageSize = config.GetPageSize(); common::StripSurroundingWhitespaces(address); common::StripSurroundingWhitespaces(dsn); - - distributedJoins = distributedJoinsCheckBox->IsEnabled() && distributedJoinsCheckBox->IsChecked(); - enforceJoinOrder = enforceJoinOrderCheckBox->IsEnabled() && enforceJoinOrderCheckBox->IsChecked(); - replicatedOnly = replicatedOnlyCheckBox->IsEnabled() && replicatedOnlyCheckBox->IsChecked(); - collocated = collocatedCheckBox->IsEnabled() && collocatedCheckBox->IsChecked(); - lazy = lazyCheckBox->IsEnabled() && lazyCheckBox->IsChecked(); - - skipReducerOnUpdate = - skipReducerOnUpdateCheckBox->IsEnabled() && skipReducerOnUpdateCheckBox->IsChecked(); + // Stripping of whitespaces off the schema skipped intentionally LOG_MSG("Retriving arguments:"); LOG_MSG("DSN: " << dsn); LOG_MSG("Address: " << address); LOG_MSG("Schema: " << schema); - LOG_MSG("Page size: " << pageSize); LOG_MSG("Protocol version: " << version); - LOG_MSG("Distributed Joins: " << (distributedJoins ? "true" : "false")); - LOG_MSG("Enforce Join Order: " << (enforceJoinOrder ? "true" : "false")); - LOG_MSG("Replicated only: " << (replicatedOnly ? "true" : "false")); - LOG_MSG("Collocated: " << (collocated ? "true" : "false")); - LOG_MSG("Lazy: " << (lazy ? "true" : "false")); - LOG_MSG("Skip reducer on update: " << (skipReducerOnUpdate ? "true" : "false")); if (dsn.empty()) throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty."); @@ -367,8 +450,68 @@ namespace ignite cfg.SetDsn(dsn); cfg.SetAddress(address); cfg.SetSchema(schema); - cfg.SetPageSize(pageSize); cfg.SetProtocolVersion(version); + } + + void DsnConfigurationWindow::RetrieveSslParameters(config::Configuration& cfg) const + { + std::string sslMode; + std::string sslKey; + std::string sslCert; + std::string sslCa; + + sslModeComboBox->GetText(sslMode); + sslKeyFileEdit->GetText(sslKey); + sslCertFileEdit->GetText(sslCert); + sslCaFileEdit->GetText(sslCa); + + LOG_MSG("Retriving arguments:"); + LOG_MSG("SSL Mode: " << sslMode); + LOG_MSG("SSL Key: " << sslKey); + LOG_MSG("SSL Certificate: " << sslCert); + LOG_MSG("SSL CA: " << sslCa); + + cfg.SetSslMode(sslMode); + cfg.SetSslKeyFile(sslKey); + cfg.SetSslCertFile(sslCert); + cfg.SetSslCaFile(sslCa); + } + + void DsnConfigurationWindow::RetrieveAdditionalParameters(config::Configuration& cfg) const + { + std::string pageSizeStr; + + bool distributedJoins; + bool enforceJoinOrder; + bool replicatedOnly; + bool collocated; + bool lazy; + bool skipReducerOnUpdate; + + pageSizeEdit->GetText(pageSizeStr); + + int32_t pageSize = common::LexicalCast<int32_t>(pageSizeStr); + + if (pageSize <= 0) + pageSize = config.GetPageSize(); + + distributedJoins = distributedJoinsCheckBox->IsChecked(); + enforceJoinOrder = enforceJoinOrderCheckBox->IsChecked(); + replicatedOnly = replicatedOnlyCheckBox->IsChecked(); + collocated = collocatedCheckBox->IsChecked(); + lazy = lazyCheckBox->IsChecked(); + skipReducerOnUpdate = skipReducerOnUpdateCheckBox->IsChecked(); + + LOG_MSG("Retriving arguments:"); + LOG_MSG("Page size: " << pageSize); + LOG_MSG("Distributed Joins: " << (distributedJoins ? "true" : "false")); + LOG_MSG("Enforce Join Order: " << (enforceJoinOrder ? "true" : "false")); + LOG_MSG("Replicated only: " << (replicatedOnly ? "true" : "false")); + LOG_MSG("Collocated: " << (collocated ? "true" : "false")); + LOG_MSG("Lazy: " << (lazy ? "true" : "false")); + LOG_MSG("Skip reducer on update: " << (skipReducerOnUpdate ? "true" : "false")); + + cfg.SetPageSize(pageSize); cfg.SetDistributedJoins(distributedJoins); cfg.SetEnforceJoinOrder(enforceJoinOrder); cfg.SetReplicatedOnly(replicatedOnly); http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp index aca23eb..8f2340a 100644 --- a/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp +++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp @@ -130,6 +130,13 @@ namespace ignite void Window::GetText(std::string& text) const { + if (!IsEnabled()) + { + text.clear(); + + return; + } + int len = GetWindowTextLength(handle); if (len <= 0) @@ -154,7 +161,7 @@ namespace ignite bool Window::IsChecked() const { - return Button_GetCheck(handle) == BST_CHECKED; + return IsEnabled() && Button_GetCheck(handle) == BST_CHECKED; } void Window::SetChecked(bool state) http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj index c5783ff..239a30f 100644 --- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj +++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj @@ -93,13 +93,16 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <SDLCheck>false</SDLCheck> - <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(OPENSSL_HOME)\include;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> - <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> + <DelayLoadDLLs> + </DelayLoadDLLs> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> @@ -107,13 +110,16 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <SDLCheck>false</SDLCheck> - <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(OPENSSL_HOME)\include;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> - <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> + <DelayLoadDLLs> + </DelayLoadDLLs> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> @@ -122,7 +128,7 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(OPENSSL_HOME)\include;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions> <BufferSecurityCheck>false</BufferSecurityCheck> </ClCompile> @@ -131,7 +137,8 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> - <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> @@ -140,7 +147,7 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(OPENSSL_HOME)\include;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions> <BufferSecurityCheck>false</BufferSecurityCheck> </ClCompile> @@ -149,12 +156,13 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> - <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\..\os\win\src\system_dsn.cpp" /> - <ClCompile Include="..\..\os\win\src\system\socket_client.cpp" /> + <ClCompile Include="..\..\os\win\src\system\tcp_socket_client.cpp" /> <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp" /> <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp" /> <ClCompile Include="..\..\os\win\src\system\ui\window.cpp" /> @@ -188,6 +196,9 @@ <ClCompile Include="..\..\src\query\type_info_query.cpp" /> <ClCompile Include="..\..\src\result_page.cpp" /> <ClCompile Include="..\..\src\row.cpp" /> + <ClCompile Include="..\..\src\ssl\secure_socket_client.cpp" /> + <ClCompile Include="..\..\src\ssl\ssl_gateway.cpp" /> + <ClCompile Include="..\..\src\ssl\ssl_mode.cpp" /> <ClCompile Include="..\..\src\statement.cpp" /> <ClCompile Include="..\..\src\type_traits.cpp" /> <ClCompile Include="..\..\src\utility.cpp" /> @@ -231,9 +242,14 @@ <ClInclude Include="..\..\include\ignite\odbc\query\type_info_query.h" /> <ClInclude Include="..\..\include\ignite\odbc\result_page.h" /> <ClInclude Include="..\..\include\ignite\odbc\row.h" /> + <ClInclude Include="..\..\include\ignite\odbc\socket_client.h" /> + <ClInclude Include="..\..\include\ignite\odbc\ssl\secure_socket_client.h" /> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_bindings.h" /> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_gateway.h" /> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_mode.h" /> <ClInclude Include="..\..\include\ignite\odbc\statement.h" /> <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" /> - <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" /> + <ClInclude Include="..\..\include\ignite\odbc\system\tcp_socket_client.h" /> <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h" /> <ClInclude Include="..\..\include\ignite\odbc\type_traits.h" /> <ClInclude Include="..\..\include\ignite\odbc\utility.h" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters index 8934625..b203b21 100644 --- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters +++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters @@ -29,6 +29,9 @@ <Filter Include="Code\system\ui"> <UniqueIdentifier>{ff144e89-0a10-42c3-97dd-d22bfdbc7abb}</UniqueIdentifier> </Filter> + <Filter Include="Code\ssl"> + <UniqueIdentifier>{857734a3-6b29-412a-b75e-7fcc9d3fef8c}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="..\..\src\odbc.cpp"> @@ -106,9 +109,6 @@ <ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp"> <Filter>Code\diagnostic</Filter> </ClCompile> - <ClCompile Include="..\..\os\win\src\system\socket_client.cpp"> - <Filter>Code\system</Filter> - </ClCompile> <ClCompile Include="..\..\src\query\type_info_query.cpp"> <Filter>Code\query</Filter> </ClCompile> @@ -148,6 +148,18 @@ <ClCompile Include="..\..\src\message.cpp"> <Filter>Code</Filter> </ClCompile> + <ClCompile Include="..\..\src\ssl\secure_socket_client.cpp"> + <Filter>Code\ssl</Filter> + </ClCompile> + <ClCompile Include="..\..\os\win\src\system\tcp_socket_client.cpp"> + <Filter>Code\system</Filter> + </ClCompile> + <ClCompile Include="..\..\src\ssl\ssl_mode.cpp"> + <Filter>Code\ssl</Filter> + </ClCompile> + <ClCompile Include="..\..\src\ssl\ssl_gateway.cpp"> + <Filter>Code\ssl</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <None Include="module.def"> @@ -245,9 +257,6 @@ <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h"> <Filter>Code\system</Filter> </ClInclude> - <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h"> - <Filter>Code\system</Filter> - </ClInclude> <ClInclude Include="..\..\include\ignite\odbc\query\type_info_query.h"> <Filter>Code\query</Filter> </ClInclude> @@ -284,5 +293,23 @@ <ClInclude Include="..\..\include\ignite\odbc\odbc_error.h"> <Filter>Code</Filter> </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\ssl\secure_socket_client.h"> + <Filter>Code\ssl</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\socket_client.h"> + <Filter>Code</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\system\tcp_socket_client.h"> + <Filter>Code\system</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_mode.h"> + <Filter>Code\ssl</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_gateway.h"> + <Filter>Code\ssl</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_bindings.h"> + <Filter>Code\ssl</Filter> + </ClInclude> </ItemGroup> </Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/394019ee/modules/platforms/cpp/odbc/src/config/configuration.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp index be5a781..769e167 100644 --- a/modules/platforms/cpp/odbc/src/config/configuration.cpp +++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp @@ -46,12 +46,20 @@ namespace ignite const std::string Configuration::Key::collocated = "collocated"; const std::string Configuration::Key::lazy = "lazy"; const std::string Configuration::Key::skipReducerOnUpdate = "skip_reducer_on_update"; + const std::string Configuration::Key::sslMode = "ssl_mode"; + const std::string Configuration::Key::sslKeyFile = "ssl_key_file"; + const std::string Configuration::Key::sslCertFile = "ssl_cert_file"; + const std::string Configuration::Key::sslCaFile = "ssl_ca_file"; const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN"; const std::string Configuration::DefaultValue::driver = "Apache Ignite"; const std::string Configuration::DefaultValue::schema = "PUBLIC"; const std::string Configuration::DefaultValue::address = ""; const std::string Configuration::DefaultValue::server = ""; + const std::string Configuration::DefaultValue::sslMode = "disable"; + const std::string Configuration::DefaultValue::sslKeyFile = ""; + const std::string Configuration::DefaultValue::sslCertFile = ""; + const std::string Configuration::DefaultValue::sslCaFile = ""; const uint16_t Configuration::DefaultValue::port = 10800; const int32_t Configuration::DefaultValue::pageSize = 1024;
