annotate src/gt_search.h @ 0:d39e1d0d75b6

initial add
author paulo@hit-nxdomain.opendns.com
date Sat, 20 Feb 2010 21:18:28 -0800
parents
children
rev   line source
paulo@0 1 /*
paulo@0 2 * $Id: gt_search.h,v 1.19 2004/01/18 05:43:13 hipnod Exp $
paulo@0 3 *
paulo@0 4 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net)
paulo@0 5 *
paulo@0 6 * This program is free software; you can redistribute it and/or modify it
paulo@0 7 * under the terms of the GNU General Public License as published by the
paulo@0 8 * Free Software Foundation; either version 2, or (at your option) any
paulo@0 9 * later version.
paulo@0 10 *
paulo@0 11 * This program is distributed in the hope that it will be useful, but
paulo@0 12 * WITHOUT ANY WARRANTY; without even the implied warranty of
paulo@0 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
paulo@0 14 * General Public License for more details.
paulo@0 15 */
paulo@0 16
paulo@0 17 #ifndef GIFT_GT_SEARCH_H_
paulo@0 18 #define GIFT_GT_SEARCH_H_
paulo@0 19
paulo@0 20 /******************************************************************************/
paulo@0 21
paulo@0 22 struct tcp_conn;
paulo@0 23 struct file_share;
paulo@0 24
paulo@0 25 typedef enum
paulo@0 26 {
paulo@0 27 GT_SEARCH_HASH,
paulo@0 28 GT_SEARCH_KEYWORD,
paulo@0 29 } gt_search_type_t;
paulo@0 30
paulo@0 31 /*
paulo@0 32 * These flags exist in what used to be the MinSpeed field of
paulo@0 33 * queries. The documentation for this field is arranged as two
paulo@0 34 * bytes in big-endian order, but this uses it in little-endian
paulo@0 35 * order so as to be consistent with the rest of the protocol.
paulo@0 36 */
paulo@0 37 typedef enum gt_query_flags
paulo@0 38 {
paulo@0 39 QF_WANTS_XML = 0x0020, /* servent wants XML metadata */
paulo@0 40 QF_ONLY_NON_FW = 0x0040, /* source desires non-firewalled hits only */
paulo@0 41 QF_HAS_FLAGS = 0x0080, /* this query has this interpretation */
paulo@0 42 } gt_query_flags_t;
paulo@0 43
paulo@0 44 typedef struct gt_search
paulo@0 45 {
paulo@0 46 /* giFT event */
paulo@0 47 IFEvent *event;
paulo@0 48
paulo@0 49 /* what kind of search this is */
paulo@0 50 gt_search_type_t type;
paulo@0 51
paulo@0 52 /* the guid used to identify the search */
paulo@0 53 char *guid;
paulo@0 54
paulo@0 55 /* the query used for the search */
paulo@0 56 char *query;
paulo@0 57
paulo@0 58 /* the hash to look for this search if a URN query XXX should use gt_urn_t
paulo@0 59 * here, but the interface is just too borked */
paulo@0 60 char *hash;
paulo@0 61
paulo@0 62 /* the realm used for this query, if any */
paulo@0 63 char *realm;
paulo@0 64
paulo@0 65 /* expires the search according to critieria: see
paulo@0 66 * gt_search.c:search_timeout */
paulo@0 67 timer_id timeout_timer;
paulo@0 68
paulo@0 69 /* when the search was started */
paulo@0 70 time_t start;
paulo@0 71
paulo@0 72 /* how many nodes this search has been submitted to */
paulo@0 73 size_t submitted;
paulo@0 74
paulo@0 75 /* the last time we submitted to a node */
paulo@0 76 time_t last_submit;
paulo@0 77
paulo@0 78 /* time the last result for this search was seen */
paulo@0 79 time_t last_result;
paulo@0 80
paulo@0 81 /* results count */
paulo@0 82 size_t results;
paulo@0 83 } GtSearch;
paulo@0 84
paulo@0 85 /* the default ttl for searches */
paulo@0 86 #define GT_SEARCH_TTL (5)
paulo@0 87
paulo@0 88 /******************************************************************************/
paulo@0 89
paulo@0 90 GtSearch *gt_search_new (IFEvent *event, char *query,
paulo@0 91 gt_search_type_t type);
paulo@0 92 void gt_search_free (GtSearch *search);
paulo@0 93 void gt_search_disable (IFEvent *event);
paulo@0 94 void gt_search_reply (GtSearch *search, struct tcp_conn *c,
paulo@0 95 in_addr_t ip, in_port_t gt_port,
paulo@0 96 gt_guid_t *client_guid, int availability,
paulo@0 97 BOOL firewalled, struct file_share *file);
paulo@0 98 GtSearch *gt_search_find (gt_guid_t *guid);
paulo@0 99
paulo@0 100 /* submit active searches to a node after a timeout */
paulo@0 101 void gt_searches_submit (struct tcp_conn *c, time_t delay);
paulo@0 102
paulo@0 103 /******************************************************************************/
paulo@0 104
paulo@0 105 BOOL gnutella_search (Protocol *p, IFEvent *event, char *query,
paulo@0 106 char *exclude, char *realm, Dataset *meta);
paulo@0 107
paulo@0 108 BOOL gnutella_locate (Protocol *p, IFEvent *event, char *htype,
paulo@0 109 char *hash);
paulo@0 110
paulo@0 111 void gnutella_search_cancel (Protocol *p, IFEvent *event);
paulo@0 112
paulo@0 113 /******************************************************************************/
paulo@0 114
paulo@0 115 void gt_search_init (void);
paulo@0 116 void gt_search_cleanup (void);
paulo@0 117
paulo@0 118 /******************************************************************************/
paulo@0 119
paulo@0 120 #endif /* GIFT_GT_SEARCH_H_ */