Skip to content
Ken Keys edited this page Jun 30, 2020 · 1 revision

Overview

Version 3 adds support for IPv6, as well as MaxMind v2 data files.

Updating existing v2 code to the v3 API

The lookup functions that used to take a uint32_t addr argument have been replaced with functions that take int family, void *addrp arguments, where family is AF_INET or AF_INET6; also, the function names have changed to more accurately describe them. Additionally, a few integers have become wider to accommodate larger values in IPv6.

Specifically:

v2: int ipmeta_lookup(ipmeta_t *ipmeta, uint32_t addr, uint8_t mask, uint32_t provmask, ipmeta_record_set_t *records)
v3: int ipmeta_lookup_pfx(ipmeta_t *ipmeta, int family, void *addrp, uint8_t pfxlen, uint32_t provmask, ipmeta_record_set_t *records)

v2: int ipmeta_lookup_single(ipmeta_t *ipmeta, uint32_t addr, uint32_t providermask, ipmeta_record_set_t *found)
v3: int ipmeta_lookup_addr(ipmeta_t *ipmeta, int family, void *addrp, uint32_t providermask, ipmeta_record_set_t *found)

In ipmeta_record_set_next(), ipmeta_dump_record(), and ipmeta_write_record(): the num_ips parameter is now uint64_t, and for IPv6 it counts /64 blocks, not addresses.

Members of ipmeta_record_t:

  • asn_ip_cnt: changed from uint32_t to uint64_t. For IPv6, it counts /64 blocks, not addresses.
  • char *timezone: new field from MaxMind v2
  • int accuracy: new field from MaxMind v2

New functions

int ipmeta_lookup(ipmeta_t *ipmeta, const char *addr_str, uint32_t providermask, ipmeta_record_set_t *found):
Like the other lookup functions, but takes an address or prefix in string form.

Provider interface

netacq-edge:

  • New -6 option to specify a IPv6 data file

maxmind:

  • The -b option may be repeated to specify multiple block files (e.g., IPv4 and IPv6)
  • Data files may be in MaxMind v1 or v2 format.
Clone this wiki locally