|
|
@ -3,8 +3,10 @@ |
|
|
namespace RouterOS; |
|
|
namespace RouterOS; |
|
|
|
|
|
|
|
|
use DomainException; |
|
|
use DomainException; |
|
|
|
|
|
use OverflowException; |
|
|
use RouterOS\Interfaces\StreamInterface; |
|
|
use RouterOS\Interfaces\StreamInterface; |
|
|
use RouterOS\Helpers\BinaryStringHelper; |
|
|
use RouterOS\Helpers\BinaryStringHelper; |
|
|
|
|
|
use UnexpectedValueException; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* class APILengthCoDec |
|
|
* class APILengthCoDec |
|
|
@ -19,8 +21,6 @@ class APILengthCoDec |
|
|
/** |
|
|
/** |
|
|
* Encode string to length of string |
|
|
* Encode string to length of string |
|
|
* |
|
|
* |
|
|
* <<<<<<< HEAD |
|
|
|
|
|
* ======= |
|
|
|
|
|
* Encode the length: |
|
|
* Encode the length: |
|
|
* - if length <= 0x7F (binary : 01111111 => 7 bits set to 1) |
|
|
* - if length <= 0x7F (binary : 01111111 => 7 bits set to 1) |
|
|
* - encode length with one byte |
|
|
* - encode length with one byte |
|
|
@ -51,10 +51,9 @@ class APILengthCoDec |
|
|
* - end |
|
|
* - end |
|
|
* - length > 0x7FFFFFFFFF : not supported |
|
|
* - length > 0x7FFFFFFFFF : not supported |
|
|
* |
|
|
* |
|
|
* >>>>>>> master |
|
|
|
|
|
* @param int|float $length |
|
|
* @param int|float $length |
|
|
* |
|
|
* |
|
|
* @return string |
|
|
|
|
|
|
|
|
* @return string |
|
|
*/ |
|
|
*/ |
|
|
public static function encodeLength($length): string |
|
|
public static function encodeLength($length): string |
|
|
{ |
|
|
{ |
|
|
@ -172,7 +171,7 @@ class APILengthCoDec |
|
|
// How can we test it ?
|
|
|
// How can we test it ?
|
|
|
|
|
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
// @codeCoverageIgnoreStart
|
|
|
throw new \OverflowException("Your system is using 32 bits integers, cannot decode this value ($firstByte) on this system"); |
|
|
|
|
|
|
|
|
throw new OverflowException("Your system is using 32 bits integers, cannot decode this value ($firstByte) on this system"); |
|
|
// @codeCoverageIgnoreEnd
|
|
|
// @codeCoverageIgnoreEnd
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -192,6 +191,6 @@ class APILengthCoDec |
|
|
|
|
|
|
|
|
// Now the only solution is 5 most significance bits are set to 1 (11111xxx)
|
|
|
// Now the only solution is 5 most significance bits are set to 1 (11111xxx)
|
|
|
// This is a control word, not implemented by Mikrotik for the moment
|
|
|
// This is a control word, not implemented by Mikrotik for the moment
|
|
|
throw new \UnexpectedValueException('Control Word found'); |
|
|
|
|
|
|
|
|
throw new UnexpectedValueException('Control Word found'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |