Skip to content

Commit d32dd2b

Browse files
Merge pull request #873 from ejohnstown/misc-updates
Misc Updates
2 parents e8e5d37 + ea45034 commit d32dd2b

File tree

4 files changed

+65
-41
lines changed

4 files changed

+65
-41
lines changed

src/internal.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13477,7 +13477,8 @@ int SendIgnore(WOLFSSH* ssh, const unsigned char* data, word32 dataSz)
1347713477
return ret;
1347813478
}
1347913479

13480-
int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, int reply)
13480+
int SendGlobalRequest(WOLFSSH* ssh,
13481+
const unsigned char* data, word32 dataSz, int reply)
1348113482
{
1348213483
byte* output;
1348313484
word32 idx = 0;
@@ -13490,18 +13491,15 @@ int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, in
1349013491

1349113492
if (ret == WS_SUCCESS)
1349213493
ret = PreparePacket(ssh, MSG_ID_SZ + LENGTH_SZ + dataSz + BOOLEAN_SZ);
13493-
WLOG(WS_LOG_DEBUG, "Done PreparePacket");
1349413494

13495-
if (ret == WS_SUCCESS)
13496-
{
13495+
if (ret == WS_SUCCESS) {
1349713496
output = ssh->outputBuffer.buffer;
1349813497
idx = ssh->outputBuffer.length;
1349913498

1350013499
output[idx++] = MSGID_GLOBAL_REQUEST;
1350113500
c32toa(dataSz, output + idx);
1350213501
idx += LENGTH_SZ;
13503-
if (dataSz > 0)
13504-
{
13502+
if (dataSz > 0) {
1350513503
WMEMCPY(output + idx, data, dataSz);
1350613504
idx += dataSz;
1350713505
}
@@ -13512,12 +13510,11 @@ int SendGlobalRequest(WOLFSSH* ssh, const unsigned char* data, word32 dataSz, in
1351213510

1351313511
ret = BundlePacket(ssh);
1351413512
}
13515-
WLOG(WS_LOG_DEBUG, "Done BundlePacket");
1351613513

1351713514
if (ret == WS_SUCCESS)
1351813515
ret = wolfSSH_SendPacket(ssh);
1351913516

13520-
WLOG(WS_LOG_DEBUG, "Leaving SendServiceRequest(), ret = %d", ret);
13517+
WLOG(WS_LOG_DEBUG, "Leaving SendGlobalRequest(), ret = %d", ret);
1352113518

1352213519
return ret;
1352313520
}
@@ -13590,8 +13587,7 @@ int SendServiceRequest(WOLFSSH* ssh, byte serviceId)
1359013587
serviceName = IdToName(serviceId);
1359113588
serviceNameSz = (word32)WSTRLEN(serviceName);
1359213589

13593-
ret = PreparePacket(ssh,
13594-
MSG_ID_SZ + LENGTH_SZ + serviceNameSz);
13590+
ret = PreparePacket(ssh, MSG_ID_SZ + LENGTH_SZ + serviceNameSz);
1359513591
}
1359613592

1359713593
if (ret == WS_SUCCESS) {

src/ssh.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3282,16 +3282,34 @@ void wolfSSH_SetKeyingCompletionCbCtx(WOLFSSH* ssh, void* ctx)
32823282
}
32833283

32843284

3285+
const char* wolfSSH_ChannelGetType(const WOLFSSH_CHANNEL* channel)
3286+
{
3287+
const char* name = NULL;
3288+
3289+
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetType()");
3290+
3291+
if (channel != NULL) {
3292+
name = IdToName(channel->channelType);
3293+
}
3294+
3295+
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_ChannelGetType(), name = %s",
3296+
channel ? name : "null channel");
3297+
return name;
3298+
}
3299+
3300+
32853301
WS_SessionType wolfSSH_ChannelGetSessionType(const WOLFSSH_CHANNEL* channel)
32863302
{
32873303
WS_SessionType type = WOLFSSH_SESSION_UNKNOWN;
32883304

3289-
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetType()");
3305+
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_ChannelGetSessionType()");
32903306

32913307
if (channel) {
32923308
type = (WS_SessionType)channel->sessionType;
32933309
}
32943310

3311+
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_ChannelGetSessionType(), type = %d",
3312+
type);
32953313
return type;
32963314
}
32973315

tests/testsuite.c

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ char* myoptarg = NULL;
6969
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT) && \
7070
!defined(SINGLE_THREADED) && !defined(WOLFSSH_TEST_BLOCK)
7171

72+
#ifdef WOLFSSH_SHELL
73+
7274
static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
7375
{
7476
static char password[] = "upthehill";
@@ -91,7 +93,7 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
9193
#define NUMARGS 5
9294
#define ARGLEN 32
9395

94-
int wolfSSH_TestsuiteTest(int argc, char** argv)
96+
static void wolfSSH_EchoTest(void)
9597
{
9698
tcp_ready ready;
9799
THREAD_TYPE serverThread;
@@ -106,30 +108,6 @@ int wolfSSH_TestsuiteTest(int argc, char** argv)
106108
int serverArgc = 0;
107109
int clientArgc = 0;
108110

109-
(void)argc;
110-
(void)argv;
111-
112-
WSTARTTCP();
113-
114-
#if defined(DEBUG_WOLFSSH)
115-
wolfSSH_Debugging_ON();
116-
#endif
117-
118-
wolfSSH_Init();
119-
120-
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2)
121-
{
122-
int i;
123-
for (i = 0; i < FIPS_CAST_COUNT; i++) {
124-
wc_RunCast_fips(i);
125-
}
126-
}
127-
#endif /* HAVE_FIPS */
128-
129-
#if !defined(WOLFSSL_TIRTOS)
130-
ChangeToWolfSshRoot();
131-
#endif
132-
133111
InitTcpReady(&ready);
134112

135113
WSTRNCPY(serverArgv[serverArgc++], "echoserver", ARGLEN);
@@ -163,18 +141,49 @@ int wolfSSH_TestsuiteTest(int argc, char** argv)
163141
clientArgs.user_auth = tsClientUserAuth;
164142

165143
client_test(&clientArgs);
166-
if (clientArgs.return_code != 0) {
167-
return clientArgs.return_code;
168-
}
169144

170145
#ifdef WOLFSSH_ZEPHYR
171146
/* Weird deadlock without this sleep */
172147
k_sleep(Z_TIMEOUT_TICKS(100));
173148
#endif
174149
ThreadJoin(serverThread);
175150

176-
wolfSSH_Cleanup();
177151
FreeTcpReady(&ready);
152+
}
153+
#endif /* WOLFSSH_SHELL */
154+
155+
156+
int wolfSSH_TestsuiteTest(int argc, char** argv)
157+
{
158+
(void)argc;
159+
(void)argv;
160+
161+
WSTARTTCP();
162+
163+
#if defined(DEBUG_WOLFSSH)
164+
wolfSSH_Debugging_ON();
165+
#endif
166+
167+
wolfSSH_Init();
168+
169+
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2)
170+
{
171+
int i;
172+
for (i = 0; i < FIPS_CAST_COUNT; i++) {
173+
wc_RunCast_fips(i);
174+
}
175+
}
176+
#endif /* HAVE_FIPS */
177+
178+
#if !defined(WOLFSSL_TIRTOS)
179+
ChangeToWolfSshRoot();
180+
#endif
181+
182+
#ifdef WOLFSSH_SHELL
183+
wolfSSH_EchoTest();
184+
#endif
185+
186+
wolfSSH_Cleanup();
178187

179188
#ifdef WOLFSSH_SFTP
180189
printf("testing SFTP blocking\n");
@@ -184,7 +193,6 @@ int wolfSSH_TestsuiteTest(int argc, char** argv)
184193
wolfSSH_SftpTest(1);
185194
#endif
186195
#endif
187-
188196
return EXIT_SUCCESS;
189197
}
190198

wolfssh/ssh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ WOLFSSH_API int wolfSSH_ChannelRead(WOLFSSH_CHANNEL*, byte*, word32);
229229
WOLFSSH_API int wolfSSH_ChannelSend(WOLFSSH_CHANNEL*, const byte*, word32);
230230
WOLFSSH_API int wolfSSH_ChannelExit(WOLFSSH_CHANNEL*);
231231
WOLFSSH_API int wolfSSH_ChannelGetEof(WOLFSSH_CHANNEL*);
232+
WOLFSSH_API const char* wolfSSH_ChannelGetType(
233+
const WOLFSSH_CHANNEL* channel);
232234
WOLFSSH_API WS_SessionType wolfSSH_ChannelGetSessionType(
233235
const WOLFSSH_CHANNEL* channel);
234236
WOLFSSH_API const char* wolfSSH_ChannelGetSessionCommand(

0 commit comments

Comments
 (0)