Code Search for Developers
 
 
  

dmesh.h from Gtk-Gnutella at Krugle


Show dmesh.h syntax highlighted

/*
 * $Id: dmesh.h 13969 2007-06-24 11:03:15Z cbiere $
 *
 * Copyright (c) 2002-2003, Raphael Manfredi
 *
 *----------------------------------------------------------------------
 * This file is part of gtk-gnutella.
 *
 *  gtk-gnutella is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  gtk-gnutella is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with gtk-gnutella; if not, write to the Free Software
 *  Foundation, Inc.:
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *----------------------------------------------------------------------
 */

/**
 * @ingroup core
 * @file
 *
 * Download mesh.
 *
 * @author Raphael Manfredi
 * @date 2002-2003
 */

#ifndef _core_dmesh_h_
#define _core_dmesh_h_

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

/**
 * A download mesh info (describes an URL).
 *
 * It can describe URLs like:
 *
 *  - http://1.2.3.4:5678/get/1/name.txt
 *  - http://1.2.3.4:5678/uri-res/N2R?urn:sha1:ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
 *
 * We use the `idx' to discriminate between the two forms, URN_INDEX meaning
 * it's an URN.
 */
typedef struct {
	const gchar *name;			/**< File name (atom) */
	host_addr_t addr;			/**< Host address */
	guint idx;					/**< File index (URN_INDEX means URN access) */
	guint16 port;				/**< Host port */
} dmesh_urlinfo_t;

/**
 * Error codes from dmesh_url_parse().
 */

typedef enum {
	DMESH_URL_OK = 0,			/**< 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? */
} dmesh_url_error_t;

extern dmesh_url_error_t dmesh_url_errno;

/*
 * Public interface
 */

void dmesh_init(void);
void dmesh_close(void);

const gchar *dmesh_url_strerror(dmesh_url_error_t errnum);
gboolean dmesh_url_parse(const gchar *url, dmesh_urlinfo_t *info);

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

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

void dmesh_add_alternate(const struct sha1 *sha1,
		host_addr_t addr, guint16 port);
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);
void dmesh_add_alternates(const struct sha1 *sha1, const gnet_host_vec_t *vec);

void dmesh_negative_alt(const struct sha1 *sha1,
	host_addr_t reporter, host_addr_t addr, guint16 port);
void dmesh_good_mark(const struct sha1 *sha1,
	host_addr_t addr, guint16 port, gboolean good);

gint dmesh_count(const struct sha1 *sha1);

gboolean dmesh_collect_sha1(const gchar *value, struct sha1 *sha1);
void dmesh_collect_locations(const struct sha1 *sha1, const gchar *value);
void dmesh_collect_compact_locations(const struct sha1 *sha1,
		const gchar *value);
void dmesh_collect_negative_locations(const struct sha1 *sha1,
	const gchar *value, host_addr_t reporter);
gint dmesh_fill_alternate(const struct sha1 *sha1,
		gnet_host_t *hvec, gint hcnt);

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);

void dmesh_multiple_downloads(
	const struct sha1 *sha1, filesize_t size, fileinfo_t *fi);

void dmesh_check_results_set(gnet_results_set_t *rs);

void dmesh_store(void);
void dmesh_ban_store(void);

#endif	/* _core_dmesh_h_ */

/* vi: set ts=4 sw=4 cindent: */




See more files for this project here

Gtk-Gnutella

A GTK+ Gnutella client for Unix, efficient, reliable and fast, written in C. It has been optimized for speed and scalability, with low-memory consumption. It is meant to be left running 24x7, using little CPU and only the configured bandwidth.

Project homepage: http://sourceforge.net/projects/gtk-gnutella
Programming language(s): C
License: other

  Jmakefile
  Makefile.SH
  alive.c
  alive.h
  ban.c
  ban.h
  bh_download.c
  bh_download.h
  bh_upload.c
  bh_upload.h
  bitzi.c
  bitzi.h
  bogons.c
  bogons.h
  bsched.c
  bsched.h
  clock.c
  clock.h
  dh.c
  dh.h
  dime.c
  dime.h
  dmesh.c
  dmesh.h
  downloads.c
  downloads.h
  dq.c
  dq.h
  extensions.c
  extensions.h
  features.c
  features.h
  file_object.c
  file_object.h
  fileinfo.c
  fileinfo.h
  geo_ip.c
  geo_ip.h
  ggep.c
  ggep.h
  ggep_type.c
  ggep_type.h
  gmsg.c
  gmsg.h
  gnet_stats.c
  gnet_stats.h
  gnutella.h
  guid.c
  guid.h
  hcache.c
  hcache.h
  hostiles.c
  hostiles.h
  hosts.c
  hosts.h
  hsep.c
  hsep.h
  http.c
  http.h
  huge.c
  huge.h
  ignore.c
  ignore.h
  inet.c
  inet.h
  ioheader.c
  ioheader.h
  local_shell.c
  local_shell.h
  matching.c
  matching.h
  mime_types.h
  move.c
  move.h
  mq.c
  mq.h
  mq_tcp.c
  mq_tcp.h
  mq_udp.c
  mq_udp.h
  namesize.c
  namesize.h
  nodes.c
  nodes.h
  ntp.c
  ntp.h
  oob.c
  oob.h
  oob_proxy.c
  oob_proxy.h
  parq.c
  parq.h
  pcache.c
  pcache.h
  pmsg.c
  pmsg.h
  pproxy.c
  pproxy.h
  qhit.c
  qhit.h
  qrp.c
  qrp.h