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

uhc.c File Reference


Detailed Description

UDP Host Cache.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "gnutella.h"
#include "uhc.h"
#include "udp.h"
#include "nodes.h"
#include "sockets.h"
#include "pcache.h"
#include "hcache.h"
#include "hosts.h"
#include "lib/adns.h"
#include "lib/atoms.h"
#include "lib/cq.h"
#include "lib/endian.h"
#include "lib/hashlist.h"
#include "lib/glib-missing.h"
#include "lib/misc.h"
#include "if/gnet_property_priv.h"
#include "if/bridge/c2ui.h"
#include "lib/override.h"

Data Structures

struct  uhc_context
 Request context, used when we decide to get hosts via the UDP host caches. More...

struct  used_uhc

Defines

#define UHC_MAX_ATTEMPTS   3 /**< Maximum connection / resolution attempts */
 Maximum connection / resolution attempts.

#define UHC_TIMEOUT   20 /**< Host cache timeout, in seconds */
 Host cache timeout, in seconds.

#define UHC_RETRY_AFTER   3600 /**< Frequency of contacts for an UHC (secs) */
 Frequency of contacts for an UHC (secs).


Functions

 RCSID ("$Id:uhc.c, v 1.43 2006/02/10 00:00:22 cbiere Exp $")
void uhc_host_resolved (const host_addr_t *addr, gpointer uu_udata)
 Callback for adns_resolve(), invoked when the resolution is complete.

gboolean uhc_get_host_port (const gchar *hp, const gchar **host, guint16 *port)
 Parse hostname:port and return the hostname and port parts.

void add_available_uhc (const gchar *hc)
gboolean uhc_pick (void)
 Pick host at random among the host array.

gboolean uhc_guid_free (gpointer key, gpointer uu_data, gpointer uu_user)
 Free GUID atoms held in hash table.

void uhc_guid_reset (void)
 Reset the list of ping GUIDs.

void uhc_try_random (void)
 Try a random host cache.

void uhc_ping_timeout (cqueue_t *unused_cq, gpointer unused_obj)
 Callout queue callback, invoked when the ping was sent and we did not get a reply within the specified timeout.

void uhc_send_ping (const host_addr_t addr, guint16 port)
 Send an UDP ping to the host cache.

gboolean uhc_is_waiting (void)
 Check whether we're waiting for some UDP host cache pongs.

void uhc_get_hosts (void)
 Get more hosts to connect to from UDP host caches, asynchronously.

void uhc_ipp_extract (gnutella_node_t *n, const gchar *payload, gint paylen)
 Called when a pong with an "IPP" extension was received.

void uhc_init (void)
 Initializations.

void uhc_close (void)
 Cleanup during process termination.


Variables

uhc_context uhc_ctx
 Request context, used when we decide to get hosts via the UDP host caches.

GList * uhc_avail = NULL
 List of UHCs as string.

GList * uhc_used = NULL
 List of used UHCs as ``struct used_uhc''.

struct {
   const gchar *   uhc
boot_hosts []
 The following hosts are there for bootstrapping purposes only.

gboolean uhc_connecting = FALSE


Define Documentation

#define UHC_MAX_ATTEMPTS   3 /**< Maximum connection / resolution attempts */
 

Maximum connection / resolution attempts.

#define UHC_RETRY_AFTER   3600 /**< Frequency of contacts for an UHC (secs) */
 

Frequency of contacts for an UHC (secs).

#define UHC_TIMEOUT   20 /**< Host cache timeout, in seconds */
 

Host cache timeout, in seconds.


Function Documentation

void add_available_uhc const gchar *  hc  )  [static]
 

RCSID "$Id:uhc.  c,
v 1.43 2006/02/10 00:00:22 cbiere Exp $" 
 

void uhc_close void   ) 
 

Cleanup during process termination.

gboolean uhc_get_host_port const gchar *  hp,
const gchar **  host,
guint16 *  port
[static]
 

Parse hostname:port and return the hostname and port parts.

Parameters:
hp host:port string
host where the pointer to the hostname is returned (static data)
port where the port is written to
Returns:
TRUE if we successfully parsed the string.

void uhc_get_hosts void   ) 
 

Get more hosts to connect to from UDP host caches, asynchronously.

gboolean uhc_guid_free gpointer  key,
gpointer  uu_data,
gpointer  uu_user
[static]
 

Free GUID atoms held in hash table.

-- foreach() callback

void uhc_guid_reset void   )  [static]
 

Reset the list of ping GUIDs.

void uhc_host_resolved const host_addr_t addr,
gpointer  uu_udata
[static]
 

Callback for adns_resolve(), invoked when the resolution is complete.

void uhc_init void   ) 
 

Initializations.

void uhc_ipp_extract gnutella_node_t n,
const gchar *  payload,
gint  paylen
 

Called when a pong with an "IPP" extension was received.

gboolean uhc_is_waiting void   ) 
 

Check whether we're waiting for some UDP host cache pongs.

gboolean uhc_pick void   )  [static]
 

Pick host at random among the host array.

Returns:
TRUE if OK.

void uhc_ping_timeout cqueue_t unused_cq,
gpointer  unused_obj
[static]
 

Callout queue callback, invoked when the ping was sent and we did not get a reply within the specified timeout.

void uhc_send_ping const host_addr_t  addr,
guint16  port
[static]
 

Send an UDP ping to the host cache.

void uhc_try_random void   )  [static]
 

Try a random host cache.


Variable Documentation

const { ... } boot_hosts[] [static]
 

The following hosts are there for bootstrapping purposes only.

const gchar* uhc
 

GList* uhc_avail = NULL [static]
 

List of UHCs as string.

gboolean uhc_connecting = FALSE [static]
 

struct uhc_context uhc_ctx [static]
 

Request context, used when we decide to get hosts via the UDP host caches.

It keeps track of the amount of messages we sent, and which GUID we used in the pings.

GList* uhc_used = NULL [static]
 

List of used UHCs as ``struct used_uhc''.


Generated on Sun Feb 12 10:50:08 2006 for Gtk-Gnutella by doxygen 1.3.6