Lines Matching refs:channel

112      * a sender channel and the server sends a SSH_MSG_CHANNEL_OPEN_CONFIRMATION in response, with a sender and a
113 * recipient channel. at first glance, you might conclude that SSH_MSG_CHANNEL_OPEN_CONFIRMATION's sender channel
114 * would be the same thing as SSH_MSG_CHANNEL_OPEN's sender channel, but it's not, per this snippet:
115 * The 'recipient channel' is the channel number given in the original
116 * open request, and 'sender channel' is the channel number allocated by
630 * If a client requests a packet from one channel but receives two packets from another those packets should
650 * The identifier of the interactive channel which was opened most recently
660 * Maximum packet size indexed by channel
710 * Window size indexed by channel
720 * Window size indexed by channel
2934 * Opens a channel
2936 * @param string $channel
2940 protected function open_channel($channel, $skip_extended = false)
2942 if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_CLOSE) {
2943 throw new \RuntimeException('Please close the channel (' . $channel . ') before trying to open it again');
2956 $this->window_size_server_to_client[$channel] = $this->window_size;
2965 $channel,
2966 $this->window_size_server_to_client[$channel],
2972 $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_OPEN;
2974 return $this->get_channel_packet($channel, $skip_extended);
3046 * Return the channel to be used with read(), write(), and reset(), if none were specified
3047 * @deprecated for lack of transparency in intended channel target, to be potentially replaced
3067 * Indicates the DATA status on the given channel
3069 * @param int $channel The channel number to evaluate
3072 private function is_channel_status_data($channel)
3074 return isset($this->channel_status[$channel]) && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA;
3078 * Return an available open channel
3084 $channel = self::CHANNEL_EXEC;
3086 if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_OPEN) {
3087 return $channel;
3089 } while ($channel++ < self::CHANNEL_SUBSYSTEM);
3133 * If not specifying a channel, an open interactive channel will be selected, or, if there are
3135 * interactive channels, a legacy behavior will apply in which channel selection prioritizes
3138 * the intended channel.
3143 * @param int|null $channel Channel id returned by self::getInteractiveChannelId()
3146 * @throws InsufficientSetupException on unexpected channel status, possibly due to closure
3148 public function read($expect = '', $mode = self::READ_SIMPLE, $channel = null)
3157 if ($channel === null) {
3158 $channel = $this->get_interactive_channel();
3161 if (!$this->is_channel_status_data($channel) && empty($this->channel_buffers[$channel])) {
3162 if ($channel != self::CHANNEL_SHELL) {
3163 throw new InsufficientSetupException('Data is not available on channel');
3170 return $this->get_channel_packet($channel);
3183 $response = $this->get_channel_packet($channel);
3195 * If not specifying a channel, an open interactive channel will be selected, or, if there are
3197 * interactive channels, a legacy behavior will apply in which channel selection prioritizes
3200 * the intended channel.
3204 * @param int|null $channel Channel id returned by self::getInteractiveChannelId()
3207 * @throws InsufficientSetupException on unexpected channel status, possibly due to closure
3209 public function write($cmd, $channel = null)
3215 if ($channel === null) {
3216 $channel = $this->get_interactive_channel();
3219 if (!$this->is_channel_status_data($channel)) {
3220 if ($channel != self::CHANNEL_SHELL) {
3221 throw new InsufficientSetupException('Data is not available on channel');
3227 $this->send_channel_packet($channel, $cmd);
3235 * To support multiple subsystem's of the same name maybe it'd be best if startSubsystem() generated a new channel id and
3285 * Closes a channel
3287 * If read() timed out you might want to just close the channel and have it auto-restart on the next read() call
3289 * If not specifying a channel, an open interactive channel will be selected. If there are
3290 * multiple open interactive channels, a legacy behavior will apply in which channel selection
3293 * should specify the intended channel.
3295 * @param int|null $channel Channel id returned by self::getInteractiveChannelId()
3298 public function reset($channel = null)
3300 if ($channel === null) {
3301 $channel = $this->get_interactive_channel();
3303 if ($this->isInteractiveChannelOpen($channel)) {
3304 $this->close_channel($channel);
3353 * packet and imediately trying to close that channel. some routers, in particular, however, will only let you
3354 * open one channel, so this approach could yield false positives
3412 * Is the given interactive channel active?
3414 * @param int $channel Channel id returned by self::getInteractiveChannelId()
3417 public function isInteractiveChannelOpen($channel)
3419 return $this->isAuthenticated() && $this->is_channel_status_data($channel);
3423 * Returns a channel identifier, presently of the last interactive channel opened, regardless of current status.
3424 * Returns 0 if no interactive channel has been opened.
3867 if (substr($payload, 9, $length) == 'keepalive@openssh.com' && isset($this->server_channels[$channel])) {
3869 $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_SUCCESS, $this->server_channels[$channel]));
3953 list($channel, $window_size) = Strings::unpackSSH2('NN', $payload);
3955 $this->window_size_client_to_server[$channel] += $window_size;
4032 * Gets channel data
4036 * - the server closes the channel
4038 * - if the channel status is CHANNEL_OPEN and the response was CHANNEL_OPEN_CONFIRMATION
4039 * - if the channel status is CHANNEL_REQUEST and the response was CHANNEL_SUCCESS
4040 * - if the channel status is CHANNEL_CLOSE and the response was CHANNEL_CLOSE
4044 * - if the channel status is CHANNEL_REQUEST and the response was CHANNEL_FAILURE
4091 list($type, $channel) = Strings::unpackSSH2('CN', $response);
4093 // will not be setup yet on incoming channel open request
4094 if (isset($channel) && isset($this->channel_status[$channel]) && isset($this->window_size_server_to_client[$channel])) {
4095 $this->window_size_server_to_client[$channel] -= strlen($response);
4098 if ($this->window_size_server_to_client[$channel] < 0) {
4100 //if ($this->window_size_server_to_client[$channel] < 0x3FFFFFFF) {
4101 $packet = pack('CNN', NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST, $this->server_channels[$channel], $this->window_resize);
4103 $this->window_size_server_to_client[$channel] += $this->window_resize;
4119 if ($client_channel == $channel && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA) {
4122 $this->channel_buffers[$channel][] = chr($type) . $data;
4126 if ($this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_CLOSE) {
4145 $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel]));
4147 $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF;
4164 switch ($this->channel_status[$channel]) {
4169 $this->server_channels[$channel],
4171 $this->packet_size_client_to_server[$channel]
4178 $this->window_size_client_to_server[$channel] = $window_size;
4179 $result = $client_channel == $channel ? true : $this->get_channel_packet($client_channel, $skip_extended);
4184 throw new \RuntimeException('Unable to open channel');
4186 if ($client_channel == $channel) {
4201 $this->channel_buffers[$channel][] = chr($type) . $data;
4205 throw new \RuntimeException('Unable to fulfill channel request');
4208 if ($client_channel == $channel && $type == NET_SSH2_MSG_CHANNEL_CLOSE) {
4215 // ie. $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA
4220 if ($channel == self::CHANNEL_EXEC) {
4225 $this->send_channel_packet($channel, chr(0));
4230 if ($channel == self::CHANNEL_AGENT_FORWARD) {
4233 $this->send_channel_packet($channel, $agent_response);
4238 if ($client_channel == $channel) {
4241 $this->channel_buffers[$channel][] = chr($type) . $data;
4246 $this->close_channel_bitmap($channel);
4248 if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) {
4249 $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel]));
4252 $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE;
4255 if ($client_channel == $channel) {
4263 throw new \RuntimeException("Error reading channel data ($type)");
4528 * Sends channel data
4541 // using an invalid channel will let the buffers be built up for the valid channels
4547 packet size for the channel, and the current window size, whichever
4568 * Closes and flushes a channel
4604 * Maintains execution state bitmap in response to channel closure
4606 * @param int $client_channel The channel number to maintain closure status of
4732 * of said channel opening. Must be called after
4733 * channel open confirmation received