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

dmesh.h File Reference


Detailed Description

Download mesh.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "downloads.h"

Go to the source code of this file.

Data Structures

struct  dmesh_urlinfo_t
 A download mesh info (describes an URL). More...

Enumerations

enum  dmesh_url_error_t {
  DMESH_URL_OK = 0, DMESH_URL_HTTP_PARSER, DMESH_URL_BAD_FILE_PREFIX, DMESH_URL_RESERVED_INDEX,
  DMESH_URL_NO_FILENAME, DMESH_URL_BAD_ENCODING, DMESH_URL_BAD_URI_RES
}
 Error codes from dmesh_url_parse(). More...

Functions

void dmesh_init (void)
 Initialize the download mesh.
void dmesh_close (void)
 Called at servent shutdown time.
const gchar * dmesh_url_strerror (dmesh_url_error_t errnum)
gboolean dmesh_url_parse (const gchar *url, dmesh_urlinfo_t *info)
 Parse URL `url', and fill a structure `info' representing this URL.
gboolean dmesh_add (const struct sha1 *sha1, const host_addr_t addr, guint16 port, guint idx, const gchar *name, time_t stamp)
 Same as dmesh_raw_add(), but this is for public consumption.
gboolean dmesh_remove (const struct sha1 *sha1, const host_addr_t addr, guint16 port, guint idx, const gchar *name)
 Remove entry from mesh due to a failed download attempt.
void dmesh_add_alternate (const struct sha1 *sha1, host_addr_t addr, guint16 port)
 Add addr:port as a known alternate location for given sha1.
void dmesh_add_good_alternate (const struct sha1 *sha1, host_addr_t addr, guint16 port)
void dmesh_remove_alternate (const struct sha1 *sha1, host_addr_t addr, guint16 port)
 Remove addr:port as a known alternate location for given sha1.
void dmesh_add_alternates (const struct sha1 *sha1, const gnet_host_vec_t *vec)
 Add a set of alternate locations (IP + port) to the mesh.
void dmesh_negative_alt (const struct sha1 *sha1, host_addr_t reporter, host_addr_t addr, guint16 port)
 Record that addr:port was signalled negatively as an alternate location for given sha1.
void dmesh_good_mark (const struct sha1 *sha1, host_addr_t addr, guint16 port, gboolean good)
 Flag dmesh entry for this SHA1, address and port as good or bad.
gint dmesh_count (const struct sha1 *sha1)
 Get the number of dmesh entries for a given SHA1.
gboolean dmesh_collect_sha1 (const gchar *value, struct sha1 *sha1)
 Parse the value of the X-Gnutella-Content-URN header in `value', looking for a SHA1.
void dmesh_collect_locations (const struct sha1 *sha1, const gchar *value)
 Parse value of the "X-Gnutella-Alternate-Location" to extract alternate sources for a given SHA1 key.
void dmesh_collect_compact_locations (const struct sha1 *sha1, const gchar *value)
 Parse the value of the "X-Alt" header to extract alternate sources for a given SHA1 key given in the new compact form.
void dmesh_collect_negative_locations (const struct sha1 *sha1, const gchar *value, host_addr_t reporter)
 Parse the value of the "X-Nalt" header to extract bad sources for a given SHA1 key, given in the new compact form.
gint dmesh_fill_alternate (const struct sha1 *sha1, gnet_host_t *hvec, gint hcnt)
 Fill supplied vector `hvec' whose size is `hcnt' with some alternate locations for a given SHA1 key, that can be requested by hash directly.
gint dmesh_alternate_location (const struct sha1 *sha1, gchar *buf, size_t size, const host_addr_t addr, time_t last_sent, const gchar *vendor, fileinfo_t *fi, gboolean request)
 Build alternate location header for a given SHA1 key.
void dmesh_multiple_downloads (const struct sha1 *sha1, filesize_t size, fileinfo_t *fi)
 This is called when swarming is first requested to get a list of all the servers with the requested file known by dmesh.
void dmesh_check_results_set (gnet_results_set_t *rs)
 Parse query hit (result set) for entries whose SHA1 match something we have into the mesh or share, and insert them if needed.
void dmesh_store (void)
 Store download mesh onto file.
void dmesh_ban_store (void)
 Store banned mesh onto file.

Variables

dmesh_url_error_t dmesh_url_errno
 Error from dmesh_url_parse().


Enumeration Type Documentation

enum dmesh_url_error_t
 

Error codes from dmesh_url_parse().

Enumeration values:
DMESH_URL_OK  All OK.
DMESH_URL_HTTP_PARSER  Error from http_url_parse().
DMESH_URL_BAD_FILE_PREFIX  File prefix neither /uri-res nor /get.
DMESH_URL_RESERVED_INDEX  Index in /get/index is reserved.
DMESH_URL_NO_FILENAME  No filename after /get/index.
DMESH_URL_BAD_ENCODING  Bad URL encoding.
DMESH_URL_BAD_URI_RES  Malformed /uri-res/N2R?


Function Documentation

gboolean dmesh_add const struct sha1 sha1,
const host_addr_t  addr,
guint16  port,
guint  idx,
const gchar *  name,
time_t  stamp
 

Same as dmesh_raw_add(), but this is for public consumption.

void dmesh_add_alternate const struct sha1 sha1,
host_addr_t  addr,
guint16  port
 

