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

oob.c File Reference


Detailed Description

Out of band query hits.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "oob.h"
#include "hosts.h"
#include "nodes.h"
#include "share.h"
#include "guid.h"
#include "pmsg.h"
#include "mq.h"
#include "mq_udp.h"
#include "vmsg.h"
#include "qhit.h"
#include "gmsg.h"
#include "gnet_stats.h"
#include "if/gnet_property_priv.h"
#include "lib/atoms.h"
#include "lib/cq.h"
#include "lib/fifo.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  oob_results
 A set of hits awaiting delivery. More...
struct  gservent
 A servent entry, used as values in the `servent_by_host' table. More...

Defines

#define OOB_EXPIRE_MS   (2*60*1000)
 2 minutes at most
#define OOB_TIMEOUT_MS   (45*1000)
 45 secs for them to reply
#define OOB_DELIVER_BASE_MS   2500
 1 msg queued every 2.5 secs
#define OOB_DELIVER_RAND_MS   5000
 ..
#define OOB_MAX_QUEUED   50
 Max # of messages per host.
#define OOB_MAX_RETRY   3
 Retry # if LIME/12v2 dropped.
#define OOB_MAX_QHIT_SIZE   645
 Flush hits larger than this.
#define OOB_MAX_DQHIT_SIZE   1075
 Flush limit for deflated hits.

Enumerations

enum  oob_results_magic_t { OOB_RESULTS_MAGIC = 0x7ae5e685 }

Functions

void results_destroy (cqueue_t *cq, gpointer obj)
 Callout queue callback to free the results.
void servent_free (struct gservent *s)
 Free servent structure.
void oob_send_reply_ind (struct oob_results *r)
 Send them a LIME/12v2, monitoring progress in queue via a callback.
void oob_results_check (const struct oob_results *r)
oob_resultsresults_make (const gchar *muid, GSList *files, gint count, gnet_host_t *to, gboolean secure, gboolean ggep_h)
 Create new "struct oob_results" to handle the initial negotiation of results delivery via the sent LIME/12v2 and the expected LIME/11v2 reply.
void results_free_remove (struct oob_results *r)
 Dispose of results.
void results_timeout (cqueue_t *unused_cq, gpointer obj)
 Callout queue callback to free the results.
void servent_free_remove (struct gservent *s)
 Dispose of servent, removing entry from the `servent_by_host' table.
gint deliver_delay (void)
 Computes the amount of milliseconds before the next OOB hit delivery,.
void servent_service (cqueue_t *cq, gpointer obj)
 Service servent's FIFO: send next packet, and re-arm servicing callback if there are more data to send.
gserventservent_make (gnet_host_t *host, gboolean can_deflate)
 Create a new servent structure.
void free_pmsg (gpointer item, gpointer unused_udata)
 Cleanup items from FIFO.
void oob_record_hit (gpointer data, size_t len, gpointer udata)
 Invoked via qhit_build_results() for each fully built query hit message.
void oob_deliver_hits (struct gnutella_node *n, const gchar *muid, guint8 wanted, const struct array *token)
 The remote host acknowledges that we have some hits for it and wishes to get the specified amount.
void oob_pmsg_free (pmsg_t *mb, gpointer arg)
 Callback invoked when the LIME/12v2 message we queued is freed.
void oob_got_results (struct gnutella_node *n, GSList *files, gint count, gboolean secure, gboolean ggep_h)
 Notification that we got matches for a query from some node that needs to be replied to using out-of-band delivery.
void oob_init (void)
 Initialize out-of-band query hit delivery.
void free_oob_kv (gpointer key, gpointer value, gpointer unused_udata)
 Cleanup oob_results -- hash table iterator callback.
void free_servent_kv (gpointer key, gpointer value, gpointer unused_udata)
 Cleanup servent -- hash table iterator callback.
void oob_shutdown (void)
 Cleanup at shutdown time.
void oob_close (void)
 Final cleanup.

Variables

GHashTable * results_by_muid = NULL
 Indexes all OOB queries by MUID.
GHashTable * servent_by_host = NULL
 Each servent, as identified by its IP:port, is given a FIFO for queuing messages and sending them at a rate of 1 message every OOB_DELIVER_MS, to avoid UDP flooding on the remote side.
gint num_oob_records
 Leak and duplicate free detector.
gboolean oob_shutdown_running


Define Documentation

#define OOB_DELIVER_BASE_MS   2500
 

1 msg queued every 2.5 secs

