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

qrp.h File Reference


Detailed Description

Query Routing Protocol (LimeWire's scheme).

Author:
Raphael Manfredi
Date:
2002-2003

#include <glib.h>
#include "matching.h"

Go to the source code of this file.

Data Structures

struct  query_hash
struct  query_hashvec
struct  qrt_info

Defines

#define QRP_MIN_WORD_LENGTH   3 /**< Minimal word length */
 Minimal word length.

#define qhvec_has_urn(x)   ((x)->has_urn)

Typedefs

typedef query_hashvec query_hashvec_t
typedef qrt_info qrt_info_t
typedef void(* qrp_callback_t )(gpointer arg, gboolean cancelled)

Enumerations

enum  query_hsrc { QUERY_H_WORD = 0, QUERY_H_URN }

Functions

void qrp_init (char_map_t map)
 Initialize QRP.

void qrp_close (void)
 Called at servent shutdown to reclaim all the memory.

void qrp_leaf_changed (void)
 Called when we get a new QRT from a leaf node, or when we loose a leaf that sent us its QRT.

void qrp_peermode_changed (void)
 Called when the current peermode has changed.

void qrp_prepare_computation (void)
 This routine must be called to initialize the computation of the new QRP based on our local files.

void qrp_add_file (struct shared_file *sf)
 Add shared file to our QRP.

void qrp_finalize_computation (void)
 This routine must be called once all the files have been added to finalize the computation of the new QRP.

gpointer qrt_update_create (struct gnutella_node *n, gpointer query_table)
 Create structure keeping track of the table update.

void qrt_update_free (gpointer handle)
 Free query routing update tracker.

gboolean qrt_update_send_next (gpointer handle)
 Send the next batch of data.

gboolean qrt_update_was_ok (gpointer handle)
 Check whether sending was successful.

gpointer qrt_receive_create (struct gnutella_node *n, gpointer query_table)
 Create a new QRT receiving handler, to process all incoming QRP messages from the leaf node.

void qrt_receive_free (gpointer handle)
 Dispose of the QRP receiving state.

gboolean qrt_receive_next (gpointer handle, gboolean *done)
 Handle reception of the next QRP message in the stream for a given update.

gpointer qrt_get_table (void)
gpointer qrt_ref (gpointer obj)
 Get a new reference on the query routing table.

void qrt_unref (gpointer obj)
 Remove one reference to query routing table.

void qrt_get_info (gpointer obj, qrt_info_t *qi)
query_hashvecqhvec_alloc (gint size)
 Allocate a query hash container for at most `size' entries.

void qhvec_free (struct query_hashvec *qhvec)
void qhvec_reset (struct query_hashvec *qhvec)
query_hashvec_tqhvec_clone (const query_hashvec_t *qsrc)
 Clone query hash vector.

void qhvec_add (struct query_hashvec *qhvec, const gchar *word, enum query_hsrc src)
GSList * qrt_build_query_target (query_hashvec_t *qhvec, gint hops, gint ttl, struct gnutella_node *source)
 Compute list of nodes to send the query to, based on node's QRT.

void qrt_route_query (struct gnutella_node *n, query_hashvec_t *qhvec)
 Route query message to leaf nodes, based on their QRT, or to ultrapeers that support last-hop QRP if TTL=1.

gboolean qrp_node_can_route (struct gnutella_node *n, query_hashvec_t *qhv)


Define Documentation

#define qhvec_has_urn  )     ((x)->has_urn)
 

#define QRP_MIN_WORD_LENGTH   3 /**< Minimal word length */
 

Minimal word length.


Typedef Documentation

typedef void(* qrp_callback_t)(gpointer arg, gboolean cancelled)
 

typedef struct qrt_info qrt_info_t
 

typedef struct query_hashvec query_hashvec_t
 


Enumeration Type Documentation

enum query_hsrc
 

Enumeration values:
QUERY_H_WORD  Query word (AND-ed).
QUERY_H_URN  URN (OR-ed).


Function Documentation

void qhvec_add struct query_hashvec qhvec,
const gchar *  word,
enum query_hsrc  src
 

struct query_hashvec* qhvec_alloc gint  size  ) 
 

Allocate a query hash container for at most `size' entries.

query_hashvec_t* qhvec_clone const query_hashvec_t qsrc  ) 
 

