2c20df2c4748a4347cb5b18f14f8d1db4297a75a
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file dht/gnunet-service-dht_neighbours.h
23  * @brief GNUnet DHT routing code
24  * @author Christian Grothoff
25  * @author Nathan Evans
26  */
27 #ifndef GNUNET_SERVICE_DHT_NEIGHBOURS_H
28 #define GNUNET_SERVICE_DHT_NEIGHBOURS_H
29
30
31 /**
32  * Perform a PUT operation.  Forwards the given request to other
33  * peers.   Does not store the data locally.  Does not give the
34  * data to local clients.  May do nothing if this is the only
35  * peer in the network (or if we are the closest peer in the
36  * network).
37  *
38  * @param type type of the block
39  * @param options routing options
40  * @param desired_replication_level desired replication level
41  * @param expiration_time when does the content expire
42  * @param hop_count how many hops has this message traversed so far
43  * @param bf Bloom filter of peers this PUT has already traversed
44  * @param key key for the content
45  * @param put_path_length number of entries in put_path
46  * @param put_path peers this request has traversed so far (if tracked)
47  * @param data payload to store
48  * @param data_size number of bytes in data
49  */
50 void
51 GDS_NEIGHBOURS_handle_put (uint32_t type,
52                            uint32_t options,
53                            uint32_t desired_replication_level,
54                            GNUNET_TIME_Absolute expiration_time,
55                            uint32_t hop_count,
56                            struct GNUNET_CONTAINER_BloomFilter *bf,
57                            const GNUNET_HashCode *key,
58                            unsigned int put_path_length,
59                            struct GNUNET_PeerIdentity *put_path,
60                            const void *data,
61                            size_t data_size);
62
63
64 /**
65  * Perform a GET operation.  Forwards the given request to other
66  * peers.  Does not lookup the key locally.  May do nothing if this is
67  * the only peer in the network (or if we are the closest peer in the
68  * network).
69  *
70  * @param type type of the block
71  * @param options routing options
72  * @param desired_replication_level desired replication count
73  * @param hop_count how many hops did this request traverse so far?
74  * @param key key for the content
75  * @param xquery extended query
76  * @param xquery_size number of bytes in xquery
77  * @param reply_bf bloomfilter to filter duplicates
78  * @param reply_bf_mutator mutator for reply_bf
79  * @param peer_bf filter for peers not to select (again)
80  */
81 void
82 GDS_NEIGHBOURS_handle_get (uint32_t type,
83                            uint32_t options,
84                            uint32_t desired_replication_level,
85                            uint32_t hop_count,
86                            const GNUNET_HashCode *key,
87                            const void *xquery,
88                            size_t xquery_size,
89                            const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
90                            uint32_t reply_bf_mutator,
91                            const struct GNUNET_CONTAINER_BloomFilter *peer_bf);
92
93
94 /**
95  * Handle a reply (route to origin).  Only forwards the reply back to
96  * other peers waiting for it.  Does not do local caching or
97  * forwarding to local clients.
98  *
99  * @param type type of the block
100  * @param expiration_time when does the content expire
101  * @param key key for the content
102  * @param put_path_length number of entries in put_path
103  * @param put_path peers the original PUT traversed (if tracked)
104  * @param get_path_length number of entries in put_path
105  * @param get_path peers this reply has traversed so far (if tracked)
106  * @param data payload of the reply
107  * @param data_size number of bytes in data
108  */
109 void
110 GDS_NEIGHBOURS_handle_reply (uint32_t type,
111                              GNUNET_TIME_Absolute expiration_time,
112                              const GNUNET_HashCode *key,
113                              unsigned int put_path_length,
114                              struct GNUNET_PeerIdentity *put_path,
115                              unsigned int get_path_length,
116                              struct GNUNET_PeerIdentity *get_path,
117                              const void *data,
118                              size_t data_size);
119
120
121 /**
122  * Initialize neighbours subsystem.
123  */
124 void
125 GDS_NEIGHBOURS_init (void);
126
127 /**
128  * Shutdown neighbours subsystem.
129  */
130 void
131 GDS_NEIGHBOURS_done (void);
132
133
134 #endif