29 const BOOLEAN closeLastChannel );
42 IN const long channelNo,
49 REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
53 status = getChannelExtAttribute( sessionInfoPtr,
57 status = getChannelExtAttribute( sessionInfoPtr,
86 REQUIRES( windowCount > 0 && windowCount <= windowSize );
88 if( windowCount < windowSize / 2 )
103 if( windowCount < 0 || windowCount >= windowSize )
107 adjustCount = windowSize;
112 adjustCount = windowSize - windowCount;
114 ENSURES( adjustCount > windowSize / 2 && \
115 adjustCount <= windowSize );
116 status = enqueueChannelData( sessionInfoPtr,
118 channelNo, adjustCount );
123 "Error sending SSH window adjust for data flow "
128 windowCount += adjustCount;
129 if( windowCount < windowSize / 2 || windowCount > windowSize )
133 "Invalid SSH flow control window count %d, should be "
134 "%d ... %d", windowCount, windowSize / 2,
138 status = setChannelExtAttribute( sessionInfoPtr,
197 status = processChannelRequest( sessionInfoPtr, stream,
210 status = processChannelOpen( sessionInfoPtr, stream );
236 return( getDisconnectInfo( sessionInfoPtr, stream ) );
271 "Unexpected KEXINIT request received" ) );
280 channelNo = readUint32( stream );
291 "Invalid channel number in channel-specific packet "
294 if( channelNo != getCurrentChannelNo( sessionInfoPtr, \
299 status = selectChannel( sessionInfoPtr, channelNo,
306 "Invalid channel number %lX in "
307 "channel-specific packet type %d, current "
308 "channel is %lX", channelNo,
324 status = length = sread( stream, buffer, 8 );
331 "Unexpected control packet type %d received",
336 "Unexpected control packet type %d received, "
337 "beginning %02X %02X %02X %02X %02X %02X %02X %02X",
339 buffer[ 0 ], buffer[ 1 ], buffer[ 2 ], buffer[ 3 ],
340 buffer[ 4 ], buffer[ 5 ], buffer[ 6 ], buffer[ 7 ] ) );
357 status = length = readUint32( stream );
359 length < 0 || length > sessionInfoPtr->receiveBufSize )
365 status = handleWindowAdjust( sessionInfoPtr, channelNo, length );
390 status = processChannelRequest( sessionInfoPtr, stream,
412 if( getChannelStatusByChannelNo( sessionInfoPtr,
415 status = sendChannelClose( sessionInfoPtr, channelNo,
421 status = deleteChannel( sessionInfoPtr, channelNo,
437 "Remote system closed last remaining SSH channel" ) );
454 IN const long channelNo,
456 const BOOLEAN closeLastChannel )
463 REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
469 status = deleteChannel( sessionInfoPtr, channelNo, channelType,
497 status = sendEnqueuedResponse( sessionInfoPtr );
513 const int currWriteChannelNo = \
515 int noChannels = 1, iterationCount,
status;
524 sNetDisconnect( &sessionInfoPtr->stream );
536 "No channel information available to identify the "
537 "channel to close" ) );
561 ( void ) sendEnqueuedResponse( sessionInfoPtr );
563 sNetDisconnect( &sessionInfoPtr->stream );
568 if( closeAllChannels )
575 for( noChannels = 0, iterationCount = 0;
580 noChannels++, iterationCount++ )
582 status = sendChannelClose( sessionInfoPtr,
586 ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );
595 status = sendChannelClose( sessionInfoPtr, currWriteChannelNo,
605 "Cannot close last remaining channel without "
606 "closing the overall session" ) );
614 status = sendCloseNotification( sessionInfoPtr, NULL, 0 );
620 sNetDisconnect( &sessionInfoPtr->stream );
626 if( sessionInfoPtr->receiveBufSize - sessionInfoPtr->receiveBufEnd < \
627 min( sessionInfoPtr->pendingPacketRemaining, 1024 ) )
629 sNetDisconnect( &sessionInfoPtr->stream );
639 if( sessionInfoPtr->receiveBufPos != sessionInfoPtr->receiveBufEnd )
641 sNetDisconnect( &sessionInfoPtr->stream );
673 for( iterationCount = 0;
675 noChannels--, iterationCount++ )
677 status = sessionInfoPtr->readHeaderFunction( sessionInfoPtr, &readInfo );
683 sessionInfoPtr->receiveBufEnd +=
status;
684 sessionInfoPtr->pendingPacketRemaining -=
status;
685 if( sessionInfoPtr->pendingPacketRemaining <= 512 )
687 const int bytesLeft = sessionInfoPtr->receiveBufSize -
\
692 status = sread( &sessionInfoPtr->stream,
693 sessionInfoPtr->receiveBuffer + \
694 sessionInfoPtr->receiveBufEnd,
695 min( sessionInfoPtr->pendingPacketRemaining, \
701 ENSURES( iterationCount < FAILSAFE_ITERATIONS_SMALL );
702 sNetDisconnect( &sessionInfoPtr->stream );