Main Page | Modules | Alphabetical List | Data Structures | 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

 RCSID ("$Id:geo_ip.c, v 1.25 2005/12/17 10:32:06 cbiere Exp $")
void gip_add_cidr (guint32 ip, guint bits, gpointer udata)
 ip_range_split() callback.

gint 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.

gint 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"
gpointer geo_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.

gint 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 -1 when unknown.

void gip_init void   ) 
 

Called on startup.

Loads the bogons.txt into memory.

gint 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.

RCSID "$Id:geo_ip.  c,
v 1.25 2005/12/17 10:32:06 cbiere Exp $" 
 


Variable Documentation

gpointer 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 Sun Feb 12 10:50:01 2006 for Gtk-Gnutella by doxygen 1.3.6