diff options
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index da6ee9df8..f689b54c0 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -29,6 +29,7 @@ | |||
29 | */ | 29 | */ |
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_client_lib.h" | 31 | #include "gnunet_client_lib.h" |
32 | #include "gnunet_constants.h" | ||
32 | #include "gnunet_getopt_lib.h" | 33 | #include "gnunet_getopt_lib.h" |
33 | #include "gnunet_hello_lib.h" | 34 | #include "gnunet_hello_lib.h" |
34 | #include "gnunet_os_lib.h" | 35 | #include "gnunet_os_lib.h" |
@@ -82,12 +83,6 @@ | |||
82 | */ | 83 | */ |
83 | #define HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12) | 84 | #define HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 12) |
84 | 85 | ||
85 | /** | ||
86 | * After how long do we consider a connection to a peer dead | ||
87 | * if we don't receive messages from the peer? | ||
88 | */ | ||
89 | #define IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | ||
90 | |||
91 | 86 | ||
92 | /** | 87 | /** |
93 | * Entry in linked list of network addresses. | 88 | * Entry in linked list of network addresses. |
@@ -356,7 +351,7 @@ struct NeighbourList | |||
356 | uint64_t last_received; | 351 | uint64_t last_received; |
357 | 352 | ||
358 | /** | 353 | /** |
359 | * Global quota for outbound traffic for the neighbour in bytes/ms. | 354 | * Global quota for inbound traffic for the neighbour in bytes/ms. |
360 | */ | 355 | */ |
361 | uint32_t quota_in; | 356 | uint32_t quota_in; |
362 | 357 | ||
@@ -641,16 +636,6 @@ static struct GNUNET_SERVER_Handle *server; | |||
641 | static struct NeighbourList *neighbours; | 636 | static struct NeighbourList *neighbours; |
642 | 637 | ||
643 | /** | 638 | /** |
644 | * Default bandwidth quota for receiving for new peers in bytes/ms. | ||
645 | */ | ||
646 | static uint32_t default_quota_in; | ||
647 | |||
648 | /** | ||
649 | * Default bandwidth quota for sending for new peers in bytes/ms. | ||
650 | */ | ||
651 | static uint32_t default_quota_out; | ||
652 | |||
653 | /** | ||
654 | * Number of neighbours we'd like to have. | 639 | * Number of neighbours we'd like to have. |
655 | */ | 640 | */ |
656 | static uint32_t max_connect_per_transport; | 641 | static uint32_t max_connect_per_transport; |
@@ -930,7 +915,7 @@ transmit_send_continuation (void *cls, | |||
930 | } | 915 | } |
931 | if (result == GNUNET_OK) | 916 | if (result == GNUNET_OK) |
932 | { | 917 | { |
933 | rl->timeout = GNUNET_TIME_relative_to_absolute (IDLE_CONNECTION_TIMEOUT); | 918 | rl->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
934 | } | 919 | } |
935 | else | 920 | else |
936 | { | 921 | { |
@@ -1139,7 +1124,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour) | |||
1139 | rl, | 1124 | rl, |
1140 | &neighbour->id, | 1125 | &neighbour->id, |
1141 | mq->message, | 1126 | mq->message, |
1142 | IDLE_CONNECTION_TIMEOUT, | 1127 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1143 | &transmit_send_continuation, mq); | 1128 | &transmit_send_continuation, mq); |
1144 | } | 1129 | } |
1145 | 1130 | ||
@@ -1510,7 +1495,7 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
1510 | #endif | 1495 | #endif |
1511 | cim.header.size = htons (sizeof (struct ConnectInfoMessage)); | 1496 | cim.header.size = htons (sizeof (struct ConnectInfoMessage)); |
1512 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 1497 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
1513 | cim.quota_out = htonl (default_quota_out); | 1498 | cim.quota_out = htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60*1000)); |
1514 | cim.latency = GNUNET_TIME_relative_hton (latency); | 1499 | cim.latency = GNUNET_TIME_relative_hton (latency); |
1515 | memcpy (&cim.id, peer, sizeof (struct GNUNET_PeerIdentity)); | 1500 | memcpy (&cim.id, peer, sizeof (struct GNUNET_PeerIdentity)); |
1516 | cpos = clients; | 1501 | cpos = clients; |
@@ -2196,15 +2181,15 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer) | |||
2196 | n->id = *peer; | 2181 | n->id = *peer; |
2197 | n->last_quota_update = GNUNET_TIME_absolute_get (); | 2182 | n->last_quota_update = GNUNET_TIME_absolute_get (); |
2198 | n->peer_timeout = | 2183 | n->peer_timeout = |
2199 | GNUNET_TIME_relative_to_absolute (IDLE_CONNECTION_TIMEOUT); | 2184 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2200 | n->quota_in = default_quota_in; | 2185 | n->quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); |
2201 | add_plugins (n); | 2186 | add_plugins (n); |
2202 | n->hello_version_sent = our_hello_version; | 2187 | n->hello_version_sent = our_hello_version; |
2203 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, | 2188 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, |
2204 | GNUNET_NO, | 2189 | GNUNET_NO, |
2205 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 2190 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
2206 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, | 2191 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, |
2207 | IDLE_CONNECTION_TIMEOUT, | 2192 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
2208 | &neighbour_timeout_task, n); | 2193 | &neighbour_timeout_task, n); |
2209 | transmit_to_peer (NULL, | 2194 | transmit_to_peer (NULL, |
2210 | (const struct GNUNET_MessageHeader *) our_hello, | 2195 | (const struct GNUNET_MessageHeader *) our_hello, |
@@ -2297,7 +2282,7 @@ plugin_env_receive (void *cls, | |||
2297 | service_context->connect_attempts++; | 2282 | service_context->connect_attempts++; |
2298 | } | 2283 | } |
2299 | service_context->timeout | 2284 | service_context->timeout |
2300 | = GNUNET_TIME_relative_to_absolute (IDLE_CONNECTION_TIMEOUT); | 2285 | = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2301 | service_context->plugin_handle = plugin_context; | 2286 | service_context->plugin_handle = plugin_context; |
2302 | service_context->latency = latency; | 2287 | service_context->latency = latency; |
2303 | } | 2288 | } |
@@ -2306,12 +2291,12 @@ plugin_env_receive (void *cls, | |||
2306 | n->last_received += msize; | 2291 | n->last_received += msize; |
2307 | GNUNET_SCHEDULER_cancel (sched, n->timeout_task); | 2292 | GNUNET_SCHEDULER_cancel (sched, n->timeout_task); |
2308 | n->peer_timeout = | 2293 | n->peer_timeout = |
2309 | GNUNET_TIME_relative_to_absolute (IDLE_CONNECTION_TIMEOUT); | 2294 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2310 | n->timeout_task = | 2295 | n->timeout_task = |
2311 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, | 2296 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, |
2312 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 2297 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
2313 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, | 2298 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, |
2314 | IDLE_CONNECTION_TIMEOUT, | 2299 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
2315 | &neighbour_timeout_task, n); | 2300 | &neighbour_timeout_task, n); |
2316 | update_quota (n); | 2301 | update_quota (n); |
2317 | if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) | 2302 | if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) |
@@ -2426,7 +2411,7 @@ handle_start (void *cls, | |||
2426 | /* tell new client about all existing connections */ | 2411 | /* tell new client about all existing connections */ |
2427 | cim.header.size = htons (sizeof (struct ConnectInfoMessage)); | 2412 | cim.header.size = htons (sizeof (struct ConnectInfoMessage)); |
2428 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 2413 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
2429 | cim.quota_out = htonl (default_quota_out); | 2414 | cim.quota_out = htonl (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT / (60 * 1000)); |
2430 | cim.latency = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); /* FIXME? */ | 2415 | cim.latency = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); /* FIXME? */ |
2431 | im = GNUNET_malloc (sizeof (struct InboundMessage) + | 2416 | im = GNUNET_malloc (sizeof (struct InboundMessage) + |
2432 | sizeof (struct GNUNET_MessageHeader)); | 2417 | sizeof (struct GNUNET_MessageHeader)); |
@@ -2639,7 +2624,7 @@ create_environment (struct TransportPlugin *plug) | |||
2639 | plug->env.receive = &plugin_env_receive; | 2624 | plug->env.receive = &plugin_env_receive; |
2640 | plug->env.lookup = &plugin_env_lookup_address; | 2625 | plug->env.lookup = &plugin_env_lookup_address; |
2641 | plug->env.notify_address = &plugin_env_notify_address; | 2626 | plug->env.notify_address = &plugin_env_notify_address; |
2642 | plug->env.default_quota_in = default_quota_in; | 2627 | plug->env.default_quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); |
2643 | plug->env.max_connections = max_connect_per_transport; | 2628 | plug->env.max_connections = max_connect_per_transport; |
2644 | } | 2629 | } |
2645 | 2630 | ||
@@ -2738,8 +2723,6 @@ run (void *cls, | |||
2738 | char *plugs; | 2723 | char *plugs; |
2739 | char *pos; | 2724 | char *pos; |
2740 | int no_transports; | 2725 | int no_transports; |
2741 | unsigned long long qin; | ||
2742 | unsigned long long qout; | ||
2743 | unsigned long long tneigh; | 2726 | unsigned long long tneigh; |
2744 | char *keyfile; | 2727 | char *keyfile; |
2745 | 2728 | ||
@@ -2749,16 +2732,6 @@ run (void *cls, | |||
2749 | if ((GNUNET_OK != | 2732 | if ((GNUNET_OK != |
2750 | GNUNET_CONFIGURATION_get_value_number (c, | 2733 | GNUNET_CONFIGURATION_get_value_number (c, |
2751 | "TRANSPORT", | 2734 | "TRANSPORT", |
2752 | "DEFAULT_QUOTA_IN", | ||
2753 | &qin)) || | ||
2754 | (GNUNET_OK != | ||
2755 | GNUNET_CONFIGURATION_get_value_number (c, | ||
2756 | "TRANSPORT", | ||
2757 | "DEFAULT_QUOTA_OUT", | ||
2758 | &qout)) || | ||
2759 | (GNUNET_OK != | ||
2760 | GNUNET_CONFIGURATION_get_value_number (c, | ||
2761 | "TRANSPORT", | ||
2762 | "NEIGHBOUR_LIMIT", | 2735 | "NEIGHBOUR_LIMIT", |
2763 | &tneigh)) || | 2736 | &tneigh)) || |
2764 | (GNUNET_OK != | 2737 | (GNUNET_OK != |
@@ -2773,8 +2746,6 @@ run (void *cls, | |||
2773 | return; | 2746 | return; |
2774 | } | 2747 | } |
2775 | max_connect_per_transport = (uint32_t) tneigh; | 2748 | max_connect_per_transport = (uint32_t) tneigh; |
2776 | default_quota_in = (uint32_t) qin; | ||
2777 | default_quota_out = (uint32_t) qout; | ||
2778 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 2749 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
2779 | GNUNET_free (keyfile); | 2750 | GNUNET_free (keyfile); |
2780 | if (my_private_key == NULL) | 2751 | if (my_private_key == NULL) |