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

qhit.c File Reference


Detailed Description

Query hit packet management.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "qhit.h"
#include "gnutella.h"
#include "ggep.h"
#include "ggep_type.h"
#include "gmsg.h"
#include "share.h"
#include "nodes.h"
#include "bsched.h"
#include "dmesh.h"
#include "uploads.h"
#include "settings.h"
#include "if/gnet_property_priv.h"
#include "lib/getdate.h"
#include "lib/endian.h"
#include "lib/misc.h"
#include "lib/tm.h"
#include "lib/override.h"

Data Structures

struct  found_struct

Defines

#define QHIT_SIZE_THRESHOLD   2016 /**< Flush query hits larger than this */
 Flush query hits larger than this.

#define QHIT_MAX_RESULTS   255 /**< Maximum amount of hits in a query hit */
 Maximum amount of hits in a query hit.

#define QHIT_MAX_ALT   15 /**< Send out 15 alt-locs per entry, max */
 Send out 15 alt-locs per entry, max.

#define QHIT_MAX_PROXIES   5 /**< Send out 5 push-proxies at most */
 Send out 5 push-proxies at most.

#define QHIT_MAX_GGEP   512 /**< Allocated room for trailing GGEP */
 Allocated room for trailing GGEP.

#define QHIT_MIN_TRAILER_LEN   (4+3+16) /**< NAME + open flags + GUID */
 NAME + open flags + GUID.


Functions

 RCSID ("$Id:qhit.c, v 1.38 2005/11/21 21:12:27 rmanfredi Exp $")
found_structfound_get (void)
size_t found_file_count (void)
size_t found_max_size (void)
void found_add_files (size_t n)
gboolean found_ggep_h (void)
gchar * found_open (void)
void found_close (size_t len)
size_t found_size (void)
size_t found_left (void)
gboolean found_write (gconstpointer data, size_t length)
void found_set_header (void)
void found_clear (void)
void found_process (void)
void found_init (size_t max_size, const gchar *xuid, gboolean ggep_h, qhit_process_t proc, gpointer udata)
void qhit_send_node (gpointer data, size_t len, gpointer udata)
 Processor for query hits sent inbound.

void flush_match (void)
 Flush pending search request to the network.

gboolean add_file (const struct shared_file *sf)
 Add file to current query hit.

void found_reset (size_t max_size, const gchar *muid, gboolean use_ggep_h, qhit_process_t process, gpointer udata)
 Reset the QueryHit, that is, the "data found" pointer is at the beginning of the data found section in the query hit packet.

void qhit_send_results (struct gnutella_node *n, GSList *files, gint count, const gchar *muid, gboolean use_ggep_h)
 Send as many small query hit packets as necessary to hold the `count' results held in the `files' list.

void qhit_build_results (GSList *files, gint count, size_t max_msgsize, qhit_process_t cb, gpointer udata, const gchar *muid, gboolean use_ggep_h)
 Build query hit results for later delivery.

void qhit_init (void)
 Initialization of the query hit generation.

void qhit_close (void)
 Shutdown cleanup.


Variables

time_t release_date


Define Documentation

#define QHIT_MAX_ALT   15 /**< Send out 15 alt-locs per entry, max */
 

Send out 15 alt-locs per entry, max.

#define QHIT_MAX_GGEP   512 /**< Allocated room for trailing GGEP */
 

Allocated room for trailing GGEP.

#define QHIT_MAX_PROXIES   5 /**< Send out 5 push-proxies at most */
 

Send out 5 push-proxies at most.

#define QHIT_MAX_RESULTS   255 /**< Maximum amount of hits in a query hit */
 

Maximum amount of hits in a query hit.

#define QHIT_MIN_TRAILER_LEN   (4+3+16) /**< NAME + open flags + GUID */
 

NAME + open flags + GUID.

#define QHIT_SIZE_THRESHOLD   2016 /**< Flush query hits larger than this */
 

Flush query hits larger than this.


Function Documentation

gboolean add_file const struct shared_file sf  )  [static]
 

Add file to current query hit.

Returns:
TRUE if we inserted the record, FALSE if we refused it due to lack of space.

void flush_match void   )  [static]
 

Flush pending search request to the network.

void found_add_files size_t  n  )  [static]
 

void found_clear void   )  [static]
 

void found_close size_t  len  )  [static]
 

size_t found_file_count void   )  [static]
 

struct found_struct* found_get void   )  [static]
 

gboolean found_ggep_h void   )  [static]
 

void found_init size_t  max_size,
const gchar *  xuid,
gboolean  ggep_h,
qhit_process_t  proc,
gpointer  udata
[static]
 

size_t found_left void   )  [static]
 

size_t found_max_size void   )  [static]
 

gchar* found_open void   )  [static]
 

void found_process void   )  [static]
 

void found_reset size_t  max_size,
const gchar *  muid,
gboolean  use_ggep_h,
qhit_process_t  process,
gpointer  udata
[static]
 

Reset the QueryHit, that is, the "data found" pointer is at the beginning of the data found section in the query hit packet.

Parameters:
max_size the maximum size in bytes of individual query hits
use_ggep_h whether GGEP "H" can be used to send the SHA1 of files
muid is the MUID that should be put in all the generated hits. This must point to a memory location that is guaranteed to stay accurate during all the processing.
process the processor callback to invoke on each individually built query hit message, along with `udata'.
udata the node that issued the query hit and to which we must reply for inbound query hit processor, an OOB holding structure when the hits have to be sent out-of-bound

void found_set_header void   )  [static]
 

size_t found_size void   )  [static]
 

gboolean found_write gconstpointer  data,
size_t  length
[static]
 

void qhit_build_results GSList *  files,
gint  count,
size_t  max_msgsize,
qhit_process_t  cb,
gpointer  udata,
const gchar *  muid,
gboolean  use_ggep_h
 

Build query hit results for later delivery.

Results are held in the `files' list. They are packed in hits until the message reaches the `max_msgsize' limit at which time the packet is flushed and given the the `cb' callback for processing (sending, queueing, whatever).

The callback is invoked as

cb(data, len, udata)

where the query hit message is held in the `len' bytes starting at `data'. The `udata' parameter is simply user-supplied data, opaque for us.

Parameters:
files the list of shared_file_t entries that make up results
count the amount of results to deliver (first `count' files)
max_msgsize the targeted maximum hit size before flushing
cb the processor callback to invoke on each built hit
udata argument to pass to callback
muid the MUID to use on each generated hit
use_ggep_h whether GGEP "H" can be used to send the SHA1 of files

void qhit_close void   ) 
 

Shutdown cleanup.

void qhit_init void   ) 
 

Initialization of the query hit generation.

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

Processor for query hits sent inbound.

void qhit_send_results struct gnutella_node n,
GSList *  files,
gint  count,
const gchar *  muid,
gboolean  use_ggep_h
 

Send as many small query hit packets as necessary to hold the `count' results held in the `files' list.

Parameters:
n the node where we should send results to
files the list of shared_file_t entries that make up results
count the amount of results
muid the query's MUID
use_ggep_h whether GGEP "H" can be used to send the SHA1 of files

RCSID "$Id:qhit.  c,
v 1.38 2005/11/21 21:12:27 rmanfredi Exp $" 
 


Variable Documentation

time_t release_date [static]
 


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