Updated the main API, echoserver, client, and server for the NO_WOLFSSH_SERVER and NO_WOLFSSH_CLIENT options.

pull/134/head
John Safranek 2019-01-09 14:25:28 -08:00
parent 42675723e2
commit 7e9981c6ec
4 changed files with 31 additions and 7 deletions

View File

@ -20,7 +20,6 @@
#define WOLFSSH_TEST_CLIENT
#include <wolfssh/ssh.h>
#include <wolfssh/test.h>
#include "examples/client/client.h"
@ -28,6 +27,8 @@
#include <termios.h>
#endif
#ifndef NO_WOLFSSH_CLIENT
const char testString[] = "Hello, wolfSSH!";
@ -323,6 +324,8 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
return 0;
}
#endif /* NO_WOLFSSH_CLIENT */
#ifndef NO_MAIN_DRIVER
@ -344,7 +347,9 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
wolfSSH_Init();
ChangeToWolfSshRoot();
#ifndef NO_WOLFSSH_CLIENT
client_test(&args);
#endif
wolfSSH_Cleanup();

View File

@ -46,6 +46,8 @@
#endif
#ifndef NO_WOLFSSH_SERVER
static const char echoserverBanner[] = "wolfSSH Example Echo Server\n";
@ -179,14 +181,11 @@ static int ssh_worker(thread_ctx_t* threadCtx) {
* returns 0 on success
*/
static int sftp_worker(thread_ctx_t* threadCtx) {
int ret = 0;
int ret;
(void)threadCtx;
#ifndef NO_WOLFSSH_SERVER
do {
ret = wolfSSH_SFTP_read(threadCtx->ssh);
} while (ret != WS_FATAL_ERROR);
#endif
return ret;
}
@ -815,6 +814,8 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
return 0;
}
#endif /* NO_WOLFSSH_SERVER */
#ifndef NO_MAIN_DRIVER
@ -836,7 +837,9 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
#ifndef WOLFSSL_NUCLEUS
ChangeToWolfSshRoot();
#endif
#ifndef NO_WOLFSSH_SERVER
echoserver_test(&args);
#endif
wolfSSH_Cleanup();

View File

@ -39,6 +39,8 @@
#endif
#ifndef NO_WOLFSSH_SERVER
static const char serverBanner[] = "wolfSSH Example Server\n";
@ -709,6 +711,9 @@ THREAD_RETURN WOLFSSH_THREAD server_test(void* args)
return 0;
}
#endif /* NO_WOLFSSH_SERVER */
#ifndef NO_MAIN_DRIVER
int main(int argc, char** argv)
@ -728,7 +733,9 @@ THREAD_RETURN WOLFSSH_THREAD server_test(void* args)
wolfSSH_Init();
#ifndef NO_WOLFSSH_SERVER
server_test(&args);
#endif
wolfSSH_Cleanup();

View File

@ -254,6 +254,8 @@ const char* wolfSSH_ErrorToName(int err)
}
#ifndef NO_WOLFSSH_SERVER
const char acceptError[] = "accept error: %s, %d";
const char acceptState[] = "accept state: %s";
@ -434,6 +436,10 @@ int wolfSSH_accept(WOLFSSH* ssh)
return WS_SUCCESS;
}
#endif /* NO_WOLFSSH_SERVER */
#ifndef NO_WOLFSSH_CLIENT
const char connectError[] = "connect error: %s, %d";
const char connectState[] = "connect state: %s";
@ -473,7 +479,7 @@ int wolfSSH_connect(WOLFSSH* ssh)
case CONNECT_SERVER_VERSION_DONE:
if ( (ssh->error = SendKexInit(ssh)) < WS_SUCCESS) {
WLOG(WS_LOG_DEBUG, acceptError,
WLOG(WS_LOG_DEBUG, connectError,
"SERVER_VERSION_DONE", ssh->error);
return WS_FATAL_ERROR;
}
@ -648,6 +654,8 @@ int wolfSSH_connect(WOLFSSH* ssh)
return WS_SUCCESS;
}
#endif /* NO_WOLFSSH_CLIENT */
int wolfSSH_shutdown(WOLFSSH* ssh)
{
@ -1232,7 +1240,8 @@ int wolfSSH_ChannelSend(WOLFSSH_CHANNEL* channel,
{
int bytesTxd = 0;
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelSend(), ID = %d, peerID = %d", channel->channel, channel->peerChannel);
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelSend(), ID = %d, peerID = %d",
channel->channel, channel->peerChannel);
#ifdef DEBUG_WOLFSSH
DumpOctetString(buf, bufSz);