diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-03-18 16:33:14 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-03-18 16:33:14 +0000 |
commit | 558fa8b012469c0ada0c4fac6d05c01a727ef764 (patch) | |
tree | 3ee6faa97ff54cdc8565915dde3876d6a1c0c919 /src/include/gnunet_dht_service.h | |
parent | e86fd05ff7bbef8aa1741671163564fb35beafb5 (diff) | |
download | gnunet-558fa8b012469c0ada0c4fac6d05c01a727ef764.tar.gz gnunet-558fa8b012469c0ada0c4fac6d05c01a727ef764.zip |
dht related changes to message types and whatnot
Diffstat (limited to 'src/include/gnunet_dht_service.h')
-rw-r--r-- | src/include/gnunet_dht_service.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index be7594e32..9e2e5d163 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -43,6 +43,12 @@ extern "C" | |||
43 | */ | 43 | */ |
44 | struct GNUNET_DHT_Handle; | 44 | struct GNUNET_DHT_Handle; |
45 | 45 | ||
46 | /** | ||
47 | * Iterator called on each result obtained from a generic route | ||
48 | * operation | ||
49 | */ | ||
50 | typedef void (*GNUNET_DHT_MessageCallback)(void *cls, | ||
51 | int code); | ||
46 | 52 | ||
47 | /** | 53 | /** |
48 | * Initialize the connection with the DHT service. | 54 | * Initialize the connection with the DHT service. |
@@ -87,14 +93,14 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *h); | |||
87 | * @param cont_cls closure for cont | 93 | * @param cont_cls closure for cont |
88 | */ | 94 | */ |
89 | void | 95 | void |
90 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, | 96 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, |
91 | const GNUNET_HashCode * key, | 97 | const GNUNET_HashCode * key, |
92 | uint32_t type, | 98 | uint32_t type, |
93 | uint32_t size, | 99 | uint32_t size, |
94 | const char *data, | 100 | const char *data, |
95 | struct GNUNET_TIME_Absolute exp, | 101 | struct GNUNET_TIME_Absolute exp, |
96 | struct GNUNET_TIME_Relative timeout, | 102 | struct GNUNET_TIME_Relative timeout, |
97 | GNUNET_SCHEDULER_Task cont, | 103 | GNUNET_DHT_MessageCallback cont, |
98 | void *cont_cls); | 104 | void *cont_cls); |
99 | 105 | ||
100 | 106 | ||
@@ -105,8 +111,8 @@ struct GNUNET_DHT_GetHandle; | |||
105 | 111 | ||
106 | 112 | ||
107 | /** | 113 | /** |
108 | * Iterator called on each result obtained for a GET | 114 | * Iterator called on each result obtained for a DHT |
109 | * operation. | 115 | * operation that expects a reply |
110 | * | 116 | * |
111 | * @param cls closure | 117 | * @param cls closure |
112 | * @param exp when will this value expire | 118 | * @param exp when will this value expire |
@@ -115,7 +121,7 @@ struct GNUNET_DHT_GetHandle; | |||
115 | * @param size number of bytes in data | 121 | * @param size number of bytes in data |
116 | * @param data pointer to the result data | 122 | * @param data pointer to the result data |
117 | */ | 123 | */ |
118 | typedef void (*GNUNET_DHT_Iterator)(void *cls, | 124 | typedef void (*GNUNET_DHT_GetIterator)(void *cls, |
119 | struct GNUNET_TIME_Absolute exp, | 125 | struct GNUNET_TIME_Absolute exp, |
120 | const GNUNET_HashCode * key, | 126 | const GNUNET_HashCode * key, |
121 | uint32_t type, | 127 | uint32_t type, |
@@ -128,17 +134,20 @@ typedef void (*GNUNET_DHT_Iterator)(void *cls, | |||
128 | * Perform an asynchronous GET operation on the DHT identified. | 134 | * Perform an asynchronous GET operation on the DHT identified. |
129 | * | 135 | * |
130 | * @param h handle to the DHT service | 136 | * @param h handle to the DHT service |
137 | * @param timeout timeout for this request to be sent to the | ||
138 | * service | ||
131 | * @param type expected type of the response object | 139 | * @param type expected type of the response object |
132 | * @param key the key to look up | 140 | * @param key the key to look up |
133 | * @param iter function to call on each result | 141 | * @param iter function to call on each result |
134 | * @param iter_cls closure for iter | 142 | * @param iter_cls closure for iter |
135 | * @return handle to stop the async get, NULL on error | 143 | * @return handle to stop the async get, NULL on error |
136 | */ | 144 | */ |
137 | struct GNUNET_DHT_GetHandle * | 145 | struct GNUNET_DHT_RouteHandle * |
138 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, | 146 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, |
147 | struct GNUNET_TIME_Relative timeout, | ||
139 | uint32_t type, | 148 | uint32_t type, |
140 | const GNUNET_HashCode * key, | 149 | const GNUNET_HashCode * key, |
141 | GNUNET_DHT_Iterator iter, | 150 | GNUNET_DHT_GetIterator iter, |
142 | void *iter_cls); | 151 | void *iter_cls); |
143 | 152 | ||
144 | /** | 153 | /** |
@@ -147,23 +156,30 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, | |||
147 | * @param get_handle GET operation to stop. | 156 | * @param get_handle GET operation to stop. |
148 | */ | 157 | */ |
149 | void | 158 | void |
150 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | 159 | GNUNET_DHT_get_stop (struct GNUNET_DHT_RouteHandle *get_handle); |
151 | 160 | ||
152 | 161 | ||
153 | /** | 162 | /** |
154 | * Iterator called on each result obtained from a FIND_PEER | 163 | * Iterator called on each result obtained from a find peer |
155 | * operation | 164 | * operation |
156 | * | 165 | * |
157 | * @param cls closure | 166 | * @param cls closure |
158 | * @param peer a peer that was located | 167 | * @param reply response |
159 | * @param reply response generated by the peer (for example, a HELLO); or NULL | ||
160 | */ | 168 | */ |
161 | typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, | 169 | typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls, |
162 | const struct GNUNET_PeerIdentity *peer, | 170 | const struct GNUNET_PeerIdentity *peer, |
163 | const struct GNUNET_MessageHeader *reply); | 171 | const struct GNUNET_MessageHeader *reply); |
164 | 172 | ||
165 | 173 | ||
166 | /** | 174 | /** |
175 | * Iterator called on each result obtained from a generic route | ||
176 | * operation | ||
177 | */ | ||
178 | typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, | ||
179 | const struct GNUNET_MessageHeader *reply); | ||
180 | |||
181 | |||
182 | /** | ||
167 | * Options for routing. | 183 | * Options for routing. |
168 | */ | 184 | */ |
169 | enum GNUNET_DHT_RouteOption | 185 | enum GNUNET_DHT_RouteOption |
@@ -180,6 +196,10 @@ enum GNUNET_DHT_RouteOption | |||
180 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 | 196 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 |
181 | }; | 197 | }; |
182 | 198 | ||
199 | /** | ||
200 | * Handle to control a route operation. | ||
201 | */ | ||
202 | struct GNUNET_DHT_RouteHandle; | ||
183 | 203 | ||
184 | /** | 204 | /** |
185 | * Perform an asynchronous FIND_PEER operation on the DHT. | 205 | * Perform an asynchronous FIND_PEER operation on the DHT. |
@@ -195,13 +215,12 @@ enum GNUNET_DHT_RouteOption | |||
195 | * @param iter_cls closure for iter | 215 | * @param iter_cls closure for iter |
196 | * @param timeout when to abort with an error if we fail to get | 216 | * @param timeout when to abort with an error if we fail to get |
197 | * a confirmation for the PUT from the local DHT service | 217 | * a confirmation for the PUT from the local DHT service |
198 | * @param cont continuation to call when done; | 218 | * @param cont continuation to call when done, GNUNET_SYSERR if failed |
199 | * reason will be TIMEOUT on error, | 219 | * GNUNET_OK otherwise |
200 | * reason will be PREREQ_DONE on success | ||
201 | * @param cont_cls closure for cont | 220 | * @param cont_cls closure for cont |
202 | * @return handle to stop the request | 221 | * @return handle to stop the request |
203 | */ | 222 | */ |
204 | struct GNUNET_DHT_FindPeerHandle * | 223 | struct GNUNET_DHT_RouteHandle * |
205 | GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | 224 | GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, |
206 | const GNUNET_HashCode *key, | 225 | const GNUNET_HashCode *key, |
207 | unsigned int desired_replication_level, | 226 | unsigned int desired_replication_level, |
@@ -210,11 +229,11 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
210 | struct GNUNET_TIME_Relative timeout, | 229 | struct GNUNET_TIME_Relative timeout, |
211 | GNUNET_DHT_ReplyProcessor iter, | 230 | GNUNET_DHT_ReplyProcessor iter, |
212 | void *iter_cls, | 231 | void *iter_cls, |
213 | GNUNET_SCHEDULER_Task cont, | 232 | GNUNET_DHT_MessageCallback cont, |
214 | void *cont_cls); | 233 | void *cont_cls); |
215 | 234 | ||
216 | void | 235 | void |
217 | GNUNET_DHT_route_stop (struct GNUNET_DHT_FindPeerHandle *fph); | 236 | GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *fph); |
218 | 237 | ||
219 | 238 | ||
220 | #if 0 /* keep Emacsens' auto-indent happy */ | 239 | #if 0 /* keep Emacsens' auto-indent happy */ |