diff options
Diffstat (limited to 'src/dht/gnunet-service-wdht_neighbours.h')
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.h | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/src/dht/gnunet-service-wdht_neighbours.h b/src/dht/gnunet-service-wdht_neighbours.h new file mode 100644 index 000000000..edb241a6c --- /dev/null +++ b/src/dht/gnunet-service-wdht_neighbours.h | |||
@@ -0,0 +1,146 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (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 | #if ENABLE_MALICIOUS | ||
36 | /** | ||
37 | * Set the ENABLE_MALICIOUS value to malicious. | ||
38 | * @param malicious | ||
39 | */ | ||
40 | int | ||
41 | GDS_NEIGHBOURS_act_malicious (unsigned int malicious); | ||
42 | #endif | ||
43 | |||
44 | /** | ||
45 | * Handle the put request from the client. | ||
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 expiration_time When does the content expire | ||
51 | * @param data Content to store | ||
52 | * @param data_size Size of content @a data in bytes | ||
53 | */ | ||
54 | void | ||
55 | GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key, | ||
56 | enum GNUNET_BLOCK_Type block_type, | ||
57 | enum GNUNET_DHT_RouteOption options, | ||
58 | uint32_t desired_replication_level, | ||
59 | struct GNUNET_TIME_Absolute expiration_time, | ||
60 | const void *data, size_t data_size); | ||
61 | |||
62 | /** | ||
63 | * Handle the get request from the client file. If I am destination do | ||
64 | * datacache put and return. Else find the target friend and forward message | ||
65 | * to it. | ||
66 | * @param key Key for the content | ||
67 | * @param block_type Type of the block | ||
68 | * @param options Routing options | ||
69 | * @param desired_replication_level Desired replication count | ||
70 | */ | ||
71 | void | ||
72 | GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key, | ||
73 | enum GNUNET_BLOCK_Type block_type, | ||
74 | enum GNUNET_DHT_RouteOption options, | ||
75 | uint32_t desired_replication_level); | ||
76 | |||
77 | /** | ||
78 | * Send the get result to requesting client. | ||
79 | * @param key Key of the requested data. | ||
80 | * @param type Block type | ||
81 | * @param target_peer Next peer to forward the message to. | ||
82 | * @param source_peer Peer which has the data for the key. | ||
83 | * @param put_path_length Number of peers in @a put_path | ||
84 | * @param put_path Path taken to put the data at its stored location. | ||
85 | * @param get_path_length Number of peers in @a get_path | ||
86 | * @param get_path Path taken to reach to the location of the key. | ||
87 | * @param expiration When will this result expire? | ||
88 | * @param data Payload to store | ||
89 | * @param data_size Size of the @a data | ||
90 | */ | ||
91 | void | ||
92 | GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, | ||
93 | enum GNUNET_BLOCK_Type type, | ||
94 | const struct GNUNET_PeerIdentity *target_peer, | ||
95 | const struct GNUNET_PeerIdentity *source_peer, | ||
96 | unsigned int put_path_length, | ||
97 | const struct GNUNET_PeerIdentity *put_path, | ||
98 | unsigned int get_path_length, | ||
99 | const struct GNUNET_PeerIdentity *get_path, | ||
100 | struct GNUNET_TIME_Absolute expiration, | ||
101 | const void *data, size_t data_size); | ||
102 | |||
103 | /** | ||
104 | * Construct a trail teardown message and forward it to target friend. | ||
105 | * @param trail_id Unique identifier of the trail. | ||
106 | * @param trail_direction Direction of trail. | ||
107 | * @param target_friend Friend to get this message. | ||
108 | */ | ||
109 | void | ||
110 | GDS_NEIGHBOURS_send_trail_teardown (const struct GNUNET_HashCode *trail_id, | ||
111 | unsigned int trail_direction, | ||
112 | const struct GNUNET_PeerIdentity *peer); | ||
113 | |||
114 | /** | ||
115 | * Return friend corresponding to peer. | ||
116 | * @param peer | ||
117 | * @return Friend | ||
118 | */ | ||
119 | struct FriendInfo * | ||
120 | GDS_NEIGHBOURS_get_friend (struct GNUNET_PeerIdentity peer); | ||
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 | #endif | ||