# Buffer file format

All integers are little-endian. This means a uint128 is a pair of uint64's, which is convenient and less confusing.

## Header

32 bytes total, some unused

* 8 bytes = `ip-map\0\0`
* 5x uint32:
  * `version` = 1
  * `num6` = number of IPv6 entries (including 0 and ~0)
  * `num4` = number of IPv4 entries (including 0.0.0.0 and 255.255.255.255)
  * `asOffset` = starting offset of AS info block
  * `bufSize` = expected total buffer size

## Data

* num6 x 16 bytes = uint128 (or a pair of uint64) for each IPv6 range *start* only (since the TSV does not seem to have holes)
* num4 x 4 bytes = per IPv4 range start
* num6 x 4 bytes = uint32 AS info record offset for IPv6 records
* num4 x 4 bytes = uint32 AS info record offset for IPv4 records
* AS records. Each record is at `asOffset` + value from previous two tables and consists of:
  * uint32 = AS number
  * 2 bytes = country code (or 0x0000)
  * uint16 = description length
  * description (if any)
