diff options
Diffstat (limited to 'src/transport/transport_api_monitor_peers.c')
-rw-r--r-- | src/transport/transport_api_monitor_peers.c | 362 |
1 files changed, 183 insertions, 179 deletions
diff --git a/src/transport/transport_api_monitor_peers.c b/src/transport/transport_api_monitor_peers.c index 44127eb7e..956bf9e15 100644 --- a/src/transport/transport_api_monitor_peers.c +++ b/src/transport/transport_api_monitor_peers.c | |||
@@ -39,7 +39,8 @@ | |||
39 | /** | 39 | /** |
40 | * Context for iterating validation entries. | 40 | * Context for iterating validation entries. |
41 | */ | 41 | */ |
42 | struct GNUNET_TRANSPORT_PeerMonitoringContext { | 42 | struct GNUNET_TRANSPORT_PeerMonitoringContext |
43 | { | ||
43 | /** | 44 | /** |
44 | * Function to call with the binary address. | 45 | * Function to call with the binary address. |
45 | */ | 46 | */ |
@@ -89,34 +90,34 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext { | |||
89 | * @return #GNUNET_YES or #GNUNET_NO | 90 | * @return #GNUNET_YES or #GNUNET_NO |
90 | */ | 91 | */ |
91 | int | 92 | int |
92 | GNUNET_TRANSPORT_is_connected(enum GNUNET_TRANSPORT_PeerState state) | 93 | GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state) |
93 | { | 94 | { |
94 | switch (state) | 95 | switch (state) |
95 | { | 96 | { |
96 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: | 97 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: |
97 | case GNUNET_TRANSPORT_PS_INIT_ATS: | 98 | case GNUNET_TRANSPORT_PS_INIT_ATS: |
98 | case GNUNET_TRANSPORT_PS_SYN_SENT: | 99 | case GNUNET_TRANSPORT_PS_SYN_SENT: |
99 | case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: | 100 | case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: |
100 | case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: | 101 | case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: |
101 | return GNUNET_NO; | 102 | return GNUNET_NO; |
102 | 103 | ||
103 | case GNUNET_TRANSPORT_PS_CONNECTED: | 104 | case GNUNET_TRANSPORT_PS_CONNECTED: |
104 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 105 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
105 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: | 106 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
106 | case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: | 107 | case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: |
107 | return GNUNET_YES; | 108 | return GNUNET_YES; |
108 | 109 | ||
109 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 110 | case GNUNET_TRANSPORT_PS_DISCONNECT: |
110 | case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: | 111 | case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: |
111 | return GNUNET_NO; | 112 | return GNUNET_NO; |
112 | 113 | ||
113 | default: | 114 | default: |
114 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
115 | "Unhandled state `%s'\n", | 116 | "Unhandled state `%s'\n", |
116 | GNUNET_TRANSPORT_ps2s(state)); | 117 | GNUNET_TRANSPORT_ps2s (state)); |
117 | GNUNET_break(0); | 118 | GNUNET_break (0); |
118 | break; | 119 | break; |
119 | } | 120 | } |
120 | return GNUNET_SYSERR; | 121 | return GNUNET_SYSERR; |
121 | } | 122 | } |
122 | 123 | ||
@@ -128,47 +129,47 @@ GNUNET_TRANSPORT_is_connected(enum GNUNET_TRANSPORT_PeerState state) | |||
128 | * @return corresponding string | 129 | * @return corresponding string |
129 | */ | 130 | */ |
130 | const char * | 131 | const char * |
131 | GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state) | 132 | GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state) |
132 | { | 133 | { |
133 | switch (state) | 134 | switch (state) |
134 | { | 135 | { |
135 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: | 136 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: |
136 | return "S_NOT_CONNECTED"; | 137 | return "S_NOT_CONNECTED"; |
137 | 138 | ||
138 | case GNUNET_TRANSPORT_PS_INIT_ATS: | 139 | case GNUNET_TRANSPORT_PS_INIT_ATS: |
139 | return "S_INIT_ATS"; | 140 | return "S_INIT_ATS"; |
140 | 141 | ||
141 | case GNUNET_TRANSPORT_PS_SYN_SENT: | 142 | case GNUNET_TRANSPORT_PS_SYN_SENT: |
142 | return "S_SYN_SENT"; | 143 | return "S_SYN_SENT"; |
143 | 144 | ||
144 | case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: | 145 | case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: |
145 | return "S_SYN_RECV_ATS"; | 146 | return "S_SYN_RECV_ATS"; |
146 | 147 | ||
147 | case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: | 148 | case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: |
148 | return "S_SYN_RECV_ACK"; | 149 | return "S_SYN_RECV_ACK"; |
149 | 150 | ||
150 | case GNUNET_TRANSPORT_PS_CONNECTED: | 151 | case GNUNET_TRANSPORT_PS_CONNECTED: |
151 | return "S_CONNECTED"; | 152 | return "S_CONNECTED"; |
152 | 153 | ||
153 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 154 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
154 | return "S_RECONNECT_ATS"; | 155 | return "S_RECONNECT_ATS"; |
155 | 156 | ||
156 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: | 157 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
157 | return "S_RECONNECT_SENT"; | 158 | return "S_RECONNECT_SENT"; |
158 | 159 | ||
159 | case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: | 160 | case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: |
160 | return "S_SWITCH_SYN_SENT"; | 161 | return "S_SWITCH_SYN_SENT"; |
161 | 162 | ||
162 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 163 | case GNUNET_TRANSPORT_PS_DISCONNECT: |
163 | return "S_DISCONNECT"; | 164 | return "S_DISCONNECT"; |
164 | 165 | ||
165 | case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: | 166 | case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: |
166 | return "S_DISCONNECT_FINISHED"; | 167 | return "S_DISCONNECT_FINISHED"; |
167 | 168 | ||
168 | default: | 169 | default: |
169 | GNUNET_break(0); | 170 | GNUNET_break (0); |
170 | return "UNDEFINED"; | 171 | return "UNDEFINED"; |
171 | } | 172 | } |
172 | } | 173 | } |
173 | 174 | ||
174 | 175 | ||
@@ -178,7 +179,7 @@ GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state) | |||
178 | * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *` | 179 | * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *` |
179 | */ | 180 | */ |
180 | static void | 181 | static void |
181 | do_peer_connect(void *cls); | 182 | do_peer_connect (void *cls); |
182 | 183 | ||
183 | 184 | ||
184 | /** | 185 | /** |
@@ -187,20 +188,20 @@ do_peer_connect(void *cls); | |||
187 | * @param pal_ctx our context | 188 | * @param pal_ctx our context |
188 | */ | 189 | */ |
189 | static void | 190 | static void |
190 | reconnect_peer_ctx(struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) | 191 | reconnect_peer_ctx (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) |
191 | { | 192 | { |
192 | GNUNET_assert(GNUNET_NO == pal_ctx->one_shot); | 193 | GNUNET_assert (GNUNET_NO == pal_ctx->one_shot); |
193 | GNUNET_MQ_destroy(pal_ctx->mq); | 194 | GNUNET_MQ_destroy (pal_ctx->mq); |
194 | pal_ctx->mq = NULL; | 195 | pal_ctx->mq = NULL; |
195 | pal_ctx->cb(pal_ctx->cb_cls, | 196 | pal_ctx->cb (pal_ctx->cb_cls, |
196 | NULL, | 197 | NULL, |
197 | NULL, | 198 | NULL, |
198 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, | 199 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, |
199 | GNUNET_TIME_UNIT_ZERO_ABS); | 200 | GNUNET_TIME_UNIT_ZERO_ABS); |
200 | pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF(pal_ctx->backoff); | 201 | pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff); |
201 | pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed(pal_ctx->backoff, | 202 | pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff, |
202 | &do_peer_connect, | 203 | &do_peer_connect, |
203 | pal_ctx); | 204 | pal_ctx); |
204 | } | 205 | } |
205 | 206 | ||
206 | 207 | ||
@@ -211,25 +212,25 @@ reconnect_peer_ctx(struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) | |||
211 | * @param msg message from service | 212 | * @param msg message from service |
212 | */ | 213 | */ |
213 | static void | 214 | static void |
214 | handle_response_end(void *cls, | 215 | handle_response_end (void *cls, |
215 | const struct GNUNET_MessageHeader *msg) | 216 | const struct GNUNET_MessageHeader *msg) |
216 | { | 217 | { |
217 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; | 218 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; |
218 | 219 | ||
219 | if (pal_ctx->one_shot) | 220 | if (pal_ctx->one_shot) |
220 | { | 221 | { |
221 | /* iteration finished */ | 222 | /* iteration finished */ |
222 | pal_ctx->cb(pal_ctx->cb_cls, | 223 | pal_ctx->cb (pal_ctx->cb_cls, |
223 | NULL, | 224 | NULL, |
224 | NULL, | 225 | NULL, |
225 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, | 226 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, |
226 | GNUNET_TIME_UNIT_ZERO_ABS); | 227 | GNUNET_TIME_UNIT_ZERO_ABS); |
227 | GNUNET_TRANSPORT_monitor_peers_cancel(pal_ctx); | 228 | GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx); |
228 | return; | 229 | return; |
229 | } | 230 | } |
230 | /* not quite what we expected, reconnect */ | 231 | /* not quite what we expected, reconnect */ |
231 | GNUNET_break(0); | 232 | GNUNET_break (0); |
232 | reconnect_peer_ctx(pal_ctx); | 233 | reconnect_peer_ctx (pal_ctx); |
233 | } | 234 | } |
234 | 235 | ||
235 | 236 | ||
@@ -241,34 +242,34 @@ handle_response_end(void *cls, | |||
241 | * @return #GNUNET_OK if @a pir_msg is well-formed | 242 | * @return #GNUNET_OK if @a pir_msg is well-formed |
242 | */ | 243 | */ |
243 | static int | 244 | static int |
244 | check_response(void *cls, | 245 | check_response (void *cls, |
245 | const struct PeerIterateResponseMessage *pir_msg) | 246 | const struct PeerIterateResponseMessage *pir_msg) |
246 | { | 247 | { |
247 | uint16_t size = ntohs(pir_msg->header.size) - sizeof(*pir_msg); | 248 | uint16_t size = ntohs (pir_msg->header.size) - sizeof(*pir_msg); |
248 | size_t alen = ntohl(pir_msg->addrlen); | 249 | size_t alen = ntohl (pir_msg->addrlen); |
249 | size_t tlen = ntohl(pir_msg->pluginlen); | 250 | size_t tlen = ntohl (pir_msg->pluginlen); |
250 | const char *addr; | 251 | const char *addr; |
251 | const char *transport_name; | 252 | const char *transport_name; |
252 | 253 | ||
253 | if (size != tlen + alen) | 254 | if (size != tlen + alen) |
254 | { | 255 | { |
255 | GNUNET_break(0); | 256 | GNUNET_break (0); |
256 | return GNUNET_SYSERR; | 257 | return GNUNET_SYSERR; |
257 | } | 258 | } |
258 | if ((0 == tlen) && (0 == alen)) | 259 | if ((0 == tlen) && (0 == alen)) |
259 | return GNUNET_OK; | 260 | return GNUNET_OK; |
260 | if (0 == tlen) | 261 | if (0 == tlen) |
261 | { | 262 | { |
262 | GNUNET_break(0); /* This must not happen: address without plugin */ | 263 | GNUNET_break (0); /* This must not happen: address without plugin */ |
263 | return GNUNET_SYSERR; | 264 | return GNUNET_SYSERR; |
264 | } | 265 | } |
265 | addr = (const char *)&pir_msg[1]; | 266 | addr = (const char *) &pir_msg[1]; |
266 | transport_name = &addr[alen]; | 267 | transport_name = &addr[alen]; |
267 | if (transport_name[tlen - 1] != '\0') | 268 | if (transport_name[tlen - 1] != '\0') |
268 | { | 269 | { |
269 | GNUNET_break(0); | 270 | GNUNET_break (0); |
270 | return GNUNET_SYSERR; | 271 | return GNUNET_SYSERR; |
271 | } | 272 | } |
272 | return GNUNET_OK; | 273 | return GNUNET_OK; |
273 | } | 274 | } |
274 | 275 | ||
@@ -280,42 +281,42 @@ check_response(void *cls, | |||
280 | * @param msg message with the human-readable address | 281 | * @param msg message with the human-readable address |
281 | */ | 282 | */ |
282 | static void | 283 | static void |
283 | handle_response(void *cls, | 284 | handle_response (void *cls, |
284 | const struct PeerIterateResponseMessage *pir_msg) | 285 | const struct PeerIterateResponseMessage *pir_msg) |
285 | { | 286 | { |
286 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; | 287 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; |
287 | struct GNUNET_HELLO_Address *address; | 288 | struct GNUNET_HELLO_Address *address; |
288 | size_t alen = ntohl(pir_msg->addrlen); | 289 | size_t alen = ntohl (pir_msg->addrlen); |
289 | size_t tlen = ntohl(pir_msg->pluginlen); | 290 | size_t tlen = ntohl (pir_msg->pluginlen); |
290 | const char *addr; | 291 | const char *addr; |
291 | const char *transport_name; | 292 | const char *transport_name; |
292 | 293 | ||
293 | if ((0 == tlen) && | 294 | if ((0 == tlen) && |
294 | (0 == alen)) | 295 | (0 == alen)) |
295 | { | 296 | { |
296 | /* No address available */ | 297 | /* No address available */ |
297 | pal_ctx->cb(pal_ctx->cb_cls, | 298 | pal_ctx->cb (pal_ctx->cb_cls, |
298 | &pir_msg->peer, | 299 | &pir_msg->peer, |
299 | NULL, | 300 | NULL, |
300 | ntohl(pir_msg->state), | 301 | ntohl (pir_msg->state), |
301 | GNUNET_TIME_absolute_ntoh(pir_msg->state_timeout)); | 302 | GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout)); |
302 | return; | 303 | return; |
303 | } | 304 | } |
304 | addr = (const char *)&pir_msg[1]; | 305 | addr = (const char *) &pir_msg[1]; |
305 | transport_name = &addr[alen]; | 306 | transport_name = &addr[alen]; |
306 | 307 | ||
307 | /* notify client */ | 308 | /* notify client */ |
308 | address = GNUNET_HELLO_address_allocate(&pir_msg->peer, | 309 | address = GNUNET_HELLO_address_allocate (&pir_msg->peer, |
309 | transport_name, | 310 | transport_name, |
310 | addr, | 311 | addr, |
311 | alen, | 312 | alen, |
312 | ntohl(pir_msg->local_address_info)); | 313 | ntohl (pir_msg->local_address_info)); |
313 | pal_ctx->cb(pal_ctx->cb_cls, | 314 | pal_ctx->cb (pal_ctx->cb_cls, |
314 | &pir_msg->peer, | 315 | &pir_msg->peer, |
315 | address, | 316 | address, |
316 | ntohl(pir_msg->state), | 317 | ntohl (pir_msg->state), |
317 | GNUNET_TIME_absolute_ntoh(pir_msg->state_timeout)); | 318 | GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout)); |
318 | GNUNET_HELLO_address_free(address); | 319 | GNUNET_HELLO_address_free (address); |
319 | } | 320 | } |
320 | 321 | ||
321 | 322 | ||
@@ -329,23 +330,23 @@ handle_response(void *cls, | |||
329 | * @param error error code | 330 | * @param error error code |
330 | */ | 331 | */ |
331 | static void | 332 | static void |
332 | mq_error_handler(void *cls, | 333 | mq_error_handler (void *cls, |
333 | enum GNUNET_MQ_Error error) | 334 | enum GNUNET_MQ_Error error) |
334 | { | 335 | { |
335 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; | 336 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; |
336 | 337 | ||
337 | if (pal_ctx->one_shot) | 338 | if (pal_ctx->one_shot) |
338 | { | 339 | { |
339 | /* Disconnect */ | 340 | /* Disconnect */ |
340 | pal_ctx->cb(pal_ctx->cb_cls, | 341 | pal_ctx->cb (pal_ctx->cb_cls, |
341 | NULL, | 342 | NULL, |
342 | NULL, | 343 | NULL, |
343 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, | 344 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, |
344 | GNUNET_TIME_UNIT_ZERO_ABS); | 345 | GNUNET_TIME_UNIT_ZERO_ABS); |
345 | GNUNET_TRANSPORT_monitor_peers_cancel(pal_ctx); | 346 | GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx); |
346 | return; | 347 | return; |
347 | } | 348 | } |
348 | reconnect_peer_ctx(pal_ctx); | 349 | reconnect_peer_ctx (pal_ctx); |
349 | } | 350 | } |
350 | 351 | ||
351 | 352 | ||
@@ -355,37 +356,37 @@ mq_error_handler(void *cls, | |||
355 | * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *` | 356 | * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *` |
356 | */ | 357 | */ |
357 | static void | 358 | static void |
358 | do_peer_connect(void *cls) | 359 | do_peer_connect (void *cls) |
359 | { | 360 | { |
360 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; | 361 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; |
361 | struct GNUNET_MQ_MessageHandler handlers[] = { | 362 | struct GNUNET_MQ_MessageHandler handlers[] = { |
362 | GNUNET_MQ_hd_var_size(response, | 363 | GNUNET_MQ_hd_var_size (response, |
363 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE, | 364 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE, |
364 | struct PeerIterateResponseMessage, | 365 | struct PeerIterateResponseMessage, |
365 | pal_ctx), | 366 | pal_ctx), |
366 | GNUNET_MQ_hd_fixed_size(response_end, | 367 | GNUNET_MQ_hd_fixed_size (response_end, |
367 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END, | 368 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END, |
368 | struct GNUNET_MessageHeader, | 369 | struct GNUNET_MessageHeader, |
369 | pal_ctx), | 370 | pal_ctx), |
370 | GNUNET_MQ_handler_end() | 371 | GNUNET_MQ_handler_end () |
371 | }; | 372 | }; |
372 | struct PeerMonitorMessage *msg; | 373 | struct PeerMonitorMessage *msg; |
373 | struct GNUNET_MQ_Envelope *env; | 374 | struct GNUNET_MQ_Envelope *env; |
374 | 375 | ||
375 | pal_ctx->reconnect_task = NULL; | 376 | pal_ctx->reconnect_task = NULL; |
376 | pal_ctx->mq = GNUNET_CLIENT_connect(pal_ctx->cfg, | 377 | pal_ctx->mq = GNUNET_CLIENT_connect (pal_ctx->cfg, |
377 | "transport", | 378 | "transport", |
378 | handlers, | 379 | handlers, |
379 | &mq_error_handler, | 380 | &mq_error_handler, |
380 | pal_ctx); | 381 | pal_ctx); |
381 | if (NULL == pal_ctx->mq) | 382 | if (NULL == pal_ctx->mq) |
382 | return; | 383 | return; |
383 | env = GNUNET_MQ_msg(msg, | 384 | env = GNUNET_MQ_msg (msg, |
384 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST); | 385 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST); |
385 | msg->one_shot = htonl(pal_ctx->one_shot); | 386 | msg->one_shot = htonl (pal_ctx->one_shot); |
386 | msg->peer = pal_ctx->peer; | 387 | msg->peer = pal_ctx->peer; |
387 | GNUNET_MQ_send(pal_ctx->mq, | 388 | GNUNET_MQ_send (pal_ctx->mq, |
388 | env); | 389 | env); |
389 | } | 390 | } |
390 | 391 | ||
391 | 392 | ||
@@ -416,14 +417,15 @@ do_peer_connect(void *cls) | |||
416 | * @param peer_callback_cls closure for @a peer_address_callback | 417 | * @param peer_callback_cls closure for @a peer_address_callback |
417 | */ | 418 | */ |
418 | struct GNUNET_TRANSPORT_PeerMonitoringContext * | 419 | struct GNUNET_TRANSPORT_PeerMonitoringContext * |
419 | GNUNET_TRANSPORT_monitor_peers(const struct GNUNET_CONFIGURATION_Handle *cfg, | 420 | GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, |
420 | const struct GNUNET_PeerIdentity *peer, | 421 | const struct GNUNET_PeerIdentity *peer, |
421 | int one_shot, | 422 | int one_shot, |
422 | GNUNET_TRANSPORT_PeerIterateCallback peer_callback, | 423 | GNUNET_TRANSPORT_PeerIterateCallback |
423 | void *peer_callback_cls) | 424 | peer_callback, |
425 | void *peer_callback_cls) | ||
424 | { | 426 | { |
425 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx | 427 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx |
426 | = GNUNET_new(struct GNUNET_TRANSPORT_PeerMonitoringContext); | 428 | = GNUNET_new (struct GNUNET_TRANSPORT_PeerMonitoringContext); |
427 | 429 | ||
428 | pal_ctx->cb = peer_callback; | 430 | pal_ctx->cb = peer_callback; |
429 | pal_ctx->cb_cls = peer_callback_cls; | 431 | pal_ctx->cb_cls = peer_callback_cls; |
@@ -431,12 +433,12 @@ GNUNET_TRANSPORT_monitor_peers(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
431 | if (NULL != peer) | 433 | if (NULL != peer) |
432 | pal_ctx->peer = *peer; | 434 | pal_ctx->peer = *peer; |
433 | pal_ctx->one_shot = one_shot; | 435 | pal_ctx->one_shot = one_shot; |
434 | do_peer_connect(pal_ctx); | 436 | do_peer_connect (pal_ctx); |
435 | if (NULL == pal_ctx->mq) | 437 | if (NULL == pal_ctx->mq) |
436 | { | 438 | { |
437 | GNUNET_free(pal_ctx); | 439 | GNUNET_free (pal_ctx); |
438 | return NULL; | 440 | return NULL; |
439 | } | 441 | } |
440 | return pal_ctx; | 442 | return pal_ctx; |
441 | } | 443 | } |
442 | 444 | ||
@@ -447,19 +449,21 @@ GNUNET_TRANSPORT_monitor_peers(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
447 | * @param pic handle for the request to cancel | 449 | * @param pic handle for the request to cancel |
448 | */ | 450 | */ |
449 | void | 451 | void |
450 | GNUNET_TRANSPORT_monitor_peers_cancel(struct GNUNET_TRANSPORT_PeerMonitoringContext *pic) | 452 | GNUNET_TRANSPORT_monitor_peers_cancel (struct |
453 | GNUNET_TRANSPORT_PeerMonitoringContext * | ||
454 | pic) | ||
451 | { | 455 | { |
452 | if (NULL != pic->mq) | 456 | if (NULL != pic->mq) |
453 | { | 457 | { |
454 | GNUNET_MQ_destroy(pic->mq); | 458 | GNUNET_MQ_destroy (pic->mq); |
455 | pic->mq = NULL; | 459 | pic->mq = NULL; |
456 | } | 460 | } |
457 | if (NULL != pic->reconnect_task) | 461 | if (NULL != pic->reconnect_task) |
458 | { | 462 | { |
459 | GNUNET_SCHEDULER_cancel(pic->reconnect_task); | 463 | GNUNET_SCHEDULER_cancel (pic->reconnect_task); |
460 | pic->reconnect_task = NULL; | 464 | pic->reconnect_task = NULL; |
461 | } | 465 | } |
462 | GNUNET_free(pic); | 466 | GNUNET_free (pic); |
463 | } | 467 | } |
464 | 468 | ||
465 | 469 | ||