From 6e7bcc3fe85f00d13cc347e48af49e89da84ab80 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 31 Jan 2025 15:54:46 +1100 Subject: [PATCH] IAC binary --- app/Classes/Protocol/EMSI.php | 17 ++++++++++++----- app/Classes/Sock/SocketClient.php | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Classes/Protocol/EMSI.php b/app/Classes/Protocol/EMSI.php index 5784511..b213d6d 100644 --- a/app/Classes/Protocol/EMSI.php +++ b/app/Classes/Protocol/EMSI.php @@ -944,20 +944,22 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface // Peek for the next 2 chars do { $iac = $this->client->read(10,1,MSG_PEEK); - Log::debug(sprintf('%s: - IAC LOOP',self::LOGKEY,['iac'=>ord($iac),'cmd'=>$iaccmd)]); + Log::debug(sprintf('%s: - IAC LOOP',self::LOGKEY),['iac'=>ord($iac),'cmd'=>$iaccmd]); switch (ord($iac)) { + // Binary Mode case 0x00: if ($iaccmd === 0xfb) { Log::debug(sprintf('%s: - IAC WILL BINARY [%02x]',self::LOGKEY,ord($iac))); // Config with DO - $this->client->send(chr(0xff).chr(0xfd).$iac); + $this->client->send(chr(0xff).chr(0xfd).$iac,10); + } elseif ($iaccmd === 0xfd) { Log::debug(sprintf('%s: - IAC DO BINARY [%02x]',self::LOGKEY,ord($iac))); // Config with WILL - $this->client->send(chr(0xff).chr(0xfb).$iac); + $this->client->send(chr(0xff).chr(0xfb).$iac,10); $this->client->iac_bin = true; } @@ -970,12 +972,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface Log::debug(sprintf('%s: - IAC WILL SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac))); // Config with DO - $this->client->send(chr(0xff).chr(0xfd).$iac); + $this->client->send(chr(0xff).chr(0xfd).$iac,10); } elseif ($iaccmd === 0xfd) { Log::debug(sprintf('%s: - IAC DO SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac))); // Config with WILL - $this->client->send(chr(0xff).chr(0xfb).$iac); + $this->client->send(chr(0xff).chr(0xfb).$iac,10); $this->client->iac_bin = true; } @@ -992,6 +994,11 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface $iaccmd = ord($iac); break; + case 0xff: + Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,ord($iac))); + $iaccmd = ord($iac); + break; + default: Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,ord($iac))); diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index fd6db86..e87cf2d 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -436,6 +436,9 @@ final class SocketClient { return $result; } + if (self::DEBUG) + Log::debug(sprintf('%s:- Buffer doesnt have [%d] chars, it only has [%d]',self::LOGKEY,$len,strlen($this->rx_buf))); + if ($timeout && (! $this->hasData($timeout))) throw new SocketException(SocketException::SOCKET_TIMEOUT,$timeout);