diff --git a/src/internal.c b/src/internal.c index 3a7508fc9..72e909f45 100644 --- a/src/internal.c +++ b/src/internal.c @@ -13477,7 +13477,8 @@ int SendIgnore(WOLFSSH* ssh, const unsigned char* data, word32 dataSz) return ret; } -int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, int reply) +int SendGlobalRequest(WOLFSSH* ssh, + const unsigned char* data, word32 dataSz, int reply) { byte* output; word32 idx = 0; @@ -13490,18 +13491,15 @@ int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, in if (ret == WS_SUCCESS) ret = PreparePacket(ssh, MSG_ID_SZ + LENGTH_SZ + dataSz + BOOLEAN_SZ); - WLOG(WS_LOG_DEBUG, "Done PreparePacket"); - if (ret == WS_SUCCESS) - { + if (ret == WS_SUCCESS) { output = ssh->outputBuffer.buffer; idx = ssh->outputBuffer.length; output[idx++] = MSGID_GLOBAL_REQUEST; c32toa(dataSz, output + idx); idx += LENGTH_SZ; - if (dataSz > 0) - { + if (dataSz > 0) { WMEMCPY(output + idx, data, dataSz); idx += dataSz; } @@ -13512,12 +13510,11 @@ int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, in ret = BundlePacket(ssh); } - WLOG(WS_LOG_DEBUG, "Done BundlePacket"); if (ret == WS_SUCCESS) ret = wolfSSH_SendPacket(ssh); - WLOG(WS_LOG_DEBUG, "Leaving SendServiceRequest(), ret = %d", ret); + WLOG(WS_LOG_DEBUG, "Leaving SendGlobalRequest(), ret = %d", ret); return ret; } @@ -13590,8 +13587,7 @@ int SendServiceRequest(WOLFSSH* ssh, byte serviceId) serviceName = IdToName(serviceId); serviceNameSz = (word32)WSTRLEN(serviceName); - ret = PreparePacket(ssh, - MSG_ID_SZ + LENGTH_SZ + serviceNameSz); + ret = PreparePacket(ssh, MSG_ID_SZ + LENGTH_SZ + serviceNameSz); } if (ret == WS_SUCCESS) { diff --git a/src/ssh.c b/src/ssh.c index 84986a205..c30d5fd4a 100644 --- a/src/ssh.c +++ b/src/ssh.c @@ -3282,16 +3282,34 @@ void wolfSSH_SetKeyingCompletionCbCtx(WOLFSSH* ssh, void* ctx) } +const char* wolfSSH_ChannelGetType(const WOLFSSH_CHANNEL* channel) +{ + const char* name = NULL; + + WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetType()"); + + if (channel != NULL) { + name = IdToName(channel->channelType); + } + + WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_ChannelGetType(), name = %s", + channel ? name : "null channel"); + return name; +} + + WS_SessionType wolfSSH_ChannelGetSessionType(const WOLFSSH_CHANNEL* channel) { WS_SessionType type = WOLFSSH_SESSION_UNKNOWN; - WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetType()"); + WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetSessionType()"); if (channel) { type = (WS_SessionType)channel->sessionType; } + WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_ChannelGetSessionType(), type = %d", + type); return type; } diff --git a/tests/testsuite.c b/tests/testsuite.c index 9fc21ba96..f7111920d 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -69,6 +69,8 @@ char* myoptarg = NULL; #if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT) && \ !defined(SINGLE_THREADED) && !defined(WOLFSSH_TEST_BLOCK) +#ifdef WOLFSSH_SHELL + static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx) { static char password[] = "upthehill"; @@ -91,7 +93,7 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx) #define NUMARGS 5 #define ARGLEN 32 -int wolfSSH_TestsuiteTest(int argc, char** argv) +static void wolfSSH_EchoTest(void) { tcp_ready ready; THREAD_TYPE serverThread; @@ -106,30 +108,6 @@ int wolfSSH_TestsuiteTest(int argc, char** argv) int serverArgc = 0; int clientArgc = 0; - (void)argc; - (void)argv; - - WSTARTTCP(); - - #if defined(DEBUG_WOLFSSH) - wolfSSH_Debugging_ON(); - #endif - - wolfSSH_Init(); - - #if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2) - { - int i; - for (i = 0; i < FIPS_CAST_COUNT; i++) { - wc_RunCast_fips(i); - } - } - #endif /* HAVE_FIPS */ - - #if !defined(WOLFSSL_TIRTOS) - ChangeToWolfSshRoot(); - #endif - InitTcpReady(&ready); WSTRNCPY(serverArgv[serverArgc++], "echoserver", ARGLEN); @@ -163,9 +141,6 @@ int wolfSSH_TestsuiteTest(int argc, char** argv) clientArgs.user_auth = tsClientUserAuth; client_test(&clientArgs); - if (clientArgs.return_code != 0) { - return clientArgs.return_code; - } #ifdef WOLFSSH_ZEPHYR /* Weird deadlock without this sleep */ @@ -173,8 +148,42 @@ int wolfSSH_TestsuiteTest(int argc, char** argv) #endif ThreadJoin(serverThread); - wolfSSH_Cleanup(); FreeTcpReady(&ready); +} +#endif /* WOLFSSH_SHELL */ + + +int wolfSSH_TestsuiteTest(int argc, char** argv) +{ + (void)argc; + (void)argv; + + WSTARTTCP(); + + #if defined(DEBUG_WOLFSSH) + wolfSSH_Debugging_ON(); + #endif + + wolfSSH_Init(); + + #if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2) + { + int i; + for (i = 0; i < FIPS_CAST_COUNT; i++) { + wc_RunCast_fips(i); + } + } + #endif /* HAVE_FIPS */ + + #if !defined(WOLFSSL_TIRTOS) + ChangeToWolfSshRoot(); + #endif + +#ifdef WOLFSSH_SHELL + wolfSSH_EchoTest(); +#endif + + wolfSSH_Cleanup(); #ifdef WOLFSSH_SFTP printf("testing SFTP blocking\n"); @@ -184,7 +193,6 @@ int wolfSSH_TestsuiteTest(int argc, char** argv) wolfSSH_SftpTest(1); #endif #endif - return EXIT_SUCCESS; } diff --git a/wolfssh/ssh.h b/wolfssh/ssh.h index b1b489431..b5b04eb59 100644 --- a/wolfssh/ssh.h +++ b/wolfssh/ssh.h @@ -229,6 +229,8 @@ WOLFSSH_API int wolfSSH_ChannelRead(WOLFSSH_CHANNEL*, byte*, word32); WOLFSSH_API int wolfSSH_ChannelSend(WOLFSSH_CHANNEL*, const byte*, word32); WOLFSSH_API int wolfSSH_ChannelExit(WOLFSSH_CHANNEL*); WOLFSSH_API int wolfSSH_ChannelGetEof(WOLFSSH_CHANNEL*); +WOLFSSH_API const char* wolfSSH_ChannelGetType( + const WOLFSSH_CHANNEL* channel); WOLFSSH_API WS_SessionType wolfSSH_ChannelGetSessionType( const WOLFSSH_CHANNEL* channel); WOLFSSH_API const char* wolfSSH_ChannelGetSessionCommand(