Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

geo_ip.c File Reference


Detailed Description

Support for geographic (country-level) IP mapping.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "geo_ip.h"
#include "settings.h"
#include "lib/file.h"
#include "lib/misc.h"
#include "lib/glib-missing.h"
#include "lib/iprange.h"
#include "lib/iso3166.h"
#include "lib/walloc.h"
#include "lib/watcher.h"
#include "if/gnet_property_priv.h"
#include "if/bridge/c2ui.h"
#include "lib/override.h"

Data Structures

struct  range_context
 Context used during ip_range_split() calls. More...

Functions

void gip_add_cidr (guint32 ip, guint bits, gpointer udata)
 ip_range_split() callback.
guint gip_load (FILE *f)
 Load geographic IP data from the supplied FILE.
void gip_changed (const gchar *filename, gpointer unused)
 Watcher callback, invoked when the file from which we read the geographic IP mappings changed.
void gip_retrieve (void)
 Loads the geo-ip.txt into memory.
void gip_init (void)
 Called on startup.
void gip_close (void)
 Frees all entries in the hostiles.
guint16 gip_country (const host_addr_t ha)
 Retrieves the country an address is assigned to.

Variables

const gchar gip_file [] = "geo-ip.txt"
const gchar gip_what [] = "Geographic IP mappings"
iprange_dbgeo_db
 The database of bogus CIDR ranges.


Function Documentation

void gip_add_cidr guint32  ip,
guint  bits,
gpointer  udata
[static]
 

ip_range_split() callback.

Insert IP range in database, linking it to the proper country code.

void gip_changed const gchar *  filename,
gpointer  unused
[static]
 

Watcher callback, invoked when the file from which we read the geographic IP mappings changed.

void gip_close void   ) 
 

Frees all entries in the hostiles.

guint16 gip_country const host_addr_t  ha  ) 
 

Retrieves the country an address is assigned to.

Parameters:
ha the host address to look up.
Returns:
the country mapped to this IP address as an numerical encoded country code, or ISO3166_INVALID when unknown.

void gip_init void   ) 
 

Called on startup.

Loads the bogons.txt into memory.

guint gip_load FILE *  f  )  [static]
 

Load geographic IP data from the supplied FILE.

Returns:
The amount of entries loaded.

void gip_retrieve void   )  [static]
 

Loads the geo-ip.txt into memory.

Choosing the first file we find among the several places we look at, typically:

  1. ~/.gtk-gnutella/geo-ip.txt
  2. /usr/share/gtk-gnutella/geo-ip.txt
  3. /home/src/gtk-gnutella/geo-ip.txt

The selected file will then be monitored and a reloading will occur shortly after a modification.


Variable Documentation

struct iprange_db* geo_db [static]
 

The database of bogus CIDR ranges.

const gchar gip_file[] = "geo-ip.txt" [static]
 

const gchar gip_what[] = "Geographic IP mappings" [static]
 


Generated on Sat Jun 30 17:53:26 2007 for gtk-gnutella by  doxygen 1.3.9.1