PHP Class PHPDaemon\Utils\Binary

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Afficher le fichier Open project: kakserpom/phpdaemon Class Usage Examples

Méthodes publiques

Méthode Description
LV ( string $str, integer $len = 1, boolean $lrev = false ) : string Build length-value binary snippet
LVnull ( string $str ) : string Build nul-terminated string, with 2-byte of length
b2i ( string $str, boolean $l = false ) : integer Convert bytes into integer
bitmap2bytes ( string $bitmap, integer $check_len ) : string | false Convert bitmap into bytes
byte ( integer $int ) : string Build byte
bytes2int ( string $str, boolean $l = false ) : integer Convert bytes into integer
dword ( integer $int ) : string Build double word (4 bytes) big-endian
dwordl ( integer $int ) : string Build double word (4 bytes) little endian
flags2bitarray ( array $flags, integer $len = 4 ) : string Convert array of flags into bit array
getByte ( &$p ) : integer Parse byte, and remove it
getChar ( &$p ) : string Get single-byte character
getDWord ( &$p, boolean $l = false ) : integer Get double word (4 bytes)
getLV ( &$p, integer $l = 1, boolean $nul = false, boolean $lrev = false ) : string Parse length-value structure
getQword ( &$p, boolean $l = false ) : integer Parse quadro word (8 bytes)
getStrQWord ( &$p, boolean $l = false ) : string Get quadro word (8 bytes)
getStrWord ( &$p, boolean $l = false ) : string Get word (2 bytes)
getString ( &$str ) : string Parse nul-terminated string
getWord ( &$p, boolean $l = false ) : integer Parse word (2 bytes)
getbitmap ( integer $byte ) : string Get bitmap
i2b ( integer $len, integer $int, boolean $l = false ) : string Converts integer to binary string
int2bytes ( integer $len, integer $int, boolean $l = false ) : string Converts integer to binary string
labels ( string $q ) : string Build structure of labels
parseLabels ( &$data, string $orig = null ) : string Parse structure of labels
qword ( integer $int ) : string Build quadro word (8 bytes) big endian
qwordl ( integer $int ) : string Build quadro word (8 bytes) little endian
word ( integer $int ) : string Build word (2 bytes) big-endian
wordl ( integer $int ) : string Build word (2 bytes) little-endian

Method Details

LV() public static méthode

Build length-value binary snippet
public static LV ( string $str, integer $len = 1, boolean $lrev = false ) : string
$str string Data
$len integer Number of bytes to encode length. Default is 1
$lrev boolean Reverse?
Résultat string

LVnull() public static méthode

Build nul-terminated string, with 2-byte of length
public static LVnull ( string $str ) : string
$str string Data
Résultat string

b2i() public static méthode

Convert bytes into integer
public static b2i ( string $str, boolean $l = false ) : integer
$str string Bytes
$l boolean Little endian? Default is false
Résultat integer

bitmap2bytes() public static méthode

Convert bitmap into bytes
public static bitmap2bytes ( string $bitmap, integer $check_len ) : string | false
$bitmap string Bitmap
$check_len integer Check length?
Résultat string | false

byte() public static méthode

Build byte
public static byte ( integer $int ) : string
$int integer Byte number
Résultat string

bytes2int() public static méthode

Convert bytes into integer
public static bytes2int ( string $str, boolean $l = false ) : integer
$str string Bytes
$l boolean Little endian? Default is false
Résultat integer

dword() public static méthode

Build double word (4 bytes) big-endian
public static dword ( integer $int ) : string
$int integer Integer
Résultat string

dwordl() public static méthode

Build double word (4 bytes) little endian
public static dwordl ( integer $int ) : string
$int integer Integer
Résultat string

flags2bitarray() public static méthode

Convert array of flags into bit array
public static flags2bitarray ( array $flags, integer $len = 4 ) : string
$flags array Flags
$len integer Length. Default is 4
Résultat string

getByte() public static méthode

Parse byte, and remove it
public static getByte ( &$p ) : integer
Résultat integer

getChar() public static méthode

Get single-byte character
public static getChar ( &$p ) : string
Résultat string

getDWord() public static méthode

Get double word (4 bytes)
public static getDWord ( &$p, boolean $l = false ) : integer
$l boolean Little endian?
Résultat integer

getLV() public static méthode

Parse length-value structure
public static getLV ( &$p, integer $l = 1, boolean $nul = false, boolean $lrev = false ) : string
$l integer Number of length bytes
$nul boolean Nul-terminated? Default is false
$lrev boolean Length is little endian?
Résultat string

getQword() public static méthode

Parse quadro word (8 bytes)
public static getQword ( &$p, boolean $l = false ) : integer
$l boolean Little endian?
Résultat integer

getStrQWord() public static méthode

Get quadro word (8 bytes)
public static getStrQWord ( &$p, boolean $l = false ) : string
$l boolean Little endian?
Résultat string

getStrWord() public static méthode

Get word (2 bytes)
public static getStrWord ( &$p, boolean $l = false ) : string
$l boolean Little endian?
Résultat string

getString() public static méthode

Parse nul-terminated string
public static getString ( &$str ) : string
Résultat string

getWord() public static méthode

Parse word (2 bytes)
public static getWord ( &$p, boolean $l = false ) : integer
$l boolean Little endian?
Résultat integer

getbitmap() public static méthode

Get bitmap
public static getbitmap ( integer $byte ) : string
$byte integer Byte
Résultat string

i2b() public static méthode

Converts integer to binary string
public static i2b ( integer $len, integer $int, boolean $l = false ) : string
$len integer Length
$int integer Integer
$l boolean Optional. Little endian. Default value - false
Résultat string Resulting binary string

int2bytes() public static méthode

Converts integer to binary string
public static int2bytes ( integer $len, integer $int, boolean $l = false ) : string
$len integer Length
$int integer Integer
$l boolean Optional. Little endian. Default value - false
Résultat string Resulting binary string

labels() public static méthode

Build structure of labels
public static labels ( string $q ) : string
$q string Dot-separated labels list
Résultat string

parseLabels() public static méthode

Parse structure of labels
public static parseLabels ( &$data, string $orig = null ) : string
$orig string Original packet
Résultat string Dot-separated labels list

qword() public static méthode

Build quadro word (8 bytes) big endian
public static qword ( integer $int ) : string
$int integer Integer
Résultat string

qwordl() public static méthode

Build quadro word (8 bytes) little endian
public static qwordl ( integer $int ) : string
$int integer Integer
Résultat string

word() public static méthode

Build word (2 bytes) big-endian
public static word ( integer $int ) : string
$int integer Integer
Résultat string

wordl() public static méthode

Build word (2 bytes) little-endian
public static wordl ( integer $int ) : string
$int integer Integer
Résultat string