Skip to content

Commit 327e1d5

Browse files
committed
Channel Type Accessor
Each channel has a type: session, forward, etc. Add an accessor to return the channel type for the specified channel.
1 parent 023b7d7 commit 327e1d5

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

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

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)