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