/** * Allocate a new communication channel. * * \param fpoirotte::Pssht::Messages::CHANNEL::OPEN $message * Original message requesting channel allocation. * * \return int * Newly allocated channel's identifier. */ public function allocateChannel(\fpoirotte\Pssht\Messages\CHANNEL\OPEN $message) { for ($i = 0; isset($this->channels[$i]); ++$i) { // Do nothing. } $this->channels[$i] = $message->getChannel(); $this->handlers[$i] = array(); return $i; }
public function handle($msgType, \fpoirotte\Pssht\Wire\Decoder $decoder, \fpoirotte\Pssht\Transport $transport, array &$context) { $message = \fpoirotte\Pssht\Messages\CHANNEL\OPEN::unserialize($decoder); $recipientChannel = $message->getChannel(); if ($message->getType() === 'session') { $response = new \fpoirotte\Pssht\Messages\CHANNEL\OPEN\CONFIRMATION($recipientChannel, $this->connection->allocateChannel($message), 0x200000, 0x800000); } else { $response = new \fpoirotte\Pssht\Messages\CHANNEL\OPEN\FAILURE($recipientChannel, \fpoirotte\Pssht\Messages\CHANNEL\OPEN\FAILURE::SSH_OPEN_UNKNOWN_CHANNEL_TYPE, 'No such channel type'); } $transport->writeMessage($response); return true; }