-allow caller ID to differ from zone used for resolution
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_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-xdht_neighbours.h
23  * @brief GNUnet DHT routing code
24  * @author Supriti Singh
25  */
26
27 #ifndef GNUNET_SERVICE_XDHT_NEIGHBOURS_H
28 #define GNUNET_SERVICE_XDHT_NEIGHBOURS_H
29
30 #include "gnunet_util_lib.h"
31 #include "gnunet_block_lib.h"
32 #include "gnunet_dht_service.h"
33
34
35 /**
36  * Construct a Put message and send it to target_peer.
37  * @param key Key for the content
38  * @param block_type Type of the block
39  * @param options Routing options
40  * @param desired_replication_level Desired replication count
41  * @param best_known_dest Peer to which this message should reach eventually,
42  *                        as it is best known destination to me. 
43  * @param intermediate_trail_id Trail id in case 
44  * @param target_peer Peer to which this message will be forwarded.
45  * @param hop_count Number of hops traversed so far.
46  * @param put_path_length Total number of peers in @a put_path
47  * @param put_path Number of peers traversed so far
48  * @param expiration_time When does the content expire
49  * @param data Content to store
50  * @param data_size Size of content @a data in bytes
51  */
52 void
53 GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
54                          enum GNUNET_BLOCK_Type block_type,
55                          enum GNUNET_DHT_RouteOption options,
56                          uint32_t desired_replication_level,
57                          struct GNUNET_PeerIdentity *best_known_dest,
58                          struct GNUNET_HashCode *intermediate_trail_id,
59                          struct GNUNET_PeerIdentity *target_peer,
60                          uint32_t hop_count,
61                          uint32_t put_path_length,
62                          struct GNUNET_PeerIdentity *put_path,
63                          struct GNUNET_TIME_Absolute expiration_time,
64                          const void *data, size_t data_size);
65
66
67 /**
68  * Construct a Get message and send it to target_peer.
69  * @param key Key for the content
70  * @param block_type Type of the block
71  * @param options Routing options
72  * @param desired_replication_level Desired replication count
73  * @param best_known_dest 
74  * @param intermediate_trail_id 
75  * @param target_peer Peer to which this message will be forwarded.
76  * @param hop_count Number of hops traversed so far.
77  * @param data Content to store
78  * @param data_size Size of content @a data in bytes
79  * @param get_path_length Total number of peers in @a get_path
80  * @param get_path Number of peers traversed so far
81  */
82 void
83 GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
84                          enum GNUNET_BLOCK_Type block_type,
85                          enum GNUNET_DHT_RouteOption options,
86                          uint32_t desired_replication_level,
87                          struct GNUNET_PeerIdentity *best_known_dest,
88                          struct GNUNET_HashCode *intermediate_trail_id,
89                          struct GNUNET_PeerIdentity *target_peer,
90                          uint32_t hop_count,
91                          uint32_t get_path_length,
92                          struct GNUNET_PeerIdentity *get_path);
93
94
95 /**
96  * Send the get result to requesting client.
97  * @param key Key of the requested data.
98  * @param type Block type
99  * @param target_peer Next peer to forward the message to. 
100  * @param source_peer Peer which has the data for the key.
101  * @param put_path_length Number of peers in @a put_path
102  * @param put_path Path taken to put the data at its stored location.
103  * @param get_path_length Number of peers in @a get_path
104  * @param get_path Path taken to reach to the location of the key.
105  * @param expiration When will this result expire?
106  * @param data Payload to store
107  * @param data_size Size of the @a data 
108  */
109 void 
110 GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
111                                 enum GNUNET_BLOCK_Type type, 
112                                 struct GNUNET_PeerIdentity *target_peer,
113                                 struct GNUNET_PeerIdentity *source_peer,
114                                 unsigned int put_path_length,
115                                 const struct GNUNET_PeerIdentity *put_path,
116                                 unsigned int get_path_length,
117                                 struct GNUNET_PeerIdentity *get_path,
118                                 struct GNUNET_TIME_Absolute expiration,
119                                 const void *data, size_t data_size);
120
121 /**
122  * Initialize neighbours subsystem.
123  *
124  * @return #GNUNET_OK on success, 
125  *         #GNUNET_SYSERR on error
126  */
127 int
128 GDS_NEIGHBOURS_init (void);
129
130
131 /**
132  * Shutdown neighbours subsystem.
133  */
134 void
135 GDS_NEIGHBOURS_done (void);
136
137
138 /**
139  * Get my identity
140  *
141  * @return my identity
142  */
143 struct GNUNET_PeerIdentity 
144 GDS_NEIGHBOURS_get_my_id (void);
145
146
147 #endif