-only trigger check config if we actually need it
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_neighbours.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2010, 2011 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, 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  * Handle the put request from the client.
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 expiration_time When does the content expire
42  * @param data Content to store
43  * @param data_size Size of content @a data in bytes
44  */
45 void
46 GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key,
47                            enum GNUNET_BLOCK_Type block_type,
48                            enum GNUNET_DHT_RouteOption options,
49                            uint32_t desired_replication_level,
50                            struct GNUNET_TIME_Absolute expiration_time,
51                            const void *data, size_t data_size);
52
53 /**
54  * Handle the get request from the client file. If I am destination do
55  * datacache put and return. Else find the target friend and forward message
56  * to it.
57  * @param key Key for the content
58  * @param block_type Type of the block
59  * @param options Routing options
60  * @param desired_replication_level Desired replication count
61  */
62 void
63 GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key,
64                           enum GNUNET_BLOCK_Type block_type,
65                           enum GNUNET_DHT_RouteOption options,
66                           uint32_t desired_replication_level);
67
68 /**
69  * Send the get result to requesting client.
70  * @param key Key of the requested data.
71  * @param type Block type
72  * @param target_peer Next peer to forward the message to.
73  * @param source_peer Peer which has the data for the key.
74  * @param put_path_length Number of peers in @a put_path
75  * @param put_path Path taken to put the data at its stored location.
76  * @param get_path_length Number of peers in @a get_path
77  * @param get_path Path taken to reach to the location of the key.
78  * @param expiration When will this result expire?
79  * @param data Payload to store
80  * @param data_size Size of the @a data
81  */
82 void
83 GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
84                                 enum GNUNET_BLOCK_Type type,
85                                 const struct GNUNET_PeerIdentity *target_peer,
86                                 const struct GNUNET_PeerIdentity *source_peer,
87                                 unsigned int put_path_length,
88                                 const struct GNUNET_PeerIdentity *put_path,
89                                 unsigned int get_path_length,
90                                 const struct GNUNET_PeerIdentity *get_path,
91                                 struct GNUNET_TIME_Absolute expiration,
92                                 const void *data, size_t data_size);
93
94 /**
95  * Construct a trail teardown message and forward it to target friend.
96  * @param trail_id Unique identifier of the trail.
97  * @param trail_direction Direction of trail.
98  * @param target_friend Friend to get this message.
99  */
100 void
101 GDS_NEIGHBOURS_send_trail_teardown (const struct GNUNET_HashCode *trail_id,
102                                     unsigned int trail_direction,
103                                     const struct GNUNET_PeerIdentity *peer);
104
105
106 /**
107  * Initialize neighbours subsystem.
108  *
109  * @return #GNUNET_OK on success,
110  *         #GNUNET_SYSERR on error
111  */
112 int
113 GDS_NEIGHBOURS_init (void);
114
115
116 /**
117  * Shutdown neighbours subsystem.
118  */
119 void
120 GDS_NEIGHBOURS_done (void);
121
122
123 /**
124  * Get my identity
125  *
126  * @return my identity
127  */
128 struct GNUNET_PeerIdentity
129 GDS_NEIGHBOURS_get_my_id (void);
130
131 #endif