Properties

$MAGIC_NUMBER

$MAGIC_NUMBER : 

Data file component

Type

$FILE_ID

$FILE_ID : 

Data file component

Type

$START_BYTES_LEN

$START_BYTES_LEN : 

magic number [2B] + file id [1B] + header length [2B]

Type

$CREATION_DATE_LEN

$CREATION_DATE_LEN : 

e.g. 2013-08-07T15:36:44+0000

Type

$BUCKET_START_BYTES_LEN

$BUCKET_START_BYTES_LEN : 

bucket ID [2B], bucket CRC-32 [4B], bucket length [4B]

Type

$copyright

$copyright : 

Data file copyright tag

Type

$creationDate

$creationDate : 

Data file creation date

Type

$version

$version : 

Data file version

Type

$cursor

$cursor : 

Data cursor

Type

$NULL_PTR

$NULL_PTR : 

Data for the IPv4 radix tree

Type

$ROOT_PTR

$ROOT_PTR : 

Starting pointer

Type

$MAX_IPV4_BIT

$MAX_IPV4_BIT : 

MAX_IPV4_BIT

Type

$treeLefts

$treeLefts : 

Trie component

Type

$treeRights

$treeRights : 

Trie component

Type

$treeProperties

$treeProperties : 

Trie component

Type

$propertyNames

$propertyNames : 

Property Names

Type

$propertyStringNames

$propertyStringNames : 

Property String Names

Type

$PROBLEM_READING_DATA_FILE

$PROBLEM_READING_DATA_FILE : 

Error message

Type

$INVALID_DATA_FILE

$INVALID_DATA_FILE : 

Error message

Type

$data

$data : 

Carrier data

Type

Methods

loadDataFromFile()

loadDataFromFile(  $filePath) 

Load carrier data file.

Parameters

$filePath

Throws

\DeviceAtlas\Exception\DataLoadingException

Thrown when the data file can not be opened

getProperties()

getProperties(  $key) : mixed

Selects a value for a given IPv4 address, traversing tree and choosing most specific value available for a given address.

Parameters

$key
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

mixed —

value at most specific IPv4 network in a tree for a given IPv4 address

getPropertyNames()

getPropertyNames() : array

Return a list of all the property names.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array —

array of property names

getPropertyNamesAsStrings()

getPropertyNamesAsStrings() : string

Return a list of all the property names.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

string —

of property names

getCopyright()

getCopyright() : string

Get data file copyright.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

string —

the copyright

getCreationDate()

getCreationDate() : string

Get data file creation date.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

string —

the creationDate

getVersion()

getVersion() : string

Get data file version.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

string —

the version

readHeader()

readHeader() 

The header of the file contains the following data:

2B DA (US-ASCII) 1B File type ID (1: carrier data, 2:some other data.... etc) 2B Header length - the total size of the header including the preceding bytes 2B Length of copyright text ?B Copyright (US-ASCII) "(c) Copyright 2013 - DeviceAtlas Limited" 24B Creation date (US-ASCII) "2013-08-07T15:36:44+0000" 1B Version, major 1B Version, minor 4B Licence ID 4B CRC-32 - all data after first bucket offset

Throws

\DeviceAtlas\Exception\DataLoadingException

checkFileTypeGetHeaderLength()

checkFileTypeGetHeaderLength(  $startBytes) : integer

Check the first few bytes to make sure we are opening a Carrier Identification file. Also get the length of the header.

Parameters

$startBytes

Throws

\DeviceAtlas\Exception\DataLoadingException

Returns

integer —

header length

readBuckets()

readBuckets() 

Each bucket is comprised of the following. The BucketHandler is responsible for actually parsing the data in each bucket. This method keeps reading until either the end of the file or until all necessary buckets have been read. It will skip buckets with IDs it does not recognise to hopefully future proof the API against possible additions to the data file

Bucket structure:

2B Bucket ID 4B CRC-32 checksum - NOTE: unsigned int! 4B Length of the data ?B Data

Throws

\DeviceAtlas\Exception\DataLoadingException