#define OOB_DELIVER_RAND_MS   5000
 

..

+ up to 5 random secs

#define OOB_EXPIRE_MS   (2*60*1000)
 

2 minutes at most

#define OOB_MAX_DQHIT_SIZE   1075
 

Flush limit for deflated hits.

#define OOB_MAX_QHIT_SIZE   645
 

Flush hits larger than this.

#define OOB_MAX_QUEUED   50
 

Max # of messages per host.

#define OOB_MAX_RETRY   3
 

Retry # if LIME/12v2 dropped.

#define OOB_TIMEOUT_MS   (45*1000)
 

45 secs for them to reply


Enumeration Type Documentation

enum oob_results_magic_t
 

Enumeration values:
OOB_RESULTS_MAGIC 


Function Documentation

gint deliver_delay void   )  [static]
 

Computes the amount of milliseconds before the next OOB hit delivery,.

Per a suggestion of Daniel Stutzbach, we wait BASE + RAND*random secs, where "random" is a real random number between 0 and 1.

void free_oob_kv gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Cleanup oob_results -- hash table iterator callback.

void free_pmsg gpointer  item,
gpointer  unused_udata
[static]
 

Cleanup items from FIFO.

-- fifo_free_all() callback.

void free_servent_kv gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Cleanup servent -- hash table iterator callback.

void oob_close void   ) 
 

Final cleanup.

void oob_deliver_hits struct gnutella_node n,
const gchar *  muid,
guint8  wanted,
const struct array token
 

The remote host acknowledges that we have some hits for it and wishes to get the specified amount.

Parameters:
n where we got the message from
muid the query identifier
wanted the amount of results they want delivered
token the token for secure OOB

The sender's IP address can of course change any time as dynamic IP addresses are very common. The sender might also have multiple network interfaces.

void oob_got_results struct gnutella_node n,
GSList *  files,
gint  count,
gboolean  secure,
gboolean  ggep_h
 

Notification that we got matches for a query from some node that needs to be replied to using out-of-band delivery.

Parameters:
n the node from which we got the query
files the list of shared_file_t entries that make up results
count the amount of results
secure whether secure OOB was requested
ggep_h whether GGEP H is understood

void oob_init void   ) 
 

Initialize out-of-band query hit delivery.

void oob_pmsg_free pmsg_t mb,
gpointer  arg
[static]
 

Callback invoked when the LIME/12v2 message we queued is freed.

void oob_record_hit gpointer  data,
size_t  len,
gpointer  udata
[static]
 

Invoked via qhit_build_results() for each fully built query hit message.

Hit is enqueued in the FIFO, for slow delivery.

void oob_results_check const struct oob_results r  )  [static]
 

void oob_send_reply_ind struct oob_results r  )  [static]
 

Send them a LIME/12v2, monitoring progress in queue via a callback.

void oob_shutdown void   ) 
 

Cleanup at shutdown time.

void results_destroy cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback to free the results.

void results_free_remove struct oob_results r  )  [static]
 

Dispose of results.

struct oob_results* results_make const gchar *  muid,
GSList *  files,
gint  count,
gnet_host_t to,
gboolean  secure,
gboolean  ggep_h
[static]
 

Create new "struct oob_results" to handle the initial negotiation of results delivery via the sent LIME/12v2 and the expected LIME/11v2 reply.

void results_timeout cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback to free the results.

void servent_free struct gservent s  )  [static]
 

Free servent structure.

void servent_free_remove struct gservent s  )  [static]
 

Dispose of servent, removing entry from the `servent_by_host' table.

struct gservent* servent_make gnet_host_t host,
gboolean  can_deflate
[static]
 

Create a new servent structure.

Parameters:
host the servent's IP:port. Caller may free it upon return.

void servent_service cqueue_t cq,
gpointer  obj
[static]
 

Service servent's FIFO: send next packet, and re-arm servicing callback if there are more data to send.


Variable Documentation

gint num_oob_records [static]
 

Leak and duplicate free detector.

gboolean oob_shutdown_running [static]
 

GHashTable* results_by_muid = NULL [static]
 

Indexes all OOB queries by MUID.

This hash table records MUID => "struct oob_results"

GHashTable* servent_by_host = NULL [static]
 

Each servent, as identified by its IP:port, is given a FIFO for queuing messages and sending them at a rate of 1 message every OOB_DELIVER_MS, to avoid UDP flooding on the remote side.

This hash table records gnet_host_t => "struct gservent"


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