Add addr:port as a known alternate location for given sha1.

void dmesh_add_alternates const struct sha1 sha1,
const gnet_host_vec_t vec
 

Add a set of alternate locations (IP + port) to the mesh.

void dmesh_add_good_alternate const struct sha1 sha1,
host_addr_t  addr,
guint16  port
 

gint dmesh_alternate_location const struct sha1 sha1,
gchar *  buf,
size_t  size,
const host_addr_t  addr,
time_t  last_sent,
const gchar *  vendor,
fileinfo_t fi,
gboolean  request
 

Build alternate location header for a given SHA1 key.

We generate at most `size' bytes of data into `alt'.

Parameters:
`sha1' no brief description.
`buf' no brief description.
'size' no brief description.
`addr' is the host to which those alternate locations are meant: we skip any data pertaining to that host.
`last_sent' is the time at which we sent some previous alternate locations. If there has been no change to the mesh since then, we'll return an empty string. Otherwise we return entries inserted after `last_sent'.
`vendor' is given to determine whether it is apt to read our X-Alt and X-Nalt fields formatted with continuations or not.
`fi' when it is non-NULL, it means we're sharing that file and we're sending alternate locations to remote servers: include ourselves in the list of alternate locations if PFSP-server is enabled.
`request' if it is true, then the mesh entries are generated in an HTTP request; otherwise it's for an HTTP reply.
unless the `vendor' is GTKG, don't use continuation: most servent authors don't bother with a proper HTTP header parsing layer.

Returns:
amount of generated data.

void dmesh_ban_store void   ) 
 

Store banned mesh onto file.

The banned mesh is normally stored in ~/.gtk-gnutella/dmesh_ban.

void dmesh_check_results_set gnet_results_set_t rs  ) 
 

Parse query hit (result set) for entries whose SHA1 match something we have into the mesh or share, and insert them if needed.

void dmesh_close void   ) 
 

Called at servent shutdown time.

void dmesh_collect_compact_locations const struct sha1 sha1,
const gchar *  value
 

Parse the value of the "X-Alt" header to extract alternate sources for a given SHA1 key given in the new compact form.

void dmesh_collect_locations const struct sha1 sha1,
const gchar *  value
 

Parse value of the "X-Gnutella-Alternate-Location" to extract alternate sources for a given SHA1 key.

void dmesh_collect_negative_locations const struct sha1 sha1,
const gchar *  value,
host_addr_t  reporter
 

Parse the value of the "X-Nalt" header to extract bad sources for a given SHA1 key, given in the new compact form.

Parameters:
reporter the address of the host supplying the X-Nalt header

gboolean dmesh_collect_sha1 const gchar *  value,
struct sha1 sha1
 

Parse the value of the X-Gnutella-Content-URN header in `value', looking for a SHA1.

When found, the SHA1 is extracted and placed into the given `digest' buffer.

Returns:
whether we successfully extracted the SHA1.

gint dmesh_count const struct sha1 sha1  ) 
 

Get the number of dmesh entries for a given SHA1.

Returns:
the number of dmesh entries

gint dmesh_fill_alternate const struct sha1 sha1,
gnet_host_t hvec,
gint  hcnt
 

Fill supplied vector `hvec' whose size is `hcnt' with some alternate locations for a given SHA1 key, that can be requested by hash directly.

Returns:
the amount of locations filled.

void dmesh_good_mark const struct sha1 sha1,
host_addr_t  addr,
guint16  port,
gboolean  good
 

Flag dmesh entry for this SHA1, address and port as good or bad.

void dmesh_init void   ) 
 

Initialize the download mesh.

void dmesh_multiple_downloads const struct sha1 sha1,
filesize_t  size,
fileinfo_t fi
 

This is called when swarming is first requested to get a list of all the servers with the requested file known by dmesh.

It creates a new download for every server found.

Parameters:
`sha1' (atom) the SHA1 of the file.
`size' the original file size.
`fi' no brief description.

void dmesh_negative_alt const struct sha1 sha1,
host_addr_t  reporter,
host_addr_t  addr,
guint16  port
 

Record that addr:port was signalled negatively as an alternate location for given sha1.

The reporter's address is also given so that we can wait until we have sufficient evidence from at least 2 different parties.

When there is sufficient evidence, the entry is evicted from the mesh and placed into the banned mesh.

gboolean dmesh_remove const struct sha1 sha1,
const host_addr_t  addr,
guint16  port,
guint  idx,
const gchar *  name
 

Remove entry from mesh due to a failed download attempt.

void dmesh_remove_alternate const struct sha1 sha1,
host_addr_t  addr,
guint16  port
 

Remove addr:port as a known alternate location for given sha1.

This inserts the location into the banned mesh.

void dmesh_store void   ) 
 

Store download mesh onto file.

The download mesh is normally stored in ~/.gtk-gnutella/dmesh.

gboolean dmesh_url_parse const gchar *  url,
dmesh_urlinfo_t info
 

Parse URL `url', and fill a structure `info' representing this URL.

Returns:
TRUE if OK, FALSE if we could not parse it. The variable `dmesh_url_errno' is set accordingly.

const gchar* dmesh_url_strerror dmesh_url_error_t  errnum  ) 
 

Returns:
human-readable error string corresponding to error code `errnum'.


Variable Documentation

dmesh_url_error_t dmesh_url_errno
 

Error from dmesh_url_parse().


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