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

iprange.h File Reference


Detailed Description

Needs brief description here.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"

Go to the source code of this file.

Enumerations

enum  iprange_err_t {
  IPR_ERR_OK = 0, IPR_ERR_BAD_PREFIX, IPR_ERR_RANGE_CLASH, IPR_ERR_RANGE_DUP,
  IPR_ERR_RANGE_SUBNET, IPR_ERR_RANGE_OVERLAP, IPR_ERROR_COUNT
}
 Error codes. More...

Functions

const gchar * iprange_strerror (iprange_err_t errnum)
iprange_dbiprange_new (void)
 Create a new IP range database.
iprange_err_t iprange_add_cidr (struct iprange_db *db, guint32 net, guint bits, void *value)
 Add CIDR network to the database.
void * iprange_get (const struct iprange_db *db, guint32 ip)
 Retrieve value associated with an IPv4 address, i.e.
void iprange_sync (struct iprange_db *idb)
 This function must be called after iprange_add_cidr() to make the changes effective.
void iprange_free (struct iprange_db **idb_ptr)
 Destroy the database.
guint iprange_get_item_count (const struct iprange_db *idb)
 Get the number of ranges in the database.
guint iprange_get_host_count (const struct iprange_db *idb)
 Calculate the number of hosts covered by the ranges in the database.


Enumeration Type Documentation

enum iprange_err_t
 

Error codes.

Enumeration values:
IPR_ERR_OK  OK.
IPR_ERR_BAD_PREFIX  Incorrect network prefix.
IPR_ERR_RANGE_CLASH  CIDR range clash.
IPR_ERR_RANGE_DUP  Duplicate range.
IPR_ERR_RANGE_SUBNET  Range is subnet of existing range.
IPR_ERR_RANGE_OVERLAP  Range is overlapping existing range.
IPR_ERROR_COUNT  Amount of error codes defined.


Function Documentation

iprange_err_t iprange_add_cidr struct iprange_db idb,
guint32  net,
guint  bits,
void *  value
 

Add CIDR network to the database.

Parameters:
db the IP range database
net the network prefix
bits the amount of bits in the network prefix
value value associated to this IP network
Returns:
IPR_ERR_OK if successful, an error code otherwise.

void iprange_free struct iprange_db **  idb_ptr  ) 
 

Destroy the database.

Parameters:
db the database

void* iprange_get const struct iprange_db idb,
guint32  ip
 

Retrieve value associated with an IPv4 address, i.e.

that of the range containing it.

Parameters:
db the IP range database
ip the IPv4 address to lookup
Returns:
The data associated with the IPv address or NULL if not found.

guint iprange_get_host_count const struct iprange_db idb  ) 
 

Calculate the number of hosts covered by the ranges in the database.

Parameters:
db the IP range database
Returns:
The number of hosts listed.

guint iprange_get_item_count const struct iprange_db idb  ) 
 

Get the number of ranges in the database.

Parameters:
db the IP range database
Returns:
The number of items.

struct iprange_db* iprange_new void   ) 
 

Create a new IP range database.

const gchar* iprange_strerror iprange_err_t  errnum  ) 
 

Returns:
human-readable error string for given error code.

void iprange_sync struct iprange_db idb  ) 
 

This function must be called after iprange_add_cidr() to make the changes effective.

As this function is costly, it should not be called each time but rather after the complete list of addresses has been added to the database.

Parameters:
db the IP range database


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