diff options
Diffstat (limited to 'src/vpn/vpn_api.c')
-rw-r--r-- | src/vpn/vpn_api.c | 339 |
1 files changed, 171 insertions, 168 deletions
diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c index b53c32e64..dcb1d99c9 100644 --- a/src/vpn/vpn_api.c +++ b/src/vpn/vpn_api.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 vpn/vpn_api.c | 22 | * @file vpn/vpn_api.c |
@@ -31,8 +31,7 @@ | |||
31 | /** | 31 | /** |
32 | * Opaque VPN handle | 32 | * Opaque VPN handle |
33 | */ | 33 | */ |
34 | struct GNUNET_VPN_Handle | 34 | struct GNUNET_VPN_Handle { |
35 | { | ||
36 | /** | 35 | /** |
37 | * Configuration we use. | 36 | * Configuration we use. |
38 | */ | 37 | */ |
@@ -67,15 +66,13 @@ struct GNUNET_VPN_Handle | |||
67 | * ID of the last request that was submitted to the service. | 66 | * ID of the last request that was submitted to the service. |
68 | */ | 67 | */ |
69 | uint64_t request_id_gen; | 68 | uint64_t request_id_gen; |
70 | |||
71 | }; | 69 | }; |
72 | 70 | ||
73 | 71 | ||
74 | /** | 72 | /** |
75 | * Opaque redirection request handle. | 73 | * Opaque redirection request handle. |
76 | */ | 74 | */ |
77 | struct GNUNET_VPN_RedirectionRequest | 75 | struct GNUNET_VPN_RedirectionRequest { |
78 | { | ||
79 | /** | 76 | /** |
80 | * Element in DLL. | 77 | * Element in DLL. |
81 | */ | 78 | */ |
@@ -141,7 +138,6 @@ struct GNUNET_VPN_RedirectionRequest | |||
141 | * For service redirection, IPPROT_UDP or IPPROTO_TCP. | 138 | * For service redirection, IPPROT_UDP or IPPROTO_TCP. |
142 | */ | 139 | */ |
143 | uint8_t protocol; | 140 | uint8_t protocol; |
144 | |||
145 | }; | 141 | }; |
146 | 142 | ||
147 | 143 | ||
@@ -151,7 +147,7 @@ struct GNUNET_VPN_RedirectionRequest | |||
151 | * @param vh handle to reconnect. | 147 | * @param vh handle to reconnect. |
152 | */ | 148 | */ |
153 | static void | 149 | static void |
154 | reconnect (struct GNUNET_VPN_Handle *vh); | 150 | reconnect(struct GNUNET_VPN_Handle *vh); |
155 | 151 | ||
156 | 152 | ||
157 | /** | 153 | /** |
@@ -163,34 +159,37 @@ reconnect (struct GNUNET_VPN_Handle *vh); | |||
163 | * @return #GNUNET_OK if @a rm is well-formed | 159 | * @return #GNUNET_OK if @a rm is well-formed |
164 | */ | 160 | */ |
165 | static int | 161 | static int |
166 | check_use_ip (void *cls, | 162 | check_use_ip(void *cls, |
167 | const struct RedirectToIpResponseMessage *rm) | 163 | const struct RedirectToIpResponseMessage *rm) |
168 | { | 164 | { |
169 | size_t alen; | 165 | size_t alen; |
170 | int af; | 166 | int af; |
171 | 167 | ||
172 | af = (int) ntohl (rm->result_af); | 168 | af = (int)ntohl(rm->result_af); |
173 | switch (af) | 169 | switch (af) |
174 | { | 170 | { |
175 | case AF_UNSPEC: | 171 | case AF_UNSPEC: |
176 | alen = 0; | 172 | alen = 0; |
177 | break; | 173 | break; |
178 | case AF_INET: | 174 | |
179 | alen = sizeof (struct in_addr); | 175 | case AF_INET: |
180 | break; | 176 | alen = sizeof(struct in_addr); |
181 | case AF_INET6: | 177 | break; |
182 | alen = sizeof (struct in6_addr); | 178 | |
183 | break; | 179 | case AF_INET6: |
184 | default: | 180 | alen = sizeof(struct in6_addr); |
185 | GNUNET_break (0); | 181 | break; |
186 | return GNUNET_SYSERR; | 182 | |
187 | } | 183 | default: |
188 | if ( (ntohs (rm->header.size) != alen + sizeof (*rm)) || | 184 | GNUNET_break(0); |
189 | (0 == rm->request_id) ) | 185 | return GNUNET_SYSERR; |
190 | { | 186 | } |
191 | GNUNET_break (0); | 187 | if ((ntohs(rm->header.size) != alen + sizeof(*rm)) || |
192 | return GNUNET_SYSERR; | 188 | (0 == rm->request_id)) |
193 | } | 189 | { |
190 | GNUNET_break(0); | ||
191 | return GNUNET_SYSERR; | ||
192 | } | ||
194 | return GNUNET_OK; | 193 | return GNUNET_OK; |
195 | } | 194 | } |
196 | 195 | ||
@@ -203,28 +202,28 @@ check_use_ip (void *cls, | |||
203 | * @param rm message received | 202 | * @param rm message received |
204 | */ | 203 | */ |
205 | static void | 204 | static void |
206 | handle_use_ip (void *cls, | 205 | handle_use_ip(void *cls, |
207 | const struct RedirectToIpResponseMessage *rm) | 206 | const struct RedirectToIpResponseMessage *rm) |
208 | { | 207 | { |
209 | struct GNUNET_VPN_Handle *vh = cls; | 208 | struct GNUNET_VPN_Handle *vh = cls; |
210 | struct GNUNET_VPN_RedirectionRequest *rr; | 209 | struct GNUNET_VPN_RedirectionRequest *rr; |
211 | int af; | 210 | int af; |
212 | 211 | ||
213 | af = (int) ntohl (rm->result_af); | 212 | af = (int)ntohl(rm->result_af); |
214 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) | 213 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) |
215 | { | ||
216 | if (rr->request_id == rm->request_id) | ||
217 | { | 214 | { |
218 | GNUNET_CONTAINER_DLL_remove (vh->rr_head, | 215 | if (rr->request_id == rm->request_id) |
219 | vh->rr_tail, | 216 | { |
220 | rr); | 217 | GNUNET_CONTAINER_DLL_remove(vh->rr_head, |
221 | rr->cb (rr->cb_cls, | 218 | vh->rr_tail, |
222 | af, | 219 | rr); |
223 | (af == AF_UNSPEC) ? NULL : &rm[1]); | 220 | rr->cb(rr->cb_cls, |
224 | GNUNET_free (rr); | 221 | af, |
225 | break; | 222 | (af == AF_UNSPEC) ? NULL : &rm[1]); |
223 | GNUNET_free(rr); | ||
224 | break; | ||
225 | } | ||
226 | } | 226 | } |
227 | } | ||
228 | } | 227 | } |
229 | 228 | ||
230 | 229 | ||
@@ -234,7 +233,7 @@ handle_use_ip (void *cls, | |||
234 | * @param rr request to queue and transmit. | 233 | * @param rr request to queue and transmit. |
235 | */ | 234 | */ |
236 | static void | 235 | static void |
237 | send_request (struct GNUNET_VPN_RedirectionRequest *rr) | 236 | send_request(struct GNUNET_VPN_RedirectionRequest *rr) |
238 | { | 237 | { |
239 | struct GNUNET_VPN_Handle *vh = rr->vh; | 238 | struct GNUNET_VPN_Handle *vh = rr->vh; |
240 | struct RedirectToIpRequestMessage *rip; | 239 | struct RedirectToIpRequestMessage *rip; |
@@ -245,45 +244,47 @@ send_request (struct GNUNET_VPN_RedirectionRequest *rr) | |||
245 | if (NULL == vh->mq) | 244 | if (NULL == vh->mq) |
246 | return; | 245 | return; |
247 | if (NULL == rr->addr) | 246 | if (NULL == rr->addr) |
248 | { | 247 | { |
249 | env = GNUNET_MQ_msg (rs, | 248 | env = GNUNET_MQ_msg(rs, |
250 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE); | 249 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE); |
251 | rs->reserved = htonl (0); | 250 | rs->reserved = htonl(0); |
252 | rs->expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time); | 251 | rs->expiration_time = GNUNET_TIME_absolute_hton(rr->expiration_time); |
253 | rs->protocol = htonl (rr->protocol); | 252 | rs->protocol = htonl(rr->protocol); |
254 | rs->result_af = htonl (rr->result_af); | 253 | rs->result_af = htonl(rr->result_af); |
255 | rs->target = rr->peer; | 254 | rs->target = rr->peer; |
256 | rs->service_descriptor = rr->serv; | 255 | rs->service_descriptor = rr->serv; |
257 | rs->request_id = rr->request_id = ++vh->request_id_gen; | 256 | rs->request_id = rr->request_id = ++vh->request_id_gen; |
258 | } | 257 | } |
259 | else | 258 | else |
260 | { | ||
261 | switch (rr->addr_af) | ||
262 | { | 259 | { |
263 | case AF_INET: | 260 | switch (rr->addr_af) |
264 | alen = sizeof (struct in_addr); | 261 | { |
265 | break; | 262 | case AF_INET: |
266 | case AF_INET6: | 263 | alen = sizeof(struct in_addr); |
267 | alen = sizeof (struct in6_addr); | 264 | break; |
268 | break; | 265 | |
269 | default: | 266 | case AF_INET6: |
270 | GNUNET_assert (0); | 267 | alen = sizeof(struct in6_addr); |
271 | return; | 268 | break; |
269 | |||
270 | default: | ||
271 | GNUNET_assert(0); | ||
272 | return; | ||
273 | } | ||
274 | env = GNUNET_MQ_msg_extra(rip, | ||
275 | alen, | ||
276 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP); | ||
277 | rip->reserved = htonl(0); | ||
278 | rip->expiration_time = GNUNET_TIME_absolute_hton(rr->expiration_time); | ||
279 | rip->result_af = htonl(rr->result_af); | ||
280 | rip->addr_af = htonl(rr->addr_af); | ||
281 | rip->request_id = rr->request_id = ++vh->request_id_gen; | ||
282 | GNUNET_memcpy(&rip[1], | ||
283 | rr->addr, | ||
284 | alen); | ||
272 | } | 285 | } |
273 | env = GNUNET_MQ_msg_extra (rip, | 286 | GNUNET_MQ_send(vh->mq, |
274 | alen, | 287 | env); |
275 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP); | ||
276 | rip->reserved = htonl (0); | ||
277 | rip->expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time); | ||
278 | rip->result_af = htonl (rr->result_af); | ||
279 | rip->addr_af = htonl (rr->addr_af); | ||
280 | rip->request_id = rr->request_id = ++vh->request_id_gen; | ||
281 | GNUNET_memcpy (&rip[1], | ||
282 | rr->addr, | ||
283 | alen); | ||
284 | } | ||
285 | GNUNET_MQ_send (vh->mq, | ||
286 | env); | ||
287 | } | 288 | } |
288 | 289 | ||
289 | 290 | ||
@@ -296,12 +297,12 @@ send_request (struct GNUNET_VPN_RedirectionRequest *rr) | |||
296 | * @param error error code | 297 | * @param error error code |
297 | */ | 298 | */ |
298 | static void | 299 | static void |
299 | mq_error_handler (void *cls, | 300 | mq_error_handler(void *cls, |
300 | enum GNUNET_MQ_Error error) | 301 | enum GNUNET_MQ_Error error) |
301 | { | 302 | { |
302 | struct GNUNET_VPN_Handle *vh = cls; | 303 | struct GNUNET_VPN_Handle *vh = cls; |
303 | 304 | ||
304 | reconnect (vh); | 305 | reconnect(vh); |
305 | } | 306 | } |
306 | 307 | ||
307 | 308 | ||
@@ -311,28 +312,28 @@ mq_error_handler (void *cls, | |||
311 | * @param cls the `struct GNUNET_VPN_Handle *` | 312 | * @param cls the `struct GNUNET_VPN_Handle *` |
312 | */ | 313 | */ |
313 | static void | 314 | static void |
314 | connect_task (void *cls) | 315 | connect_task(void *cls) |
315 | { | 316 | { |
316 | struct GNUNET_VPN_Handle *vh = cls; | 317 | struct GNUNET_VPN_Handle *vh = cls; |
317 | struct GNUNET_MQ_MessageHandler handlers[] = { | 318 | struct GNUNET_MQ_MessageHandler handlers[] = { |
318 | GNUNET_MQ_hd_var_size (use_ip, | 319 | GNUNET_MQ_hd_var_size(use_ip, |
319 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP, | 320 | GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP, |
320 | struct RedirectToIpResponseMessage, | 321 | struct RedirectToIpResponseMessage, |
321 | cls), | 322 | cls), |
322 | GNUNET_MQ_handler_end () | 323 | GNUNET_MQ_handler_end() |
323 | }; | 324 | }; |
324 | struct GNUNET_VPN_RedirectionRequest *rr; | 325 | struct GNUNET_VPN_RedirectionRequest *rr; |
325 | 326 | ||
326 | vh->rt = NULL; | 327 | vh->rt = NULL; |
327 | vh->mq = GNUNET_CLIENT_connect (vh->cfg, | 328 | vh->mq = GNUNET_CLIENT_connect(vh->cfg, |
328 | "vpn", | 329 | "vpn", |
329 | handlers, | 330 | handlers, |
330 | &mq_error_handler, | 331 | &mq_error_handler, |
331 | vh); | 332 | vh); |
332 | if (NULL == vh->mq) | 333 | if (NULL == vh->mq) |
333 | return; | 334 | return; |
334 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) | 335 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) |
335 | send_request (rr); | 336 | send_request(rr); |
336 | } | 337 | } |
337 | 338 | ||
338 | 339 | ||
@@ -342,21 +343,21 @@ connect_task (void *cls) | |||
342 | * @param vh handle to reconnect. | 343 | * @param vh handle to reconnect. |
343 | */ | 344 | */ |
344 | static void | 345 | static void |
345 | reconnect (struct GNUNET_VPN_Handle *vh) | 346 | reconnect(struct GNUNET_VPN_Handle *vh) |
346 | { | 347 | { |
347 | struct GNUNET_VPN_RedirectionRequest *rr; | 348 | struct GNUNET_VPN_RedirectionRequest *rr; |
348 | 349 | ||
349 | GNUNET_MQ_destroy (vh->mq); | 350 | GNUNET_MQ_destroy(vh->mq); |
350 | vh->mq = NULL; | 351 | vh->mq = NULL; |
351 | vh->request_id_gen = 0; | 352 | vh->request_id_gen = 0; |
352 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) | 353 | for (rr = vh->rr_head; NULL != rr; rr = rr->next) |
353 | rr->request_id = 0; | 354 | rr->request_id = 0; |
354 | vh->backoff = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, | 355 | vh->backoff = GNUNET_TIME_relative_max(GNUNET_TIME_UNIT_MILLISECONDS, |
355 | GNUNET_TIME_relative_min (GNUNET_TIME_relative_saturating_multiply (vh->backoff, 2), | 356 | GNUNET_TIME_relative_min(GNUNET_TIME_relative_saturating_multiply(vh->backoff, 2), |
356 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30))); | 357 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30))); |
357 | vh->rt = GNUNET_SCHEDULER_add_delayed (vh->backoff, | 358 | vh->rt = GNUNET_SCHEDULER_add_delayed(vh->backoff, |
358 | &connect_task, | 359 | &connect_task, |
359 | vh); | 360 | vh); |
360 | } | 361 | } |
361 | 362 | ||
362 | 363 | ||
@@ -366,15 +367,15 @@ reconnect (struct GNUNET_VPN_Handle *vh) | |||
366 | * @param rr request to cancel | 367 | * @param rr request to cancel |
367 | */ | 368 | */ |
368 | void | 369 | void |
369 | GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr) | 370 | GNUNET_VPN_cancel_request(struct GNUNET_VPN_RedirectionRequest *rr) |
370 | { | 371 | { |
371 | struct GNUNET_VPN_Handle *vh; | 372 | struct GNUNET_VPN_Handle *vh; |
372 | 373 | ||
373 | vh = rr->vh; | 374 | vh = rr->vh; |
374 | GNUNET_CONTAINER_DLL_remove (vh->rr_head, | 375 | GNUNET_CONTAINER_DLL_remove(vh->rr_head, |
375 | vh->rr_tail, | 376 | vh->rr_tail, |
376 | rr); | 377 | rr); |
377 | GNUNET_free (rr); | 378 | GNUNET_free(rr); |
378 | } | 379 | } |
379 | 380 | ||
380 | 381 | ||
@@ -401,18 +402,18 @@ GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr) | |||
401 | * anyway) | 402 | * anyway) |
402 | */ | 403 | */ |
403 | struct GNUNET_VPN_RedirectionRequest * | 404 | struct GNUNET_VPN_RedirectionRequest * |
404 | GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh, | 405 | GNUNET_VPN_redirect_to_peer(struct GNUNET_VPN_Handle *vh, |
405 | int result_af, | 406 | int result_af, |
406 | uint8_t protocol, | 407 | uint8_t protocol, |
407 | const struct GNUNET_PeerIdentity *peer, | 408 | const struct GNUNET_PeerIdentity *peer, |
408 | const struct GNUNET_HashCode *serv, | 409 | const struct GNUNET_HashCode *serv, |
409 | struct GNUNET_TIME_Absolute expiration_time, | 410 | struct GNUNET_TIME_Absolute expiration_time, |
410 | GNUNET_VPN_AllocationCallback cb, | 411 | GNUNET_VPN_AllocationCallback cb, |
411 | void *cb_cls) | 412 | void *cb_cls) |
412 | { | 413 | { |
413 | struct GNUNET_VPN_RedirectionRequest *rr; | 414 | struct GNUNET_VPN_RedirectionRequest *rr; |
414 | 415 | ||
415 | rr = GNUNET_new (struct GNUNET_VPN_RedirectionRequest); | 416 | rr = GNUNET_new(struct GNUNET_VPN_RedirectionRequest); |
416 | rr->vh = vh; | 417 | rr->vh = vh; |
417 | rr->cb = cb; | 418 | rr->cb = cb; |
418 | rr->cb_cls = cb_cls; | 419 | rr->cb_cls = cb_cls; |
@@ -421,10 +422,10 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh, | |||
421 | rr->expiration_time = expiration_time; | 422 | rr->expiration_time = expiration_time; |
422 | rr->result_af = result_af; | 423 | rr->result_af = result_af; |
423 | rr->protocol = protocol; | 424 | rr->protocol = protocol; |
424 | GNUNET_CONTAINER_DLL_insert_tail (vh->rr_head, | 425 | GNUNET_CONTAINER_DLL_insert_tail(vh->rr_head, |
425 | vh->rr_tail, | 426 | vh->rr_tail, |
426 | rr); | 427 | rr); |
427 | send_request (rr); | 428 | send_request(rr); |
428 | return rr; | 429 | return rr; |
429 | } | 430 | } |
430 | 431 | ||
@@ -452,30 +453,32 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh, | |||
452 | * anyway) | 453 | * anyway) |
453 | */ | 454 | */ |
454 | struct GNUNET_VPN_RedirectionRequest * | 455 | struct GNUNET_VPN_RedirectionRequest * |
455 | GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh, | 456 | GNUNET_VPN_redirect_to_ip(struct GNUNET_VPN_Handle *vh, |
456 | int result_af, | 457 | int result_af, |
457 | int addr_af, | 458 | int addr_af, |
458 | const void *addr, | 459 | const void *addr, |
459 | struct GNUNET_TIME_Absolute expiration_time, | 460 | struct GNUNET_TIME_Absolute expiration_time, |
460 | GNUNET_VPN_AllocationCallback cb, | 461 | GNUNET_VPN_AllocationCallback cb, |
461 | void *cb_cls) | 462 | void *cb_cls) |
462 | { | 463 | { |
463 | struct GNUNET_VPN_RedirectionRequest *rr; | 464 | struct GNUNET_VPN_RedirectionRequest *rr; |
464 | size_t alen; | 465 | size_t alen; |
465 | 466 | ||
466 | switch (addr_af) | 467 | switch (addr_af) |
467 | { | 468 | { |
468 | case AF_INET: | 469 | case AF_INET: |
469 | alen = sizeof (struct in_addr); | 470 | alen = sizeof(struct in_addr); |
470 | break; | 471 | break; |
471 | case AF_INET6: | 472 | |
472 | alen = sizeof (struct in6_addr); | 473 | case AF_INET6: |
473 | break; | 474 | alen = sizeof(struct in6_addr); |
474 | default: | 475 | break; |
475 | GNUNET_break (0); | 476 | |
476 | return NULL; | 477 | default: |
477 | } | 478 | GNUNET_break(0); |
478 | rr = GNUNET_malloc (sizeof (struct GNUNET_VPN_RedirectionRequest) + alen); | 479 | return NULL; |
480 | } | ||
481 | rr = GNUNET_malloc(sizeof(struct GNUNET_VPN_RedirectionRequest) + alen); | ||
479 | rr->vh = vh; | 482 | rr->vh = vh; |
480 | rr->addr = &rr[1]; | 483 | rr->addr = &rr[1]; |
481 | rr->cb = cb; | 484 | rr->cb = cb; |
@@ -483,13 +486,13 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh, | |||
483 | rr->expiration_time = expiration_time; | 486 | rr->expiration_time = expiration_time; |
484 | rr->result_af = result_af; | 487 | rr->result_af = result_af; |
485 | rr->addr_af = addr_af; | 488 | rr->addr_af = addr_af; |
486 | GNUNET_memcpy (&rr[1], | 489 | GNUNET_memcpy(&rr[1], |
487 | addr, | 490 | addr, |
488 | alen); | 491 | alen); |
489 | GNUNET_CONTAINER_DLL_insert_tail (vh->rr_head, | 492 | GNUNET_CONTAINER_DLL_insert_tail(vh->rr_head, |
490 | vh->rr_tail, | 493 | vh->rr_tail, |
491 | rr); | 494 | rr); |
492 | send_request (rr); | 495 | send_request(rr); |
493 | return rr; | 496 | return rr; |
494 | } | 497 | } |
495 | 498 | ||
@@ -501,18 +504,18 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh, | |||
501 | * @return VPN handle | 504 | * @return VPN handle |
502 | */ | 505 | */ |
503 | struct GNUNET_VPN_Handle * | 506 | struct GNUNET_VPN_Handle * |
504 | GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | 507 | GNUNET_VPN_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) |
505 | { | 508 | { |
506 | struct GNUNET_VPN_Handle *vh | 509 | struct GNUNET_VPN_Handle *vh |
507 | = GNUNET_new (struct GNUNET_VPN_Handle); | 510 | = GNUNET_new(struct GNUNET_VPN_Handle); |
508 | 511 | ||
509 | vh->cfg = cfg; | 512 | vh->cfg = cfg; |
510 | connect_task (vh); | 513 | connect_task(vh); |
511 | if (NULL == vh->mq) | 514 | if (NULL == vh->mq) |
512 | { | 515 | { |
513 | GNUNET_free (vh); | 516 | GNUNET_free(vh); |
514 | return NULL; | 517 | return NULL; |
515 | } | 518 | } |
516 | return vh; | 519 | return vh; |
517 | } | 520 | } |
518 | 521 | ||
@@ -523,20 +526,20 @@ GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
523 | * @param vh VPN handle | 526 | * @param vh VPN handle |
524 | */ | 527 | */ |
525 | void | 528 | void |
526 | GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh) | 529 | GNUNET_VPN_disconnect(struct GNUNET_VPN_Handle *vh) |
527 | { | 530 | { |
528 | GNUNET_assert (NULL == vh->rr_head); | 531 | GNUNET_assert(NULL == vh->rr_head); |
529 | if (NULL != vh->mq) | 532 | if (NULL != vh->mq) |
530 | { | 533 | { |
531 | GNUNET_MQ_destroy (vh->mq); | 534 | GNUNET_MQ_destroy(vh->mq); |
532 | vh->mq = NULL; | 535 | vh->mq = NULL; |
533 | } | 536 | } |
534 | if (NULL != vh->rt) | 537 | if (NULL != vh->rt) |
535 | { | 538 | { |
536 | GNUNET_SCHEDULER_cancel (vh->rt); | 539 | GNUNET_SCHEDULER_cancel(vh->rt); |
537 | vh->rt = NULL; | 540 | vh->rt = NULL; |
538 | } | 541 | } |
539 | GNUNET_free (vh); | 542 | GNUNET_free(vh); |
540 | } | 543 | } |
541 | 544 | ||
542 | /* end of vpn_api.c */ | 545 | /* end of vpn_api.c */ |