| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\extra\ip2region\xdb;
- const IPv6VersionNo = 6;
- class IPv6
- {
- public $id;
- public $name;
- public $bytes;
- public $segmentIndexSize;
- private static $C = null;
- public static function default() {
- if (self::$C == null) {
- // 38 = 16 + 16 + 2 + 4
- self::$C = new self(IPv6VersionNo, 'IPv6', 16, 38);
- }
- return self::$C;
- }
- public function __construct($id, $name, $bytes, $segmentIndexSize) {
- $this->id = $id;
- $this->name = $name;
- $this->bytes = $bytes;
- $this->segmentIndexSize = $segmentIndexSize;
- }
- public function ipSubCompare($ip, $buff, $offset) {
- // return Util::ipCompare($ip, substr($buff, $offset, strlen($ip)));
- return SearchIp::ipSubCompare($ip, $buff, $offset);
- }
- public function __toString() {
- return sprintf(
- "{id:%d, name:%s, bytes:%d, segmentIndexSize:%d}",
- $this->id, $this->name, $this->bytes, $this->segmentIndexSize
- );
- }
- }
|