mirror of https://github.com/wolfSSL/wolfssh.git
commit
b6ccb07de4
|
@ -991,7 +991,8 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args)
|
|||
err_sys("Couldn't set the username.");
|
||||
|
||||
build_addr(&clientAddr, config.hostname, config.port);
|
||||
tcp_socket(&sockFd);
|
||||
tcp_socket(&sockFd, ((struct sockaddr_in *)&clientAddr)->sin_family);
|
||||
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz);
|
||||
if (ret != 0)
|
||||
err_sys("Couldn't connect to server.");
|
||||
|
|
|
@ -2374,8 +2374,8 @@ static int StartSSHD(int argc, char** argv)
|
|||
#ifdef WOLFSSL_NUCLEUS
|
||||
struct addr_struct clientAddr;
|
||||
#else
|
||||
SOCKADDR_IN_T clientAddr;
|
||||
socklen_t clientAddrSz = sizeof(clientAddr);
|
||||
struct sockaddr_in6 clientAddr;
|
||||
socklen_t clientAddrSz = sizeof(clientAddr);
|
||||
#endif
|
||||
conn = (WOLFSSHD_CONNECTION*)WMALLOC(sizeof(WOLFSSHD_CONNECTION), NULL, DYNTYPE_SSHD);
|
||||
if (conn == NULL) {
|
||||
|
@ -2396,13 +2396,16 @@ static int StartSSHD(int argc, char** argv)
|
|||
conn->fd = (int)accept(listenFd, (struct sockaddr*)&clientAddr,
|
||||
&clientAddrSz);
|
||||
if (conn->fd >= 0) {
|
||||
inet_ntop(AF_INET,
|
||||
#ifdef TEST_IPV6
|
||||
&clientAddr.sin6_addr,
|
||||
#else
|
||||
&clientAddr.sin_addr,
|
||||
#endif /* TEST_IPV6 */
|
||||
conn->ip, INET_ADDRSTRLEN);
|
||||
if (clientAddr.sin6_family == AF_INET) {
|
||||
struct sockaddr_in* addr4 =
|
||||
(struct sockaddr_in*)&clientAddr;
|
||||
inet_ntop(AF_INET, &addr4->sin_addr, conn->ip,
|
||||
INET_ADDRSTRLEN);
|
||||
}
|
||||
else if (clientAddr.sin6_family == AF_INET6) {
|
||||
inet_ntop(AF_INET6, &clientAddr.sin6_addr, conn->ip,
|
||||
INET6_ADDRSTRLEN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -904,7 +904,8 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
|
|||
}
|
||||
|
||||
build_addr(&clientAddr, host, port);
|
||||
tcp_socket(&sockFd);
|
||||
tcp_socket(&sockFd, ((struct sockaddr_in *)&clientAddr)->sin_family);
|
||||
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz);
|
||||
if (ret != 0)
|
||||
err_sys("Couldn't connect to server.");
|
||||
|
|
|
@ -380,12 +380,14 @@ THREAD_RETURN WOLFSSH_THREAD portfwd_worker(void* args)
|
|||
if (ret != WS_SUCCESS)
|
||||
err_sys("Couldn't set the username.");
|
||||
|
||||
/* Socket to SSH peer. */
|
||||
build_addr(&hostAddr, host, port);
|
||||
build_addr(&fwdFromHostAddr, fwdFromHost, fwdFromPort);
|
||||
tcp_socket(&sshFd, ((struct sockaddr_in *)&hostAddr)->sin_family);
|
||||
|
||||
/* Receive from client application or connect to server application. */
|
||||
build_addr(&fwdFromHostAddr, fwdFromHost, fwdFromPort);
|
||||
tcp_socket(&listenFd, ((struct sockaddr_in *)&fwdFromHostAddr)->sin_family);
|
||||
|
||||
tcp_socket(&sshFd); /* Socket to SSH peer. */
|
||||
tcp_socket(&listenFd); /* Either receive from client application or connect
|
||||
to server application. */
|
||||
tcp_listen(&listenFd, &fwdFromPort, 1);
|
||||
|
||||
printf("Connecting to the SSH server...\n");
|
||||
|
|
|
@ -280,8 +280,9 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
|
|||
{
|
||||
printf("IPV4 address\n");
|
||||
build_addr(&clientAddr, host, port);
|
||||
tcp_socket(&sockFd);
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz);
|
||||
tcp_socket(&sockFd, ((struct sockaddr_in *)&clientAddr)->sin_family);
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr,
|
||||
clientAddrSz);
|
||||
}
|
||||
|
||||
if (ret != 0)
|
||||
|
|
|
@ -1366,7 +1366,8 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
|
|||
err_sys("Couldn't set the username.");
|
||||
|
||||
build_addr(&clientAddr, host, port);
|
||||
tcp_socket(&sockFd);
|
||||
tcp_socket(&sockFd, ((struct sockaddr_in *)&clientAddr)->sin_family);
|
||||
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz);
|
||||
if (ret != 0)
|
||||
err_sys("Couldn't connect to server.");
|
||||
|
|
|
@ -921,7 +921,7 @@ static void sftp_client_connect(WOLFSSH_CTX** ctx, WOLFSSH** ssh, int port)
|
|||
}
|
||||
|
||||
build_addr(&clientAddr, host, port);
|
||||
tcp_socket(&sockFd);
|
||||
tcp_socket(&sockFd, ((struct sockaddr_in *)&clientAddr)->sin_family);
|
||||
ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz);
|
||||
if (ret != 0){
|
||||
wolfSSH_free(*ssh);
|
||||
|
|
|
@ -519,7 +519,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
|||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
|
||||
hints.ai_family = AF_INET_V;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
|
@ -546,8 +546,10 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
|||
#endif
|
||||
|
||||
|
||||
static INLINE void tcp_socket(WS_SOCKET_T* sockFd)
|
||||
static INLINE void tcp_socket(WS_SOCKET_T* sockFd, int targetProtocol)
|
||||
{
|
||||
/* targetProtocol is only used if none of these platforms are defined. */
|
||||
WOLFSSH_UNUSED(targetProtocol);
|
||||
#ifdef MICROCHIP_MPLAB_HARMONY
|
||||
/* creates socket in listen or connect */
|
||||
*sockFd = 0;
|
||||
|
@ -558,7 +560,7 @@ static INLINE void tcp_socket(WS_SOCKET_T* sockFd)
|
|||
#elif defined(WOLFSSL_NUCLEUS)
|
||||
*sockFd = NU_Socket(NU_FAMILY_IP, NU_TYPE_STREAM, 0);
|
||||
#else
|
||||
*sockFd = socket(AF_INET_V, SOCK_STREAM, 0);
|
||||
*sockFd = socket(targetProtocol, SOCK_STREAM, 0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
|
@ -637,8 +639,7 @@ static INLINE void tcp_listen(WS_SOCKET_T* sockfd, word16* port, int useAnyAddr)
|
|||
/* don't use INADDR_ANY by default, firewall may block, make user switch
|
||||
on */
|
||||
build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfSshIp), *port);
|
||||
tcp_socket(sockfd);
|
||||
|
||||
tcp_socket(sockfd, ((struct sockaddr_in *)&addr)->sin_family);
|
||||
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM) \
|
||||
&& !defined(WOLFSSL_KEIL_TCP_NET) \
|
||||
&& !defined(WOLFSSL_NUCLEUS) \
|
||||
|
|
Loading…
Reference in New Issue