id = $id; $this->name = $name; $this->bytes = $bytes; $this->segmentIndexSize = $segmentIndexSize; } // compare the two ip bytes with the current version public function ipSubCompare($ip1, $buff, $offset) { // ip1: Little endian byte order encoded long from searcher. // ip2: Little endian byte order read from xdb index. $len = strlen($ip1); $eIdx = $offset + $len; for ($i = 0, $j = $eIdx - 1; $i < $len; $i++, $j--) { $i1 = ord($ip1[$i]) & 0xFF; $i2 = ord($buff[$j]) & 0xFF; // printf("i:%d, j:%d, i1:%d, i2:%d\n", $i, $j, $i1, $i2); if ($i1 > $i2) { return 1; } else if ($i1 < $i2) { return -1; } } return 0; } public function __toString() { return sprintf( "{id:%d, name:%s, bytes:%d, segmentIndexSize:%d}", $this->id, $this->name, $this->bytes, $this->segmentIndexSize ); } }