diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 4fe4d94cf..6327d744f 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -82,7 +82,7 @@ struct PrettyPrinterContext | |||
82 | * DLL | 82 | * DLL |
83 | */ | 83 | */ |
84 | struct PrettyPrinterContext *next; | 84 | struct PrettyPrinterContext *next; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * DLL | 87 | * DLL |
88 | */ | 88 | */ |
@@ -502,7 +502,7 @@ schedule_select (struct Plugin *plugin) | |||
502 | for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next) | 502 | for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next) |
503 | min_delay = GNUNET_TIME_relative_min (min_delay, | 503 | min_delay = GNUNET_TIME_relative_min (min_delay, |
504 | GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); | 504 | GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); |
505 | 505 | ||
506 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) | 506 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) |
507 | GNUNET_SCHEDULER_cancel(plugin->select_task); | 507 | GNUNET_SCHEDULER_cancel(plugin->select_task); |
508 | 508 | ||
@@ -514,7 +514,7 @@ schedule_select (struct Plugin *plugin) | |||
514 | (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, | 514 | (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, |
515 | plugin->rs_v4, | 515 | plugin->rs_v4, |
516 | (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, | 516 | (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, |
517 | &udp_plugin_select, plugin); | 517 | &udp_plugin_select, plugin); |
518 | } | 518 | } |
519 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) | 519 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) |
520 | { | 520 | { |
@@ -522,7 +522,7 @@ schedule_select (struct Plugin *plugin) | |||
522 | for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) | 522 | for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) |
523 | min_delay = GNUNET_TIME_relative_min (min_delay, | 523 | min_delay = GNUNET_TIME_relative_min (min_delay, |
524 | GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); | 524 | GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); |
525 | 525 | ||
526 | if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task_v6) | 526 | if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task_v6) |
527 | GNUNET_SCHEDULER_cancel(plugin->select_task_v6); | 527 | GNUNET_SCHEDULER_cancel(plugin->select_task_v6); |
528 | plugin->select_task_v6 = | 528 | plugin->select_task_v6 = |
@@ -589,7 +589,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
589 | } | 589 | } |
590 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); | 590 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); |
591 | 591 | ||
592 | GNUNET_snprintf (rbuf, sizeof (rbuf), | 592 | GNUNET_snprintf (rbuf, sizeof (rbuf), |
593 | (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u", | 593 | (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u", |
594 | PLUGIN_NAME, options, buf, port); | 594 | PLUGIN_NAME, options, buf, port); |
595 | return rbuf; | 595 | return rbuf; |
@@ -1150,11 +1150,11 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1150 | struct UDP_MessageWrapper dummy; | 1150 | struct UDP_MessageWrapper dummy; |
1151 | struct Session *s = fc->session; | 1151 | struct Session *s = fc->session; |
1152 | 1152 | ||
1153 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1153 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1154 | "%p : Fragmented message removed with result %s\n", | 1154 | "%p : Fragmented message removed with result %s\n", |
1155 | fc, | 1155 | fc, |
1156 | (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS"); | 1156 | (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS"); |
1157 | 1157 | ||
1158 | /* Call continuation for fragmented message */ | 1158 | /* Call continuation for fragmented message */ |
1159 | memset (&dummy, 0, sizeof (dummy)); | 1159 | memset (&dummy, 0, sizeof (dummy)); |
1160 | dummy.msg_type = MSG_FRAGMENTED_COMPLETE; | 1160 | dummy.msg_type = MSG_FRAGMENTED_COMPLETE; |
@@ -1376,7 +1376,7 @@ reschedule_session_timeout (struct Session *s) | |||
1376 | s); | 1376 | s); |
1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1378 | "Timeout rescheduled for session %p set to %s\n", | 1378 | "Timeout rescheduled for session %p set to %s\n", |
1379 | s, | 1379 | s, |
1380 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1380 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1381 | GNUNET_YES)); | 1381 | GNUNET_YES)); |
1382 | } | 1382 | } |
@@ -1478,7 +1478,7 @@ session_cmp_it (void *cls, | |||
1478 | 1478 | ||
1479 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1479 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1480 | "Comparing address %s <-> %s\n", | 1480 | "Comparing address %s <-> %s\n", |
1481 | udp_address_to_string (NULL, (void *) address->address, | 1481 | udp_address_to_string (NULL, (void *) address->address, |
1482 | address->address_length), | 1482 | address->address_length), |
1483 | GNUNET_a2s (s->sock_addr, s->addrlen)); | 1483 | GNUNET_a2s (s->sock_addr, s->addrlen)); |
1484 | if (s->inbound != cctx->inbound) | 1484 | if (s->inbound != cctx->inbound) |
@@ -1524,7 +1524,7 @@ session_cmp_it (void *cls, | |||
1524 | * @return the network type in HBO or GNUNET_SYSERR | 1524 | * @return the network type in HBO or GNUNET_SYSERR |
1525 | */ | 1525 | */ |
1526 | static enum GNUNET_ATS_Network_Type | 1526 | static enum GNUNET_ATS_Network_Type |
1527 | udp_get_network (void *cls, | 1527 | udp_get_network (void *cls, |
1528 | struct Session *session) | 1528 | struct Session *session) |
1529 | { | 1529 | { |
1530 | return ntohl (session->ats.value); | 1530 | return ntohl (session->ats.value); |
@@ -1589,8 +1589,8 @@ udp_plugin_lookup_session (void *cls, | |||
1589 | cctx.res = NULL; | 1589 | cctx.res = NULL; |
1590 | cctx.inbound = inbound; | 1590 | cctx.inbound = inbound; |
1591 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1591 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1592 | "Looking for existing session for peer `%s' `%s' \n", | 1592 | "Looking for existing session for peer `%s' `%s' \n", |
1593 | GNUNET_i2s (&address->peer), | 1593 | GNUNET_i2s (&address->peer), |
1594 | udp_address_to_string(NULL, address->address, address->address_length)); | 1594 | udp_address_to_string(NULL, address->address, address->address_length)); |
1595 | GNUNET_CONTAINER_multipeermap_get_multiple(plugin->sessions, &address->peer, session_cmp_it, &cctx); | 1595 | GNUNET_CONTAINER_multipeermap_get_multiple(plugin->sessions, &address->peer, session_cmp_it, &cctx); |
1596 | if (cctx.res != NULL) | 1596 | if (cctx.res != NULL) |
@@ -1666,7 +1666,7 @@ udp_plugin_get_session (void *cls, | |||
1666 | } | 1666 | } |
1667 | 1667 | ||
1668 | 1668 | ||
1669 | static void | 1669 | static void |
1670 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 1670 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) |
1671 | { | 1671 | { |
1672 | if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) | 1672 | if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) |
@@ -1708,7 +1708,7 @@ send_next_fragment (void *cls, | |||
1708 | { | 1708 | { |
1709 | struct UDP_MessageWrapper *udpw = cls; | 1709 | struct UDP_MessageWrapper *udpw = cls; |
1710 | 1710 | ||
1711 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); | 1711 | GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | 1714 | ||
@@ -1728,8 +1728,8 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1728 | struct Plugin *plugin = frag_ctx->plugin; | 1728 | struct Plugin *plugin = frag_ctx->plugin; |
1729 | struct UDP_MessageWrapper * udpw; | 1729 | struct UDP_MessageWrapper * udpw; |
1730 | size_t msg_len = ntohs (msg->size); | 1730 | size_t msg_len = ntohs (msg->size); |
1731 | 1731 | ||
1732 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1732 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1733 | "Enqueuing fragment with %u bytes\n", msg_len); | 1733 | "Enqueuing fragment with %u bytes\n", msg_len); |
1734 | frag_ctx->fragments_used ++; | 1734 | frag_ctx->fragments_used ++; |
1735 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); | 1735 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); |
@@ -1862,11 +1862,11 @@ udp_plugin_send (void *cls, | |||
1862 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, | 1862 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, |
1863 | UDP_MTU, | 1863 | UDP_MTU, |
1864 | &plugin->tracker, | 1864 | &plugin->tracker, |
1865 | s->last_expected_msg_delay, | 1865 | s->last_expected_msg_delay, |
1866 | s->last_expected_ack_delay, | 1866 | s->last_expected_ack_delay, |
1867 | &udp->header, | 1867 | &udp->header, |
1868 | &enqueue_fragment, | 1868 | &enqueue_fragment, |
1869 | frag_ctx); | 1869 | frag_ctx); |
1870 | s->frag_ctx = frag_ctx; | 1870 | s->frag_ctx = frag_ctx; |
1871 | GNUNET_STATISTICS_update (plugin->env->stats, | 1871 | GNUNET_STATISTICS_update (plugin->env->stats, |
1872 | "# UDP, fragmented msgs, messages, pending", | 1872 | "# UDP, fragmented msgs, messages, pending", |
@@ -2138,8 +2138,8 @@ struct LookupContext | |||
2138 | 2138 | ||
2139 | 2139 | ||
2140 | static int | 2140 | static int |
2141 | lookup_session_by_addr_it (void *cls, | 2141 | lookup_session_by_addr_it (void *cls, |
2142 | const struct GNUNET_PeerIdentity *key, | 2142 | const struct GNUNET_PeerIdentity *key, |
2143 | void *value) | 2143 | void *value) |
2144 | { | 2144 | { |
2145 | struct LookupContext *l_ctx = cls; | 2145 | struct LookupContext *l_ctx = cls; |
@@ -2223,7 +2223,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
2223 | } | 2223 | } |
2224 | 2224 | ||
2225 | 2225 | ||
2226 | static void | 2226 | static void |
2227 | read_process_msg (struct Plugin *plugin, | 2227 | read_process_msg (struct Plugin *plugin, |
2228 | const struct GNUNET_MessageHeader *msg, | 2228 | const struct GNUNET_MessageHeader *msg, |
2229 | const char *addr, | 2229 | const char *addr, |
@@ -2239,7 +2239,7 @@ read_process_msg (struct Plugin *plugin, | |||
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | 2241 | ||
2242 | static void | 2242 | static void |
2243 | read_process_ack (struct Plugin *plugin, | 2243 | read_process_ack (struct Plugin *plugin, |
2244 | const struct GNUNET_MessageHeader *msg, | 2244 | const struct GNUNET_MessageHeader *msg, |
2245 | char *addr, | 2245 | char *addr, |
@@ -2273,7 +2273,7 @@ read_process_ack (struct Plugin *plugin, | |||
2273 | 2273 | ||
2274 | 2274 | ||
2275 | flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); | 2275 | flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); |
2276 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2276 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2277 | "We received a sending delay of %s\n", | 2277 | "We received a sending delay of %s\n", |
2278 | GNUNET_STRINGS_relative_time_to_string (flow_delay, | 2278 | GNUNET_STRINGS_relative_time_to_string (flow_delay, |
2279 | GNUNET_YES)); | 2279 | GNUNET_YES)); |
@@ -2310,7 +2310,7 @@ read_process_ack (struct Plugin *plugin, | |||
2310 | } | 2310 | } |
2311 | 2311 | ||
2312 | 2312 | ||
2313 | static void | 2313 | static void |
2314 | read_process_fragment (struct Plugin *plugin, | 2314 | read_process_fragment (struct Plugin *plugin, |
2315 | const struct GNUNET_MessageHeader *msg, | 2315 | const struct GNUNET_MessageHeader *msg, |
2316 | char *addr, | 2316 | char *addr, |
@@ -2350,7 +2350,7 @@ read_process_fragment (struct Plugin *plugin, | |||
2350 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, | 2350 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, |
2351 | (GNUNET_CONTAINER_HeapCostType) | 2351 | (GNUNET_CONTAINER_HeapCostType) |
2352 | now.abs_value_us); | 2352 | now.abs_value_us); |
2353 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2353 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2354 | "Created new defragmentation context for %u-byte fragment from `%s'\n", | 2354 | "Created new defragmentation context for %u-byte fragment from `%s'\n", |
2355 | (unsigned int) ntohs (msg->size), | 2355 | (unsigned int) ntohs (msg->size), |
2356 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2356 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
@@ -2571,7 +2571,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2571 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) | 2571 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) |
2572 | { | 2572 | { |
2573 | /* this message is not delayed */ | 2573 | /* this message is not delayed */ |
2574 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2574 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2575 | "Message for peer `%s' (%u bytes) is not delayed \n", | 2575 | "Message for peer `%s' (%u bytes) is not delayed \n", |
2576 | GNUNET_i2s(&udpw->session->target), udpw->payload_size); | 2576 | GNUNET_i2s(&udpw->session->target), udpw->payload_size); |
2577 | break; /* Found message to send, break */ | 2577 | break; /* Found message to send, break */ |
@@ -2581,7 +2581,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2581 | /* Message is delayed, try next */ | 2581 | /* Message is delayed, try next */ |
2582 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2582 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2583 | "Message for peer `%s' (%u bytes) is delayed for %s\n", | 2583 | "Message for peer `%s' (%u bytes) is delayed for %s\n", |
2584 | GNUNET_i2s(&udpw->session->target), udpw->payload_size, | 2584 | GNUNET_i2s(&udpw->session->target), udpw->payload_size, |
2585 | GNUNET_STRINGS_relative_time_to_string (remaining, | 2585 | GNUNET_STRINGS_relative_time_to_string (remaining, |
2586 | GNUNET_YES)); | 2586 | GNUNET_YES)); |
2587 | udpw = udpw->next; | 2587 | udpw = udpw->next; |
@@ -2719,10 +2719,10 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2719 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)) ) | 2719 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)) ) |
2720 | udp_select_read (plugin, plugin->sockv4); | 2720 | udp_select_read (plugin, plugin->sockv4); |
2721 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && | 2721 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && |
2722 | (NULL != plugin->sockv4) && | 2722 | (NULL != plugin->sockv4) && |
2723 | (NULL != plugin->ipv4_queue_head) && | 2723 | (NULL != plugin->ipv4_queue_head) && |
2724 | (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv4)) ) | 2724 | (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv4)) ) |
2725 | udp_select_send (plugin, plugin->sockv4); | 2725 | udp_select_send (plugin, plugin->sockv4); |
2726 | schedule_select (plugin); | 2726 | schedule_select (plugin); |
2727 | } | 2727 | } |
2728 | 2728 | ||
@@ -2749,7 +2749,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2749 | udp_select_read (plugin, plugin->sockv6); | 2749 | udp_select_read (plugin, plugin->sockv6); |
2750 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && | 2750 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && |
2751 | (NULL != plugin->sockv6) && (plugin->ipv6_queue_head != NULL) && | 2751 | (NULL != plugin->sockv6) && (plugin->ipv6_queue_head != NULL) && |
2752 | (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) ) | 2752 | (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) ) |
2753 | udp_select_send (plugin, plugin->sockv6); | 2753 | udp_select_send (plugin, plugin->sockv6); |
2754 | schedule_select (plugin); | 2754 | schedule_select (plugin); |
2755 | } | 2755 | } |
@@ -2760,7 +2760,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2760 | * @return number of sockets that were successfully bound | 2760 | * @return number of sockets that were successfully bound |
2761 | */ | 2761 | */ |
2762 | static int | 2762 | static int |
2763 | setup_sockets (struct Plugin *plugin, | 2763 | setup_sockets (struct Plugin *plugin, |
2764 | const struct sockaddr_in6 *bind_v6, | 2764 | const struct sockaddr_in6 *bind_v6, |
2765 | const struct sockaddr_in *bind_v4) | 2765 | const struct sockaddr_in *bind_v4) |
2766 | { | 2766 | { |
@@ -2869,23 +2869,23 @@ setup_sockets (struct Plugin *plugin, | |||
2869 | serverAddrv4.sin_addr = bind_v4->sin_addr; | 2869 | serverAddrv4.sin_addr = bind_v4->sin_addr; |
2870 | else | 2870 | else |
2871 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; | 2871 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; |
2872 | 2872 | ||
2873 | if (0 == plugin->port) | 2873 | if (0 == plugin->port) |
2874 | /* autodetect */ | 2874 | /* autodetect */ |
2875 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); | 2875 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
2876 | else | 2876 | else |
2877 | serverAddrv4.sin_port = htons (plugin->port); | 2877 | serverAddrv4.sin_port = htons (plugin->port); |
2878 | 2878 | ||
2879 | 2879 | ||
2880 | addrlen = sizeof (struct sockaddr_in); | 2880 | addrlen = sizeof (struct sockaddr_in); |
2881 | serverAddr = (struct sockaddr *) &serverAddrv4; | 2881 | serverAddr = (struct sockaddr *) &serverAddrv4; |
2882 | 2882 | ||
2883 | tries = 0; | 2883 | tries = 0; |
2884 | while (tries < 10) | 2884 | while (tries < 10) |
2885 | { | 2885 | { |
2886 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", | 2886 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", |
2887 | GNUNET_a2s (serverAddr, addrlen)); | 2887 | GNUNET_a2s (serverAddr, addrlen)); |
2888 | 2888 | ||
2889 | /* binding */ | 2889 | /* binding */ |
2890 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, | 2890 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, |
2891 | serverAddr, addrlen, 0)) | 2891 | serverAddr, addrlen, 0)) |
@@ -2896,19 +2896,19 @@ setup_sockets (struct Plugin *plugin, | |||
2896 | tries = 10; /* fail */ | 2896 | tries = 10; /* fail */ |
2897 | break; /* bind failed on specific port */ | 2897 | break; /* bind failed on specific port */ |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | /* autodetect */ | 2900 | /* autodetect */ |
2901 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); | 2901 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
2902 | tries ++; | 2902 | tries ++; |
2903 | } | 2903 | } |
2904 | 2904 | ||
2905 | if (tries >= 10) | 2905 | if (tries >= 10) |
2906 | { | 2906 | { |
2907 | GNUNET_NETWORK_socket_close (plugin->sockv4); | 2907 | GNUNET_NETWORK_socket_close (plugin->sockv4); |
2908 | plugin->enable_ipv4 = GNUNET_NO; | 2908 | plugin->enable_ipv4 = GNUNET_NO; |
2909 | plugin->sockv4 = NULL; | 2909 | plugin->sockv4 = NULL; |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | if (plugin->sockv4 != NULL) | 2912 | if (plugin->sockv4 != NULL) |
2913 | { | 2913 | { |
2914 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2914 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2918,13 +2918,13 @@ setup_sockets (struct Plugin *plugin, | |||
2918 | sockets_created++; | 2918 | sockets_created++; |
2919 | } | 2919 | } |
2920 | else | 2920 | else |
2921 | { | 2921 | { |
2922 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2922 | LOG (GNUNET_ERROR_TYPE_ERROR, |
2923 | "Failed to bind UDP socket to %s: %s\n", | 2923 | "Failed to bind UDP socket to %s: %s\n", |
2924 | GNUNET_a2s (serverAddr, addrlen), STRERROR (eno)); | 2924 | GNUNET_a2s (serverAddr, addrlen), STRERROR (eno)); |
2925 | } | 2925 | } |
2926 | } | 2926 | } |
2927 | 2927 | ||
2928 | if (0 == sockets_created) | 2928 | if (0 == sockets_created) |
2929 | { | 2929 | { |
2930 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); | 2930 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); |