This page provides a summary of the function of each module in geoloc. It is in roughly topological order.
This file contains a command line argument helper class.
This file contains the declarations needed to support logging and error handling.
This file contains the logging and error handling implementation. We use a mirrored ring buffer to handle log messages. The ring buffer is dumped out to stderr when an assert or fatal error fires.
Note - log messages larger than 4095 bytes will get truncated to 4095 bytes.
This file contains utility functions for tokenizing and parsing strings.
This file contains macros that are commonly used throughout the source.
This file contains macros to paper over differences between older/newer compilers as far as using std::unordered_map is concerned.
This module contains the pipeline framework core classes.
The basic idea is similar to a unix pipeline, allowing the user to connect Connectors like so:
a | b | c
A Connector is analogous to a unix filter, and a Buffer is analogous to a line of text.
This class is used for interning strings. It uses a hash map to track the string to id mapping. The layout of indices and the char vector makes it easier to serialize later.
This module contains classes for saving data into binary files, and loading it back in from memory maps.
This module contains some pipeline framework utility classes. They are used to input data into the pipelines. Analogous to cat or echo.
This module handles representations of location data, both normal and packed formats.
A Location stores an id and positional information from the MaxMind dataset, namely:
country, region, city, latitude, longitude
This module handles representations of ASN data, both normal and packed formats.
An ASN describes an ip range, autonomous system number, and some text describing the system.
This module handles representations of IP ranges, both normal and packed formats.
A Block is an ip range, and an index into another structure.
This module contains helper functions to extract, transform and load a MaxMind csv dataset.
This module handles the query phase of geoloc. It is reponsible for loading the geodata file, and providing interfaces for querying it.
The main part of the query code uses a binary search (std::upper_bound) against a set of memory mapped sorted vectors.
geoloc is a command line application for retrieving MaxMind geolocation and ASN info for a set of IP addresses.
The default output format is one record per line, space separated, with no headers. The columns output are as follows:
ip, country, region, city, latitude, longitude, as_num, as_text
This file contains test code for geoloc. It is mostly serialization tests.