Clone query hash vector.

void qhvec_free struct query_hashvec qhvec  ) 
 

void qhvec_reset struct query_hashvec qhvec  ) 
 

void qrp_add_file struct shared_file sf  ) 
 

Add shared file to our QRP.

void qrp_close void   ) 
 

Called at servent shutdown to reclaim all the memory.

void qrp_finalize_computation void   ) 
 

This routine must be called once all the files have been added to finalize the computation of the new QRP.

If the routing table has changed, the node_qrt_changed() routine will be called once we have finished its computation.

void qrp_init char_map_t  map  ) 
 

Initialize QRP.

void qrp_leaf_changed void   ) 
 

Called when we get a new QRT from a leaf node, or when we loose a leaf that sent us its QRT.

gboolean qrp_node_can_route struct gnutella_node n,
query_hashvec_t qhv
 

void qrp_peermode_changed void   ) 
 

Called when the current peermode has changed.

void qrp_prepare_computation void   ) 
 

This routine must be called to initialize the computation of the new QRP based on our local files.

GSList* qrt_build_query_target query_hashvec_t qhvec,
gint  hops,
gint  ttl,
struct gnutella_node source
 

Compute list of nodes to send the query to, based on node's QRT.

The query is identified by its list of QRP hashes, by its hop count, TTL and by its source node (so we don't send back the query where it came from).

Attention:
NB: it is allowed to call this with TTL=0, in which case we won't consider UPs for forwarding. If TTL=1, we forward to all normal nodes or UPs that don't support last-hop QRP, plus those whose QRP table says they could bring a match.
Returns:
list of nodes, a subset of the currently connected nodes. Once used, the list of nodes can be freed with g_slist_free().

void qrt_get_info gpointer  obj,
qrt_info_t qi
 

Returns:
information about query routing table.

gpointer qrt_get_table void   ) 
 

Returns:
the query routing table, NULL if not computed yet.

gpointer qrt_receive_create struct gnutella_node n,
gpointer  query_table
 

Create a new QRT receiving handler, to process all incoming QRP messages from the leaf node.

Parameters:
`n' no brief description.
`query_table' The existing query table we have for the node.
If `query_table' is NULL, it means we have no query table yet, and the first QRP message will have to be a RESET.

Returns:
pointer to handler.

void qrt_receive_free gpointer  handle  ) 
 

Dispose of the QRP receiving state.

gboolean qrt_receive_next gpointer  handle,
gboolean *  done
 

Handle reception of the next QRP message in the stream for a given update.

Returns:
whether we successfully handled the message. If not, the node has been signalled if needed, and may have been BYE-ed.
When the last message from the sequence has been processed, set `done' to TRUE.

gpointer qrt_ref gpointer  obj  ) 
 

Get a new reference on the query routing table.

Returns:
its argument.

void qrt_route_query struct gnutella_node n,
query_hashvec_t qhvec
 

Route query message to leaf nodes, based on their QRT, or to ultrapeers that support last-hop QRP if TTL=1.

void qrt_unref gpointer  obj  ) 
 

Remove one reference to query routing table.

When the last reference is removed, the table is freed.

gpointer qrt_update_create struct gnutella_node n,
gpointer  query_table
 

Create structure keeping track of the table update.

Call qrt_update_send_next() to send the next patching message.

`query_table' is the table that was fully propagated to that node already. It can be NULL if no table was fully propagated yet.

NB: we become owner of the routing_patch, and it will be freed when the created handle is destroyed.

Returns:
opaque handle.

void qrt_update_free gpointer  handle  ) 
 

Free query routing update tracker.

gboolean qrt_update_send_next gpointer  handle  ) 
 

Send the next batch of data.

Returns:
whether the routing should still be called.

gboolean qrt_update_was_ok gpointer  handle  ) 
 

Check whether sending was successful.

Should be called when qrt_update_send_next() returned FALSE.


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