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

dmesh.h File Reference


Detailed Description

Download mesh.

Author:
Raphael Manfredi
Date:
2002-2003

#include "downloads.h"
#include <glib.h>
#include <errno.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
}
 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 (gchar *sha1, const host_addr_t addr, guint16 port, guint idx, gchar *name, time_t stamp)
 Same as dmesh_raw_add(), but this is for public consumption.

gboolean dmesh_remove (const gchar *sha1, const host_addr_t addr, guint16 port, guint idx, gchar *name)
 Remove entry from mesh due to a failed download attempt.

gint dmesh_count (const gchar *sha1)
 Get the number of dmesh entries for a given SHA1.

gboolean dmesh_collect_sha1 (const gchar *value, gchar *digest)
 Parse the value of the X-Gnutella-Content-URN header in `value', looking for a SHA1.

void dmesh_collect_locations (gchar *sha1, gchar *value, gboolean defer)
 Parse value of the "X-Gnutella-Alternate-Location" to extract alternate sources for a given SHA1 key.

void dmesh_collect_compact_locations (gchar *sha1, 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.

gint dmesh_fill_alternate (const gchar *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 gchar *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 (gchar *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.


Function Documentation

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

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

gint dmesh_alternate_location const gchar *  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 gchar *  sha1,
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 gchar *  sha1,
gchar *  value,
gboolean  defer
 

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

gboolean dmesh_collect_sha1 const gchar *  value,
gchar *  digest
 

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 gchar *  sha1  ) 
 

Get the number of dmesh entries for a given SHA1.

Returns:
the number of dmesh entries

gint dmesh_fill_alternate const gchar *  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_init void   ) 
 

Initialize the download mesh.

void dmesh_multiple_downloads gchar *  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.

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

Remove entry from mesh due to a failed download attempt.

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 Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6