diff options
Diffstat (limited to 'src/transport/gnunet-communicator-udp.c')
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 1c2063d58..6193b9225 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1043,7 +1043,7 @@ check_timeouts (void *cls) | |||
1043 | st = GNUNET_TIME_UNIT_FOREVER_REL; | 1043 | st = GNUNET_TIME_UNIT_FOREVER_REL; |
1044 | while (NULL != (sender = GNUNET_CONTAINER_heap_peek (senders_heap))) | 1044 | while (NULL != (sender = GNUNET_CONTAINER_heap_peek (senders_heap))) |
1045 | { | 1045 | { |
1046 | st = GNUNET_TIME_absolute_get_remaining (receiver->timeout); | 1046 | st = GNUNET_TIME_absolute_get_remaining (sender->timeout); |
1047 | if (0 != st.rel_value_us) | 1047 | if (0 != st.rel_value_us) |
1048 | break; | 1048 | break; |
1049 | sender_destroy (sender); | 1049 | sender_destroy (sender); |
@@ -2113,51 +2113,6 @@ setup_receiver_mq (struct ReceiverAddress *receiver) | |||
2113 | 2113 | ||
2114 | 2114 | ||
2115 | /** | 2115 | /** |
2116 | * Setup a receiver for transmission. Setup the MQ processing and | ||
2117 | * inform transport that the queue is ready. | ||
2118 | * | ||
2119 | * @param target which peer are we talking to | ||
2120 | * @param address address of the peer | ||
2121 | * @param address_len number of bytes in @a address | ||
2122 | * @return handle for the address | ||
2123 | */ | ||
2124 | static struct ReceiverAddress * | ||
2125 | receiver_setup (const struct GNUNET_PeerIdentity *target, | ||
2126 | const struct sockaddr *address, | ||
2127 | socklen_t address_len) | ||
2128 | { | ||
2129 | struct ReceiverAddress *receiver; | ||
2130 | |||
2131 | receiver = GNUNET_new (struct ReceiverAddress); | ||
2132 | receiver->address = GNUNET_memdup (address, address_len); | ||
2133 | receiver->address_len = address_len; | ||
2134 | receiver->target = *target; | ||
2135 | receiver->nt = GNUNET_NT_scanner_get_type (is, address, address_len); | ||
2136 | (void) GNUNET_CONTAINER_multipeermap_put ( | ||
2137 | receivers, | ||
2138 | &receiver->target, | ||
2139 | receiver, | ||
2140 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
2141 | receiver->timeout = | ||
2142 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
2143 | receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap, | ||
2144 | receiver, | ||
2145 | receiver->timeout.abs_value_us); | ||
2146 | GNUNET_STATISTICS_set (stats, | ||
2147 | "# receivers active", | ||
2148 | GNUNET_CONTAINER_multipeermap_size (receivers), | ||
2149 | GNUNET_NO); | ||
2150 | receiver->foreign_addr = | ||
2151 | sockaddr_to_udpaddr_string (receiver->address, receiver->address_len); | ||
2152 | setup_receiver_mq (receiver); | ||
2153 | |||
2154 | if (NULL == timeout_task) | ||
2155 | timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL); | ||
2156 | return receiver; | ||
2157 | } | ||
2158 | |||
2159 | |||
2160 | /** | ||
2161 | * Function called by the transport service to initialize a | 2116 | * Function called by the transport service to initialize a |
2162 | * message queue given address information about another peer. | 2117 | * message queue given address information about another peer. |
2163 | * If and when the communication channel is established, the | 2118 | * If and when the communication channel is established, the |
@@ -2192,8 +2147,30 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2192 | } | 2147 | } |
2193 | path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; | 2148 | path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; |
2194 | in = udp_address_to_sockaddr (path, &in_len); | 2149 | in = udp_address_to_sockaddr (path, &in_len); |
2195 | receiver = receiver_setup (peer, in, in_len); | 2150 | |
2196 | (void) receiver; | 2151 | receiver = GNUNET_new (struct ReceiverAddress); |
2152 | receiver->address = in; | ||
2153 | receiver->address_len = in_len; | ||
2154 | receiver->target = *peer; | ||
2155 | receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len); | ||
2156 | (void) GNUNET_CONTAINER_multipeermap_put (receivers, | ||
2157 | &receiver->target, | ||
2158 | receiver, | ||
2159 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
2160 | receiver->timeout = | ||
2161 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
2162 | receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap, | ||
2163 | receiver, | ||
2164 | receiver->timeout.abs_value_us); | ||
2165 | GNUNET_STATISTICS_set (stats, | ||
2166 | "# receivers active", | ||
2167 | GNUNET_CONTAINER_multipeermap_size (receivers), | ||
2168 | GNUNET_NO); | ||
2169 | receiver->foreign_addr = | ||
2170 | sockaddr_to_udpaddr_string (receiver->address, receiver->address_len); | ||
2171 | setup_receiver_mq (receiver); | ||
2172 | if (NULL == timeout_task) | ||
2173 | timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL); | ||
2197 | return GNUNET_OK; | 2174 | return GNUNET_OK; |
2198 | } | 2175 | } |
2199 | 2176 | ||
@@ -2489,14 +2466,14 @@ iface_proc (void *cls, | |||
2489 | 2466 | ||
2490 | (void) cls; | 2467 | (void) cls; |
2491 | (void) netmask; | 2468 | (void) netmask; |
2469 | if (NULL == addr) | ||
2470 | return GNUNET_YES; /* need to know our address! */ | ||
2492 | network = GNUNET_NT_scanner_get_type (is, addr, addrlen); | 2471 | network = GNUNET_NT_scanner_get_type (is, addr, addrlen); |
2493 | if (GNUNET_NT_LOOPBACK == network) | 2472 | if (GNUNET_NT_LOOPBACK == network) |
2494 | { | 2473 | { |
2495 | /* Broadcasting on loopback does not make sense */ | 2474 | /* Broadcasting on loopback does not make sense */ |
2496 | return GNUNET_YES; | 2475 | return GNUNET_YES; |
2497 | } | 2476 | } |
2498 | if (NULL == addr) | ||
2499 | return GNUNET_YES; /* need to know our address! */ | ||
2500 | for (bi = bi_head; NULL != bi; bi = bi->next) | 2477 | for (bi = bi_head; NULL != bi; bi = bi->next) |
2501 | { | 2478 | { |
2502 | if ((bi->salen == addrlen) && (0 == memcmp (addr, bi->sa, addrlen))) | 2479 | if ((bi->salen == addrlen) && (0 == memcmp (addr, bi->sa, addrlen))) |