diff options
Diffstat (limited to 'src/pt/gnunet-daemon-pt.c')
-rw-r--r-- | src/pt/gnunet-daemon-pt.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c index 1d9abf81a..f10274328 100644 --- a/src/pt/gnunet-daemon-pt.c +++ b/src/pt/gnunet-daemon-pt.c | |||
@@ -64,7 +64,7 @@ enum RequestGroup | |||
64 | /** | 64 | /** |
65 | * DNS answers | 65 | * DNS answers |
66 | */ | 66 | */ |
67 | ANSWERS = 0, | 67 | ANSWERS = 0, |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * DNS authority records | 70 | * DNS authority records |
@@ -92,7 +92,7 @@ struct ReplyContext | |||
92 | * Handle to submit the final result. | 92 | * Handle to submit the final result. |
93 | */ | 93 | */ |
94 | struct GNUNET_DNS_RequestHandle *rh; | 94 | struct GNUNET_DNS_RequestHandle *rh; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * DNS packet that is being modified. | 97 | * DNS packet that is being modified. |
98 | */ | 98 | */ |
@@ -117,7 +117,7 @@ struct ReplyContext | |||
117 | * Group that is being modified | 117 | * Group that is being modified |
118 | */ | 118 | */ |
119 | enum RequestGroup group; | 119 | enum RequestGroup group; |
120 | 120 | ||
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
@@ -144,7 +144,7 @@ struct MeshExit | |||
144 | * not initialze a tunnel to this peer yet. | 144 | * not initialze a tunnel to this peer yet. |
145 | */ | 145 | */ |
146 | struct GNUNET_MESH_Tunnel *mesh_tunnel; | 146 | struct GNUNET_MESH_Tunnel *mesh_tunnel; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * At what time did the peer's advertisement expire? | 149 | * At what time did the peer's advertisement expire? |
150 | */ | 150 | */ |
@@ -177,7 +177,7 @@ struct MeshExit | |||
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Identity of the peer that is providing the exit for us. | 179 | * Identity of the peer that is providing the exit for us. |
180 | */ | 180 | */ |
181 | struct GNUNET_PeerIdentity peer; | 181 | struct GNUNET_PeerIdentity peer; |
182 | 182 | ||
183 | /** | 183 | /** |
@@ -218,7 +218,7 @@ struct RequestContext | |||
218 | * Handle for interaction with DNS service. | 218 | * Handle for interaction with DNS service. |
219 | */ | 219 | */ |
220 | struct GNUNET_DNS_RequestHandle *rh; | 220 | struct GNUNET_DNS_RequestHandle *rh; |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * Message we're sending out via MESH, allocated at the | 223 | * Message we're sending out via MESH, allocated at the |
224 | * end of this struct. | 224 | * end of this struct. |
@@ -243,7 +243,7 @@ struct RequestContext | |||
243 | /** | 243 | /** |
244 | * #GNUNET_NO if this request is still in the transmit_queue, | 244 | * #GNUNET_NO if this request is still in the transmit_queue, |
245 | * #GNUNET_YES if we are in the receive_queue. | 245 | * #GNUNET_YES if we are in the receive_queue. |
246 | */ | 246 | */ |
247 | int16_t was_transmitted; | 247 | int16_t was_transmitted; |
248 | 248 | ||
249 | }; | 249 | }; |
@@ -388,7 +388,7 @@ get_tunnel_weight (struct MeshExit *exit) | |||
388 | uint32_t dropped; | 388 | uint32_t dropped; |
389 | uint32_t drop_percent; | 389 | uint32_t drop_percent; |
390 | uint32_t good_percent; | 390 | uint32_t good_percent; |
391 | 391 | ||
392 | GNUNET_assert (exit->num_transmitted >= exit->num_answered); | 392 | GNUNET_assert (exit->num_transmitted >= exit->num_answered); |
393 | dropped = exit->num_transmitted - exit->num_answered; | 393 | dropped = exit->num_transmitted - exit->num_answered; |
394 | if (exit->num_transmitted > 0) | 394 | if (exit->num_transmitted > 0) |
@@ -408,7 +408,7 @@ get_tunnel_weight (struct MeshExit *exit) | |||
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 tunnel |
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 | * tunnels 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 tunnel. That |
@@ -520,7 +520,7 @@ submit_request (struct ReplyContext *rc); | |||
520 | * will match 'result_af' from the request | 520 | * will match 'result_af' from the request |
521 | * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') | 521 | * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') |
522 | * that the VPN allocated for the redirection; | 522 | * that the VPN allocated for the redirection; |
523 | * traffic to this IP will now be redirected to the | 523 | * traffic to this IP will now be redirected to the |
524 | * specified target peer; NULL on error | 524 | * specified target peer; NULL on error |
525 | */ | 525 | */ |
526 | static void | 526 | static void |
@@ -633,7 +633,7 @@ submit_request (struct ReplyContext *rc) | |||
633 | finish_request (rc); | 633 | finish_request (rc); |
634 | return; | 634 | return; |
635 | default: | 635 | default: |
636 | GNUNET_assert (0); | 636 | GNUNET_assert (0); |
637 | } | 637 | } |
638 | for (i=rc->offset;i<ra_len;i++) | 638 | for (i=rc->offset;i<ra_len;i++) |
639 | { | 639 | { |
@@ -694,7 +694,7 @@ work_test (const struct GNUNET_DNSPARSER_Record *ra, | |||
694 | 694 | ||
695 | 695 | ||
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 tunnel requests |
700 | * destined for this IP address via VPN and MESH. | 700 | * destined for this IP address via VPN and MESH. |
@@ -704,7 +704,7 @@ work_test (const struct GNUNET_DNSPARSER_Record *ra, | |||
704 | * @param request_length number of bytes in request | 704 | * @param request_length number of bytes in request |
705 | * @param request udp payload of the DNS request | 705 | * @param request udp payload of the DNS request |
706 | */ | 706 | */ |
707 | static void | 707 | static void |
708 | dns_post_request_handler (void *cls, | 708 | dns_post_request_handler (void *cls, |
709 | struct GNUNET_DNS_RequestHandle *rh, | 709 | struct GNUNET_DNS_RequestHandle *rh, |
710 | size_t request_length, | 710 | size_t request_length, |
@@ -809,7 +809,7 @@ timeout_request (void *cls, | |||
809 | { | 809 | { |
810 | struct RequestContext *rc = cls; | 810 | struct RequestContext *rc = cls; |
811 | struct MeshExit *exit = rc->exit; | 811 | struct MeshExit *exit = rc->exit; |
812 | 812 | ||
813 | if (rc->was_transmitted) | 813 | if (rc->was_transmitted) |
814 | { | 814 | { |
815 | exit->num_transmitted++; | 815 | exit->num_transmitted++; |
@@ -844,7 +844,7 @@ timeout_request (void *cls, | |||
844 | exit_tail, | 844 | exit_tail, |
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_tunnel_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) */ |
@@ -858,7 +858,7 @@ timeout_request (void *cls, | |||
858 | 858 | ||
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. Tunneling 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 | * tunnel to a DNS EXIT for resolution. |
@@ -868,7 +868,7 @@ timeout_request (void *cls, | |||
868 | * @param request_length number of bytes in request | 868 | * @param request_length number of bytes in request |
869 | * @param request udp payload of the DNS request | 869 | * @param request udp payload of the DNS request |
870 | */ | 870 | */ |
871 | static void | 871 | static void |
872 | dns_pre_request_handler (void *cls, | 872 | dns_pre_request_handler (void *cls, |
873 | struct GNUNET_DNS_RequestHandle *rh, | 873 | struct GNUNET_DNS_RequestHandle *rh, |
874 | size_t request_length, | 874 | size_t request_length, |
@@ -943,7 +943,7 @@ dns_pre_request_handler (void *cls, | |||
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_Tunnel *tunnel, |
948 | void **tunnel_ctx, | 948 | void **tunnel_ctx, |
949 | const struct GNUNET_MessageHeader *message) | 949 | const struct GNUNET_MessageHeader *message) |
@@ -979,7 +979,7 @@ receive_dns_response (void *cls, | |||
979 | GNUNET_free (rc); | 979 | GNUNET_free (rc); |
980 | exit->num_answered++; | 980 | exit->num_answered++; |
981 | exit->num_transmitted++; | 981 | exit->num_transmitted++; |
982 | return GNUNET_OK; | 982 | return GNUNET_OK; |
983 | } | 983 | } |
984 | } | 984 | } |
985 | GNUNET_STATISTICS_update (stats, | 985 | GNUNET_STATISTICS_update (stats, |
@@ -993,7 +993,7 @@ receive_dns_response (void *cls, | |||
993 | * Abort all pending DNS requests with the given mesh exit. | 993 | * Abort all pending DNS requests with the given mesh exit. |
994 | * | 994 | * |
995 | * @param exit mesh exit to abort requests for | 995 | * @param exit mesh exit to abort requests for |
996 | */ | 996 | */ |
997 | static void | 997 | static void |
998 | abort_all_requests (struct MeshExit *exit) | 998 | abort_all_requests (struct MeshExit *exit) |
999 | { | 999 | { |
@@ -1006,7 +1006,7 @@ abort_all_requests (struct MeshExit *exit) | |||
1006 | rc); | 1006 | rc); |
1007 | GNUNET_DNS_request_drop (rc->rh); | 1007 | GNUNET_DNS_request_drop (rc->rh); |
1008 | GNUNET_SCHEDULER_cancel (rc->timeout_task); | 1008 | GNUNET_SCHEDULER_cancel (rc->timeout_task); |
1009 | GNUNET_free (rc); | 1009 | GNUNET_free (rc); |
1010 | } | 1010 | } |
1011 | while (NULL != (rc = exit->transmit_queue_head)) | 1011 | while (NULL != (rc = exit->transmit_queue_head)) |
1012 | { | 1012 | { |
@@ -1015,7 +1015,7 @@ abort_all_requests (struct MeshExit *exit) | |||
1015 | rc); | 1015 | rc); |
1016 | GNUNET_DNS_request_drop (rc->rh); | 1016 | GNUNET_DNS_request_drop (rc->rh); |
1017 | GNUNET_SCHEDULER_cancel (rc->timeout_task); | 1017 | GNUNET_SCHEDULER_cancel (rc->timeout_task); |
1018 | GNUNET_free (rc); | 1018 | GNUNET_free (rc); |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | 1021 | ||
@@ -1093,7 +1093,7 @@ cleanup (void *cls, | |||
1093 | /** | 1093 | /** |
1094 | * Function called whenever a tunnel is destroyed. Should clean up | 1094 | * Function called whenever a tunnel 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_tunnel_destroy on the tunnel. |
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) |
@@ -1103,12 +1103,12 @@ cleanup (void *cls, | |||
1103 | */ | 1103 | */ |
1104 | static void | 1104 | static void |
1105 | mesh_tunnel_end_cb (void *cls, | 1105 | mesh_tunnel_end_cb (void *cls, |
1106 | const struct GNUNET_MESH_Tunnel *tunnel, | 1106 | const struct GNUNET_MESH_Tunnel *tunnel, |
1107 | void *tunnel_ctx) | 1107 | void *tunnel_ctx) |
1108 | { | 1108 | { |
1109 | struct MeshExit *exit = tunnel_ctx; | 1109 | struct MeshExit *exit = tunnel_ctx; |
1110 | struct MeshExit *alt; | 1110 | struct MeshExit *alt; |
1111 | struct RequestContext *rc; | 1111 | struct RequestContext *rc; |
1112 | 1112 | ||
1113 | if (NULL != exit->mesh_th) | 1113 | if (NULL != exit->mesh_th) |
1114 | { | 1114 | { |
@@ -1149,7 +1149,7 @@ mesh_tunnel_end_cb (void *cls, | |||
1149 | else | 1149 | else |
1150 | { | 1150 | { |
1151 | /* the same peer was chosen, just make sure the queue processing is restarted */ | 1151 | /* the same peer was chosen, just make sure the queue processing is restarted */ |
1152 | alt = exit; | 1152 | alt = exit; |
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)) ) |
@@ -1163,7 +1163,7 @@ mesh_tunnel_end_cb (void *cls, | |||
1163 | 1163 | ||
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 tunnel, |
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. |
@@ -1185,7 +1185,7 @@ static void | |||
1185 | handle_dht_result (void *cls, | 1185 | handle_dht_result (void *cls, |
1186 | struct GNUNET_TIME_Absolute exp, | 1186 | struct GNUNET_TIME_Absolute exp, |
1187 | const struct GNUNET_HashCode *key, | 1187 | const struct GNUNET_HashCode *key, |
1188 | const struct GNUNET_PeerIdentity *get_path, | 1188 | const struct GNUNET_PeerIdentity *get_path, |
1189 | unsigned int get_path_length, | 1189 | unsigned int get_path_length, |
1190 | const struct GNUNET_PeerIdentity *put_path, | 1190 | const struct GNUNET_PeerIdentity *put_path, |
1191 | unsigned int put_path_length, | 1191 | unsigned int put_path_length, |
@@ -1201,7 +1201,7 @@ handle_dht_result (void *cls, | |||
1201 | return; | 1201 | return; |
1202 | } | 1202 | } |
1203 | ad = data; | 1203 | ad = data; |
1204 | for (exit = exit_head; NULL != exit; exit = exit->next) | 1204 | for (exit = exit_head; NULL != exit; exit = exit->next) |
1205 | if (0 == memcmp (&ad->peer, | 1205 | if (0 == memcmp (&ad->peer, |
1206 | &exit->peer, | 1206 | &exit->peer, |
1207 | sizeof (struct GNUNET_PeerIdentity))) | 1207 | sizeof (struct GNUNET_PeerIdentity))) |
@@ -1240,23 +1240,23 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1240 | cfg = cfg_; | 1240 | cfg = cfg_; |
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_tunnel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS"); |
1245 | if (! (ipv4_pt || ipv6_pt || dns_tunnel)) | 1245 | if (! (ipv4_pt || ipv6_pt || dns_tunnel)) |
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")); |
1249 | GNUNET_SCHEDULER_shutdown (); | 1249 | GNUNET_SCHEDULER_shutdown (); |
1250 | return; | 1250 | return; |
1251 | } | 1251 | } |
1252 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 1252 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); |
1253 | if (ipv4_pt || ipv6_pt) | 1253 | if (ipv4_pt || ipv6_pt) |
1254 | { | 1254 | { |
1255 | dns_post_handle | 1255 | dns_post_handle |
1256 | = GNUNET_DNS_connect (cfg, | 1256 | = GNUNET_DNS_connect (cfg, |
1257 | GNUNET_DNS_FLAG_POST_RESOLUTION, | 1257 | GNUNET_DNS_FLAG_POST_RESOLUTION, |
1258 | &dns_post_request_handler, NULL); | 1258 | &dns_post_request_handler, NULL); |
1259 | if (NULL == dns_post_handle) | 1259 | if (NULL == dns_post_handle) |
1260 | { | 1260 | { |
1261 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1261 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1262 | _("Failed to connect to %s service. Exiting.\n"), | 1262 | _("Failed to connect to %s service. Exiting.\n"), |
@@ -1281,11 +1281,11 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1281 | {NULL, 0, 0} | 1281 | {NULL, 0, 0} |
1282 | }; | 1282 | }; |
1283 | 1283 | ||
1284 | dns_pre_handle | 1284 | dns_pre_handle |
1285 | = GNUNET_DNS_connect (cfg, | 1285 | = GNUNET_DNS_connect (cfg, |
1286 | GNUNET_DNS_FLAG_PRE_RESOLUTION, | 1286 | GNUNET_DNS_FLAG_PRE_RESOLUTION, |
1287 | &dns_pre_request_handler, NULL); | 1287 | &dns_pre_request_handler, NULL); |
1288 | if (NULL == dns_pre_handle) | 1288 | if (NULL == dns_pre_handle) |
1289 | { | 1289 | { |
1290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1291 | _("Failed to connect to %s service. Exiting.\n"), | 1291 | _("Failed to connect to %s service. Exiting.\n"), |