2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file dht/gnunet-service-xdht_neighbours.h
23 * @brief GNUnet DHT routing code
24 * @author Supriti Singh
27 #ifndef GNUNET_SERVICE_XDHT_NEIGHBOURS_H
28 #define GNUNET_SERVICE_XDHT_NEIGHBOURS_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_block_lib.h"
32 #include "gnunet_dht_service.h"
37 * Set the ENABLE_MALICIOUS value to malicious.
41 GDS_NEIGHBOURS_act_malicious (unsigned int malicious);
45 * Construct a Put message and send it to target_peer.
46 * @param key Key for the content
47 * @param block_type Type of the block
48 * @param options Routing options
49 * @param desired_replication_level Desired replication count
50 * @param best_known_dest Peer to which this message should reach eventually,
51 * as it is best known destination to me.
52 * @param intermediate_trail_id Trail id in case
53 * @param target_peer Peer to which this message will be forwarded.
54 * @param hop_count Number of hops traversed so far.
55 * @param put_path_length Total number of peers in @a put_path
56 * @param put_path Number of peers traversed so far
57 * @param expiration_time When does the content expire
58 * @param data Content to store
59 * @param data_size Size of content @a data in bytes
62 GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
63 enum GNUNET_BLOCK_Type block_type,
64 enum GNUNET_DHT_RouteOption options,
65 uint32_t desired_replication_level,
66 struct GNUNET_PeerIdentity best_known_dest,
67 struct GNUNET_HashCode intermediate_trail_id,
68 struct GNUNET_PeerIdentity *target_peer,
70 uint32_t put_path_length,
71 struct GNUNET_PeerIdentity *put_path,
72 struct GNUNET_TIME_Absolute expiration_time,
73 const void *data, size_t data_size);
77 * Construct a Get message and send it to target_peer.
78 * @param key Key for the content
79 * @param block_type Type of the block
80 * @param options Routing options
81 * @param desired_replication_level Desired replication count
82 * @param best_known_dest
83 * @param intermediate_trail_id
84 * @param target_peer Peer to which this message will be forwarded.
85 * @param hop_count Number of hops traversed so far.
86 * @param data Content to store
87 * @param data_size Size of content @a data in bytes
88 * @param get_path_length Total number of peers in @a get_path
89 * @param get_path Number of peers traversed so far
92 GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
93 enum GNUNET_BLOCK_Type block_type,
94 enum GNUNET_DHT_RouteOption options,
95 uint32_t desired_replication_level,
96 struct GNUNET_PeerIdentity best_known_dest,
97 struct GNUNET_HashCode intermediate_trail_id,
98 struct GNUNET_PeerIdentity *target_peer,
100 uint32_t get_path_length,
101 struct GNUNET_PeerIdentity *get_path);
105 * Send the get result to requesting client.
106 * @param key Key of the requested data.
107 * @param type Block type
108 * @param target_peer Next peer to forward the message to.
109 * @param source_peer Peer which has the data for the key.
110 * @param put_path_length Number of peers in @a put_path
111 * @param put_path Path taken to put the data at its stored location.
112 * @param get_path_length Number of peers in @a get_path
113 * @param get_path Path taken to reach to the location of the key.
114 * @param expiration When will this result expire?
115 * @param data Payload to store
116 * @param data_size Size of the @a data
119 GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
120 enum GNUNET_BLOCK_Type type,
121 const struct GNUNET_PeerIdentity *target_peer,
122 const struct GNUNET_PeerIdentity *source_peer,
123 unsigned int put_path_length,
124 const struct GNUNET_PeerIdentity *put_path,
125 unsigned int get_path_length,
126 const struct GNUNET_PeerIdentity *get_path,
127 struct GNUNET_TIME_Absolute expiration,
128 const void *data, size_t data_size);
131 * Construct a trail teardown message and forward it to target friend.
132 * @param trail_id Unique identifier of the trail.
133 * @param trail_direction Direction of trail.
134 * @param target_friend Friend to get this message.
137 GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id,
138 unsigned int trail_direction,
139 struct GNUNET_PeerIdentity peer);
142 * Return friend corresponding to peer.
147 GDS_NEIGHBOURS_get_friend (struct GNUNET_PeerIdentity peer);
149 * Initialize neighbours subsystem.
151 * @return #GNUNET_OK on success,
152 * #GNUNET_SYSERR on error
155 GDS_NEIGHBOURS_init (void);
159 * Shutdown neighbours subsystem.
162 GDS_NEIGHBOURS_done (void);
168 * @return my identity
170 struct GNUNET_PeerIdentity
171 GDS_NEIGHBOURS_get_my_id (void);