Framework for put/get/monitor
[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 Christian Grothoff
25  * @author Nathan Evans
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  * FIXME: Change the comment to explain about usage of this in find successor.
36  * Field in trail setup message to understand if the message is sent to an
37  * intermediate finger, friend or me. 
38  */
39 enum current_destination_type
40 {
41   FRIEND ,
42   FINGER ,
43   MY_ID ,
44   VALUE
45 };
46
47 /**
48  * Perform a PUT operation.  Forwards the given request to other
49  * peers.   Does not store the data locally.  Does not give the
50  * data to local clients.  May do nothing if this is the only
51  * peer in the network (or if we are the closest peer in the
52  * network).
53  *
54  * @param type type of the block
55  * @param options routing options
56  * @param desired_replication_level desired replication count
57  * @param expiration_time when does the content expire
58  * @param hop_count how many hops has this message traversed so far
59  * @param key key for the content
60  * @param put_path_length number of entries in @a put_path
61  * @param put_path peers this request has traversed so far (if tracked)
62  * @param data payload to store
63  * @param data_size number of bytes in @a data
64  */
65 void
66 GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
67                            enum GNUNET_DHT_RouteOption options,
68                            uint32_t desired_replication_level,
69                            struct GNUNET_TIME_Absolute expiration_time,
70                            uint32_t hop_count,
71                            struct GNUNET_HashCode * key,
72                            unsigned int put_path_length,
73                            struct GNUNET_PeerIdentity *put_path,
74                            const void *data, size_t data_size,
75                            struct GNUNET_PeerIdentity *current_destination,
76                            enum current_destination_type *dest_type,
77                            struct GNUNET_PeerIdentity *target_peer_id);
78
79
80 /**
81  * 
82  * @param source_peer
83  * @param get_path
84  * @param get_path_length
85  * @param key
86  */
87 void
88 GDS_NEIGHBOURS_handle_get (struct GNUNET_PeerIdentity *source_peer, 
89                            struct GNUNET_PeerIdentity *get_path,
90                            unsigned int get_path_length,
91                            struct GNUNET_HashCode *key,
92                            struct GNUNET_PeerIdentity *target_peer,
93                            struct GNUNET_PeerIdentity *current_destination,
94                            enum current_destination_type *type);
95
96 /**
97  * 
98  * @param source_peer
99  * @param get_path
100  * @param get_path_length
101  * @param destination_peer
102  */
103 void 
104 GDS_NEIGHBOURS_send_get_result (struct GNUNET_PeerIdentity *source_peer,
105                                 struct GNUNET_PeerIdentity *get_path,
106                                 unsigned int get_path_length,
107                                 struct GNUNET_PeerIdentity *destination_peer,
108                                 unsigned int current_path_index);
109
110
111 /**
112  * Initialize neighbours subsystem.
113  *
114  * @return GNUNET_OK on success, GNUNET_SYSERR on error
115  */
116 int
117 GDS_NEIGHBOURS_init (void);
118
119
120 /**
121  * Shutdown neighbours subsystem.
122  */
123 void
124 GDS_NEIGHBOURS_done (void);
125
126
127 /**
128  * Get the ID of the local node.
129  *
130  * @return identity of the local node
131  */
132 struct GNUNET_PeerIdentity *
133 GDS_NEIGHBOURS_get_id ();
134
135
136 #endif