aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps_api.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-01-13 10:20:32 +0000
committerJulius Bünger <buenger@mytum.de>2015-01-13 10:20:32 +0000
commitf5b01ce67749faebc26be6c1cb1b064f8c02655e (patch)
tree066e97b6b285679fae45a9c5357fb8f3844109d5 /src/rps/rps_api.c
parent0f649608b4d8c3f82fd1f240bc0d28c2713c7699 (diff)
downloadgnunet-f5b01ce67749faebc26be6c1cb1b064f8c02655e.tar.gz
gnunet-f5b01ce67749faebc26be6c1cb1b064f8c02655e.zip
implemented seeding
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r--src/rps/rps_api.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index ee00db911..9d6183103 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -108,8 +108,6 @@ struct cb_cls_pack
108}; 108};
109 109
110 110
111
112
113/** 111/**
114 * This function is called, when the service replies to our request. 112 * This function is called, when the service replies to our request.
115 * It calls the callback the caller gave us with the provided closure 113 * It calls the callback the caller gave us with the provided closure
@@ -141,9 +139,16 @@ handle_reply (void *cls,
141} 139}
142 140
143/** 141/**
142 * Error handler for mq.
143 *
144 * This function is called whan mq encounters an error.
145 * Until now mq doesn't provide useful error messages.
146 *
147 * @param cls the closure
148 * @param error error code without specyfied meaning
144 */ 149 */
145 static void 150 static void
146mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 151mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
147{ 152{
148 //TODO LOG 153 //TODO LOG
149} 154}
@@ -155,7 +160,7 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
155 * @return a handle to the service 160 * @return a handle to the service
156 */ 161 */
157 struct GNUNET_RPS_Handle * 162 struct GNUNET_RPS_Handle *
158GNUNET_RPS_connect( const struct GNUNET_CONFIGURATION_Handle *cfg ) 163GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
159{ 164{
160 struct GNUNET_RPS_Handle *h; 165 struct GNUNET_RPS_Handle *h;
161 //struct GNUNET_RPS_Request_Handle *rh; 166 //struct GNUNET_RPS_Request_Handle *rh;
@@ -197,19 +202,19 @@ GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint64_t n,
197 struct GNUNET_RPS_CS_RequestMessage *msg; 202 struct GNUNET_RPS_CS_RequestMessage *msg;
198 203
199 // assert func != NULL 204 // assert func != NULL
200 rh = GNUNET_new(struct GNUNET_RPS_Request_Handle); 205 rh = GNUNET_new (struct GNUNET_RPS_Request_Handle);
201 rh->h = h; 206 rh->h = h;
202 rh->n = req_handlers_size; // TODO ntoh 207 rh->n = req_handlers_size; // TODO ntoh
203 rh->ready_cb = ready_cb; 208 rh->ready_cb = ready_cb;
204 rh->ready_cb_cls = cls; 209 rh->ready_cb_cls = cls;
205 210
206 GNUNET_array_append(req_handlers, req_handlers_size, *rh); 211 GNUNET_array_append (req_handlers, req_handlers_size, *rh);
207 //memcpy(&req_handlers[req_handlers_size-1], rh, sizeof(struct GNUNET_RPS_Request_Handle)); 212 //memcpy(&req_handlers[req_handlers_size-1], rh, sizeof(struct GNUNET_RPS_Request_Handle));
208 213
209 ev = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RPS_CS_REQUEST); 214 ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RPS_CS_REQUEST);
210 msg->num_peers = GNUNET_htonll(n); 215 msg->num_peers = GNUNET_htonll (n);
211 msg->n = rh->n; 216 msg->n = rh->n;
212 GNUNET_MQ_send(h->mq, ev); 217 GNUNET_MQ_send (h->mq, ev);
213 return rh; 218 return rh;
214} 219}
215 220
@@ -222,8 +227,16 @@ GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint64_t n,
222 */ 227 */
223 void 228 void
224GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint64_t n, 229GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint64_t n,
225 struct GNUNET_PeerIdentity * ids) 230 const struct GNUNET_PeerIdentity * ids)
226{ 231{
232 struct GNUNET_MQ_Envelope *ev;
233 struct GNUNET_RPS_CS_SeedMessage *msg;
234
235 ev = GNUNET_MQ_msg_extra (msg, n * sizeof (struct GNUNET_PeerIdentity),
236 GNUNET_MESSAGE_TYPE_RPS_CS_SEED);
237 msg->num_peers = GNUNET_htonll (n);
238 memcpy (&msg[1], ids, n * sizeof (struct GNUNET_PeerIdentity));
239 GNUNET_MQ_send (h->mq, ev);
227} 240}
228 241
229/** 242/**
@@ -232,7 +245,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint64_t n,
232 * @param rh request handle of request to cancle 245 * @param rh request handle of request to cancle
233 */ 246 */
234 void 247 void
235GNUNET_RPS_request_cancel ( struct GNUNET_RPS_Request_Handle *rh ) 248GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh)
236{ 249{
237 // TODO 250 // TODO
238} 251}
@@ -243,10 +256,10 @@ GNUNET_RPS_request_cancel ( struct GNUNET_RPS_Request_Handle *rh )
243 * @param h the handle to the rps service 256 * @param h the handle to the rps service
244 */ 257 */
245 void 258 void
246GNUNET_RPS_disconnect ( struct GNUNET_RPS_Handle *h ) 259GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h)
247{ 260{
248 if ( NULL != h->conn ) { 261 if ( NULL != h->conn ) {
249 GNUNET_CLIENT_disconnect(h->conn); 262 GNUNET_CLIENT_disconnect (h->conn);
250 } 263 }
251} 264}
252 265