diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-11-14 13:55:12 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-11-14 13:55:12 +0000 |
commit | b7366f3d6a56d38d0269a33039f88de967e8c130 (patch) | |
tree | e299448a28e358c6549670a094b82f247925f7e2 /src/pt/gnunet-daemon-pt.c | |
parent | 6bde5e0c83d1fd344a26de64172ddce37920bb40 (diff) | |
download | gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.tar.gz gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.zip |
Use encrypted MESH by default
Diffstat (limited to 'src/pt/gnunet-daemon-pt.c')
-rw-r--r-- | src/pt/gnunet-daemon-pt.c | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c index f10274328..6375406d9 100644 --- a/src/pt/gnunet-daemon-pt.c +++ b/src/pt/gnunet-daemon-pt.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #define MAX_DNS_SIZE (8 * 1024) | 51 | #define MAX_DNS_SIZE (8 * 1024) |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * How many tunnels do we open at most at the same time? | 54 | * How many channels do we open at most at the same time? |
55 | */ | 55 | */ |
56 | #define MAX_OPEN_TUNNELS 4 | 56 | #define MAX_OPEN_TUNNELS 4 |
57 | 57 | ||
@@ -123,7 +123,7 @@ struct ReplyContext | |||
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Handle to a peer that advertised that it is willing to serve | 125 | * Handle to a peer that advertised that it is willing to serve |
126 | * as a DNS exit. We try to keep a few tunnels open and a few | 126 | * as a DNS exit. We try to keep a few channels open and a few |
127 | * peers in reserve. | 127 | * peers in reserve. |
128 | */ | 128 | */ |
129 | struct MeshExit | 129 | struct MeshExit |
@@ -140,10 +140,10 @@ struct MeshExit | |||
140 | struct MeshExit *prev; | 140 | struct MeshExit *prev; |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Tunnel we use for DNS requests over MESH, NULL if we did | 143 | * Channel we use for DNS requests over MESH, NULL if we did |
144 | * not initialze a tunnel to this peer yet. | 144 | * not initialze a channel to this peer yet. |
145 | */ | 145 | */ |
146 | struct GNUNET_MESH_Tunnel *mesh_tunnel; | 146 | struct GNUNET_MESH_Channel *mesh_channel; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * At what time did the peer's advertisement expire? | 149 | * At what time did the peer's advertisement expire? |
@@ -161,17 +161,17 @@ struct MeshExit | |||
161 | struct RequestContext *receive_queue_tail; | 161 | struct RequestContext *receive_queue_tail; |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Head of DLL of requests to be transmitted to a mesh_tunnel. | 164 | * Head of DLL of requests to be transmitted to a mesh_channel. |
165 | */ | 165 | */ |
166 | struct RequestContext *transmit_queue_head; | 166 | struct RequestContext *transmit_queue_head; |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * Tail of DLL of requests to be transmitted to a mesh_tunnel. | 169 | * Tail of DLL of requests to be transmitted to a mesh_channel. |
170 | */ | 170 | */ |
171 | struct RequestContext *transmit_queue_tail; | 171 | struct RequestContext *transmit_queue_tail; |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * Active transmission request for this tunnel (or NULL). | 174 | * Active transmission request for this channel (or NULL). |
175 | */ | 175 | */ |
176 | struct GNUNET_MESH_TransmitHandle *mesh_th; | 176 | struct GNUNET_MESH_TransmitHandle *mesh_th; |
177 | 177 | ||
@@ -181,12 +181,12 @@ struct MeshExit | |||
181 | struct GNUNET_PeerIdentity peer; | 181 | struct GNUNET_PeerIdentity peer; |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * How many DNS requests did we transmit via this tunnel? | 184 | * How many DNS requests did we transmit via this channel? |
185 | */ | 185 | */ |
186 | unsigned int num_transmitted; | 186 | unsigned int num_transmitted; |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * How many DNS requests were answered via this tunnel? | 189 | * How many DNS requests were answered via this channel? |
190 | */ | 190 | */ |
191 | unsigned int num_answered; | 191 | unsigned int num_answered; |
192 | 192 | ||
@@ -250,7 +250,7 @@ struct RequestContext | |||
250 | 250 | ||
251 | 251 | ||
252 | /** | 252 | /** |
253 | * Head of DLL of mesh exits. Mesh exits with an open tunnel are | 253 | * Head of DLL of mesh exits. Mesh exits with an open channel are |
254 | * always at the beginning (so we do not have to traverse the entire | 254 | * always at the beginning (so we do not have to traverse the entire |
255 | * list to find them). | 255 | * list to find them). |
256 | */ | 256 | */ |
@@ -312,14 +312,14 @@ static int ipv4_pt; | |||
312 | static int ipv6_pt; | 312 | static int ipv6_pt; |
313 | 313 | ||
314 | /** | 314 | /** |
315 | * Are we tunneling DNS queries? | 315 | * Are we channeling DNS queries? |
316 | */ | 316 | */ |
317 | static int dns_tunnel; | 317 | static int dns_channel; |
318 | 318 | ||
319 | /** | 319 | /** |
320 | * Number of DNS exit peers we currently have in the mesh tunnel. | 320 | * Number of DNS exit peers we currently have in the mesh channel. |
321 | * Used to see if using the mesh tunnel makes any sense right now, | 321 | * Used to see if using the mesh channel makes any sense right now, |
322 | * as well as to decide if we should open new tunnels. | 322 | * as well as to decide if we should open new channels. |
323 | */ | 323 | */ |
324 | static unsigned int dns_exit_available; | 324 | static unsigned int dns_exit_available; |
325 | 325 | ||
@@ -336,25 +336,25 @@ try_open_exit () | |||
336 | 336 | ||
337 | candidate_count = 0; | 337 | candidate_count = 0; |
338 | for (pos = exit_head; NULL != pos; pos = pos->next) | 338 | for (pos = exit_head; NULL != pos; pos = pos->next) |
339 | if (NULL == pos->mesh_tunnel) | 339 | if (NULL == pos->mesh_channel) |
340 | candidate_count++; | 340 | candidate_count++; |
341 | candidate_selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 341 | candidate_selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
342 | candidate_count); | 342 | candidate_count); |
343 | candidate_count = 0; | 343 | candidate_count = 0; |
344 | for (pos = exit_head; NULL != pos; pos = pos->next) | 344 | for (pos = exit_head; NULL != pos; pos = pos->next) |
345 | if (NULL == pos->mesh_tunnel) | 345 | if (NULL == pos->mesh_channel) |
346 | { | 346 | { |
347 | candidate_count++; | 347 | candidate_count++; |
348 | if (candidate_selected < candidate_count) | 348 | if (candidate_selected < candidate_count) |
349 | { | 349 | { |
350 | /* move to the head of the DLL */ | 350 | /* move to the head of the DLL */ |
351 | pos->mesh_tunnel = GNUNET_MESH_tunnel_create (mesh_handle, | 351 | pos->mesh_channel = GNUNET_MESH_channel_create (mesh_handle, |
352 | pos, | 352 | pos, |
353 | &pos->peer, | 353 | &pos->peer, |
354 | GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, | 354 | GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, |
355 | GNUNET_YES /* no buffer */, | 355 | GNUNET_YES /* no buffer */, |
356 | GNUNET_NO /* reliable */); | 356 | GNUNET_NO /* reliable */); |
357 | if (NULL == pos->mesh_tunnel) | 357 | if (NULL == pos->mesh_channel) |
358 | { | 358 | { |
359 | GNUNET_break (0); | 359 | GNUNET_break (0); |
360 | continue; | 360 | continue; |
@@ -375,15 +375,15 @@ try_open_exit () | |||
375 | 375 | ||
376 | /** | 376 | /** |
377 | * Compute the weight of the given exit. The higher the weight, | 377 | * Compute the weight of the given exit. The higher the weight, |
378 | * the more likely it will be that the tunnel will be chosen. | 378 | * the more likely it will be that the channel will be chosen. |
379 | * A weigt of zero means that we should close the tunnel as it | 379 | * A weigt of zero means that we should close the channel as it |
380 | * is so bad, that we should not use it. | 380 | * is so bad, that we should not use it. |
381 | * | 381 | * |
382 | * @param exit exit to calculate the weight for | 382 | * @param exit exit to calculate the weight for |
383 | * @return weight of the tunnel | 383 | * @return weight of the channel |
384 | */ | 384 | */ |
385 | static uint32_t | 385 | static uint32_t |
386 | get_tunnel_weight (struct MeshExit *exit) | 386 | get_channel_weight (struct MeshExit *exit) |
387 | { | 387 | { |
388 | uint32_t dropped; | 388 | uint32_t dropped; |
389 | uint32_t drop_percent; | 389 | uint32_t drop_percent; |
@@ -407,12 +407,12 @@ get_tunnel_weight (struct MeshExit *exit) | |||
407 | 407 | ||
408 | 408 | ||
409 | /** | 409 | /** |
410 | * Choose a mesh exit for a DNS request. We try to use a tunnel | 410 | * Choose a mesh exit for a DNS request. We try to use a channel |
411 | * that is reliable and currently available. All existing | 411 | * that is reliable and currently available. All existing |
412 | * tunnels are given a base weight of 1, plus a score relating | 412 | * channels are given a base weight of 1, plus a score relating |
413 | * to the total number of queries answered in relation to the | 413 | * to the total number of queries answered in relation to the |
414 | * total number of queries we sent to that tunnel. That | 414 | * total number of queries we sent to that channel. That |
415 | * score is doubled if the tunnel is currently idle. | 415 | * score is doubled if the channel is currently idle. |
416 | * | 416 | * |
417 | * @return NULL if no exit is known, otherwise the | 417 | * @return NULL if no exit is known, otherwise the |
418 | * exit that we should use to queue a message with | 418 | * exit that we should use to queue a message with |
@@ -423,22 +423,22 @@ choose_exit () | |||
423 | struct MeshExit *pos; | 423 | struct MeshExit *pos; |
424 | uint64_t total_transmitted; | 424 | uint64_t total_transmitted; |
425 | uint64_t selected_offset; | 425 | uint64_t selected_offset; |
426 | uint32_t tunnel_weight; | 426 | uint32_t channel_weight; |
427 | 427 | ||
428 | total_transmitted = 0; | 428 | total_transmitted = 0; |
429 | for (pos = exit_head; NULL != pos; pos = pos->next) | 429 | for (pos = exit_head; NULL != pos; pos = pos->next) |
430 | { | 430 | { |
431 | if (NULL == pos->mesh_tunnel) | 431 | if (NULL == pos->mesh_channel) |
432 | break; | 432 | break; |
433 | tunnel_weight = get_tunnel_weight (pos); | 433 | channel_weight = get_channel_weight (pos); |
434 | total_transmitted += tunnel_weight; | 434 | total_transmitted += channel_weight; |
435 | /* double weight for idle tunnels */ | 435 | /* double weight for idle channels */ |
436 | if (NULL == pos->mesh_th) | 436 | if (NULL == pos->mesh_th) |
437 | total_transmitted += tunnel_weight; | 437 | total_transmitted += channel_weight; |
438 | } | 438 | } |
439 | if (0 == total_transmitted) | 439 | if (0 == total_transmitted) |
440 | { | 440 | { |
441 | /* no tunnels available, or only a very bad one... */ | 441 | /* no channels available, or only a very bad one... */ |
442 | return exit_head; | 442 | return exit_head; |
443 | } | 443 | } |
444 | selected_offset = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 444 | selected_offset = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
@@ -446,13 +446,13 @@ choose_exit () | |||
446 | total_transmitted = 0; | 446 | total_transmitted = 0; |
447 | for (pos = exit_head; NULL != pos; pos = pos->next) | 447 | for (pos = exit_head; NULL != pos; pos = pos->next) |
448 | { | 448 | { |
449 | if (NULL == pos->mesh_tunnel) | 449 | if (NULL == pos->mesh_channel) |
450 | break; | 450 | break; |
451 | tunnel_weight = get_tunnel_weight (pos); | 451 | channel_weight = get_channel_weight (pos); |
452 | total_transmitted += tunnel_weight; | 452 | total_transmitted += channel_weight; |
453 | /* double weight for idle tunnels */ | 453 | /* double weight for idle channels */ |
454 | if (NULL == pos->mesh_th) | 454 | if (NULL == pos->mesh_th) |
455 | total_transmitted += tunnel_weight; | 455 | total_transmitted += channel_weight; |
456 | if (total_transmitted > selected_offset) | 456 | if (total_transmitted > selected_offset) |
457 | return pos; | 457 | return pos; |
458 | } | 458 | } |
@@ -561,7 +561,7 @@ vpn_allocation_callback (void *cls, | |||
561 | 561 | ||
562 | 562 | ||
563 | /** | 563 | /** |
564 | * Modify the given DNS record by asking VPN to create a tunnel | 564 | * Modify the given DNS record by asking VPN to create a channel |
565 | * to the given address. When done, continue with submitting | 565 | * to the given address. When done, continue with submitting |
566 | * other records from the request context ('submit_request' is | 566 | * other records from the request context ('submit_request' is |
567 | * our continuation). | 567 | * our continuation). |
@@ -696,7 +696,7 @@ work_test (const struct GNUNET_DNSPARSER_Record *ra, | |||
696 | /** | 696 | /** |
697 | * This function is called AFTER we got an IP address for a | 697 | * This function is called AFTER we got an IP address for a |
698 | * DNS request. Now, the PT daemon has the chance to substitute | 698 | * DNS request. Now, the PT daemon has the chance to substitute |
699 | * the IP address with one from the VPN range to tunnel requests | 699 | * the IP address with one from the VPN range to channel requests |
700 | * destined for this IP address via VPN and MESH. | 700 | * destined for this IP address via VPN and MESH. |
701 | * | 701 | * |
702 | * @param cls closure | 702 | * @param cls closure |
@@ -768,7 +768,7 @@ transmit_dns_request_to_mesh (void *cls, | |||
768 | mlen = rc->mlen; | 768 | mlen = rc->mlen; |
769 | if (mlen > size) | 769 | if (mlen > size) |
770 | { | 770 | { |
771 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_tunnel, | 771 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_channel, |
772 | GNUNET_NO, | 772 | GNUNET_NO, |
773 | TIMEOUT, | 773 | TIMEOUT, |
774 | mlen, | 774 | mlen, |
@@ -787,7 +787,7 @@ transmit_dns_request_to_mesh (void *cls, | |||
787 | rc); | 787 | rc); |
788 | rc = exit->transmit_queue_head; | 788 | rc = exit->transmit_queue_head; |
789 | if (NULL != rc) | 789 | if (NULL != rc) |
790 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_tunnel, | 790 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_channel, |
791 | GNUNET_NO, | 791 | GNUNET_NO, |
792 | TIMEOUT, | 792 | TIMEOUT, |
793 | rc->mlen, | 793 | rc->mlen, |
@@ -828,15 +828,15 @@ timeout_request (void *cls, | |||
828 | 1, GNUNET_NO); | 828 | 1, GNUNET_NO); |
829 | GNUNET_DNS_request_drop (rc->rh); | 829 | GNUNET_DNS_request_drop (rc->rh); |
830 | GNUNET_free (rc); | 830 | GNUNET_free (rc); |
831 | if ( (0 == get_tunnel_weight (exit)) && | 831 | if ( (0 == get_channel_weight (exit)) && |
832 | (NULL == exit->receive_queue_head) && | 832 | (NULL == exit->receive_queue_head) && |
833 | (NULL == exit->transmit_queue_head) ) | 833 | (NULL == exit->transmit_queue_head) ) |
834 | { | 834 | { |
835 | /* this straw broke the camel's back: this tunnel now has | 835 | /* this straw broke the camel's back: this channel now has |
836 | such a low score that it will not be used; close it! */ | 836 | such a low score that it will not be used; close it! */ |
837 | GNUNET_assert (NULL == exit->mesh_th); | 837 | GNUNET_assert (NULL == exit->mesh_th); |
838 | GNUNET_MESH_tunnel_destroy (exit->mesh_tunnel); | 838 | GNUNET_MESH_channel_destroy (exit->mesh_channel); |
839 | exit->mesh_tunnel = NULL; | 839 | exit->mesh_channel = NULL; |
840 | GNUNET_CONTAINER_DLL_remove (exit_head, | 840 | GNUNET_CONTAINER_DLL_remove (exit_head, |
841 | exit_tail, | 841 | exit_tail, |
842 | exit); | 842 | exit); |
@@ -845,7 +845,7 @@ timeout_request (void *cls, | |||
845 | exit); | 845 | exit); |
846 | /* go back to semi-innocent: mark as not great, but | 846 | /* go back to semi-innocent: mark as not great, but |
847 | avoid a prohibitively negative score (see | 847 | avoid a prohibitively negative score (see |
848 | #get_tunnel_weight, which checks for a certain | 848 | #get_channel_weight, which checks for a certain |
849 | minimum number of transmissions before making | 849 | minimum number of transmissions before making |
850 | up an opinion) */ | 850 | up an opinion) */ |
851 | exit->num_transmitted = 5; | 851 | exit->num_transmitted = 5; |
@@ -859,9 +859,9 @@ timeout_request (void *cls, | |||
859 | 859 | ||
860 | /** | 860 | /** |
861 | * This function is called *before* the DNS request has been | 861 | * This function is called *before* the DNS request has been |
862 | * given to a "local" DNS resolver. Tunneling for DNS requests | 862 | * given to a "local" DNS resolver. Channeling for DNS requests |
863 | * was enabled, so we now need to send the request via some MESH | 863 | * was enabled, so we now need to send the request via some MESH |
864 | * tunnel to a DNS EXIT for resolution. | 864 | * channel to a DNS EXIT for resolution. |
865 | * | 865 | * |
866 | * @param cls closure | 866 | * @param cls closure |
867 | * @param rh request handle to user for reply | 867 | * @param rh request handle to user for reply |
@@ -886,7 +886,7 @@ dns_pre_request_handler (void *cls, | |||
886 | if (0 == dns_exit_available) | 886 | if (0 == dns_exit_available) |
887 | { | 887 | { |
888 | GNUNET_STATISTICS_update (stats, | 888 | GNUNET_STATISTICS_update (stats, |
889 | gettext_noop ("# DNS requests dropped (DNS mesh tunnel down)"), | 889 | gettext_noop ("# DNS requests dropped (DNS mesh channel down)"), |
890 | 1, GNUNET_NO); | 890 | 1, GNUNET_NO); |
891 | GNUNET_DNS_request_drop (rh); | 891 | GNUNET_DNS_request_drop (rh); |
892 | return; | 892 | return; |
@@ -903,7 +903,7 @@ dns_pre_request_handler (void *cls, | |||
903 | mlen = sizeof (struct GNUNET_MessageHeader) + request_length; | 903 | mlen = sizeof (struct GNUNET_MessageHeader) + request_length; |
904 | exit = choose_exit (); | 904 | exit = choose_exit (); |
905 | GNUNET_assert (NULL != exit); | 905 | GNUNET_assert (NULL != exit); |
906 | GNUNET_assert (NULL != exit->mesh_tunnel); | 906 | GNUNET_assert (NULL != exit->mesh_channel); |
907 | rc = GNUNET_malloc (sizeof (struct RequestContext) + mlen); | 907 | rc = GNUNET_malloc (sizeof (struct RequestContext) + mlen); |
908 | rc->exit = exit; | 908 | rc->exit = exit; |
909 | rc->rh = rh; | 909 | rc->rh = rh; |
@@ -923,7 +923,7 @@ dns_pre_request_handler (void *cls, | |||
923 | exit->transmit_queue_tail, | 923 | exit->transmit_queue_tail, |
924 | rc); | 924 | rc); |
925 | if (NULL == exit->mesh_th) | 925 | if (NULL == exit->mesh_th) |
926 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_tunnel, | 926 | exit->mesh_th = GNUNET_MESH_notify_transmit_ready (exit->mesh_channel, |
927 | GNUNET_NO, | 927 | GNUNET_NO, |
928 | TIMEOUT, | 928 | TIMEOUT, |
929 | mlen, | 929 | mlen, |
@@ -936,19 +936,19 @@ dns_pre_request_handler (void *cls, | |||
936 | * Process a request via mesh to perform a DNS query. | 936 | * Process a request via mesh to perform a DNS query. |
937 | * | 937 | * |
938 | * @param cls NULL | 938 | * @param cls NULL |
939 | * @param tunnel connection to the other end | 939 | * @param channel connection to the other end |
940 | * @param tunnel_ctx pointer to our `struct MeshExit` | 940 | * @param channel_ctx pointer to our `struct MeshExit` |
941 | * @param message the actual message | 941 | * @param message the actual message |
942 | * @return #GNUNET_OK to keep the connection open, | 942 | * @return #GNUNET_OK to keep the connection open, |
943 | * #GNUNET_SYSERR to close it (signal serious error) | 943 | * #GNUNET_SYSERR to close it (signal serious error) |
944 | */ | 944 | */ |
945 | static int | 945 | static int |
946 | receive_dns_response (void *cls, | 946 | receive_dns_response (void *cls, |
947 | struct GNUNET_MESH_Tunnel *tunnel, | 947 | struct GNUNET_MESH_Channel *channel, |
948 | void **tunnel_ctx, | 948 | void **channel_ctx, |
949 | const struct GNUNET_MessageHeader *message) | 949 | const struct GNUNET_MessageHeader *message) |
950 | { | 950 | { |
951 | struct MeshExit *exit = *tunnel_ctx; | 951 | struct MeshExit *exit = *channel_ctx; |
952 | struct GNUNET_TUN_DnsHeader dns; | 952 | struct GNUNET_TUN_DnsHeader dns; |
953 | size_t mlen; | 953 | size_t mlen; |
954 | struct RequestContext *rc; | 954 | struct RequestContext *rc; |
@@ -1049,10 +1049,10 @@ cleanup (void *cls, | |||
1049 | GNUNET_MESH_notify_transmit_ready_cancel (exit->mesh_th); | 1049 | GNUNET_MESH_notify_transmit_ready_cancel (exit->mesh_th); |
1050 | exit->mesh_th = NULL; | 1050 | exit->mesh_th = NULL; |
1051 | } | 1051 | } |
1052 | if (NULL != exit->mesh_tunnel) | 1052 | if (NULL != exit->mesh_channel) |
1053 | { | 1053 | { |
1054 | GNUNET_MESH_tunnel_destroy (exit->mesh_tunnel); | 1054 | GNUNET_MESH_channel_destroy (exit->mesh_channel); |
1055 | exit->mesh_tunnel = NULL; | 1055 | exit->mesh_channel = NULL; |
1056 | } | 1056 | } |
1057 | abort_all_requests (exit); | 1057 | abort_all_requests (exit); |
1058 | GNUNET_free (exit); | 1058 | GNUNET_free (exit); |
@@ -1091,22 +1091,22 @@ cleanup (void *cls, | |||
1091 | 1091 | ||
1092 | 1092 | ||
1093 | /** | 1093 | /** |
1094 | * Function called whenever a tunnel is destroyed. Should clean up | 1094 | * Function called whenever a channel is destroyed. Should clean up |
1095 | * the associated state and attempt to build a new one. | 1095 | * the associated state and attempt to build a new one. |
1096 | * | 1096 | * |
1097 | * It must NOT call #GNUNET_MESH_tunnel_destroy on the tunnel. | 1097 | * It must NOT call #GNUNET_MESH_channel_destroy on the channel. |
1098 | * | 1098 | * |
1099 | * @param cls closure (the `struct MeshExit` set from #GNUNET_MESH_connect) | 1099 | * @param cls closure (the `struct MeshExit` set from #GNUNET_MESH_connect) |
1100 | * @param tunnel connection to the other end (henceforth invalid) | 1100 | * @param channel connection to the other end (henceforth invalid) |
1101 | * @param tunnel_ctx place where local state associated | 1101 | * @param channel_ctx place where local state associated |
1102 | * with the tunnel is stored | 1102 | * with the channel is stored |
1103 | */ | 1103 | */ |
1104 | static void | 1104 | static void |
1105 | mesh_tunnel_end_cb (void *cls, | 1105 | mesh_channel_end_cb (void *cls, |
1106 | const struct GNUNET_MESH_Tunnel *tunnel, | 1106 | const struct GNUNET_MESH_Channel *channel, |
1107 | void *tunnel_ctx) | 1107 | void *channel_ctx) |
1108 | { | 1108 | { |
1109 | struct MeshExit *exit = tunnel_ctx; | 1109 | struct MeshExit *exit = channel_ctx; |
1110 | struct MeshExit *alt; | 1110 | struct MeshExit *alt; |
1111 | struct RequestContext *rc; | 1111 | struct RequestContext *rc; |
1112 | 1112 | ||
@@ -1115,14 +1115,14 @@ mesh_tunnel_end_cb (void *cls, | |||
1115 | GNUNET_MESH_notify_transmit_ready_cancel (exit->mesh_th); | 1115 | GNUNET_MESH_notify_transmit_ready_cancel (exit->mesh_th); |
1116 | exit->mesh_th = NULL; | 1116 | exit->mesh_th = NULL; |
1117 | } | 1117 | } |
1118 | exit->mesh_tunnel = NULL; | 1118 | exit->mesh_channel = NULL; |
1119 | dns_exit_available--; | 1119 | dns_exit_available--; |
1120 | /* open alternative tunnels */ | 1120 | /* open alternative channels */ |
1121 | try_open_exit (); | 1121 | try_open_exit (); |
1122 | if (NULL == exit->mesh_tunnel) | 1122 | if (NULL == exit->mesh_channel) |
1123 | { | 1123 | { |
1124 | /* our tunnel is now closed, move our requests to an alternative | 1124 | /* our channel is now closed, move our requests to an alternative |
1125 | tunnel */ | 1125 | channel */ |
1126 | alt = choose_exit (); | 1126 | alt = choose_exit (); |
1127 | while (NULL != (rc = exit->transmit_queue_head)) | 1127 | while (NULL != (rc = exit->transmit_queue_head)) |
1128 | { | 1128 | { |
@@ -1153,7 +1153,7 @@ mesh_tunnel_end_cb (void *cls, | |||
1153 | } | 1153 | } |
1154 | if ( (NULL == alt->mesh_th) && | 1154 | if ( (NULL == alt->mesh_th) && |
1155 | (NULL != (rc = alt->transmit_queue_head)) ) | 1155 | (NULL != (rc = alt->transmit_queue_head)) ) |
1156 | alt->mesh_th = GNUNET_MESH_notify_transmit_ready (alt->mesh_tunnel, | 1156 | alt->mesh_th = GNUNET_MESH_notify_transmit_ready (alt->mesh_channel, |
1157 | GNUNET_NO, | 1157 | GNUNET_NO, |
1158 | TIMEOUT, | 1158 | TIMEOUT, |
1159 | rc->mlen, | 1159 | rc->mlen, |
@@ -1164,7 +1164,7 @@ mesh_tunnel_end_cb (void *cls, | |||
1164 | 1164 | ||
1165 | /** | 1165 | /** |
1166 | * Function called whenever we find an advertisement for a | 1166 | * Function called whenever we find an advertisement for a |
1167 | * DNS exit in the DHT. If we don't have a mesh tunnel, | 1167 | * DNS exit in the DHT. If we don't have a mesh channel, |
1168 | * we should build one; otherwise, we should save the | 1168 | * we should build one; otherwise, we should save the |
1169 | * advertisement for later use. | 1169 | * advertisement for later use. |
1170 | * | 1170 | * |
@@ -1210,7 +1210,7 @@ handle_dht_result (void *cls, | |||
1210 | { | 1210 | { |
1211 | exit = GNUNET_new (struct MeshExit); | 1211 | exit = GNUNET_new (struct MeshExit); |
1212 | exit->peer = ad->peer; | 1212 | exit->peer = ad->peer; |
1213 | /* tunnel is closed, so insert at the end */ | 1213 | /* channel is closed, so insert at the end */ |
1214 | GNUNET_CONTAINER_DLL_insert_tail (exit_head, | 1214 | GNUNET_CONTAINER_DLL_insert_tail (exit_head, |
1215 | exit_tail, | 1215 | exit_tail, |
1216 | exit); | 1216 | exit); |
@@ -1241,8 +1241,8 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1241 | stats = GNUNET_STATISTICS_create ("pt", cfg); | 1241 | stats = GNUNET_STATISTICS_create ("pt", cfg); |
1242 | ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV4"); | 1242 | ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV4"); |
1243 | ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV6"); | 1243 | ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV6"); |
1244 | dns_tunnel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS"); | 1244 | dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS"); |
1245 | if (! (ipv4_pt || ipv6_pt || dns_tunnel)) | 1245 | if (! (ipv4_pt || ipv6_pt || dns_channel)) |
1246 | { | 1246 | { |
1247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1248 | _("No useful service enabled. Exiting.\n")); | 1248 | _("No useful service enabled. Exiting.\n")); |
@@ -1274,7 +1274,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1274 | return; | 1274 | return; |
1275 | } | 1275 | } |
1276 | } | 1276 | } |
1277 | if (dns_tunnel) | 1277 | if (dns_channel) |
1278 | { | 1278 | { |
1279 | static struct GNUNET_MESH_MessageHandler mesh_handlers[] = { | 1279 | static struct GNUNET_MESH_MessageHandler mesh_handlers[] = { |
1280 | {&receive_dns_response, GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET, 0}, | 1280 | {&receive_dns_response, GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET, 0}, |
@@ -1294,7 +1294,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1294 | return; | 1294 | return; |
1295 | } | 1295 | } |
1296 | mesh_handle = GNUNET_MESH_connect (cfg, NULL, NULL, | 1296 | mesh_handle = GNUNET_MESH_connect (cfg, NULL, NULL, |
1297 | &mesh_tunnel_end_cb, | 1297 | &mesh_channel_end_cb, |
1298 | mesh_handlers, NULL); | 1298 | mesh_handlers, NULL); |
1299 | if (NULL == mesh_handle) | 1299 | if (NULL == mesh_handle) |
1300 | { | 1300 | { |