aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-29 20:47:18 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-29 20:47:18 +0000
commit71ea5bd2d05058008e604ffd42993be9c7250e04 (patch)
treea5074671ddfaa9d1621a4182fc95a91a98b3d536 /src/transport
parentb335777fd435142c16eb05e86c8a64a4b1a45447 (diff)
downloadgnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.tar.gz
gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.zip
-fixing indentation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c39
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c2
-rw-r--r--src/transport/gnunet-service-transport_clients.c43
-rw-r--r--src/transport/gnunet-service-transport_hello.c15
-rw-r--r--src/transport/gnunet-service-transport_hello.h4
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c463
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h19
-rw-r--r--src/transport/gnunet-service-transport_plugins.c17
-rw-r--r--src/transport/gnunet-service-transport_validation.c146
-rw-r--r--src/transport/gnunet-service-transport_validation.h18
-rw-r--r--src/transport/gnunet-transport-wlan-helper-dummy.c47
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c1033
-rw-r--r--src/transport/gnunet-transport.c38
-rw-r--r--src/transport/plugin_transport_http.c41
-rw-r--r--src/transport/plugin_transport_http_server.c49
-rw-r--r--src/transport/plugin_transport_udp.c301
-rw-r--r--src/transport/plugin_transport_wlan.c23
-rw-r--r--src/transport/test_quota_compliance.c3
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c10
-rw-r--r--src/transport/test_transport_api_disconnect.c2
-rw-r--r--src/transport/test_transport_api_restart_1peer.c28
-rw-r--r--src/transport/test_transport_api_restart_2peers.c30
-rw-r--r--src/transport/test_transport_api_unreliability.c7
-rw-r--r--src/transport/transport-testing.c90
-rw-r--r--src/transport/transport-testing.h8
-rw-r--r--src/transport/transport.h2
-rw-r--r--src/transport/transport_api_address_lookup.c43
-rw-r--r--src/transport/transport_api_address_to_string.c22
28 files changed, 1264 insertions, 1279 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index b148f289b..d4d8828d0 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -90,7 +90,7 @@ static void
90transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, 90transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
91 const struct GNUNET_ATS_Information *ats, 91 const struct GNUNET_ATS_Information *ats,
92 uint32_t ats_count, 92 uint32_t ats_count,
93 const struct GNUNET_HELLO_Address *address) 93 const struct GNUNET_HELLO_Address *address)
94{ 94{
95 const struct GNUNET_MessageHeader *hello = cls; 95 const struct GNUNET_MessageHeader *hello = cls;
96 96
@@ -136,7 +136,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
136 size_t msg_size = ntohs (message->size); 136 size_t msg_size = ntohs (message->size);
137 size_t size = 137 size_t size =
138 sizeof (struct InboundMessage) + msg_size + 138 sizeof (struct InboundMessage) + msg_size +
139 sizeof (struct GNUNET_ATS_Information) * (ats_count + 1); 139 sizeof (struct GNUNET_ATS_Information) * (ats_count + 1);
140 char buf[size]; 140 char buf[size];
141 struct GNUNET_ATS_Information *ap; 141 struct GNUNET_ATS_Information *ap;
142 142
@@ -168,10 +168,11 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
168 ap = (struct GNUNET_ATS_Information *) &im[1]; 168 ap = (struct GNUNET_ATS_Information *) &im[1];
169 memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); 169 memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
170 ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 170 ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
171 ap[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); 171 ap[ats_count].value =
172 htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
172 memcpy (&ap[ats_count + 1], message, ntohs (message->size)); 173 memcpy (&ap[ats_count + 1], message, ntohs (message->size));
173 174
174 GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count +1 ); 175 GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count + 1);
175 GST_clients_broadcast (&im->header, GNUNET_YES); 176 GST_clients_broadcast (&im->header, GNUNET_YES);
176 177
177 return ret; 178 return ret;
@@ -202,8 +203,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
202 * (plugins that do not support this, can ignore the return value) 203 * (plugins that do not support this, can ignore the return value)
203 */ 204 */
204static struct GNUNET_TIME_Relative 205static struct GNUNET_TIME_Relative
205plugin_env_receive_callback (void *cls, 206plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
206 const struct GNUNET_PeerIdentity *peer,
207 const struct GNUNET_MessageHeader *message, 207 const struct GNUNET_MessageHeader *message,
208 const struct GNUNET_ATS_Information *ats, 208 const struct GNUNET_ATS_Information *ats,
209 uint32_t ats_count, struct Session *session, 209 uint32_t ats_count, struct Session *session,
@@ -237,8 +237,8 @@ plugin_env_receive_callback (void *cls,
237#if DEBUG_TRANSPORT 237#if DEBUG_TRANSPORT
238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
239 "Processing `%s' from `%s'\n", "PING", 239 "Processing `%s' from `%s'\n", "PING",
240 (sender_address != NULL) ? GST_plugins_a2s (&address) 240 (sender_address !=
241 : "<inbound>"); 241 NULL) ? GST_plugins_a2s (&address) : "<inbound>");
242#endif 242#endif
243 GST_validation_handle_ping (peer, message, &address, session); 243 GST_validation_handle_ping (peer, message, &address, session);
244 break; 244 break;
@@ -246,20 +246,22 @@ plugin_env_receive_callback (void *cls,
246#if DEBUG_TRANSPORT 246#if DEBUG_TRANSPORT
247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
248 "Processing `%s' from `%s'\n", "PONG", 248 "Processing `%s' from `%s'\n", "PONG",
249 (sender_address != NULL) ? GST_plugins_a2s (&address) 249 (sender_address !=
250 : "<inbound>"); 250 NULL) ? GST_plugins_a2s (&address) : "<inbound>");
251#endif 251#endif
252 GST_validation_handle_pong (peer, message); 252 GST_validation_handle_pong (peer, message);
253 break; 253 break;
254 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 254 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
255 GST_neighbours_handle_connect (message, peer, &address, session, ats, ats_count); 255 GST_neighbours_handle_connect (message, peer, &address, session, ats,
256 ats_count);
256 break; 257 break;
257 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: 258 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
258 GST_neighbours_handle_connect_ack (message, peer, &address, 259 GST_neighbours_handle_connect_ack (message, peer, &address, session, ats,
259 session, ats, ats_count); 260 ats_count);
260 break; 261 break;
261 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 262 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
262 GST_neighbours_handle_ack (message, peer, &address, session, ats, ats_count); 263 GST_neighbours_handle_ack (message, peer, &address, session, ats,
264 ats_count);
263 break; 265 break;
264 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: 266 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
265 GST_neighbours_handle_disconnect_message (peer, message); 267 GST_neighbours_handle_disconnect_message (peer, message);
@@ -336,7 +338,7 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
336 const char *transport_name = cls; 338 const char *transport_name = cls;
337 struct GNUNET_HELLO_Address address; 339 struct GNUNET_HELLO_Address address;
338 340
339 GNUNET_assert (strlen(transport_name) > 0); 341 GNUNET_assert (strlen (transport_name) > 0);
340#if DEBUG_TRANSPORT 342#if DEBUG_TRANSPORT
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", 343 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
342 session, GNUNET_i2s (peer)); 344 session, GNUNET_i2s (peer));
@@ -369,8 +371,8 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
369 * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer 371 * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer
370 */ 372 */
371static void 373static void
372ats_request_address_change (void *cls, 374ats_request_address_change (void *cls,
373 const struct GNUNET_HELLO_Address *address, 375 const struct GNUNET_HELLO_Address *address,
374 struct Session *session, 376 struct Session *session,
375 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 377 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
376 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 378 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -392,8 +394,7 @@ ats_request_address_change (void *cls,
392 return; 394 return;
393 } 395 }
394 /* will never return GNUNET_YES since connection is to be established */ 396 /* will never return GNUNET_YES since connection is to be established */
395 GST_neighbours_switch_to_address_3way (&address->peer, 397 GST_neighbours_switch_to_address_3way (&address->peer, address, session, ats,
396 address, session, ats,
397 ats_count, bandwidth_in, 398 ats_count, bandwidth_in,
398 bandwidth_out); 399 bandwidth_out);
399} 400}
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index b3edc01db..105f1fcaf 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -556,7 +556,7 @@ static void
556test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, 556test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
557 const struct GNUNET_ATS_Information *ats, 557 const struct GNUNET_ATS_Information *ats,
558 uint32_t ats_count, 558 uint32_t ats_count,
559 const struct GNUNET_HELLO_Address *address) 559 const struct GNUNET_HELLO_Address *address)
560{ 560{
561 struct TestConnectionContext *tcc = cls; 561 struct TestConnectionContext *tcc = cls;
562 struct GST_BlacklistCheck *bc; 562 struct GST_BlacklistCheck *bc;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 2aea7aa7e..da6201d97 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -331,8 +331,8 @@ static void
331notify_client_about_neighbour (void *cls, 331notify_client_about_neighbour (void *cls,
332 const struct GNUNET_PeerIdentity *peer, 332 const struct GNUNET_PeerIdentity *peer,
333 const struct GNUNET_ATS_Information *ats, 333 const struct GNUNET_ATS_Information *ats,
334 uint32_t ats_count, 334 uint32_t ats_count,
335 const struct GNUNET_HELLO_Address *address) 335 const struct GNUNET_HELLO_Address *address)
336{ 336{
337 struct TransportClient *tc = cls; 337 struct TransportClient *tc = cls;
338 struct ConnectInfoMessage *cim; 338 struct ConnectInfoMessage *cim;
@@ -633,8 +633,9 @@ transmit_address_to_client (void *cls, const char *buf)
633 * @param message the resolution request 633 * @param message the resolution request
634 */ 634 */
635static void 635static void
636clients_handle_address_to_string (void *cls, struct GNUNET_SERVER_Client *client, 636clients_handle_address_to_string (void *cls,
637 const struct GNUNET_MessageHeader *message) 637 struct GNUNET_SERVER_Client *client,
638 const struct GNUNET_MessageHeader *message)
638{ 639{
639 const struct AddressLookupMessage *alum; 640 const struct AddressLookupMessage *alum;
640 struct GNUNET_TRANSPORT_PluginFunctions *papi; 641 struct GNUNET_TRANSPORT_PluginFunctions *papi;
@@ -699,34 +700,38 @@ clients_handle_address_to_string (void *cls, struct GNUNET_SERVER_Client *client
699 */ 700 */
700static void 701static void
701output_address (void *cls, const struct GNUNET_PeerIdentity *peer, 702output_address (void *cls, const struct GNUNET_PeerIdentity *peer,
702 const struct GNUNET_ATS_Information *ats, uint32_t ats_count, 703 const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
703 const struct GNUNET_HELLO_Address *address) 704 const struct GNUNET_HELLO_Address *address)
704{ 705{
705 struct GNUNET_SERVER_TransmitContext *tc = cls; 706 struct GNUNET_SERVER_TransmitContext *tc = cls;
706 struct AddressIterateResponseMessage *msg; 707 struct AddressIterateResponseMessage *msg;
707 size_t size; 708 size_t size;
708 size_t tlen; 709 size_t tlen;
709 size_t alen; 710 size_t alen;
710 char * addr; 711 char *addr;
711 712
712 tlen = strlen (address->transport_name) + 1; 713 tlen = strlen (address->transport_name) + 1;
713 alen = address->address_length; 714 alen = address->address_length;
714 size = (sizeof (struct AddressIterateResponseMessage) + alen + tlen); 715 size = (sizeof (struct AddressIterateResponseMessage) + alen + tlen);
715 { 716 {
716 char buf[size]; 717 char buf[size];
717 718
718 msg = (struct AddressIterateResponseMessage*) buf; 719 msg = (struct AddressIterateResponseMessage *) buf;
719 msg->reserved = htonl (0); 720 msg->reserved = htonl (0);
720 msg->peer = *peer; 721 msg->peer = *peer;
721 msg->addrlen = htonl (alen); 722 msg->addrlen = htonl (alen);
722 msg->pluginlen = htonl (tlen); 723 msg->pluginlen = htonl (tlen);
723 addr = (char *) &msg[1]; 724 addr = (char *) &msg[1];
724 memcpy (addr,address->address, alen); 725 memcpy (addr, address->address, alen);
725 memcpy (&addr[alen], address->transport_name, tlen); 726 memcpy (&addr[alen], address->transport_name, tlen);
726 GNUNET_SERVER_transmit_context_append_data (tc, 727 GNUNET_SERVER_transmit_context_append_data (tc,
727 &buf[sizeof(struct GNUNET_MessageHeader)], 728 &buf[sizeof
728 size - sizeof (struct GNUNET_MessageHeader), 729 (struct
729 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); 730 GNUNET_MessageHeader)],
731 size -
732 sizeof (struct
733 GNUNET_MessageHeader),
734 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
730 } 735 }
731} 736}
732 737
@@ -746,7 +751,7 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
746{ 751{
747 static struct GNUNET_PeerIdentity all_zeros; 752 static struct GNUNET_PeerIdentity all_zeros;
748 struct GNUNET_SERVER_TransmitContext *tc; 753 struct GNUNET_SERVER_TransmitContext *tc;
749 struct AddressIterateMessage * msg; 754 struct AddressIterateMessage *msg;
750 struct GNUNET_HELLO_Address *address; 755 struct GNUNET_HELLO_Address *address;
751 756
752 if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE) 757 if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE)
@@ -765,7 +770,7 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
765 if (GNUNET_YES != ntohl (msg->one_shot)) 770 if (GNUNET_YES != ntohl (msg->one_shot))
766 { 771 {
767 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 772 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
768 "Address monitoring not implemented\n"); 773 "Address monitoring not implemented\n");
769 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 774 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
770 return; 775 return;
771 } 776 }
@@ -779,12 +784,12 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
779 else 784 else
780 { 785 {
781 /* just return one neighbour */ 786 /* just return one neighbour */
782 address = GST_neighbour_get_current_address(&msg->peer); 787 address = GST_neighbour_get_current_address (&msg->peer);
783 if (address != NULL) 788 if (address != NULL)
784 output_address (tc, &msg->peer, NULL, 0, address); 789 output_address (tc, &msg->peer, NULL, 0, address);
785 } 790 }
786 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, 791 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
787 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); 792 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
788 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); 793 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
789} 794}
790 795
@@ -809,7 +814,7 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server)
809 sizeof (struct TransportRequestConnectMessage)}, 814 sizeof (struct TransportRequestConnectMessage)},
810 {&clients_handle_address_to_string, NULL, 815 {&clients_handle_address_to_string, NULL,
811 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, 816 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0},
812 {&clients_handle_address_iterate, NULL, 817 {&clients_handle_address_iterate, NULL,
813 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE, 818 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE,
814 sizeof (struct AddressIterateMessage)}, 819 sizeof (struct AddressIterateMessage)},
815 {&GST_blacklist_handle_init, NULL, 820 {&GST_blacklist_handle_init, NULL,
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index 8b38a673e..120f17668 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -138,8 +138,8 @@ address_generator (void *cls, size_t max, void *buf)
138 if (NULL == gc->addr_pos) 138 if (NULL == gc->addr_pos)
139 return 0; 139 return 0;
140 ret = 140 ret =
141 GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, 141 GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, buf,
142 buf, max); 142 max);
143 gc->addr_pos = gc->addr_pos->next; 143 gc->addr_pos = gc->addr_pos->next;
144 return ret; 144 return ret;
145} 145}
@@ -251,7 +251,7 @@ GST_hello_get ()
251 */ 251 */
252void 252void
253GST_hello_modify_addresses (int addremove, 253GST_hello_modify_addresses (int addremove,
254 const struct GNUNET_HELLO_Address *address) 254 const struct GNUNET_HELLO_Address *address)
255{ 255{
256 struct OwnAddressList *al; 256 struct OwnAddressList *al;
257 257
@@ -266,10 +266,8 @@ GST_hello_modify_addresses (int addremove,
266 if (GNUNET_NO == addremove) 266 if (GNUNET_NO == addremove)
267 { 267 {
268 for (al = oal_head; al != NULL; al = al->next) 268 for (al = oal_head; al != NULL; al = al->next)
269 if (0 == 269 if (0 == GNUNET_HELLO_address_cmp (address, al->address))
270 GNUNET_HELLO_address_cmp (address, 270 {
271 al->address))
272 {
273 GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al); 271 GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al);
274 GNUNET_HELLO_address_free (al->address); 272 GNUNET_HELLO_address_free (al->address);
275 GNUNET_free (al); 273 GNUNET_free (al);
@@ -305,8 +303,7 @@ GST_hello_test_address (const struct GNUNET_HELLO_Address *address,
305 struct OwnAddressList *al; 303 struct OwnAddressList *al;
306 304
307 for (al = oal_head; al != NULL; al = al->next) 305 for (al = oal_head; al != NULL; al = al->next)
308 if (0 == GNUNET_HELLO_address_cmp (address, 306 if (0 == GNUNET_HELLO_address_cmp (address, al->address))
309 al->address))
310 { 307 {
311 *sig = &al->pong_signature; 308 *sig = &al->pong_signature;
312 *sig_expiration = &al->pong_sig_expires; 309 *sig_expiration = &al->pong_sig_expires;
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h
index 168dd4364..605d19861 100644
--- a/src/transport/gnunet-service-transport_hello.h
+++ b/src/transport/gnunet-service-transport_hello.h
@@ -76,8 +76,8 @@ GST_hello_get (void);
76 * @param address address to add or remove 76 * @param address address to add or remove
77 */ 77 */
78void 78void
79GST_hello_modify_addresses (int addremove, 79GST_hello_modify_addresses (int addremove,
80 const struct GNUNET_HELLO_Address *address); 80 const struct GNUNET_HELLO_Address *address);
81 81
82 82
83/** 83/**
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 3024d8bc1..a0f6e2e42 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -190,22 +190,22 @@ struct MessageQueue
190enum State 190enum State
191{ 191{
192 /** 192 /**
193 * fresh peer or completely disconnected 193 * fresh peer or completely disconnected
194 */ 194 */
195 S_NOT_CONNECTED, 195 S_NOT_CONNECTED,
196 196
197 /** 197 /**
198 * sent CONNECT message to other peer, waiting for CONNECT_ACK 198 * sent CONNECT message to other peer, waiting for CONNECT_ACK
199 */ 199 */
200 S_CONNECT_SENT, 200 S_CONNECT_SENT,
201 201
202 /** 202 /**
203 * received CONNECT message to other peer, sending CONNECT_ACK 203 * received CONNECT message to other peer, sending CONNECT_ACK
204 */ 204 */
205 S_CONNECT_RECV, 205 S_CONNECT_RECV,
206 206
207 /** 207 /**
208 * received ACK or payload 208 * received ACK or payload
209 */ 209 */
210 S_CONNECTED, 210 S_CONNECTED,
211 211
@@ -215,7 +215,7 @@ enum State
215 S_FAST_RECONNECT, 215 S_FAST_RECONNECT,
216 216
217 /** 217 /**
218 * Disconnect in progress 218 * Disconnect in progress
219 */ 219 */
220 S_DISCONNECT 220 S_DISCONNECT
221}; 221};
@@ -452,6 +452,7 @@ static void
452reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 452reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
453{ 453{
454 struct NeighbourMapEntry *n = cls; 454 struct NeighbourMapEntry *n = cls;
455
455 if (n == NULL) 456 if (n == NULL)
456 return; 457 return;
457 458
@@ -472,7 +473,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
472 /* destroying address */ 473 /* destroying address */
473 if (n->address != NULL) 474 if (n->address != NULL)
474 { 475 {
475 GNUNET_assert (strlen(n->address->transport_name) > 0); 476 GNUNET_assert (strlen (n->address->transport_name) > 0);
476 GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session); 477 GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session);
477 } 478 }
478 479
@@ -522,6 +523,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
522 { 523 {
523 char *old = GNUNET_strdup (print_state (n->state)); 524 char *old = GNUNET_strdup (print_state (n->state));
524 char *new = GNUNET_strdup (print_state (state)); 525 char *new = GNUNET_strdup (print_state (state));
526
525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 527 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
526 "Illegal state transition from `%s' to `%s' in line %u \n", old, 528 "Illegal state transition from `%s' to `%s' in line %u \n", old,
527 new, line); 529 new, line);
@@ -534,6 +536,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
534 { 536 {
535 char *old = GNUNET_strdup (print_state (n->state)); 537 char *old = GNUNET_strdup (print_state (n->state));
536 char *new = GNUNET_strdup (print_state (state)); 538 char *new = GNUNET_strdup (print_state (state));
539
537 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 540 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
538 "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n", 541 "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n",
539 GNUNET_i2s (&n->id), n, old, new, line); 542 GNUNET_i2s (&n->id), n, old, new, line);
@@ -551,8 +554,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
551 if (n->state_reset != GNUNET_SCHEDULER_NO_TASK) 554 if (n->state_reset != GNUNET_SCHEDULER_NO_TASK)
552 GNUNET_SCHEDULER_cancel (n->state_reset); 555 GNUNET_SCHEDULER_cancel (n->state_reset);
553 n->state_reset = 556 n->state_reset =
554 GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, 557 GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, n);
555 n);
556 break; 558 break;
557 case S_CONNECTED: 559 case S_CONNECTED:
558 case S_NOT_CONNECTED: 560 case S_NOT_CONNECTED:
@@ -562,10 +564,10 @@ change (struct NeighbourMapEntry *n, int state, int line)
562#if DEBUG_TRANSPORT 564#if DEBUG_TRANSPORT
563 char *old = GNUNET_strdup (print_state (n->state)); 565 char *old = GNUNET_strdup (print_state (n->state));
564 char *new = GNUNET_strdup (print_state (state)); 566 char *new = GNUNET_strdup (print_state (state));
567
565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 568 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
566 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", 569 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
567 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), 570 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), old, new);
568 old, new);
569 GNUNET_free (old); 571 GNUNET_free (old);
570 GNUNET_free (new); 572 GNUNET_free (new);
571#endif 573#endif
@@ -578,7 +580,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
578 default: 580 default:
579 GNUNET_assert (0); 581 GNUNET_assert (0);
580 } 582 }
581 583
582 584
583 585
584 return GNUNET_OK; 586 return GNUNET_OK;
@@ -588,9 +590,8 @@ static ssize_t
588send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, 590send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
589 size_t msgbuf_size, uint32_t priority, 591 size_t msgbuf_size, uint32_t priority,
590 struct GNUNET_TIME_Relative timeout, struct Session *session, 592 struct GNUNET_TIME_Relative timeout, struct Session *session,
591 const struct GNUNET_HELLO_Address *address, 593 const struct GNUNET_HELLO_Address *address, int force_address,
592 int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, 594 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
593 void *cont_cls)
594{ 595{
595 struct GNUNET_TRANSPORT_PluginFunctions *papi; 596 struct GNUNET_TRANSPORT_PluginFunctions *papi;
596 size_t ret = GNUNET_SYSERR; 597 size_t ret = GNUNET_SYSERR;
@@ -620,8 +621,8 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
620 621
621 ret = 622 ret =
622 papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session, 623 papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session,
623 address->address, 624 address->address, address->address_length, GNUNET_YES, cont,
624 address->address_length, GNUNET_YES, cont, cont_cls); 625 cont_cls);
625 626
626 if (ret == -1) 627 if (ret == -1)
627 { 628 {
@@ -657,7 +658,7 @@ transmit_send_continuation (void *cls,
657 struct NeighbourMapEntry *n; 658 struct NeighbourMapEntry *n;
658 struct NeighbourMapEntry *tmp; 659 struct NeighbourMapEntry *tmp;
659 660
660 tmp = lookup_neighbour(receiver); 661 tmp = lookup_neighbour (receiver);
661 662
662 mq = cls; 663 mq = cls;
663 n = mq->n; 664 n = mq->n;
@@ -720,8 +721,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
720 721
721 if (n->address == NULL) 722 if (n->address == NULL)
722 { 723 {
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
724 "No address for peer `%s'\n",
725 GNUNET_i2s (&n->id)); 725 GNUNET_i2s (&n->id));
726 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); 726 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
727 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK); 727 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
@@ -740,8 +740,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
740 740
741 if ((n->address->address_length == 0) && (n->session == NULL)) 741 if ((n->address->address_length == 0) && (n->session == NULL))
742 { 742 {
743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
744 "No address for peer `%s'\n",
745 GNUNET_i2s (&n->id)); 744 GNUNET_i2s (&n->id));
746 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); 745 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
747 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK); 746 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
@@ -751,9 +750,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
751 750
752 ret = 751 ret =
753 send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0, 752 send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0,
754 timeout, n->session, n->address, 753 timeout, n->session, n->address, GNUNET_YES,
755 GNUNET_YES, &transmit_send_continuation, 754 &transmit_send_continuation, mq);
756 mq);
757 if (ret == -1) 755 if (ret == -1)
758 { 756 {
759 /* failure, but 'send' would not call continuation in this case, 757 /* failure, but 'send' would not call continuation in this case,
@@ -826,7 +824,8 @@ send_disconnect (const struct GNUNET_PeerIdentity *target,
826#endif 824#endif
827 825
828 disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage)); 826 disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage));
829 disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT); 827 disconnect_msg.header.type =
828 htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
830 disconnect_msg.reserved = htonl (0); 829 disconnect_msg.reserved = htonl (0);
831 disconnect_msg.purpose.size = 830 disconnect_msg.purpose.size =
832 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 831 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
@@ -846,8 +845,7 @@ send_disconnect (const struct GNUNET_PeerIdentity *target,
846 send_with_plugin (target, (const char *) &disconnect_msg, 845 send_with_plugin (target, (const char *) &disconnect_msg,
847 sizeof (disconnect_msg), UINT32_MAX, 846 sizeof (disconnect_msg), UINT32_MAX,
848 GNUNET_TIME_UNIT_FOREVER_REL, session, address, 847 GNUNET_TIME_UNIT_FOREVER_REL, session, address,
849 GNUNET_YES, 848 GNUNET_YES, &send_disconnect_cont, NULL);
850 &send_disconnect_cont, NULL);
851 849
852 if (ret == GNUNET_SYSERR) 850 if (ret == GNUNET_SYSERR)
853 return GNUNET_SYSERR; 851 return GNUNET_SYSERR;
@@ -880,9 +878,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
880 /* send DISCONNECT MESSAGE */ 878 /* send DISCONNECT MESSAGE */
881 if ((previous_state == S_CONNECTED) || is_connecting (n)) 879 if ((previous_state == S_CONNECTED) || is_connecting (n))
882 { 880 {
883 if (GNUNET_OK == 881 if (GNUNET_OK == send_disconnect (&n->id, n->address, n->session))
884 send_disconnect (&n->id, n->address,
885 n->session))
886 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", 882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n",
887 GNUNET_i2s (&n->id)); 883 GNUNET_i2s (&n->id));
888 else 884 else
@@ -898,9 +894,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
898 GNUNET_assert (NULL != n->address); 894 GNUNET_assert (NULL != n->address);
899 if (n->address_state == USED) 895 if (n->address_state == USED)
900 { 896 {
901 GST_validation_set_address_use (&n->id, 897 GST_validation_set_address_use (&n->id, n->address, n->session,
902 n->address,
903 n->session,
904 GNUNET_NO); 898 GNUNET_NO);
905 899
906 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); 900 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
@@ -911,6 +905,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
911 if (n->address != NULL) 905 if (n->address != NULL)
912 { 906 {
913 struct GNUNET_TRANSPORT_PluginFunctions *papi; 907 struct GNUNET_TRANSPORT_PluginFunctions *papi;
908
914 papi = GST_plugins_find (n->address->transport_name); 909 papi = GST_plugins_find (n->address->transport_name);
915 if (papi != NULL) 910 if (papi != NULL)
916 papi->disconnect (papi->cls, &n->id); 911 papi->disconnect (papi->cls, &n->id);
@@ -928,27 +923,27 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
928 n->is_active = NULL; 923 n->is_active = NULL;
929 } 924 }
930 925
931 switch (previous_state) { 926 switch (previous_state)
932 case S_CONNECTED: 927 {
928 case S_CONNECTED:
933// GNUNET_assert (neighbours_connected > 0); 929// GNUNET_assert (neighbours_connected > 0);
934 neighbours_connected--; 930 neighbours_connected--;
935 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task); 931 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task);
936 GNUNET_SCHEDULER_cancel (n->keepalive_task); 932 GNUNET_SCHEDULER_cancel (n->keepalive_task);
937 n->keepalive_task = GNUNET_SCHEDULER_NO_TASK; 933 n->keepalive_task = GNUNET_SCHEDULER_NO_TASK;
938 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1, 934 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
939 GNUNET_NO); 935 GNUNET_NO);
940 disconnect_notify_cb (callback_cls, &n->id); 936 disconnect_notify_cb (callback_cls, &n->id);
941 break; 937 break;
942 case S_FAST_RECONNECT: 938 case S_FAST_RECONNECT:
943 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1, 939 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
944 GNUNET_NO); 940 GNUNET_NO);
945 GNUNET_STATISTICS_update (GST_stats, 941 GNUNET_STATISTICS_update (GST_stats,
946 gettext_noop 942 gettext_noop ("# fast reconnects failed"), 1,
947 ("# fast reconnects failed"), 943 GNUNET_NO);
948 1, GNUNET_NO); 944 disconnect_notify_cb (callback_cls, &n->id);
949 disconnect_notify_cb (callback_cls, &n->id); 945 default:
950 default: 946 break;
951 break;
952 } 947 }
953 948
954 GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id); 949 GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id);
@@ -1030,17 +1025,18 @@ neighbour_keepalive_task (void *cls,
1030 m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); 1025 m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
1031 1026
1032 1027
1033 ret = send_with_plugin (&n->id, (const void *) &m, sizeof (m), 1028 ret =
1034 UINT32_MAX /* priority */ , 1029 send_with_plugin (&n->id, (const void *) &m, sizeof (m),
1035 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address, 1030 UINT32_MAX /* priority */ ,
1036 GNUNET_YES, NULL, NULL); 1031 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
1032 GNUNET_YES, NULL, NULL);
1037 1033
1038 n->expect_latency_response = GNUNET_NO; 1034 n->expect_latency_response = GNUNET_NO;
1039 n->keep_alive_sent = GNUNET_TIME_absolute_get_zero(); 1035 n->keep_alive_sent = GNUNET_TIME_absolute_get_zero ();
1040 if (ret != GNUNET_SYSERR) 1036 if (ret != GNUNET_SYSERR)
1041 { 1037 {
1042 n->expect_latency_response = GNUNET_YES; 1038 n->expect_latency_response = GNUNET_YES;
1043 n->keep_alive_sent = GNUNET_TIME_absolute_get(); 1039 n->keep_alive_sent = GNUNET_TIME_absolute_get ();
1044 } 1040 }
1045 1041
1046} 1042}
@@ -1115,19 +1111,22 @@ struct ContinutionContext
1115 struct Session *session; 1111 struct Session *session;
1116}; 1112};
1117 1113
1118static void send_outbound_quota (const struct GNUNET_PeerIdentity *target, struct GNUNET_BANDWIDTH_Value32NBO quota) 1114static void
1115send_outbound_quota (const struct GNUNET_PeerIdentity *target,
1116 struct GNUNET_BANDWIDTH_Value32NBO quota)
1119{ 1117{
1120 struct QuotaSetMessage q_msg; 1118 struct QuotaSetMessage q_msg;
1119
1121#if DEBUG_TRANSPORT 1120#if DEBUG_TRANSPORT
1122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1123 "Sending outbound quota of %u Bps for peer `%s' to all clients\n", 1122 "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
1124 ntohl (quota.value__), GNUNET_i2s (target)); 1123 ntohl (quota.value__), GNUNET_i2s (target));
1125#endif 1124#endif
1126 q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); 1125 q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
1127 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); 1126 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
1128 q_msg.quota = quota; 1127 q_msg.quota = quota;
1129 q_msg.peer = (*target); 1128 q_msg.peer = (*target);
1130 GST_clients_broadcast (&q_msg.header, GNUNET_NO); 1129 GST_clients_broadcast (&q_msg.header, GNUNET_NO);
1131} 1130}
1132 1131
1133/** 1132/**
@@ -1143,17 +1142,15 @@ static void
1143send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, 1142send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1144 int success) 1143 int success)
1145{ 1144{
1146 struct ContinutionContext * cc = cls; 1145 struct ContinutionContext *cc = cls;
1147 struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer); 1146 struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer);
1148 1147
1149 if (GNUNET_YES != success) 1148 if (GNUNET_YES != success)
1150 { 1149 {
1151 GNUNET_assert (strlen(cc->address->transport_name) > 0); 1150 GNUNET_assert (strlen (cc->address->transport_name) > 0);
1152 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); 1151 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1153 } 1152 }
1154 if ( (NULL == neighbours) || 1153 if ((NULL == neighbours) || (NULL == n) || (n->state == S_DISCONNECT))
1155 (NULL == n) ||
1156 (n->state == S_DISCONNECT))
1157 { 1154 {
1158 GNUNET_HELLO_address_free (cc->address); 1155 GNUNET_HELLO_address_free (cc->address);
1159 GNUNET_free (cc); 1156 GNUNET_free (cc);
@@ -1161,7 +1158,7 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1161 } 1158 }
1162 1159
1163 if ((GNUNET_YES == success) && 1160 if ((GNUNET_YES == success) &&
1164 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT))) 1161 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
1165 { 1162 {
1166 change_state (n, S_CONNECT_SENT); 1163 change_state (n, S_CONNECT_SENT);
1167 GNUNET_HELLO_address_free (cc->address); 1164 GNUNET_HELLO_address_free (cc->address);
@@ -1170,21 +1167,19 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1170 } 1167 }
1171 1168
1172 if ((GNUNET_NO == success) && 1169 if ((GNUNET_NO == success) &&
1173 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT))) 1170 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
1174 { 1171 {
1175#if DEBUG_TRANSPORT 1172#if DEBUG_TRANSPORT
1176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1177 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n", 1174 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n",
1178 GNUNET_i2s (&n->id), 1175 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
1179 GST_plugins_a2s (n->address),
1180 n->session);
1181#endif 1176#endif
1182 change_state (n, S_NOT_CONNECTED); 1177 change_state (n, S_NOT_CONNECTED);
1183 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1178 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1184 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1179 GNUNET_SCHEDULER_cancel (n->ats_suggest);
1185 n->ats_suggest = 1180 n->ats_suggest =
1186 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel, 1181 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel,
1187 n); 1182 n);
1188 GNUNET_ATS_suggest_address (GST_ats, &n->id); 1183 GNUNET_ATS_suggest_address (GST_ats, &n->id);
1189 } 1184 }
1190 GNUNET_HELLO_address_free (cc->address); 1185 GNUNET_HELLO_address_free (cc->address);
@@ -1205,7 +1200,7 @@ send_switch_address_continuation (void *cls,
1205 const struct GNUNET_PeerIdentity *target, 1200 const struct GNUNET_PeerIdentity *target,
1206 int success) 1201 int success)
1207{ 1202{
1208 struct ContinutionContext * cc = cls; 1203 struct ContinutionContext *cc = cls;
1209 struct NeighbourMapEntry *n; 1204 struct NeighbourMapEntry *n;
1210 1205
1211 if (neighbours == NULL) 1206 if (neighbours == NULL)
@@ -1215,7 +1210,7 @@ send_switch_address_continuation (void *cls,
1215 return; /* neighbour is going away */ 1210 return; /* neighbour is going away */
1216 } 1211 }
1217 1212
1218 n = lookup_neighbour(&cc->address->peer); 1213 n = lookup_neighbour (&cc->address->peer);
1219 if ((n == NULL) || (is_disconnecting (n))) 1214 if ((n == NULL) || (is_disconnecting (n)))
1220 { 1215 {
1221 GNUNET_HELLO_address_free (cc->address); 1216 GNUNET_HELLO_address_free (cc->address);
@@ -1229,10 +1224,9 @@ send_switch_address_continuation (void *cls,
1229#if DEBUG_TRANSPORT 1224#if DEBUG_TRANSPORT
1230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1231 "Failed to switch connected peer `%s' to address '%s' session %X, asking ATS for new address \n", 1226 "Failed to switch connected peer `%s' to address '%s' session %X, asking ATS for new address \n",
1232 GNUNET_i2s (&n->id), 1227 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
1233 GST_plugins_a2s (n->address), n->session);
1234#endif 1228#endif
1235 GNUNET_assert (strlen(cc->address->transport_name) > 0); 1229 GNUNET_assert (strlen (cc->address->transport_name) > 0);
1236 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); 1230 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1237 1231
1238 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1232 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -1246,49 +1240,48 @@ send_switch_address_continuation (void *cls,
1246 return; 1240 return;
1247 } 1241 }
1248 /* Tell ATS that switching addresses was successful */ 1242 /* Tell ATS that switching addresses was successful */
1249 switch (n->state) { 1243 switch (n->state)
1250 case S_CONNECTED: 1244 {
1251 if (n->address_state == FRESH) 1245 case S_CONNECTED:
1252 { 1246 if (n->address_state == FRESH)
1253 GST_validation_set_address_use (&n->id, 1247 {
1254 cc->address, 1248 GST_validation_set_address_use (&n->id, cc->address, cc->session,
1255 cc->session, 1249 GNUNET_YES);
1256 GNUNET_YES); 1250 GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
1257 GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0); 1251 GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
1258 GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); 1252 n->address_state = USED;
1259 n->address_state = USED; 1253 }
1260 } 1254 break;
1261 break; 1255 case S_FAST_RECONNECT:
1262 case S_FAST_RECONNECT:
1263#if DEBUG_TRANSPORT 1256#if DEBUG_TRANSPORT
1264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1265 "Successful fast reconnect to peer `%s'\n", GNUNET_i2s (&n->id)); 1258 "Successful fast reconnect to peer `%s'\n",
1259 GNUNET_i2s (&n->id));
1266#endif 1260#endif
1267 change_state (n, S_CONNECTED); 1261 change_state (n, S_CONNECTED);
1268 neighbours_connected++; 1262 neighbours_connected++;
1269 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, 1263 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
1270 GNUNET_NO); 1264 GNUNET_NO);
1271 1265
1272 if (n->address_state == FRESH) 1266 if (n->address_state == FRESH)
1273 { 1267 {
1274 GST_validation_set_address_use (&n->id, 1268 GST_validation_set_address_use (&n->id, cc->address, cc->session,
1275 cc->address, 1269 GNUNET_YES);
1276 cc->session, 1270 GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
1277 GNUNET_YES); 1271 GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
1278 GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0); 1272 n->address_state = USED;
1279 GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); 1273 }
1280 n->address_state = USED; 1274
1281 } 1275 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
1282 1276 n->keepalive_task =
1283 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) 1277 GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
1284 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n); 1278
1285 1279 /* Updating quotas */
1286 /* Updating quotas */ 1280 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
1287 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); 1281 send_outbound_quota (target, n->bandwidth_out);
1288 send_outbound_quota(target, n->bandwidth_out); 1282
1289 1283 default:
1290 default: 1284 break;
1291 break;
1292 } 1285 }
1293 GNUNET_HELLO_address_free (cc->address); 1286 GNUNET_HELLO_address_free (cc->address);
1294 GNUNET_free (cc); 1287 GNUNET_free (cc);
@@ -1309,7 +1302,7 @@ send_connect_ack_continuation (void *cls,
1309 const struct GNUNET_PeerIdentity *target, 1302 const struct GNUNET_PeerIdentity *target,
1310 int success) 1303 int success)
1311{ 1304{
1312 struct ContinutionContext * cc = cls; 1305 struct ContinutionContext *cc = cls;
1313 struct NeighbourMapEntry *n; 1306 struct NeighbourMapEntry *n;
1314 1307
1315 if (neighbours == NULL) 1308 if (neighbours == NULL)
@@ -1319,7 +1312,7 @@ send_connect_ack_continuation (void *cls,
1319 return; /* neighbour is going away */ 1312 return; /* neighbour is going away */
1320 } 1313 }
1321 1314
1322 n = lookup_neighbour(&cc->address->peer); 1315 n = lookup_neighbour (&cc->address->peer);
1323 if ((n == NULL) || (is_disconnecting (n))) 1316 if ((n == NULL) || (is_disconnecting (n)))
1324 { 1317 {
1325 GNUNET_HELLO_address_free (cc->address); 1318 GNUNET_HELLO_address_free (cc->address);
@@ -1338,12 +1331,10 @@ send_connect_ack_continuation (void *cls,
1338#if DEBUG_TRANSPORT 1331#if DEBUG_TRANSPORT
1339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1340 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %X, asking ATS for new address \n", 1333 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %X, asking ATS for new address \n",
1341 GNUNET_i2s (&n->id), 1334 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
1342 GST_plugins_a2s (n->address),
1343 n->session);
1344#endif 1335#endif
1345 change_state (n, S_NOT_CONNECTED); 1336 change_state (n, S_NOT_CONNECTED);
1346 GNUNET_assert (strlen(cc->address->transport_name) > 0); 1337 GNUNET_assert (strlen (cc->address->transport_name) > 0);
1347 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); 1338 GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1348 1339
1349 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1340 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -1372,8 +1363,8 @@ send_connect_ack_continuation (void *cls,
1372 */ 1363 */
1373int 1364int
1374GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, 1365GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1375 const struct GNUNET_HELLO_Address *address, 1366 const struct GNUNET_HELLO_Address
1376 struct Session *session, 1367 *address, struct Session *session,
1377 const struct GNUNET_ATS_Information *ats, 1368 const struct GNUNET_ATS_Information *ats,
1378 uint32_t ats_count, 1369 uint32_t ats_count,
1379 struct GNUNET_BANDWIDTH_Value32NBO 1370 struct GNUNET_BANDWIDTH_Value32NBO
@@ -1383,7 +1374,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1383{ 1374{
1384 struct NeighbourMapEntry *n; 1375 struct NeighbourMapEntry *n;
1385 struct SessionConnectMessage connect_msg; 1376 struct SessionConnectMessage connect_msg;
1386 struct ContinutionContext * cc; 1377 struct ContinutionContext *cc;
1387 size_t msg_len; 1378 size_t msg_len;
1388 size_t ret; 1379 size_t ret;
1389 1380
@@ -1401,11 +1392,11 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1401 return GNUNET_NO; 1392 return GNUNET_NO;
1402 } 1393 }
1403 GNUNET_assert (address->transport_name != NULL); 1394 GNUNET_assert (address->transport_name != NULL);
1404 if ( (session == NULL) && (0 == address->address_length) ) 1395 if ((session == NULL) && (0 == address->address_length))
1405 { 1396 {
1406 GNUNET_break_op (0); 1397 GNUNET_break_op (0);
1407 /* FIXME: is this actually possible? When does this happen? */ 1398 /* FIXME: is this actually possible? When does this happen? */
1408 if (strlen(address->transport_name) > 0) 1399 if (strlen (address->transport_name) > 0)
1409 GNUNET_ATS_address_destroyed (GST_ats, address, session); 1400 GNUNET_ATS_address_destroyed (GST_ats, address, session);
1410 GNUNET_ATS_suggest_address (GST_ats, peer); 1401 GNUNET_ATS_suggest_address (GST_ats, peer);
1411 return GNUNET_NO; 1402 return GNUNET_NO;
@@ -1415,10 +1406,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1415#if DEBUG_TRANSPORT 1406#if DEBUG_TRANSPORT
1416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1407 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1417 "ATS tells us to switch to address '%s' session %p for peer `%s' in state `%s'\n", 1408 "ATS tells us to switch to address '%s' session %p for peer `%s' in state `%s'\n",
1418 GST_plugins_a2s (address), 1409 GST_plugins_a2s (address), session, GNUNET_i2s (peer),
1419 session, 1410 print_state (n->state));
1420 GNUNET_i2s (peer),
1421 print_state(n->state));
1422#endif 1411#endif
1423 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1412 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1424 { 1413 {
@@ -1426,17 +1415,15 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1426 n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; 1415 n->ats_suggest = GNUNET_SCHEDULER_NO_TASK;
1427 } 1416 }
1428 /* do not switch addresses just update quotas */ 1417 /* do not switch addresses just update quotas */
1429 if ( (n->state == S_CONNECTED) && 1418 if ((n->state == S_CONNECTED) && (NULL != n->address) &&
1430 (NULL != n->address) && 1419 (0 == GNUNET_HELLO_address_cmp (address, n->address)) &&
1431 (0 == GNUNET_HELLO_address_cmp (address, 1420 (n->session == session))
1432 n->address)) &&
1433 (n->session == session) )
1434 { 1421 {
1435 n->bandwidth_in = bandwidth_in; 1422 n->bandwidth_in = bandwidth_in;
1436 n->bandwidth_out = bandwidth_out; 1423 n->bandwidth_out = bandwidth_out;
1437 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); 1424 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
1438 send_outbound_quota(peer, n->bandwidth_out); 1425 send_outbound_quota (peer, n->bandwidth_out);
1439 return GNUNET_NO; 1426 return GNUNET_NO;
1440 } 1427 }
1441 if (n->state == S_CONNECTED) 1428 if (n->state == S_CONNECTED)
1442 { 1429 {
@@ -1444,9 +1431,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1444 GNUNET_assert (NULL != n->address); 1431 GNUNET_assert (NULL != n->address);
1445 if (n->address_state == USED) 1432 if (n->address_state == USED)
1446 { 1433 {
1447 GST_validation_set_address_use (&n->id, 1434 GST_validation_set_address_use (&n->id, n->address, n->session,
1448 n->address,
1449 n->session,
1450 GNUNET_NO); 1435 GNUNET_NO);
1451 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); 1436 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
1452 n->address_state = UNUSED; 1437 n->address_state = UNUSED;
@@ -1468,7 +1453,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1468 &neighbour_timeout_task, n); 1453 &neighbour_timeout_task, n);
1469 switch (n->state) 1454 switch (n->state)
1470 { 1455 {
1471 case S_NOT_CONNECTED: 1456 case S_NOT_CONNECTED:
1472 case S_CONNECT_SENT: 1457 case S_CONNECT_SENT:
1473 msg_len = sizeof (struct SessionConnectMessage); 1458 msg_len = sizeof (struct SessionConnectMessage);
1474 connect_msg.header.size = htons (msg_len); 1459 connect_msg.header.size = htons (msg_len);
@@ -1478,15 +1463,13 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1478 connect_msg.timestamp = 1463 connect_msg.timestamp =
1479 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1464 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1480 1465
1481 cc = GNUNET_malloc(sizeof (struct ContinutionContext)); 1466 cc = GNUNET_malloc (sizeof (struct ContinutionContext));
1482 cc->session = session; 1467 cc->session = session;
1483 cc->address = GNUNET_HELLO_address_copy (address); 1468 cc->address = GNUNET_HELLO_address_copy (address);
1484 ret = 1469 ret =
1485 send_with_plugin (peer, (const char *) &connect_msg, msg_len, 1470 send_with_plugin (peer, (const char *) &connect_msg, msg_len,
1486 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1471 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1487 address, GNUNET_YES, 1472 address, GNUNET_YES, &send_connect_continuation, cc);
1488 &send_connect_continuation,
1489 cc);
1490 return GNUNET_NO; 1473 return GNUNET_NO;
1491 case S_CONNECT_RECV: 1474 case S_CONNECT_RECV:
1492 /* We received a CONNECT message and asked ATS for an address */ 1475 /* We received a CONNECT message and asked ATS for an address */
@@ -1497,18 +1480,18 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1497 connect_msg.reserved = htonl (0); 1480 connect_msg.reserved = htonl (0);
1498 connect_msg.timestamp = 1481 connect_msg.timestamp =
1499 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1482 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1500 cc = GNUNET_malloc(sizeof (struct ContinutionContext)); 1483 cc = GNUNET_malloc (sizeof (struct ContinutionContext));
1501 cc->session = session; 1484 cc->session = session;
1502 cc->address = GNUNET_HELLO_address_copy (address); 1485 cc->address = GNUNET_HELLO_address_copy (address);
1503 ret = 1486 ret =
1504 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, 1487 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
1505 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1488 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1506 address, GNUNET_YES, 1489 address, GNUNET_YES, &send_connect_ack_continuation,
1507 &send_connect_ack_continuation, cc); 1490 cc);
1508 return GNUNET_NO; 1491 return GNUNET_NO;
1509 case S_CONNECTED: 1492 case S_CONNECTED:
1510 case S_FAST_RECONNECT: 1493 case S_FAST_RECONNECT:
1511 /* connected peer is switching addresses or tries fast reconnect*/ 1494 /* connected peer is switching addresses or tries fast reconnect */
1512 msg_len = sizeof (struct SessionConnectMessage); 1495 msg_len = sizeof (struct SessionConnectMessage);
1513 connect_msg.header.size = htons (msg_len); 1496 connect_msg.header.size = htons (msg_len);
1514 connect_msg.header.type = 1497 connect_msg.header.type =
@@ -1516,7 +1499,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1516 connect_msg.reserved = htonl (0); 1499 connect_msg.reserved = htonl (0);
1517 connect_msg.timestamp = 1500 connect_msg.timestamp =
1518 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1501 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1519 cc = GNUNET_malloc(sizeof (struct ContinutionContext)); 1502 cc = GNUNET_malloc (sizeof (struct ContinutionContext));
1520 cc->session = session; 1503 cc->session = session;
1521 cc->address = GNUNET_HELLO_address_copy (address); 1504 cc->address = GNUNET_HELLO_address_copy (address);
1522 ret = 1505 ret =
@@ -1528,13 +1511,12 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1528 { 1511 {
1529 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1512 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1530 "Failed to send CONNECT_MESSAGE to `%4s' using address '%s' session %X\n", 1513 "Failed to send CONNECT_MESSAGE to `%4s' using address '%s' session %X\n",
1531 GNUNET_i2s (peer), 1514 GNUNET_i2s (peer), GST_plugins_a2s (address), session);
1532 GST_plugins_a2s (address), session);
1533 } 1515 }
1534 return GNUNET_NO; 1516 return GNUNET_NO;
1535 default: 1517 default:
1536 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1518 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1537 "Invalid connection state to switch addresses %u \n", n->state); 1519 "Invalid connection state to switch addresses %u \n", n->state);
1538 GNUNET_break_op (0); 1520 GNUNET_break_op (0);
1539 return GNUNET_NO; 1521 return GNUNET_NO;
1540 } 1522 }
@@ -1544,7 +1526,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1544/** 1526/**
1545 * Obtain current latency information for the given neighbour. 1527 * Obtain current latency information for the given neighbour.
1546 * 1528 *
1547 * @param peer 1529 * @param peer
1548 * @return observed latency of the address, FOREVER if the address was 1530 * @return observed latency of the address, FOREVER if the address was
1549 * never successfully validated 1531 * never successfully validated
1550 */ 1532 */
@@ -1554,8 +1536,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
1554 struct NeighbourMapEntry *n; 1536 struct NeighbourMapEntry *n;
1555 1537
1556 n = lookup_neighbour (peer); 1538 n = lookup_neighbour (peer);
1557 if ( (NULL == n) || 1539 if ((NULL == n) || ((n->address == NULL) && (n->session == NULL)))
1558 ( (n->address == NULL) && (n->session == NULL) ) )
1559 return GNUNET_TIME_UNIT_FOREVER_REL; 1540 return GNUNET_TIME_UNIT_FOREVER_REL;
1560 1541
1561 return n->latency; 1542 return n->latency;
@@ -1573,8 +1554,7 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer)
1573 struct NeighbourMapEntry *n; 1554 struct NeighbourMapEntry *n;
1574 1555
1575 n = lookup_neighbour (peer); 1556 n = lookup_neighbour (peer);
1576 if ( (NULL == n) || 1557 if ((NULL == n) || ((n->address == NULL) && (n->session == NULL)))
1577 ( (n->address == NULL) && (n->session == NULL) ) )
1578 return NULL; 1558 return NULL;
1579 1559
1580 return n->address; 1560 return n->address;
@@ -1600,7 +1580,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
1600 n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); 1580 n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
1601 n->id = *peer; 1581 n->id = *peer;
1602 n->state = S_NOT_CONNECTED; 1582 n->state = S_NOT_CONNECTED;
1603 n->latency = GNUNET_TIME_relative_get_forever(); 1583 n->latency = GNUNET_TIME_relative_get_forever ();
1604 GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, 1584 GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
1605 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, 1585 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
1606 MAX_BANDWIDTH_CARRY_S); 1586 MAX_BANDWIDTH_CARRY_S);
@@ -1718,11 +1698,9 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1718 { 1698 {
1719 if (n->address_state == USED) 1699 if (n->address_state == USED)
1720 { 1700 {
1721 GST_validation_set_address_use (&n->id, 1701 GST_validation_set_address_use (&n->id, n->address, n->session,
1722 n->address,
1723 n->session,
1724 GNUNET_NO); 1702 GNUNET_NO);
1725 GNUNET_ATS_address_in_use (GST_ats,n->address, n->session, GNUNET_NO); 1703 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
1726 n->address_state = UNUSED; 1704 n->address_state = UNUSED;
1727 } 1705 }
1728 } 1706 }
@@ -1733,15 +1711,15 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1733 n->address = NULL; 1711 n->address = NULL;
1734 } 1712 }
1735 n->session = NULL; 1713 n->session = NULL;
1736 1714
1737 /* not connected anymore anyway, shouldn't matter */ 1715 /* not connected anymore anyway, shouldn't matter */
1738 if (S_CONNECTED != n->state) 1716 if (S_CONNECTED != n->state)
1739 return; 1717 return;
1740 1718
1741 /* connected, try fast reconnect */ 1719 /* connected, try fast reconnect */
1742#if DEBUG_TRANSPORT 1720#if DEBUG_TRANSPORT
1743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying fast reconnect to peer `%s'\n",
1744 "Trying fast reconnect to peer `%s'\n", GNUNET_i2s (peer)); 1722 GNUNET_i2s (peer));
1745#endif 1723#endif
1746 change_state (n, S_FAST_RECONNECT); 1724 change_state (n, S_FAST_RECONNECT);
1747 GNUNET_assert (neighbours_connected > 0); 1725 GNUNET_assert (neighbours_connected > 0);
@@ -1814,7 +1792,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
1814 return; 1792 return;
1815 } 1793 }
1816 1794
1817 if ((n->session == NULL) && (n->address == NULL) ) 1795 if ((n->session == NULL) && (n->address == NULL))
1818 { 1796 {
1819 GNUNET_STATISTICS_update (GST_stats, 1797 GNUNET_STATISTICS_update (GST_stats,
1820 gettext_noop 1798 gettext_noop
@@ -1983,6 +1961,7 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
1983 return; 1961 return;
1984 1962
1985 struct GNUNET_MessageHeader m; 1963 struct GNUNET_MessageHeader m;
1964
1986 m.size = htons (sizeof (struct GNUNET_MessageHeader)); 1965 m.size = htons (sizeof (struct GNUNET_MessageHeader));
1987 m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE); 1966 m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE);
1988 1967
@@ -2002,11 +1981,11 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
2002 */ 1981 */
2003void 1982void
2004GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, 1983GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
2005 const struct GNUNET_ATS_Information * ats, 1984 const struct GNUNET_ATS_Information *ats,
2006 uint32_t ats_count) 1985 uint32_t ats_count)
2007{ 1986{
2008 struct NeighbourMapEntry *n; 1987 struct NeighbourMapEntry *n;
2009 struct GNUNET_ATS_Information * ats_new; 1988 struct GNUNET_ATS_Information *ats_new;
2010 uint32_t latency; 1989 uint32_t latency;
2011 1990
2012 if (neighbours == NULL) 1991 if (neighbours == NULL)
@@ -2034,22 +2013,26 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
2034 } 2013 }
2035 n->expect_latency_response = GNUNET_NO; 2014 n->expect_latency_response = GNUNET_NO;
2036 2015
2037 GNUNET_assert (n->keep_alive_sent.abs_value != GNUNET_TIME_absolute_get_zero().abs_value); 2016 GNUNET_assert (n->keep_alive_sent.abs_value !=
2038 n->latency = GNUNET_TIME_absolute_get_difference(n->keep_alive_sent, GNUNET_TIME_absolute_get()); 2017 GNUNET_TIME_absolute_get_zero ().abs_value);
2018 n->latency =
2019 GNUNET_TIME_absolute_get_difference (n->keep_alive_sent,
2020 GNUNET_TIME_absolute_get ());
2039#if DEBUG_TRANSPORT 2021#if DEBUG_TRANSPORT
2040 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Latency for peer `%s' is %llu ms\n",
2041 "Latency for peer `%s' is %llu ms\n",
2042 GNUNET_i2s (&n->id), n->latency.rel_value); 2023 GNUNET_i2s (&n->id), n->latency.rel_value);
2043#endif 2024#endif
2044 2025
2045 2026
2046 if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value) 2027 if (n->latency.rel_value == GNUNET_TIME_relative_get_forever ().rel_value)
2047 { 2028 {
2048 GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count); 2029 GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count);
2049 } 2030 }
2050 else 2031 else
2051 { 2032 {
2052 ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * (ats_count + 1)); 2033 ats_new =
2034 GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) *
2035 (ats_count + 1));
2053 memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); 2036 memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
2054 2037
2055 /* add latency */ 2038 /* add latency */
@@ -2060,7 +2043,8 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
2060 latency = n->latency.rel_value; 2043 latency = n->latency.rel_value;
2061 ats_new[ats_count].value = htonl (latency); 2044 ats_new[ats_count].value = htonl (latency);
2062 2045
2063 GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats_new, ats_count + 1); 2046 GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats_new,
2047 ats_count + 1);
2064 GNUNET_free (ats_new); 2048 GNUNET_free (ats_new);
2065 } 2049 }
2066} 2050}
@@ -2314,10 +2298,11 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2314 { 2298 {
2315 /* we did not send 'CONNECT' -- at least not recently */ 2299 /* we did not send 'CONNECT' -- at least not recently */
2316 GNUNET_STATISTICS_update (GST_stats, 2300 GNUNET_STATISTICS_update (GST_stats,
2317 gettext_noop ("# unexpected CONNECT_ACK messages (no peer)"), 1, 2301 gettext_noop
2318 GNUNET_NO); 2302 ("# unexpected CONNECT_ACK messages (no peer)"),
2303 1, GNUNET_NO);
2319 return; 2304 return;
2320 } 2305 }
2321 2306
2322 /* Additional check 2307 /* Additional check
2323 * 2308 *
@@ -2326,11 +2311,13 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2326 * We also received an CONNECT message, switched from SENDT to RECV and 2311 * We also received an CONNECT message, switched from SENDT to RECV and
2327 * ATS already suggested us an address after a successful blacklist check 2312 * ATS already suggested us an address after a successful blacklist check
2328 */ 2313 */
2329 if ((n->state != S_CONNECT_SENT) && ((n->state != S_CONNECT_RECV) && (n->address != NULL))) 2314 if ((n->state != S_CONNECT_SENT) &&
2315 ((n->state != S_CONNECT_RECV) && (n->address != NULL)))
2330 { 2316 {
2331 GNUNET_STATISTICS_update (GST_stats, 2317 GNUNET_STATISTICS_update (GST_stats,
2332 gettext_noop ("# unexpected CONNECT_ACK messages"), 1, 2318 gettext_noop
2333 GNUNET_NO); 2319 ("# unexpected CONNECT_ACK messages"), 1,
2320 GNUNET_NO);
2334 return; 2321 return;
2335 } 2322 }
2336 2323
@@ -2347,10 +2334,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2347 GNUNET_assert (NULL != n->address); 2334 GNUNET_assert (NULL != n->address);
2348 if (n->address_state == FRESH) 2335 if (n->address_state == FRESH)
2349 { 2336 {
2350 GST_validation_set_address_use (&n->id, 2337 GST_validation_set_address_use (&n->id, n->address, n->session, GNUNET_YES);
2351 n->address,
2352 n->session,
2353 GNUNET_YES);
2354 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); 2338 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
2355 n->address_state = USED; 2339 n->address_state = USED;
2356 } 2340 }
@@ -2364,32 +2348,29 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2364 2348
2365 ret = 2349 ret =
2366 send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, 2350 send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
2367 GNUNET_TIME_UNIT_FOREVER_REL, n->session, 2351 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
2368 n->address, GNUNET_YES, NULL, 2352 GNUNET_YES, NULL, NULL);
2369 NULL);
2370 2353
2371 if (ret == GNUNET_SYSERR) 2354 if (ret == GNUNET_SYSERR)
2372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2355 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2373 "Failed to send SESSION_ACK to `%4s' using address '%s' session %X\n", 2356 "Failed to send SESSION_ACK to `%4s' using address '%s' session %X\n",
2374 GNUNET_i2s (&n->id), 2357 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
2375 GST_plugins_a2s (n->address), n->session);
2376 2358
2377 2359
2378 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) 2360 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
2379 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n); 2361 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
2380 2362
2381 neighbours_connected++; 2363 neighbours_connected++;
2382 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, 2364 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
2383 GNUNET_NO); 2365 GNUNET_NO);
2384#if DEBUG_TRANSPORT 2366#if DEBUG_TRANSPORT
2385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2386 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", 2368 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
2387 GNUNET_i2s (&n->id), 2369 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
2388 GST_plugins_a2s (n->address), n->session, 2370 __LINE__);
2389 __LINE__);
2390#endif 2371#endif
2391 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2372 connect_notify_cb (callback_cls, &n->id, ats, ats_count);
2392 send_outbound_quota(peer, n->bandwidth_out); 2373 send_outbound_quota (peer, n->bandwidth_out);
2393 2374
2394} 2375}
2395 2376
@@ -2398,15 +2379,14 @@ void
2398GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, 2379GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2399 const struct GNUNET_PeerIdentity *peer, 2380 const struct GNUNET_PeerIdentity *peer,
2400 const struct GNUNET_HELLO_Address *address, 2381 const struct GNUNET_HELLO_Address *address,
2401 struct Session *session, 2382 struct Session *session,
2402 const struct GNUNET_ATS_Information *ats, 2383 const struct GNUNET_ATS_Information *ats,
2403 uint32_t ats_count) 2384 uint32_t ats_count)
2404{ 2385{
2405 struct NeighbourMapEntry *n; 2386 struct NeighbourMapEntry *n;
2406 2387
2407#if DEBUG_TRANSPORT 2388#if DEBUG_TRANSPORT
2408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n",
2409 "Received ACK message from peer `%s'\n",
2410 GNUNET_i2s (peer)); 2390 GNUNET_i2s (peer));
2411#endif 2391#endif
2412 2392
@@ -2418,16 +2398,16 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2418 n = lookup_neighbour (peer); 2398 n = lookup_neighbour (peer);
2419 if (NULL == n) 2399 if (NULL == n)
2420 { 2400 {
2421 send_disconnect (peer, address, 2401 send_disconnect (peer, address, session);
2422 session);
2423 GNUNET_break (0); 2402 GNUNET_break (0);
2424 return; 2403 return;
2425 } 2404 }
2426 if (S_CONNECTED == n->state) 2405 if (S_CONNECTED == n->state)
2427 return; 2406 return;
2428 if (!is_connecting(n)) 2407 if (!is_connecting (n))
2429 { 2408 {
2430 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# unexpected ACK messages"), 1, 2409 GNUNET_STATISTICS_update (GST_stats,
2410 gettext_noop ("# unexpected ACK messages"), 1,
2431 GNUNET_NO); 2411 GNUNET_NO);
2432 return; 2412 return;
2433 } 2413 }
@@ -2441,30 +2421,26 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2441 GNUNET_assert (n->address != NULL); 2421 GNUNET_assert (n->address != NULL);
2442 if (n->address_state == FRESH) 2422 if (n->address_state == FRESH)
2443 { 2423 {
2444 GST_validation_set_address_use (&n->id, 2424 GST_validation_set_address_use (&n->id, n->address, n->session, GNUNET_YES);
2445 n->address,
2446 n->session,
2447 GNUNET_YES);
2448 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); 2425 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
2449 n->address_state = USED; 2426 n->address_state = USED;
2450 } 2427 }
2451 2428
2452 neighbours_connected++; 2429 neighbours_connected++;
2453 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, 2430 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
2454 GNUNET_NO); 2431 GNUNET_NO);
2455 2432
2456 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); 2433 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
2457 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) 2434 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
2458 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n); 2435 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
2459#if DEBUG_TRANSPORT 2436#if DEBUG_TRANSPORT
2460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2461 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", 2438 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
2462 GNUNET_i2s (&n->id), 2439 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
2463 GST_plugins_a2s (n->address), n->session, 2440 __LINE__);
2464 __LINE__);
2465#endif 2441#endif
2466 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2442 connect_notify_cb (callback_cls, &n->id, ats, ats_count);
2467 send_outbound_quota(peer, n->bandwidth_out); 2443 send_outbound_quota (peer, n->bandwidth_out);
2468} 2444}
2469 2445
2470struct BlackListCheckContext 2446struct BlackListCheckContext
@@ -2514,15 +2490,11 @@ handle_connect_blacklist_cont (void *cls,
2514 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 2490 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
2515 "transport-ats", 2491 "transport-ats",
2516 "Giving ATS session %p of address `%s' for peer %s\n", 2492 "Giving ATS session %p of address `%s' for peer %s\n",
2517 bcc->session, 2493 bcc->session, GST_plugins_a2s (bcc->address),
2518 GST_plugins_a2s (bcc->address),
2519 GNUNET_i2s (peer)); 2494 GNUNET_i2s (peer));
2520 /* Tell ATS about the session, so ATS can suggest it if it likes it. */ 2495 /* Tell ATS about the session, so ATS can suggest it if it likes it. */
2521 2496
2522 GNUNET_ATS_address_update (GST_ats, 2497 GNUNET_ATS_address_update (GST_ats, bcc->address, bcc->session, bcc->ats,
2523 bcc->address,
2524 bcc->session,
2525 bcc->ats,
2526 bcc->ats_count); 2498 bcc->ats_count);
2527 n->connect_ts = bcc->ts; 2499 n->connect_ts = bcc->ts;
2528 } 2500 }
@@ -2584,10 +2556,10 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2584 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); 2556 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
2585 2557
2586 n = lookup_neighbour (peer); 2558 n = lookup_neighbour (peer);
2587 if ( (n != NULL) && (S_CONNECTED == n->state) ) 2559 if ((n != NULL) && (S_CONNECTED == n->state))
2588 { 2560 {
2589 /* connected peer switches addresses */ 2561 /* connected peer switches addresses */
2590 return; 2562 return;
2591 } 2563 }
2592 2564
2593 2565
@@ -2603,9 +2575,10 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2603 bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; 2575 bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1];
2604 memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); 2576 memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
2605 bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 2577 bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
2606 bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); 2578 bcc->ats[ats_count].value =
2607 GST_blacklist_test_allowed (peer, address->transport_name, handle_connect_blacklist_cont, 2579 htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
2608 bcc); 2580 GST_blacklist_test_allowed (peer, address->transport_name,
2581 handle_connect_blacklist_cont, bcc);
2609} 2582}
2610 2583
2611 2584
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index e85f1a4d0..5b37ccb6a 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -134,7 +134,7 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour);
134 */ 134 */
135void 135void
136GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, 136GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
137 const struct GNUNET_ATS_Information * ats, 137 const struct GNUNET_ATS_Information *ats,
138 uint32_t ats_count); 138 uint32_t ats_count);
139 139
140 140
@@ -172,7 +172,8 @@ typedef void (*GST_NeighbourIterator) (void *cls,
172 neighbour, 172 neighbour,
173 const struct GNUNET_ATS_Information * 173 const struct GNUNET_ATS_Information *
174 ats, uint32_t ats_count, 174 ats, uint32_t ats_count,
175 const struct GNUNET_HELLO_Address *address); 175 const struct GNUNET_HELLO_Address *
176 address);
176 177
177 178
178/** 179/**
@@ -213,10 +214,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
213 */ 214 */
214int 215int
215GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, 216GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
216 const struct GNUNET_HELLO_Address *address, 217 const struct GNUNET_HELLO_Address
217 struct Session *session, 218 *address, struct Session *session,
218 const struct GNUNET_ATS_Information *ats, 219 const struct GNUNET_ATS_Information *ats,
219 uint32_t ats_count, 220 uint32_t ats_count,
220 struct GNUNET_BANDWIDTH_Value32NBO 221 struct GNUNET_BANDWIDTH_Value32NBO
221 bandwidth_in, 222 bandwidth_in,
222 struct GNUNET_BANDWIDTH_Value32NBO 223 struct GNUNET_BANDWIDTH_Value32NBO
@@ -259,7 +260,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
259void 260void
260GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 261GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
261 const struct GNUNET_PeerIdentity *peer, 262 const struct GNUNET_PeerIdentity *peer,
262 const struct GNUNET_HELLO_Address *address, 263 const struct GNUNET_HELLO_Address *address,
263 struct Session *session, 264 struct Session *session,
264 const struct GNUNET_ATS_Information *ats, 265 const struct GNUNET_ATS_Information *ats,
265 uint32_t ats_count); 266 uint32_t ats_count);
@@ -268,7 +269,7 @@ void
268GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, 269GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
269 const struct GNUNET_PeerIdentity *peer, 270 const struct GNUNET_PeerIdentity *peer,
270 const struct GNUNET_HELLO_Address *address, 271 const struct GNUNET_HELLO_Address *address,
271 struct Session *session, 272 struct Session *session,
272 const struct GNUNET_ATS_Information *ats, 273 const struct GNUNET_ATS_Information *ats,
273 uint32_t ats_count); 274 uint32_t ats_count);
274 275
@@ -276,7 +277,7 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
276/** 277/**
277 * Obtain current latency information for the given neighbour. 278 * Obtain current latency information for the given neighbour.
278 * 279 *
279 * @param peer 280 * @param peer
280 * @return observed latency of the address, FOREVER if the address was 281 * @return observed latency of the address, FOREVER if the address was
281 * never successfully validated 282 * never successfully validated
282 */ 283 */
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index f14eb57d6..4b3dd455d 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -144,7 +144,8 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
144 if (plug->api == NULL) 144 if (plug->api == NULL)
145 { 145 {
146 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 146 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
147 _("Failed to load transport plugin for `%s'\n"), plug->lib_name); 147 _("Failed to load transport plugin for `%s'\n"),
148 plug->lib_name);
148 GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); 149 GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug);
149 GNUNET_free (plug->short_name); 150 GNUNET_free (plug->short_name);
150 GNUNET_free (plug->lib_name); 151 GNUNET_free (plug->lib_name);
@@ -210,16 +211,16 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
210 api = GST_plugins_find (address->transport_name); 211 api = GST_plugins_find (address->transport_name);
211 if (NULL == api) 212 if (NULL == api)
212 return "<plugin unknown>"; 213 return "<plugin unknown>";
213 if (0 == address->address_length) 214 if (0 == address->address_length)
214 { 215 {
215 GNUNET_snprintf (unable_to_show, 216 GNUNET_snprintf (unable_to_show, sizeof (unable_to_show),
216 sizeof (unable_to_show), 217 "<unable to stringify %u-byte long address of %s transport>",
217 "<unable to stringify %u-byte long address of %s transport>", 218 (unsigned int) address->address_length,
218 (unsigned int) address->address_length, 219 address->transport_name);
219 address->transport_name);
220 return unable_to_show; 220 return unable_to_show;
221 } 221 }
222 return api->address_to_string (NULL, address->address, address->address_length); 222 return api->address_to_string (NULL, address->address,
223 address->address_length);
223} 224}
224 225
225 226
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 006a318f6..641214b39 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -333,9 +333,7 @@ validation_entry_match (void *cls, const GNUNET_HashCode * key, void *value)
333 struct ValidationEntryMatchContext *vemc = cls; 333 struct ValidationEntryMatchContext *vemc = cls;
334 struct ValidationEntry *ve = value; 334 struct ValidationEntry *ve = value;
335 335
336 if (0 == 336 if (0 == GNUNET_HELLO_address_cmp (ve->address, vemc->address))
337 GNUNET_HELLO_address_cmp (ve->address,
338 vemc->address))
339 { 337 {
340 vemc->ve = ve; 338 vemc->ve = ve;
341 return GNUNET_NO; 339 return GNUNET_NO;
@@ -397,15 +395,13 @@ timeout_hello_validation (void *cls,
397 struct GNUNET_TIME_Relative left; 395 struct GNUNET_TIME_Relative left;
398 396
399 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; 397 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
400 max = GNUNET_TIME_absolute_max (ve->valid_until, 398 max = GNUNET_TIME_absolute_max (ve->valid_until, ve->revalidation_block);
401 ve->revalidation_block);
402 left = GNUNET_TIME_absolute_get_remaining (max); 399 left = GNUNET_TIME_absolute_get_remaining (max);
403 if (left.rel_value > 0) 400 if (left.rel_value > 0)
404 { 401 {
405 /* should wait a bit longer */ 402 /* should wait a bit longer */
406 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (left, 403 ve->timeout_task =
407 &timeout_hello_validation, 404 GNUNET_SCHEDULER_add_delayed (left, &timeout_hello_validation, ve);
408 ve);
409 return; 405 return;
410 } 406 }
411 GNUNET_STATISTICS_update (GST_stats, 407 GNUNET_STATISTICS_update (GST_stats,
@@ -443,10 +439,13 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
443 slen = strlen (ve->address->transport_name) + 1; 439 slen = strlen (ve->address->transport_name) + 1;
444 hello = GST_hello_get (); 440 hello = GST_hello_get ();
445 hsize = ntohs (hello->size); 441 hsize = ntohs (hello->size);
446 tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize; 442 tsize =
443 sizeof (struct TransportPingMessage) + ve->address->address_length +
444 slen + hsize;
447 445
448 ping.header.size = 446 ping.header.size =
449 htons (sizeof (struct TransportPingMessage) + ve->address->address_length + slen); 447 htons (sizeof (struct TransportPingMessage) +
448 ve->address->address_length + slen);
450 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); 449 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
451 ping.challenge = htonl (ve->challenge); 450 ping.challenge = htonl (ve->challenge);
452 ping.target = *pid; 451 ping.target = *pid;
@@ -459,7 +458,9 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
459 "HELLO", "PING", (unsigned int) tsize); 458 "HELLO", "PING", (unsigned int) tsize);
460 /* message too big (!?), get rid of HELLO */ 459 /* message too big (!?), get rid of HELLO */
461 hsize = 0; 460 hsize = 0;
462 tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize; 461 tsize =
462 sizeof (struct TransportPingMessage) + ve->address->address_length +
463 slen + hsize;
463 } 464 }
464 { 465 {
465 char message_buf[tsize]; 466 char message_buf[tsize];
@@ -481,8 +482,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
481 ret = 482 ret =
482 papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY, 483 papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY,
483 ACCEPTABLE_PING_DELAY, NULL /* no session */ , 484 ACCEPTABLE_PING_DELAY, NULL /* no session */ ,
484 ve->address->address, ve->address->address_length, 485 ve->address->address, ve->address->address_length,
485 GNUNET_YES, NULL, NULL); 486 GNUNET_YES, NULL, NULL);
486 } 487 }
487 } 488 }
488 if (-1 != ret) 489 if (-1 != ret)
@@ -515,12 +516,11 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
515 ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; 516 ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK;
516 delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block); 517 delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block);
517 /* How long until we can possibly permit the next PING? */ 518 /* How long until we can possibly permit the next PING? */
518 canonical_delay = 519 canonical_delay =
519 (ve->in_use == GNUNET_YES) 520 (ve->in_use ==
520 ? CONNECTED_PING_FREQUENCY 521 GNUNET_YES) ? CONNECTED_PING_FREQUENCY
521 : ( (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0) 522 : ((GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value >
522 ? VALIDATED_PING_FREQUENCY 523 0) ? VALIDATED_PING_FREQUENCY : UNVALIDATED_PING_KEEPALIVE);
523 : UNVALIDATED_PING_KEEPALIVE);
524 if (delay.rel_value > canonical_delay.rel_value * 2) 524 if (delay.rel_value > canonical_delay.rel_value * 2)
525 { 525 {
526 /* situation changed, recalculate delay */ 526 /* situation changed, recalculate delay */
@@ -534,28 +534,28 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
534 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); 534 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
535 return; 535 return;
536 } 536 }
537 ve->revalidation_block = 537 ve->revalidation_block = GNUNET_TIME_relative_to_absolute (canonical_delay);
538 GNUNET_TIME_relative_to_absolute (canonical_delay);
539 538
540 /* schedule next PINGing with some extra random delay to avoid synchronous re-validations */ 539 /* schedule next PINGing with some extra random delay to avoid synchronous re-validations */
541 rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 540 rdelay =
542 canonical_delay.rel_value); 541 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
542 canonical_delay.rel_value);
543 delay = 543 delay =
544 GNUNET_TIME_relative_add (canonical_delay, 544 GNUNET_TIME_relative_add (canonical_delay,
545 GNUNET_TIME_relative_multiply 545 GNUNET_TIME_relative_multiply
546 (GNUNET_TIME_UNIT_MILLISECONDS, rdelay)); 546 (GNUNET_TIME_UNIT_MILLISECONDS, rdelay));
547 ve->revalidation_task = 547 ve->revalidation_task =
548 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); 548 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
549 549
550 /* start PINGing by checking blacklist */ 550 /* start PINGing by checking blacklist */
551 GNUNET_STATISTICS_update (GST_stats, 551 GNUNET_STATISTICS_update (GST_stats,
552 gettext_noop ("# address revalidations started"), 1, 552 gettext_noop ("# address revalidations started"), 1,
553 GNUNET_NO); 553 GNUNET_NO);
554 bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name, 554 bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name,
555 &transmit_ping_if_allowed, ve); 555 &transmit_ping_if_allowed, ve);
556 if (NULL != bc) 556 if (NULL != bc)
557 ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already 557 ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already
558 called... */ 558 * called... */
559} 559}
560 560
561 561
@@ -592,9 +592,11 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
592 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; 592 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL;
593 ve->challenge = 593 ve->challenge =
594 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 594 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
595 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, 595 ve->timeout_task =
596 &timeout_hello_validation, ve); 596 GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE,
597 GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey, ve, 597 &timeout_hello_validation, ve);
598 GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey,
599 ve,
598 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 600 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
599 ve->expecting_pong = GNUNET_NO; 601 ve->expecting_pong = GNUNET_NO;
600 return ve; 602 return ve;
@@ -611,8 +613,7 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
611 * @return GNUNET_OK (keep the address) 613 * @return GNUNET_OK (keep the address)
612 */ 614 */
613static int 615static int
614add_valid_address (void *cls, 616add_valid_address (void *cls, const struct GNUNET_HELLO_Address *address,
615 const struct GNUNET_HELLO_Address *address,
616 struct GNUNET_TIME_Absolute expiration) 617 struct GNUNET_TIME_Absolute expiration)
617{ 618{
618 const struct GNUNET_HELLO_Message *hello = cls; 619 const struct GNUNET_HELLO_Message *hello = cls;
@@ -628,7 +629,7 @@ add_valid_address (void *cls,
628 GNUNET_break (0); 629 GNUNET_break (0);
629 return GNUNET_OK; /* invalid HELLO !? */ 630 return GNUNET_OK; /* invalid HELLO !? */
630 } 631 }
631 if (0 == memcmp(&GST_my_identity, &pid, sizeof (struct GNUNET_PeerIdentity))) 632 if (0 == memcmp (&GST_my_identity, &pid, sizeof (struct GNUNET_PeerIdentity)))
632 { 633 {
633 /* Peerinfo returned own identity, skip validation */ 634 /* Peerinfo returned own identity, skip validation */
634 return GNUNET_OK; 635 return GNUNET_OK;
@@ -639,8 +640,7 @@ add_valid_address (void *cls,
639 640
640 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) 641 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
641 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); 642 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
642 GNUNET_ATS_address_update (GST_ats, address, NULL, NULL, 643 GNUNET_ATS_address_update (GST_ats, address, NULL, NULL, 0);
643 0);
644 return GNUNET_OK; 644 return GNUNET_OK;
645} 645}
646 646
@@ -716,8 +716,7 @@ GST_validation_stop ()
716static void 716static void
717multicast_pong (void *cls, 717multicast_pong (void *cls,
718 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 718 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
719 *public_key, 719 *public_key, struct GNUNET_TIME_Absolute valid_until,
720 struct GNUNET_TIME_Absolute valid_until,
721 struct GNUNET_TIME_Absolute validation_block, 720 struct GNUNET_TIME_Absolute validation_block,
722 const struct GNUNET_HELLO_Address *address) 721 const struct GNUNET_HELLO_Address *address)
723{ 722{
@@ -729,8 +728,7 @@ multicast_pong (void *cls,
729 return; 728 return;
730 (void) papi->send (papi->cls, &address->peer, (const char *) pong, 729 (void) papi->send (papi->cls, &address->peer, (const char *) pong,
731 ntohs (pong->header.size), PONG_PRIORITY, 730 ntohs (pong->header.size), PONG_PRIORITY,
732 ACCEPTABLE_PING_DELAY, NULL, 731 ACCEPTABLE_PING_DELAY, NULL, address->address,
733 address->address,
734 address->address_length, GNUNET_YES, NULL, NULL); 732 address->address_length, GNUNET_YES, NULL, NULL);
735} 733}
736 734
@@ -747,7 +745,7 @@ void
747GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 745GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
748 const struct GNUNET_MessageHeader *hdr, 746 const struct GNUNET_MessageHeader *hdr,
749 const struct GNUNET_HELLO_Address *sender_address, 747 const struct GNUNET_HELLO_Address *sender_address,
750 struct Session *session) 748 struct Session *session)
751{ 749{
752 const struct TransportPingMessage *ping; 750 const struct TransportPingMessage *ping;
753 struct TransportPongMessage *pong; 751 struct TransportPongMessage *pong;
@@ -804,8 +802,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
804 address.transport_name = addr; 802 address.transport_name = addr;
805 address.peer = *sender; 803 address.peer = *sender;
806 if (GNUNET_YES != 804 if (GNUNET_YES !=
807 GST_hello_test_address (&address, &sig_cache, 805 GST_hello_test_address (&address, &sig_cache, &sig_cache_exp))
808 &sig_cache_exp))
809 { 806 {
810 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 807 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
811 _ 808 _
@@ -867,10 +864,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
867 ret = 864 ret =
868 papi->send (papi->cls, sender, (const char *) pong, 865 papi->send (papi->cls, sender, (const char *) pong,
869 ntohs (pong->header.size), PONG_PRIORITY, 866 ntohs (pong->header.size), PONG_PRIORITY,
870 ACCEPTABLE_PING_DELAY, session, 867 ACCEPTABLE_PING_DELAY, session, sender_address->address,
871 sender_address->address, 868 sender_address->address_length, GNUNET_SYSERR, NULL, NULL);
872 sender_address->address_length,
873 GNUNET_SYSERR, NULL, NULL);
874 if (ret != -1) 869 if (ret != -1)
875 { 870 {
876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -922,9 +917,9 @@ struct ValidateAddressContext
922 * @return GNUNET_OK (keep the address) 917 * @return GNUNET_OK (keep the address)
923 */ 918 */
924static int 919static int
925validate_address_iterator (void *cls, 920validate_address_iterator (void *cls,
926 const struct GNUNET_HELLO_Address *address, 921 const struct GNUNET_HELLO_Address *address,
927 struct GNUNET_TIME_Absolute expiration) 922 struct GNUNET_TIME_Absolute expiration)
928{ 923{
929 const struct ValidateAddressContext *vac = cls; 924 const struct ValidateAddressContext *vac = cls;
930 struct ValidationEntry *ve; 925 struct ValidationEntry *ve;
@@ -933,8 +928,7 @@ validate_address_iterator (void *cls,
933 return GNUNET_OK; /* expired */ 928 return GNUNET_OK; /* expired */
934 ve = find_validation_entry (&vac->public_key, address); 929 ve = find_validation_entry (&vac->public_key, address);
935 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) 930 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
936 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, 931 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
937 ve);
938 return GNUNET_OK; 932 return GNUNET_OK;
939} 933}
940 934
@@ -956,8 +950,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
956 if (GNUNET_YES == ve->copied) 950 if (GNUNET_YES == ve->copied)
957 return 0; /* terminate */ 951 return 0; /* terminate */
958 ve->copied = GNUNET_YES; 952 ve->copied = GNUNET_YES;
959 return GNUNET_HELLO_add_address (ve->address, ve->valid_until, 953 return GNUNET_HELLO_add_address (ve->address, ve->valid_until, buf, max);
960 buf, max);
961} 954}
962 955
963 956
@@ -1056,7 +1049,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1056 struct GNUNET_ATS_Information ats; 1049 struct GNUNET_ATS_Information ats;
1057 1050
1058 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 1051 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
1059 ats.value = htonl ((uint32_t) ve->latency.rel_value); 1052 ats.value = htonl ((uint32_t) ve->latency.rel_value);
1060 GNUNET_ATS_address_update (GST_ats, ve->address, NULL, &ats, 1); 1053 GNUNET_ATS_address_update (GST_ats, ve->address, NULL, &ats, 1);
1061 } 1054 }
1062 /* build HELLO to store in PEERINFO */ 1055 /* build HELLO to store in PEERINFO */
@@ -1102,7 +1095,8 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1102 GNUNET_free (h); 1095 GNUNET_free (h);
1103 GNUNET_assert (NULL == 1096 GNUNET_assert (NULL ==
1104 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO, 1097 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
1105 &validate_address_iterator, &vac)); 1098 &validate_address_iterator,
1099 &vac));
1106} 1100}
1107 1101
1108 1102
@@ -1138,8 +1132,8 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value)
1138 struct IteratorContext *ic = cls; 1132 struct IteratorContext *ic = cls;
1139 struct ValidationEntry *ve = value; 1133 struct ValidationEntry *ve = value;
1140 1134
1141 ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until, 1135 ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until, ve->revalidation_block,
1142 ve->revalidation_block, ve->address); 1136 ve->address);
1143 return GNUNET_OK; 1137 return GNUNET_OK;
1144} 1138}
1145 1139
@@ -1178,16 +1172,15 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
1178 */ 1172 */
1179void 1173void
1180GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, 1174GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
1181 const struct GNUNET_HELLO_Address *address, 1175 const struct GNUNET_HELLO_Address *address,
1182 struct Session *session, 1176 struct Session *session, int in_use)
1183 int in_use)
1184{ 1177{
1185 struct ValidationEntry *ve; 1178 struct ValidationEntry *ve;
1186 1179
1187 if (NULL != address) 1180 if (NULL != address)
1188 ve = find_validation_entry (NULL, address); 1181 ve = find_validation_entry (NULL, address);
1189 else 1182 else
1190 ve = NULL; /* FIXME: lookup based on session... */ 1183 ve = NULL; /* FIXME: lookup based on session... */
1191 if (NULL == ve) 1184 if (NULL == ve)
1192 { 1185 {
1193 /* this can happen for inbound connections (sender_address_len == 0); */ 1186 /* this can happen for inbound connections (sender_address_len == 0); */
@@ -1195,19 +1188,16 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
1195 } 1188 }
1196 if (ve->in_use == in_use) 1189 if (ve->in_use == in_use)
1197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1198 "GST_validation_set_address_use: %s %s: ve->in_use %i <-> in_use %i\n", 1191 "GST_validation_set_address_use: %s %s: ve->in_use %i <-> in_use %i\n",
1199 GNUNET_i2s(sender), 1192 GNUNET_i2s (sender), GST_plugins_a2s (address), ve->in_use,
1200 GST_plugins_a2s(address), 1193 in_use);
1201 ve->in_use, 1194 GNUNET_break (ve->in_use != in_use); /* should be different... */
1202 in_use);
1203 GNUNET_break (ve->in_use != in_use); /* should be different... */
1204 ve->in_use = in_use; 1195 ve->in_use = in_use;
1205 if (in_use == GNUNET_YES) 1196 if (in_use == GNUNET_YES)
1206 { 1197 {
1207 /* from now on, higher frequeny, so reschedule now */ 1198 /* from now on, higher frequeny, so reschedule now */
1208 GNUNET_SCHEDULER_cancel (ve->revalidation_task); 1199 GNUNET_SCHEDULER_cancel (ve->revalidation_task);
1209 ve->revalidation_task = 1200 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
1210 GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
1211 } 1201 }
1212} 1202}
1213 1203
@@ -1218,20 +1208,20 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
1218 * 1208 *
1219 * @param sender peer 1209 * @param sender peer
1220 * @param address the address 1210 * @param address the address
1221 * @param session session 1211 * @param session session
1222 * @return observed latency of the address, FOREVER if the address was 1212 * @return observed latency of the address, FOREVER if the address was
1223 * never successfully validated 1213 * never successfully validated
1224 */ 1214 */
1225struct GNUNET_TIME_Relative 1215struct GNUNET_TIME_Relative
1226GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, 1216GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
1227 const struct GNUNET_HELLO_Address *address, 1217 const struct GNUNET_HELLO_Address *address,
1228 struct Session *session) 1218 struct Session *session)
1229{ 1219{
1230 struct ValidationEntry *ve; 1220 struct ValidationEntry *ve;
1231 1221
1232 if (NULL == address) 1222 if (NULL == address)
1233 { 1223 {
1234 GNUNET_break (0); // FIXME: support having latency only with session... 1224 GNUNET_break (0); // FIXME: support having latency only with session...
1235 return GNUNET_TIME_UNIT_FOREVER_REL; 1225 return GNUNET_TIME_UNIT_FOREVER_REL;
1236 } 1226 }
1237 ve = find_validation_entry (NULL, address); 1227 ve = find_validation_entry (NULL, address);
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index a3692e3cf..f5282d4e9 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -59,16 +59,15 @@ GST_validation_stop (void);
59 */ 59 */
60void 60void
61GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, 61GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
62 const struct GNUNET_HELLO_Address *address, 62 const struct GNUNET_HELLO_Address *address,
63 struct Session *session, 63 struct Session *session, int in_use);
64 int in_use);
65 64
66 65
67/** 66/**
68 * Query validation about the latest observed latency on a given 67 * Query validation about the latest observed latency on a given
69 * address. 68 * address.
70 * 69 *
71 * @param sender peer 70 * @param sender peer
72 * @param address the address 71 * @param address the address
73 * @param session session 72 * @param session session
74 * @return observed latency of the address, FOREVER if the address was 73 * @return observed latency of the address, FOREVER if the address was
@@ -76,8 +75,8 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
76 */ 75 */
77struct GNUNET_TIME_Relative 76struct GNUNET_TIME_Relative
78GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, 77GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
79 const struct GNUNET_HELLO_Address *address, 78 const struct GNUNET_HELLO_Address *address,
80 struct Session *session); 79 struct Session *session);
81 80
82 81
83/** 82/**
@@ -91,8 +90,8 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
91void 90void
92GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 91GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
93 const struct GNUNET_MessageHeader *hdr, 92 const struct GNUNET_MessageHeader *hdr,
94 const struct GNUNET_HELLO_Address *sender_address, 93 const struct GNUNET_HELLO_Address *sender_address,
95 struct Session *session); 94 struct Session *session);
96 95
97 96
98/** 97/**
@@ -138,7 +137,8 @@ typedef void (*GST_ValidationAddressCallback) (void *cls,
138 valid_until, 137 valid_until,
139 struct GNUNET_TIME_Absolute 138 struct GNUNET_TIME_Absolute
140 validation_block, 139 validation_block,
141 const struct GNUNET_HELLO_Address *address); 140 const struct GNUNET_HELLO_Address
141 * address);
142 142
143 143
144/** 144/**
diff --git a/src/transport/gnunet-transport-wlan-helper-dummy.c b/src/transport/gnunet-transport-wlan-helper-dummy.c
index b5f2f625a..32d58426c 100644
--- a/src/transport/gnunet-transport-wlan-helper-dummy.c
+++ b/src/transport/gnunet-transport-wlan-helper-dummy.c
@@ -188,19 +188,15 @@ main (int argc, char *argv[])
188 erg = mkfifo (FIFO_FILE1, 0666); 188 erg = mkfifo (FIFO_FILE1, 0666);
189 if (0 != erg) 189 if (0 != erg)
190 { 190 {
191 fprintf (stderr, 191 fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
192 "Error in mkfifo(%s): %s\n", 192 strerror (errno));
193 FIFO_FILE1,
194 strerror (errno));
195 //exit(1); 193 //exit(1);
196 } 194 }
197 erg = mkfifo (FIFO_FILE2, 0666); 195 erg = mkfifo (FIFO_FILE2, 0666);
198 if (0 != erg) 196 if (0 != erg)
199 { 197 {
200 fprintf (stderr, 198 fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE2,
201 "Error in mkfifo(%s): %s\n", 199 strerror (errno));
202 FIFO_FILE2,
203 strerror (errno));
204 //exit(1); 200 //exit(1);
205 } 201 }
206 202
@@ -256,9 +252,7 @@ main (int argc, char *argv[])
256 252
257 if (fdpin >= FD_SETSIZE) 253 if (fdpin >= FD_SETSIZE)
258 { 254 {
259 fprintf (stderr, 255 fprintf (stderr, "File fdpin number too large (%d > %u)\n", fdpin,
260 "File fdpin number too large (%d > %u)\n",
261 fdpin,
262 (unsigned int) FD_SETSIZE); 256 (unsigned int) FD_SETSIZE);
263 goto end; 257 goto end;
264 } 258 }
@@ -268,9 +262,7 @@ main (int argc, char *argv[])
268 262
269 if (fdpout >= FD_SETSIZE) 263 if (fdpout >= FD_SETSIZE)
270 { 264 {
271 fprintf (stderr, 265 fprintf (stderr, "File fdpout number too large (%d > %u)\n", fdpout,
272 "File fdpout number too large (%d > %u)\n",
273 fdpout,
274 (unsigned int) FD_SETSIZE); 266 (unsigned int) FD_SETSIZE);
275 goto end; 267 goto end;
276 268
@@ -328,13 +320,11 @@ main (int argc, char *argv[])
328 } 320 }
329 321
330 retval = select (maxfd + 1, &rfds, &wfds, NULL, &tv); 322 retval = select (maxfd + 1, &rfds, &wfds, NULL, &tv);
331 if ( (-1 == retval) && (EINTR == errno) ) 323 if ((-1 == retval) && (EINTR == errno))
332 continue; 324 continue;
333 if (0 > retval) 325 if (0 > retval)
334 { 326 {
335 fprintf (stderr, 327 fprintf (stderr, "select failed: %s\n", strerror (errno));
336 "select failed: %s\n",
337 strerror (errno));
338 closeprog = 1; 328 closeprog = 1;
339 break; 329 break;
340 } 330 }
@@ -347,9 +337,8 @@ main (int argc, char *argv[])
347 if (0 > ret) 337 if (0 > ret)
348 { 338 {
349 closeprog = 1; 339 closeprog = 1;
350 fprintf (stderr, 340 fprintf (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
351 "Write ERROR to STDOUT_FILENO: %s\n", 341 strerror (errno));
352 strerror (errno));
353 break; 342 break;
354 } 343 }
355 else 344 else
@@ -373,9 +362,7 @@ main (int argc, char *argv[])
373 if (0 > ret) 362 if (0 > ret)
374 { 363 {
375 closeprog = 1; 364 closeprog = 1;
376 fprintf (stderr, 365 fprintf (stderr, "Write ERROR to fdpout: %s\n", strerror (errno));
377 "Write ERROR to fdpout: %s\n",
378 strerror (errno));
379 } 366 }
380 else 367 else
381 { 368 {
@@ -396,9 +383,8 @@ main (int argc, char *argv[])
396 if (0 > readsize) 383 if (0 > readsize)
397 { 384 {
398 closeprog = 1; 385 closeprog = 1;
399 fprintf (stderr, 386 fprintf (stderr, "Error reading from STDIN_FILENO: %s\n",
400 "Error reading from STDIN_FILENO: %s\n", 387 strerror (errno));
401 strerror (errno));
402 } 388 }
403 else if (0 < readsize) 389 else if (0 < readsize)
404 { 390 {
@@ -419,9 +405,7 @@ main (int argc, char *argv[])
419 if (0 > readsize) 405 if (0 > readsize)
420 { 406 {
421 closeprog = 1; 407 closeprog = 1;
422 fprintf (stderr, 408 fprintf (stderr, "Error reading from fdpin: %s\n", strerror (errno));
423 "Error reading from fdpin: %s\n",
424 strerror (errno));
425 break; 409 break;
426 } 410 }
427 else if (0 < readsize) 411 else if (0 < readsize)
@@ -453,4 +437,3 @@ end:
453 } 437 }
454 return 0; 438 return 0;
455} 439}
456
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 53e0efedd..ca4542f1a 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -239,35 +239,35 @@ enum ieee80211_radiotap_type
239}; 239};
240 240
241/* For IEEE80211_RADIOTAP_FLAGS */ 241/* For IEEE80211_RADIOTAP_FLAGS */
242#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 242#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
243 * during CFP 243 * during CFP
244 */ 244 */
245#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 245#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
246 * with short 246 * with short
247 * preamble 247 * preamble
248 */ 248 */
249#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 249#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
250 * with WEP encryption 250 * with WEP encryption
251 */ 251 */
252#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 252#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
253 * with fragmentation 253 * with fragmentation
254 */ 254 */
255#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 255#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
256#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 256#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
257 * 802.11 header and payload 257 * 802.11 header and payload
258 * (to 32-bit boundary) 258 * (to 32-bit boundary)
259 */ 259 */
260/* For IEEE80211_RADIOTAP_RX_FLAGS */ 260/* For IEEE80211_RADIOTAP_RX_FLAGS */
261#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ 261#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
262 262
263/* For IEEE80211_RADIOTAP_TX_FLAGS */ 263/* For IEEE80211_RADIOTAP_TX_FLAGS */
264#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive 264#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
265 * retries */ 265 * retries */
266#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 266#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
267#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 267#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
268#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */ 268#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */
269#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled 269#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled
270 * by userspace */ 270 * by userspace */
271 271
272 272
273/** 273/**
@@ -478,10 +478,9 @@ struct ieee80211_radiotap_iterator
478 * index corresponds to the IEEE80211_RADIOTAP_... defines. 478 * index corresponds to the IEEE80211_RADIOTAP_... defines.
479 */ 479 */
480static int 480static int
481ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator 481ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator,
482 *iterator, 482 struct ieee80211_radiotap_header
483 struct ieee80211_radiotap_header 483 *radiotap_header, int max_length)
484 *radiotap_header, int max_length)
485{ 484{
486 if (iterator == NULL) 485 if (iterator == NULL)
487 return (-EINVAL); 486 return (-EINVAL);
@@ -503,47 +502,47 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator
503 iterator->arg_index = 0; 502 iterator->arg_index = 0;
504 iterator->bitmap_shifter = le32toh (radiotap_header->it_present); 503 iterator->bitmap_shifter = le32toh (radiotap_header->it_present);
505 iterator->arg = 504 iterator->arg =
506 ((uint8_t *) radiotap_header) + sizeof (struct ieee80211_radiotap_header); 505 ((uint8_t *) radiotap_header) + sizeof (struct ieee80211_radiotap_header);
507 iterator->this_arg = 0; 506 iterator->this_arg = 0;
508 507
509 /* find payload start allowing for extended bitmap(s) */ 508 /* find payload start allowing for extended bitmap(s) */
510 509
511 if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) 510 if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK))
511 {
512 while (le32toh (*((uint32_t *) iterator->arg)) &
513 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
512 { 514 {
513 while (le32toh (*((uint32_t *) iterator->arg)) &
514 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
515 {
516 iterator->arg += sizeof (uint32_t);
517
518 /*
519 * check for insanity where the present bitmaps
520 * keep claiming to extend up to or even beyond the
521 * stated radiotap header length
522 */
523
524 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
525 iterator->max_length)
526 return (-EINVAL);
527
528 }
529
530 iterator->arg += sizeof (uint32_t); 515 iterator->arg += sizeof (uint32_t);
531 516
532 /* 517 /*
533 * no need to check again for blowing past stated radiotap 518 * check for insanity where the present bitmaps
534 * header length, becuase ieee80211_radiotap_iterator_next 519 * keep claiming to extend up to or even beyond the
535 * checks it before it is dereferenced 520 * stated radiotap header length
536 */ 521 */
537 522
523 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
524 iterator->max_length)
525 return (-EINVAL);
526
538 } 527 }
539 528
529 iterator->arg += sizeof (uint32_t);
530
531 /*
532 * no need to check again for blowing past stated radiotap
533 * header length, becuase ieee80211_radiotap_iterator_next
534 * checks it before it is dereferenced
535 */
536
537 }
538
540 /* we are all initialized happily */ 539 /* we are all initialized happily */
541 return 0; 540 return 0;
542} 541}
543 542
544 543
545/** 544/**
546 * @brief ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg 545 * @brief ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
547 * 546 *
548 * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...) 547 * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...)
549 * and sets iterator->this_arg to point to the payload for the arg. It takes 548 * and sets iterator->this_arg to point to the payload for the arg. It takes
@@ -556,8 +555,7 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator
556 * @return next present arg index on success or negative if no more or error 555 * @return next present arg index on success or negative if no more or error
557 */ 556 */
558static int 557static int
559ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator 558ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator)
560 *iterator)
561{ 559{
562 560
563 /* 561 /*
@@ -594,10 +592,10 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator
594 [IEEE80211_RADIOTAP_RX_FLAGS] = 0x22, 592 [IEEE80211_RADIOTAP_RX_FLAGS] = 0x22,
595 [IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11, 593 [IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11,
596 [IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11 594 [IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11
597 /* 595 /*
598 * add more here as they are defined in 596 * add more here as they are defined in
599 * include/net/ieee80211_radiotap.h 597 * include/net/ieee80211_radiotap.h
600 */ 598 */
601 }; 599 };
602 600
603 /* 601 /*
@@ -606,92 +604,92 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator
606 */ 604 */
607 605
608 while (iterator->arg_index < (int) sizeof (rt_sizes)) 606 while (iterator->arg_index < (int) sizeof (rt_sizes))
607 {
608 int hit = 0;
609
610 if (!(iterator->bitmap_shifter & 1))
611 goto next_entry; /* arg not present */
612
613 /*
614 * arg is present, account for alignment padding
615 * 8-bit args can be at any alignment
616 * 16-bit args must start on 16-bit boundary
617 * 32-bit args must start on 32-bit boundary
618 * 64-bit args must start on 64-bit boundary
619 *
620 * note that total arg size can differ from alignment of
621 * elements inside arg, so we use upper nybble of length
622 * table to base alignment on
623 *
624 * also note: these alignments are ** relative to the
625 * start of the radiotap header **. There is no guarantee
626 * that the radiotap header itself is aligned on any
627 * kind of boundary.
628 */
629
630 if ((((void *) iterator->arg) -
631 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4)
632 - 1))
633 iterator->arg_index +=
634 (rt_sizes[iterator->arg_index] >> 4) -
635 ((((void *) iterator->arg) -
636 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >>
637 4) - 1));
638
639 /*
640 * this is what we will return to user, but we need to
641 * move on first so next call has something fresh to test
642 */
643
644 iterator->this_arg_index = iterator->arg_index;
645 iterator->this_arg = iterator->arg;
646 hit = 1;
647
648 /* internally move on the size of this arg */
649
650 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
651
652 /*
653 * check for insanity where we are given a bitmap that
654 * claims to have more arg content than the length of the
655 * radiotap section. We will normally end up equalling this
656 * max_length on the last arg, never exceeding it.
657 */
658
659 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
660 iterator->max_length)
661 return (-EINVAL);
662
663next_entry:
664
665 iterator->arg_index++;
666 if (((iterator->arg_index & 31) == 0))
609 { 667 {
610 int hit = 0; 668 /* completed current uint32_t bitmap */
611 669 if (iterator->bitmap_shifter & 1)
612 if (!(iterator->bitmap_shifter & 1)) 670 {
613 goto next_entry; /* arg not present */ 671 /* b31 was set, there is more */
614 672 /* move to next uint32_t bitmap */
615 /* 673 iterator->bitmap_shifter = le32toh (*iterator->next_bitmap);
616 * arg is present, account for alignment padding 674 iterator->next_bitmap++;
617 * 8-bit args can be at any alignment 675 }
618 * 16-bit args must start on 16-bit boundary
619 * 32-bit args must start on 32-bit boundary
620 * 64-bit args must start on 64-bit boundary
621 *
622 * note that total arg size can differ from alignment of
623 * elements inside arg, so we use upper nybble of length
624 * table to base alignment on
625 *
626 * also note: these alignments are ** relative to the
627 * start of the radiotap header **. There is no guarantee
628 * that the radiotap header itself is aligned on any
629 * kind of boundary.
630 */
631
632 if ((((void *) iterator->arg) -
633 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >>
634 4) - 1))
635 iterator->arg_index +=
636 (rt_sizes[iterator->arg_index] >> 4) -
637 ((((void *) iterator->arg) -
638 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index]
639 >> 4) - 1));
640
641 /*
642 * this is what we will return to user, but we need to
643 * move on first so next call has something fresh to test
644 */
645
646 iterator->this_arg_index = iterator->arg_index;
647 iterator->this_arg = iterator->arg;
648 hit = 1;
649
650 /* internally move on the size of this arg */
651
652 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
653
654 /*
655 * check for insanity where we are given a bitmap that
656 * claims to have more arg content than the length of the
657 * radiotap section. We will normally end up equalling this
658 * max_length on the last arg, never exceeding it.
659 */
660
661 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
662 iterator->max_length)
663 return (-EINVAL);
664
665 next_entry:
666
667 iterator->arg_index++;
668 if (((iterator->arg_index & 31) == 0))
669 {
670 /* completed current uint32_t bitmap */
671 if (iterator->bitmap_shifter & 1)
672 {
673 /* b31 was set, there is more */
674 /* move to next uint32_t bitmap */
675 iterator->bitmap_shifter = le32toh (*iterator->next_bitmap);
676 iterator->next_bitmap++;
677 }
678 else
679 {
680 /* no more bitmaps: end */
681 iterator->arg_index = sizeof (rt_sizes);
682 }
683 }
684 else 676 else
685 { /* just try the next bit */ 677 {
686 iterator->bitmap_shifter >>= 1; 678 /* no more bitmaps: end */
687 } 679 iterator->arg_index = sizeof (rt_sizes);
680 }
681 }
682 else
683 { /* just try the next bit */
684 iterator->bitmap_shifter >>= 1;
685 }
688 686
689 /* if we found a valid arg earlier, return it now */ 687 /* if we found a valid arg earlier, return it now */
690 688
691 if (hit) 689 if (hit)
692 return (iterator->this_arg_index); 690 return (iterator->this_arg_index);
693 691
694 } 692 }
695 693
696 /* we don't know how to handle any more args, we're done */ 694 /* we don't know how to handle any more args, we're done */
697 695
@@ -841,7 +839,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
841 crc = calc_crc_osdep (buf, len); 839 crc = calc_crc_osdep (buf, len);
842 buf += len; 840 buf += len;
843 return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && 841 return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
844 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); 842 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
845} 843}
846 844
847 845
@@ -890,8 +888,8 @@ linux_get_channel (const struct Hardware_Infos *dev)
890 * @return size read from the buffer 888 * @return size read from the buffer
891 */ 889 */
892static ssize_t 890static ssize_t
893linux_read (struct Hardware_Infos *dev, unsigned char *buf, 891linux_read (struct Hardware_Infos *dev, unsigned char *buf, size_t buf_size,
894 size_t buf_size, struct Radiotap_rx *ri) 892 struct Radiotap_rx *ri)
895{ 893{
896 unsigned char tmpbuf[buf_size]; 894 unsigned char tmpbuf[buf_size];
897 ssize_t caplen; 895 ssize_t caplen;
@@ -901,172 +899,170 @@ linux_read (struct Hardware_Infos *dev, unsigned char *buf,
901 899
902 caplen = read (dev->fd_raw, tmpbuf, buf_size); 900 caplen = read (dev->fd_raw, tmpbuf, buf_size);
903 if (0 > caplen) 901 if (0 > caplen)
904 { 902 {
905 if (EAGAIN == errno) 903 if (EAGAIN == errno)
906 return 0; 904 return 0;
907 fprintf (stderr, "Failed to read from RAW socket: %s\n", 905 fprintf (stderr, "Failed to read from RAW socket: %s\n", strerror (errno));
908 strerror (errno)); 906 return -1;
909 return -1; 907 }
910 }
911 908
912 memset (buf, 0, buf_size); 909 memset (buf, 0, buf_size);
913 memset (ri, 0, sizeof (*ri)); 910 memset (ri, 0, sizeof (*ri));
914 911
915 switch (dev->arptype_in) 912 switch (dev->arptype_in)
913 {
914 case ARPHRD_IEEE80211_PRISM:
915 {
916 /* skip the prism header */
917 if (tmpbuf[7] == 0x40)
916 { 918 {
917 case ARPHRD_IEEE80211_PRISM: 919 /* prism54 uses a different format */
918 { 920 ri->ri_power = tmpbuf[0x33];
919 /* skip the prism header */ 921 ri->ri_noise = *(unsigned int *) (tmpbuf + 0x33 + 12);
920 if (tmpbuf[7] == 0x40) 922 ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x33 + 24)) * 500000;
921 { 923 got_signal = 1;
922 /* prism54 uses a different format */ 924 got_noise = 1;
923 ri->ri_power = tmpbuf[0x33]; 925 n = 0x40;
924 ri->ri_noise = *(unsigned int *) (tmpbuf + 0x33 + 12); 926 }
925 ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x33 + 24)) * 500000; 927 else
926 got_signal = 1; 928 {
927 got_noise = 1; 929 ri->ri_mactime = *(uint64_t *) (tmpbuf + 0x5C - 48);
928 n = 0x40; 930 ri->ri_channel = *(unsigned int *) (tmpbuf + 0x5C - 36);
929 } 931 ri->ri_power = *(unsigned int *) (tmpbuf + 0x5C);
930 else 932 ri->ri_noise = *(unsigned int *) (tmpbuf + 0x5C + 12);
931 { 933 ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x5C + 24)) * 500000;
932 ri->ri_mactime = *(uint64_t *) (tmpbuf + 0x5C - 48); 934 got_channel = 1;
933 ri->ri_channel = *(unsigned int *) (tmpbuf + 0x5C - 36); 935 got_signal = 1;
934 ri->ri_power = *(unsigned int *) (tmpbuf + 0x5C); 936 got_noise = 1;
935 ri->ri_noise = *(unsigned int *) (tmpbuf + 0x5C + 12); 937 n = *(int *) (tmpbuf + 4);
936 ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x5C + 24)) * 500000; 938 }
937 got_channel = 1; 939
938 got_signal = 1; 940 if (n < 8 || n >= caplen)
939 got_noise = 1; 941 return (0);
940 n = *(int *) (tmpbuf + 4); 942 }
941 } 943 break;
942
943 if (n < 8 || n >= caplen)
944 return (0);
945 }
946 break;
947 944
948 case ARPHRD_IEEE80211_FULL: 945 case ARPHRD_IEEE80211_FULL:
946 {
947 struct ieee80211_radiotap_iterator iterator;
948 struct ieee80211_radiotap_header *rthdr;
949
950 rthdr = (struct ieee80211_radiotap_header *) tmpbuf;
951
952 if (ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen) < 0)
953 return (0);
954
955 /* go through the radiotap arguments we have been given
956 * by the driver
957 */
958
959 while (ieee80211_radiotap_iterator_next (&iterator) >= 0)
960 {
961
962 switch (iterator.this_arg_index)
949 { 963 {
950 struct ieee80211_radiotap_iterator iterator; 964
951 struct ieee80211_radiotap_header *rthdr; 965 case IEEE80211_RADIOTAP_TSFT:
952 966 ri->ri_mactime = le64toh (*((uint64_t *) iterator.this_arg));
953 rthdr = (struct ieee80211_radiotap_header *) tmpbuf; 967 break;
954 968
955 if (ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen) < 0) 969 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
956 return (0); 970 if (!got_signal)
957 971 {
958 /* go through the radiotap arguments we have been given 972 if (*iterator.this_arg < 127)
959 * by the driver 973 ri->ri_power = *iterator.this_arg;
960 */ 974 else
961 975 ri->ri_power = *iterator.this_arg - 255;
962 while (ieee80211_radiotap_iterator_next (&iterator) >= 0) 976
963 { 977 got_signal = 1;
964 978 }
965 switch (iterator.this_arg_index) 979 break;
966 { 980
967 981 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
968 case IEEE80211_RADIOTAP_TSFT: 982 if (!got_signal)
969 ri->ri_mactime = le64toh (*((uint64_t *) iterator.this_arg)); 983 {
970 break; 984 if (*iterator.this_arg < 127)
971 985 ri->ri_power = *iterator.this_arg;
972 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: 986 else
973 if (!got_signal) 987 ri->ri_power = *iterator.this_arg - 255;
974 { 988
975 if (*iterator.this_arg < 127) 989 got_signal = 1;
976 ri->ri_power = *iterator.this_arg; 990 }
977 else 991 break;
978 ri->ri_power = *iterator.this_arg - 255; 992
979 993 case IEEE80211_RADIOTAP_DBM_ANTNOISE:
980 got_signal = 1; 994 if (!got_noise)
981 } 995 {
982 break; 996 if (*iterator.this_arg < 127)
983 997 ri->ri_noise = *iterator.this_arg;
984 case IEEE80211_RADIOTAP_DB_ANTSIGNAL: 998 else
985 if (!got_signal) 999 ri->ri_noise = *iterator.this_arg - 255;
986 { 1000
987 if (*iterator.this_arg < 127) 1001 got_noise = 1;
988 ri->ri_power = *iterator.this_arg; 1002 }
989 else 1003 break;
990 ri->ri_power = *iterator.this_arg - 255; 1004
991 1005 case IEEE80211_RADIOTAP_DB_ANTNOISE:
992 got_signal = 1; 1006 if (!got_noise)
993 } 1007 {
994 break; 1008 if (*iterator.this_arg < 127)
995 1009 ri->ri_noise = *iterator.this_arg;
996 case IEEE80211_RADIOTAP_DBM_ANTNOISE: 1010 else
997 if (!got_noise) 1011 ri->ri_noise = *iterator.this_arg - 255;
998 { 1012
999 if (*iterator.this_arg < 127) 1013 got_noise = 1;
1000 ri->ri_noise = *iterator.this_arg; 1014 }
1001 else 1015 break;
1002 ri->ri_noise = *iterator.this_arg - 255; 1016
1003 1017 case IEEE80211_RADIOTAP_ANTENNA:
1004 got_noise = 1; 1018 ri->ri_antenna = *iterator.this_arg;
1005 } 1019 break;
1006 break; 1020
1007 1021 case IEEE80211_RADIOTAP_CHANNEL:
1008 case IEEE80211_RADIOTAP_DB_ANTNOISE: 1022 ri->ri_channel = *iterator.this_arg;
1009 if (!got_noise) 1023 got_channel = 1;
1010 { 1024 break;
1011 if (*iterator.this_arg < 127) 1025
1012 ri->ri_noise = *iterator.this_arg; 1026 case IEEE80211_RADIOTAP_RATE:
1013 else 1027 ri->ri_rate = (*iterator.this_arg) * 500000;
1014 ri->ri_noise = *iterator.this_arg - 255; 1028 break;
1015 1029
1016 got_noise = 1; 1030 case IEEE80211_RADIOTAP_FLAGS:
1017 } 1031 /* is the CRC visible at the end?
1018 break; 1032 * remove
1019 1033 */
1020 case IEEE80211_RADIOTAP_ANTENNA: 1034 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS)
1021 ri->ri_antenna = *iterator.this_arg; 1035 {
1022 break; 1036 fcs_removed = 1;
1023 1037 caplen -= 4;
1024 case IEEE80211_RADIOTAP_CHANNEL: 1038 }
1025 ri->ri_channel = *iterator.this_arg; 1039
1026 got_channel = 1; 1040 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_RX_BADFCS)
1027 break; 1041 return (0);
1028 1042
1029 case IEEE80211_RADIOTAP_RATE: 1043 break;
1030 ri->ri_rate = (*iterator.this_arg) * 500000;
1031 break;
1032
1033 case IEEE80211_RADIOTAP_FLAGS:
1034 /* is the CRC visible at the end?
1035 * remove
1036 */
1037 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS)
1038 {
1039 fcs_removed = 1;
1040 caplen -= 4;
1041 }
1042
1043 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_RX_BADFCS)
1044 return (0);
1045
1046 break;
1047 }
1048 }
1049 n = le16toh (rthdr->it_len);
1050 if (n <= 0 || n >= caplen)
1051 return 0;
1052 } 1044 }
1053 break;
1054 case ARPHRD_IEEE80211:
1055 /* do nothing? */
1056 break;
1057 default:
1058 errno = ENOTSUP;
1059 return -1;
1060 } 1045 }
1046 n = le16toh (rthdr->it_len);
1047 if (n <= 0 || n >= caplen)
1048 return 0;
1049 }
1050 break;
1051 case ARPHRD_IEEE80211:
1052 /* do nothing? */
1053 break;
1054 default:
1055 errno = ENOTSUP;
1056 return -1;
1057 }
1061 1058
1062 caplen -= n; 1059 caplen -= n;
1063 1060
1064 //detect fcs at the end, even if the flag wasn't set and remove it 1061 //detect fcs at the end, even if the flag wasn't set and remove it
1065 if ((0 == fcs_removed) 1062 if ((0 == fcs_removed) && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4)))
1066 && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4))) 1063 {
1067 { 1064 caplen -= 4;
1068 caplen -= 4; 1065 }
1069 }
1070 memcpy (buf, tmpbuf + n, caplen); 1066 memcpy (buf, tmpbuf + n, caplen);
1071 if (!got_channel) 1067 if (!got_channel)
1072 ri->ri_channel = linux_get_channel (dev); 1068 ri->ri_channel = linux_get_channel (dev);
@@ -1092,12 +1088,11 @@ openraw (struct Hardware_Infos *dev)
1092 memset (&ifr, 0, sizeof (ifr)); 1088 memset (&ifr, 0, sizeof (ifr));
1093 strncpy (ifr.ifr_name, dev->iface, IFNAMSIZ); 1089 strncpy (ifr.ifr_name, dev->iface, IFNAMSIZ);
1094 if (-1 == ioctl (dev->fd_raw, SIOCGIFINDEX, &ifr)) 1090 if (-1 == ioctl (dev->fd_raw, SIOCGIFINDEX, &ifr))
1095 { 1091 {
1096 fprintf (stderr, 1092 fprintf (stderr, "ioctl(SIOCGIFINDEX) on interface `%.*s' failed: %s\n",
1097 "ioctl(SIOCGIFINDEX) on interface `%.*s' failed: %s\n", 1093 IFNAMSIZ, dev->iface, strerror (errno));
1098 IFNAMSIZ, dev->iface, strerror (errno)); 1094 return 1;
1099 return 1; 1095 }
1100 }
1101 1096
1102 /* lookup the hardware type */ 1097 /* lookup the hardware type */
1103 memset (&sll, 0, sizeof (sll)); 1098 memset (&sll, 0, sizeof (sll));
@@ -1105,78 +1100,72 @@ openraw (struct Hardware_Infos *dev)
1105 sll.sll_ifindex = ifr.ifr_ifindex; 1100 sll.sll_ifindex = ifr.ifr_ifindex;
1106 sll.sll_protocol = htons (ETH_P_ALL); 1101 sll.sll_protocol = htons (ETH_P_ALL);
1107 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) 1102 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
1108 { 1103 {
1109 fprintf (stderr, 1104 fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
1110 "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", 1105 IFNAMSIZ, dev->iface, strerror (errno));
1111 IFNAMSIZ, dev->iface, strerror (errno)); 1106 return 1;
1112 return 1; 1107 }
1113 }
1114 1108
1115 /* lookup iw mode */ 1109 /* lookup iw mode */
1116 memset (&wrq, 0, sizeof (struct iwreq)); 1110 memset (&wrq, 0, sizeof (struct iwreq));
1117 strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ); 1111 strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ);
1118 if (-1 == ioctl (dev->fd_raw, SIOCGIWMODE, &wrq)) 1112 if (-1 == ioctl (dev->fd_raw, SIOCGIWMODE, &wrq))
1119 { 1113 {
1120 /* most probably not supported (ie for rtap ipw interface) * 1114 /* most probably not supported (ie for rtap ipw interface) *
1121 * so just assume its correctly set... */ 1115 * so just assume its correctly set... */
1122 wrq.u.mode = IW_MODE_MONITOR; 1116 wrq.u.mode = IW_MODE_MONITOR;
1123 } 1117 }
1124 1118
1125 if (((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) && 1119 if (((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) &&
1126 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && 1120 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) &&
1127 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) || 1121 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) ||
1128 (wrq.u.mode != IW_MODE_MONITOR)) 1122 (wrq.u.mode != IW_MODE_MONITOR))
1129 { 1123 {
1130 fprintf (stderr, 1124 fprintf (stderr, "Error: interface `%.*s' is not in monitor mode\n",
1131 "Error: interface `%.*s' is not in monitor mode\n", 1125 IFNAMSIZ, dev->iface);
1132 IFNAMSIZ, dev->iface); 1126 return 1;
1133 return 1; 1127 }
1134 }
1135 1128
1136 /* Is interface st to up, broadcast & running ? */ 1129 /* Is interface st to up, broadcast & running ? */
1137 if ((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags) 1130 if ((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags)
1131 {
1132 /* Bring interface up */
1133 ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING;
1134
1135 if (-1 == ioctl (dev->fd_raw, SIOCSIFFLAGS, &ifr))
1138 { 1136 {
1139 /* Bring interface up */ 1137 fprintf (stderr, "ioctl(SIOCSIFFLAGS) on interface `%.*s' failed: %s\n",
1140 ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING; 1138 IFNAMSIZ, dev->iface, strerror (errno));
1141 1139 return 1;
1142 if (-1 == ioctl (dev->fd_raw, SIOCSIFFLAGS, &ifr))
1143 {
1144 fprintf (stderr,
1145 "ioctl(SIOCSIFFLAGS) on interface `%.*s' failed: %s\n",
1146 IFNAMSIZ, dev->iface, strerror (errno));
1147 return 1;
1148 }
1149 } 1140 }
1141 }
1150 1142
1151 /* bind the raw socket to the interface */ 1143 /* bind the raw socket to the interface */
1152 if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll))) 1144 if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll)))
1153 { 1145 {
1154 fprintf (stderr, 1146 fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
1155 "Failed to bind interface `%.*s': %s\n", IFNAMSIZ, 1147 dev->iface, strerror (errno));
1156 dev->iface, strerror (errno)); 1148 return 1;
1157 return 1; 1149 }
1158 }
1159 1150
1160 /* lookup the hardware type */ 1151 /* lookup the hardware type */
1161 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) 1152 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
1162 { 1153 {
1163 fprintf (stderr, 1154 fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
1164 "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", 1155 IFNAMSIZ, dev->iface, strerror (errno));
1165 IFNAMSIZ, dev->iface, strerror (errno)); 1156 return 1;
1166 return 1; 1157 }
1167 }
1168 1158
1169 memcpy (&dev->pl_mac, ifr.ifr_hwaddr.sa_data, MAC_ADDR_SIZE); 1159 memcpy (&dev->pl_mac, ifr.ifr_hwaddr.sa_data, MAC_ADDR_SIZE);
1170 dev->arptype_in = ifr.ifr_hwaddr.sa_family; 1160 dev->arptype_in = ifr.ifr_hwaddr.sa_family;
1171 if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) && 1161 if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) &&
1172 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && 1162 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) &&
1173 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) 1163 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL))
1174 { 1164 {
1175 fprintf (stderr, 1165 fprintf (stderr, "Unsupported hardware link type %d on interface `%.*s'\n",
1176 "Unsupported hardware link type %d on interface `%.*s'\n", 1166 ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface);
1177 ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface); 1167 return 1;
1178 return 1; 1168 }
1179 }
1180 1169
1181 /* enable promiscuous mode */ 1170 /* enable promiscuous mode */
1182 memset (&mr, 0, sizeof (mr)); 1171 memset (&mr, 0, sizeof (mr));
@@ -1184,13 +1173,12 @@ openraw (struct Hardware_Infos *dev)
1184 mr.mr_type = PACKET_MR_PROMISC; 1173 mr.mr_type = PACKET_MR_PROMISC;
1185 if (0 != 1174 if (0 !=
1186 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, 1175 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
1187 sizeof (mr))) 1176 sizeof (mr)))
1188 { 1177 {
1189 fprintf (stderr, 1178 fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n",
1190 "Failed to enable promiscuous mode on interface `%.*s'\n", 1179 IFNAMSIZ, dev->iface);
1191 IFNAMSIZ, dev->iface); 1180 return 1;
1192 return 1; 1181 }
1193 }
1194 1182
1195 return 0; 1183 return 0;
1196} 1184}
@@ -1211,36 +1199,34 @@ wlaninit (struct Hardware_Infos *dev, const char *iface)
1211 1199
1212 dev->fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL)); 1200 dev->fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
1213 if (0 > dev->fd_raw) 1201 if (0 > dev->fd_raw)
1214 { 1202 {
1215 fprintf (stderr, "Failed to create raw socket: %s\n", strerror (errno)); 1203 fprintf (stderr, "Failed to create raw socket: %s\n", strerror (errno));
1216 return 1; 1204 return 1;
1217 } 1205 }
1218 if (dev->fd_raw >= FD_SETSIZE) 1206 if (dev->fd_raw >= FD_SETSIZE)
1219 { 1207 {
1220 fprintf (stderr, 1208 fprintf (stderr, "File descriptor too large for select (%d > %d)\n",
1221 "File descriptor too large for select (%d > %d)\n", 1209 dev->fd_raw, FD_SETSIZE);
1222 dev->fd_raw, FD_SETSIZE); 1210 close (dev->fd_raw);
1223 close (dev->fd_raw); 1211 return 1;
1224 return 1; 1212 }
1225 }
1226 1213
1227 /* mac80211 stack detection */ 1214 /* mac80211 stack detection */
1228 ret = 1215 ret =
1229 snprintf (strbuf, 1216 snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem",
1230 sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", iface); 1217 iface);
1231 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) 1218 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
1232 { 1219 {
1233 fprintf (stderr, 1220 fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface);
1234 "Did not find 802.11 interface `%s'. Exiting.\n", iface); 1221 close (dev->fd_raw);
1235 close (dev->fd_raw); 1222 return 1;
1236 return 1; 1223 }
1237 }
1238 strncpy (dev->iface, iface, IFNAMSIZ); 1224 strncpy (dev->iface, iface, IFNAMSIZ);
1239 if (0 != openraw (dev)) 1225 if (0 != openraw (dev))
1240 { 1226 {
1241 close (dev->fd_raw); 1227 close (dev->fd_raw);
1242 return 1; 1228 return 1;
1243 } 1229 }
1244 return 0; 1230 return 0;
1245} 1231}
1246 1232
@@ -1254,7 +1240,7 @@ wlaninit (struct Hardware_Infos *dev, const char *iface)
1254 */ 1240 */
1255static int 1241static int
1256mac_test (const struct ieee80211_frame *uint8_taIeeeHeader, 1242mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
1257 const struct Hardware_Infos *dev) 1243 const struct Hardware_Infos *dev)
1258{ 1244{
1259 if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE)) 1245 if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE))
1260 return 1; 1246 return 1;
@@ -1273,7 +1259,7 @@ mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
1273 */ 1259 */
1274static void 1260static void
1275mac_set (struct ieee80211_frame *uint8_taIeeeHeader, 1261mac_set (struct ieee80211_frame *uint8_taIeeeHeader,
1276 const struct Hardware_Infos *dev) 1262 const struct Hardware_Infos *dev)
1277{ 1263{
1278 uint8_taIeeeHeader->i_fc[0] = 0x08; 1264 uint8_taIeeeHeader->i_fc[0] = 0x08;
1279 uint8_taIeeeHeader->i_fc[1] = 0x00; 1265 uint8_taIeeeHeader->i_fc[1] = 0x00;
@@ -1289,8 +1275,7 @@ mac_set (struct ieee80211_frame *uint8_taIeeeHeader,
1289 * @param hdr pointer to the start of the packet 1275 * @param hdr pointer to the start of the packet
1290 */ 1276 */
1291static void 1277static void
1292stdin_send_hw (void *cls, void *client, 1278stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1293 const struct GNUNET_MessageHeader *hdr)
1294{ 1279{
1295 struct Hardware_Infos *dev = cls; 1280 struct Hardware_Infos *dev = cls;
1296 struct sendbuf *write_pout = &dev->write_pout; 1281 struct sendbuf *write_pout = &dev->write_pout;
@@ -1305,7 +1290,7 @@ stdin_send_hw (void *cls, void *client,
1305 rtheader.rate = 0x00; 1290 rtheader.rate = 0x00;
1306 rtheader.pad1 = 0x00; 1291 rtheader.pad1 = 0x00;
1307 rtheader.txflags = 1292 rtheader.txflags =
1308 htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); 1293 htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1309 1294
1310 /* { 0x00, 0x00, <-- radiotap version 1295 /* { 0x00, 0x00, <-- radiotap version
1311 * 0x0c, 0x00, <- radiotap header length 1296 * 0x0c, 0x00, <- radiotap header length
@@ -1318,24 +1303,23 @@ stdin_send_hw (void *cls, void *client,
1318 sendsize = ntohs (hdr->size); 1303 sendsize = ntohs (hdr->size);
1319 if (sendsize < 1304 if (sendsize <
1320 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader)) 1305 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader))
1321 { 1306 {
1322 fprintf (stderr, 1307 fprintf (stderr, "Function stdin_send_hw: malformed packet (too small)\n");
1323 "Function stdin_send_hw: malformed packet (too small)\n"); 1308 exit (1);
1324 exit (1); 1309 }
1325 }
1326 sendsize -= 1310 sendsize -=
1327 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader); 1311 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader);
1328 1312
1329 if (MAXLINE < sendsize) 1313 if (MAXLINE < sendsize)
1330 { 1314 {
1331 fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n"); 1315 fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n");
1332 exit (1); 1316 exit (1);
1333 } 1317 }
1334 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) 1318 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type))
1335 { 1319 {
1336 fprintf (stderr, "Function stdin_send: wrong packet type\n"); 1320 fprintf (stderr, "Function stdin_send: wrong packet type\n");
1337 exit (1); 1321 exit (1);
1338 } 1322 }
1339 1323
1340 rtheader.header.it_len = htole16 (sizeof (rtheader)); 1324 rtheader.header.it_len = htole16 (sizeof (rtheader));
1341 rtheader.rate = header->rate; 1325 rtheader.rate = header->rate;
@@ -1343,8 +1327,7 @@ stdin_send_hw (void *cls, void *client,
1343 memcpy (write_pout->buf + sizeof (rtheader), &header[1], sendsize); 1327 memcpy (write_pout->buf + sizeof (rtheader), &header[1], sendsize);
1344 /* payload contains MAC address, but we don't trust it, so we'll 1328 /* payload contains MAC address, but we don't trust it, so we'll
1345 * overwrite it with OUR MAC address again to prevent mischief */ 1329 * overwrite it with OUR MAC address again to prevent mischief */
1346 wlanheader = 1330 wlanheader = (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader));
1347 (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader));
1348 mac_set (wlanheader, dev); 1331 mac_set (wlanheader, dev);
1349 write_pout->size = sendsize + sizeof (rtheader); 1332 write_pout->size = sendsize + sizeof (rtheader);
1350} 1333}
@@ -1372,19 +1355,19 @@ main (int argc, char *argv[])
1372 struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; 1355 struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst;
1373 1356
1374 if (2 != argc) 1357 if (2 != argc)
1375 { 1358 {
1376 fprintf (stderr, 1359 fprintf (stderr,
1377 "You must specify the name of the interface as the first and only argument to this program.\n"); 1360 "You must specify the name of the interface as the first and only argument to this program.\n");
1378 return 1; 1361 return 1;
1379 } 1362 }
1380 if (0 != wlaninit (&dev, argv[1])) 1363 if (0 != wlaninit (&dev, argv[1]))
1381 return 1; 1364 return 1;
1382 uid = getuid (); 1365 uid = getuid ();
1383 if (0 != setresuid (uid, uid, uid)) 1366 if (0 != setresuid (uid, uid, uid))
1384 { 1367 {
1385 fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); 1368 fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
1386 /* not critical, continue anyway */ 1369 /* not critical, continue anyway */
1387 } 1370 }
1388 1371
1389 dev.write_pout.size = 0; 1372 dev.write_pout.size = 0;
1390 dev.write_pout.pos = 0; 1373 dev.write_pout.pos = 0;
@@ -1396,135 +1379,129 @@ main (int argc, char *argv[])
1396 stdin_open = 1; 1379 stdin_open = 1;
1397 1380
1398 while (1) 1381 while (1)
1382 {
1383 maxfd = -1;
1384 FD_ZERO (&rfds);
1385 if ((0 == dev.write_pout.size) && (1 == stdin_open))
1386 {
1387 FD_SET (STDIN_FILENO, &rfds);
1388 maxfd = MAX (maxfd, STDIN_FILENO);
1389 }
1390 if (0 == write_std.size)
1391 {
1392 FD_SET (dev.fd_raw, &rfds);
1393 maxfd = MAX (maxfd, dev.fd_raw);
1394 }
1395 FD_ZERO (&wfds);
1396 if (0 < write_std.size)
1397 {
1398 FD_SET (STDOUT_FILENO, &wfds);
1399 maxfd = MAX (maxfd, STDOUT_FILENO);
1400 }
1401 if (0 < dev.write_pout.size)
1402 {
1403 FD_SET (dev.fd_raw, &wfds);
1404 maxfd = MAX (maxfd, dev.fd_raw);
1405 }
1406 retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
1407 if ((-1 == retval) && (EINTR == errno))
1408 continue;
1409 if (0 > retval)
1410 {
1411 fprintf (stderr, "select failed: %s\n", strerror (errno));
1412 break;
1413 }
1414 if (FD_ISSET (STDOUT_FILENO, &wfds))
1415 {
1416 ret =
1417 write (STDOUT_FILENO, write_std.buf + write_std.pos,
1418 write_std.size - write_std.pos);
1419 if (0 > ret)
1420 {
1421 fprintf (stderr, "Failed to write to STDOUT: %s\n", strerror (errno));
1422 break;
1423 }
1424 write_std.pos += ret;
1425 if (write_std.pos == write_std.size)
1426 {
1427 write_std.pos = 0;
1428 write_std.size = 0;
1429 }
1430 }
1431 if (FD_ISSET (dev.fd_raw, &wfds))
1432 {
1433 ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size);
1434 if (0 > ret)
1435 {
1436 fprintf (stderr, "Failed to write to WLAN device: %s\n",
1437 strerror (errno));
1438 break;
1439 }
1440 dev.write_pout.pos += ret;
1441 if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
1442 {
1443 /* we should not get partial sends with packet-oriented devices... */
1444 fprintf (stderr, "Write error, partial send: %u/%u\n",
1445 dev.write_pout.pos, dev.write_pout.size);
1446 break;
1447 }
1448 if (dev.write_pout.pos == dev.write_pout.size)
1449 {
1450 dev.write_pout.pos = 0;
1451 dev.write_pout.size = 0;
1452 }
1453 }
1454
1455 if (FD_ISSET (STDIN_FILENO, &rfds))
1399 { 1456 {
1400 maxfd = -1; 1457 ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
1401 FD_ZERO (&rfds); 1458 if (0 > ret)
1402 if ((0 == dev.write_pout.size) && (1 == stdin_open)) 1459 {
1403 { 1460 fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno));
1404 FD_SET (STDIN_FILENO, &rfds); 1461 break;
1405 maxfd = MAX (maxfd, STDIN_FILENO); 1462 }
1406 } 1463 if (0 == ret)
1407 if (0 == write_std.size) 1464 {
1408 { 1465 /* stop reading... */
1409 FD_SET (dev.fd_raw, &rfds); 1466 stdin_open = 0;
1410 maxfd = MAX (maxfd, dev.fd_raw); 1467 }
1411 } 1468 GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO,
1412 FD_ZERO (&wfds); 1469 GNUNET_NO);
1413 if (0 < write_std.size) 1470 }
1414 {
1415 FD_SET (STDOUT_FILENO, &wfds);
1416 maxfd = MAX (maxfd, STDOUT_FILENO);
1417 }
1418 if (0 < dev.write_pout.size)
1419 {
1420 FD_SET (dev.fd_raw, &wfds);
1421 maxfd = MAX (maxfd, dev.fd_raw);
1422 }
1423 retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
1424 if ((-1 == retval) && (EINTR == errno))
1425 continue;
1426 if (0 > retval)
1427 {
1428 fprintf (stderr, "select failed: %s\n", strerror (errno));
1429 break;
1430 }
1431 if (FD_ISSET (STDOUT_FILENO, &wfds))
1432 {
1433 ret =
1434 write (STDOUT_FILENO,
1435 write_std.buf + write_std.pos,
1436 write_std.size - write_std.pos);
1437 if (0 > ret)
1438 {
1439 fprintf (stderr,
1440 "Failed to write to STDOUT: %s\n", strerror (errno));
1441 break;
1442 }
1443 write_std.pos += ret;
1444 if (write_std.pos == write_std.size)
1445 {
1446 write_std.pos = 0;
1447 write_std.size = 0;
1448 }
1449 }
1450 if (FD_ISSET (dev.fd_raw, &wfds))
1451 {
1452 ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size);
1453 if (0 > ret)
1454 {
1455 fprintf (stderr,
1456 "Failed to write to WLAN device: %s\n",
1457 strerror (errno));
1458 break;
1459 }
1460 dev.write_pout.pos += ret;
1461 if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
1462 {
1463 /* we should not get partial sends with packet-oriented devices... */
1464 fprintf (stderr,
1465 "Write error, partial send: %u/%u\n",
1466 dev.write_pout.pos, dev.write_pout.size);
1467 break;
1468 }
1469 if (dev.write_pout.pos == dev.write_pout.size)
1470 {
1471 dev.write_pout.pos = 0;
1472 dev.write_pout.size = 0;
1473 }
1474 }
1475
1476 if (FD_ISSET (STDIN_FILENO, &rfds))
1477 {
1478 ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
1479 if (0 > ret)
1480 {
1481 fprintf (stderr,
1482 "Read error from STDIN: %s\n", strerror (errno));
1483 break;
1484 }
1485 if (0 == ret)
1486 {
1487 /* stop reading... */
1488 stdin_open = 0;
1489 }
1490 GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO,
1491 GNUNET_NO);
1492 }
1493
1494 if (FD_ISSET (dev.fd_raw, &rfds))
1495 {
1496 struct GNUNET_MessageHeader *header;
1497 struct Radiotap_rx *rxinfo;
1498 struct ieee80211_frame *datastart;
1499
1500 header = (struct GNUNET_MessageHeader *) write_std.buf;
1501 rxinfo = (struct Radiotap_rx *) &header[1];
1502 datastart = (struct ieee80211_frame *) &rxinfo[1];
1503 ret =
1504 linux_read (&dev, (unsigned char *) datastart,
1505 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
1506 sizeof (struct GNUNET_MessageHeader), rxinfo);
1507 if (0 > ret)
1508 {
1509 fprintf (stderr,
1510 "Read error from raw socket: %s\n", strerror (errno));
1511 break;
1512 }
1513 if ((0 < ret) && (0 == mac_test (datastart, &dev)))
1514 {
1515 write_std.size =
1516 ret + sizeof (struct GNUNET_MessageHeader) +
1517 sizeof (struct Radiotap_rx);
1518 header->size = htons (write_std.size);
1519 header->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1520 }
1521 }
1522 1471
1472 if (FD_ISSET (dev.fd_raw, &rfds))
1473 {
1474 struct GNUNET_MessageHeader *header;
1475 struct Radiotap_rx *rxinfo;
1476 struct ieee80211_frame *datastart;
1477
1478 header = (struct GNUNET_MessageHeader *) write_std.buf;
1479 rxinfo = (struct Radiotap_rx *) &header[1];
1480 datastart = (struct ieee80211_frame *) &rxinfo[1];
1481 ret =
1482 linux_read (&dev, (unsigned char *) datastart,
1483 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
1484 sizeof (struct GNUNET_MessageHeader), rxinfo);
1485 if (0 > ret)
1486 {
1487 fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno));
1488 break;
1489 }
1490 if ((0 < ret) && (0 == mac_test (datastart, &dev)))
1491 {
1492 write_std.size =
1493 ret + sizeof (struct GNUNET_MessageHeader) +
1494 sizeof (struct Radiotap_rx);
1495 header->size = htons (write_std.size);
1496 header->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1497 }
1523 } 1498 }
1499
1500 }
1524 /* Error handling, try to clean up a bit at least */ 1501 /* Error handling, try to clean up a bit at least */
1525 GNUNET_SERVER_mst_destroy (stdin_mst); 1502 GNUNET_SERVER_mst_destroy (stdin_mst);
1526 close (dev.fd_raw); 1503 close (dev.fd_raw);
1527 return 1; /* we never exit 'normally' */ 1504 return 1; /* we never exit 'normally' */
1528} 1505}
1529 1506
1530/* end of gnunet-transport-wlan-helper.c */ 1507/* end of gnunet-transport-wlan-helper.c */
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 66f02b104..c069bfb24 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -437,14 +437,14 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
437 traffic_received += ntohs (message->size); 437 traffic_received += ntohs (message->size);
438} 438}
439 439
440void process_string (void *cls, 440void
441 const char *address) 441process_string (void *cls, const char *address)
442{ 442{
443 struct GNUNET_PeerIdentity * peer = cls; 443 struct GNUNET_PeerIdentity *peer = cls;
444 444
445 if ((address != NULL)) 445 if ((address != NULL))
446 { 446 {
447 fprintf (stdout, _("Peer `%s': %s\n"), GNUNET_i2s(peer), address); 447 fprintf (stdout, _("Peer `%s': %s\n"), GNUNET_i2s (peer), address);
448 } 448 }
449 else 449 else
450 { 450 {
@@ -463,29 +463,25 @@ void process_string (void *cls,
463 * @param addrlen number of bytes in addr 463 * @param addrlen number of bytes in addr
464 */ 464 */
465static void 465static void
466process_address (void *cls, 466process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
467 const struct GNUNET_PeerIdentity *peer, 467 const struct GNUNET_HELLO_Address *address)
468 const struct GNUNET_HELLO_Address *address)
469{ 468{
470 const struct GNUNET_CONFIGURATION_Handle * cfg = cls; 469 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
471 struct GNUNET_PeerIdentity *peercp; 470 struct GNUNET_PeerIdentity *peercp;
472 471
473 if ( (address == NULL) || (peer == NULL) ) 472 if ((address == NULL) || (peer == NULL))
474 { 473 {
475 /* done */ 474 /* done */
476 return; 475 return;
477 } 476 }
478 477
479 peercp = GNUNET_malloc(sizeof (struct GNUNET_PeerIdentity)); 478 peercp = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
480 *peercp = *peer; 479 *peercp = *peer;
481 480
482 /* Resolve address to string */ 481 /* Resolve address to string */
483 GNUNET_TRANSPORT_address_to_string (cfg, 482 GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
484 address, 483 GNUNET_TIME_UNIT_MINUTES, &process_string,
485 numeric, 484 peercp);
486 GNUNET_TIME_UNIT_MINUTES,
487 &process_string,
488 peercp);
489} 485}
490 486
491 487
@@ -542,8 +538,8 @@ run (void *cls, char *const *args, const char *cfgfile,
542 if (iterate_connections) 538 if (iterate_connections)
543 { 539 {
544 GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_YES, 540 GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_YES,
545 GNUNET_TIME_UNIT_MINUTES, 541 GNUNET_TIME_UNIT_MINUTES,
546 &process_address, (void *)cfg); 542 &process_address, (void *) cfg);
547 } 543 }
548} 544}
549 545
@@ -568,9 +564,9 @@ main (int argc, char *const *argv)
568 {'t', "test", NULL, 564 {'t', "test", NULL,
569 gettext_noop ("test transport configuration (involves external server)"), 565 gettext_noop ("test transport configuration (involves external server)"),
570 0, &GNUNET_GETOPT_set_one, &test_configuration}, 566 0, &GNUNET_GETOPT_set_one, &test_configuration},
571 {'n', "numeric", NULL, 567 {'n', "numeric", NULL,
572 gettext_noop ("do not resolve hostnames"), 568 gettext_noop ("do not resolve hostnames"),
573 0, &GNUNET_GETOPT_set_one, &numeric}, 569 0, &GNUNET_GETOPT_set_one, &numeric},
574 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), 570 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
575 GNUNET_GETOPT_OPTION_END 571 GNUNET_GETOPT_OPTION_END
576 }; 572 };
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index a6c9190bd..502e26597 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -513,6 +513,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
513 struct Plugin *plugin = cls; 513 struct Plugin *plugin = cls;
514 struct HTTP_Message *msg; 514 struct HTTP_Message *msg;
515 struct Session *s; 515 struct Session *s;
516
516 GNUNET_assert (plugin != NULL); 517 GNUNET_assert (plugin != NULL);
517 518
518 int res = GNUNET_SYSERR; 519 int res = GNUNET_SYSERR;
@@ -563,17 +564,20 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
563 GNUNET_i2s (target)); 564 GNUNET_i2s (target));
564#endif 565#endif
565 int res = GNUNET_OK; 566 int res = GNUNET_OK;
567
566 if (addrlen == sizeof (struct IPv4HttpAddress)) 568 if (addrlen == sizeof (struct IPv4HttpAddress))
567 { 569 {
568 struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr; 570 struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr;
569 if ((ntohs(a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO)) 571
570 res = GNUNET_SYSERR; 572 if ((ntohs (a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO))
573 res = GNUNET_SYSERR;
571 } 574 }
572 if (addrlen == sizeof (struct IPv6HttpAddress)) 575 if (addrlen == sizeof (struct IPv6HttpAddress))
573 { 576 {
574 struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr; 577 struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr;
575 if ((ntohs(a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO)) 578
576 res = GNUNET_SYSERR; 579 if ((ntohs (a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO))
580 res = GNUNET_SYSERR;
577 } 581 }
578 if (res == GNUNET_OK) 582 if (res == GNUNET_OK)
579 { 583 {
@@ -606,8 +610,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
606 { 610 {
607#if DEBUG_HTTP 611#if DEBUG_HTTP
608 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 612 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
609 "Using outbound client session %p to send to `%s'\n", 613 "Using outbound client session %p to send to `%s'\n", s,
610 s,
611 GNUNET_i2s (target)); 614 GNUNET_i2s (target));
612#endif 615#endif
613 616
@@ -618,8 +621,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
618 { 621 {
619#if DEBUG_HTTP 622#if DEBUG_HTTP
620 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 623 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
621 "Using inbound server %p session to send to `%s'\n", 624 "Using inbound server %p session to send to `%s'\n", s,
622 s,
623 GNUNET_i2s (target)); 625 GNUNET_i2s (target));
624#endif 626#endif
625 627
@@ -659,16 +661,17 @@ http_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
659 GNUNET_assert (GNUNET_OK == server_disconnect (s)); 661 GNUNET_assert (GNUNET_OK == server_disconnect (s));
660 GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); 662 GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
661 663
662 struct HTTP_Message * msg = s->msg_head; 664 struct HTTP_Message *msg = s->msg_head;
663 struct HTTP_Message * tmp = s->msg_head; 665 struct HTTP_Message *tmp = s->msg_head;
666
664 while (msg != NULL) 667 while (msg != NULL)
665 { 668 {
666 tmp = msg->next; 669 tmp = msg->next;
667 670
668 GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg); 671 GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
669 if (msg->transmit_cont != NULL) 672 if (msg->transmit_cont != NULL)
670 { 673 {
671 msg->transmit_cont(msg->transmit_cont_cls, target, GNUNET_SYSERR); 674 msg->transmit_cont (msg->transmit_cont_cls, target, GNUNET_SYSERR);
672 } 675 }
673 GNUNET_free (msg); 676 GNUNET_free (msg);
674 msg = tmp; 677 msg = tmp;
@@ -1427,18 +1430,20 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
1427 while (s != NULL) 1430 while (s != NULL)
1428 { 1431 {
1429 struct Session *t = s->next; 1432 struct Session *t = s->next;
1433
1430 GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); 1434 GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
1431 1435
1432 struct HTTP_Message * msg = s->msg_head; 1436 struct HTTP_Message *msg = s->msg_head;
1433 struct HTTP_Message * tmp = s->msg_head; 1437 struct HTTP_Message *tmp = s->msg_head;
1438
1434 while (msg != NULL) 1439 while (msg != NULL)
1435 { 1440 {
1436 tmp = msg->next; 1441 tmp = msg->next;
1437 1442
1438 GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg); 1443 GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
1439 if (msg->transmit_cont != NULL) 1444 if (msg->transmit_cont != NULL)
1440 { 1445 {
1441 msg->transmit_cont(msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); 1446 msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
1442 } 1447 }
1443 GNUNET_free (msg); 1448 GNUNET_free (msg);
1444 msg = tmp; 1449 msg = tmp;
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 159b0853f..2c180c5ff 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -312,6 +312,7 @@ static ssize_t
312server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) 312server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
313{ 313{
314 struct Session *s = cls; 314 struct Session *s = cls;
315
315#if VERBOSE_SERVER 316#if VERBOSE_SERVER
316 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, 317 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name,
317 "Server: %X can sent maximum %u \n", s, max); 318 "Server: %X can sent maximum %u \n", s, max);
@@ -349,6 +350,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
349 350
350#if VERBOSE_SERVER 351#if VERBOSE_SERVER
351 struct Plugin *plugin = s->plugin; 352 struct Plugin *plugin = s->plugin;
353
352 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 354 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
353 "Server: %X: sent %u bytes\n", s, bytes_read); 355 "Server: %X: sent %u bytes\n", s, bytes_read);
354#endif 356#endif
@@ -575,7 +577,8 @@ found:
575#endif 577#endif
576 MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); 578 MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to);
577 579
578 struct MHD_Daemon * d = NULL; 580 struct MHD_Daemon *d = NULL;
581
579 if (s->addrlen == sizeof (struct IPv6HttpAddress)) 582 if (s->addrlen == sizeof (struct IPv6HttpAddress))
580 d = plugin->server_v6; 583 d = plugin->server_v6;
581 if (s->addrlen == sizeof (struct IPv4HttpAddress)) 584 if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -649,10 +652,10 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
649 if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL)) 652 if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL))
650 { 653 {
651#if VERBOSE_SERVER 654#if VERBOSE_SERVER
652 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 655 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
653 "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n", 656 "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n",
654 GNUNET_i2s (&s->target), 657 GNUNET_i2s (&s->target),
655 http_plugin_address_to_string (NULL, s->addr, s->addrlen)); 658 http_plugin_address_to_string (NULL, s->addr, s->addrlen));
656#endif 659#endif
657 return MHD_YES; 660 return MHD_YES;
658 } 661 }
@@ -674,7 +677,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
674 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 677 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
675 "Server: Peer `%s' PUT on address `%s' connected\n", 678 "Server: Peer `%s' PUT on address `%s' connected\n",
676 GNUNET_i2s (&s->target), 679 GNUNET_i2s (&s->target),
677 http_plugin_address_to_string (NULL, s->addr, s->addrlen)); 680 http_plugin_address_to_string (NULL, s->addr,
681 s->addrlen));
678#endif 682#endif
679 return MHD_YES; 683 return MHD_YES;
680 } 684 }
@@ -686,7 +690,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
686 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 690 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
687 "Server: peer `%s' PUT on address `%s' received %u bytes\n", 691 "Server: peer `%s' PUT on address `%s' received %u bytes\n",
688 GNUNET_i2s (&s->target), 692 GNUNET_i2s (&s->target),
689 http_plugin_address_to_string (NULL,s->addr, s->addrlen), 693 http_plugin_address_to_string (NULL, s->addr,
694 s->addrlen),
690 *upload_data_size); 695 *upload_data_size);
691#endif 696#endif
692 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 697 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
@@ -739,6 +744,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
739 to); 744 to);
740 } 745 }
741 struct MHD_Daemon *d = NULL; 746 struct MHD_Daemon *d = NULL;
747
742 if (s->addrlen == sizeof (struct IPv6HttpAddress)) 748 if (s->addrlen == sizeof (struct IPv6HttpAddress))
743 d = plugin->server_v6; 749 d = plugin->server_v6;
744 if (s->addrlen == sizeof (struct IPv4HttpAddress)) 750 if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -839,6 +845,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
839 plugin->cur_connections--; 845 plugin->cur_connections--;
840 846
841 struct MHD_Daemon *d = NULL; 847 struct MHD_Daemon *d = NULL;
848
842 if (s->addrlen == sizeof (struct IPv6HttpAddress)) 849 if (s->addrlen == sizeof (struct IPv6HttpAddress))
843 d = plugin->server_v6; 850 d = plugin->server_v6;
844 if (s->addrlen == sizeof (struct IPv4HttpAddress)) 851 if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -894,11 +901,11 @@ server_send (struct Session *s, struct HTTP_Message *msg)
894 901
895 if (s->addrlen == sizeof (struct IPv4HttpAddress)) 902 if (s->addrlen == sizeof (struct IPv4HttpAddress))
896 { 903 {
897 server_reschedule (s->plugin, s->plugin->server_v4 , GNUNET_YES); 904 server_reschedule (s->plugin, s->plugin->server_v4, GNUNET_YES);
898 } 905 }
899 else if (s->addrlen == sizeof (struct IPv6HttpAddress)) 906 else if (s->addrlen == sizeof (struct IPv6HttpAddress))
900 { 907 {
901 server_reschedule (s->plugin, s->plugin->server_v6 , GNUNET_YES); 908 server_reschedule (s->plugin, s->plugin->server_v6, GNUNET_YES);
902 } 909 }
903 else 910 else
904 return GNUNET_SYSERR; 911 return GNUNET_SYSERR;
@@ -926,7 +933,7 @@ server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
926 return; 933 return;
927#if VERBOSE_SERVER 934#if VERBOSE_SERVER
928 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 935 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
929 "Running IPv4 server\n"); 936 "Running IPv4 server\n");
930#endif 937#endif
931 GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); 938 GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4));
932 if (plugin->server_v4 != NULL) 939 if (plugin->server_v4 != NULL)
@@ -954,7 +961,7 @@ server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
954 return; 961 return;
955#if VERBOSE_SERVER 962#if VERBOSE_SERVER
956 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 963 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
957 "Running IPv6 server\n"); 964 "Running IPv6 server\n");
958#endif 965#endif
959 GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); 966 GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6));
960 if (plugin->server_v6 != NULL) 967 if (plugin->server_v6 != NULL)
@@ -1027,8 +1034,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
1027 plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; 1034 plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK;
1028 } 1035 }
1029#if VERBOSE_SERVER 1036#if VERBOSE_SERVER
1030 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 1037 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
1031 "Scheduling IPv4 server task in %llu ms\n", tv); 1038 "Scheduling IPv4 server task in %llu ms\n", tv);
1032#endif 1039#endif
1033 ret = 1040 ret =
1034 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1041 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -1043,8 +1050,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
1043 plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; 1050 plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
1044 } 1051 }
1045#if VERBOSE_SERVER 1052#if VERBOSE_SERVER
1046 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 1053 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
1047 "Scheduling IPv6 server task in %llu ms\n", tv); 1054 "Scheduling IPv6 server task in %llu ms\n", tv);
1048#endif 1055#endif
1049 ret = 1056 ret =
1050 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1057 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -1195,8 +1202,7 @@ server_stop (struct Plugin *plugin)
1195 struct Session *t = NULL; 1202 struct Session *t = NULL;
1196 1203
1197#if VERBOSE_SERVER 1204#if VERBOSE_SERVER
1198 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 1205 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "server_stop\n");
1199 "server_stop\n");
1200#endif 1206#endif
1201 1207
1202 struct MHD_Daemon *server_v4_tmp = plugin->server_v4; 1208 struct MHD_Daemon *server_v4_tmp = plugin->server_v4;
@@ -1236,16 +1242,17 @@ server_stop (struct Plugin *plugin)
1236 "Deleting semi-sessions %p\n", s); 1242 "Deleting semi-sessions %p\n", s);
1237#endif 1243#endif
1238 t = s->next; 1244 t = s->next;
1239 struct HTTP_Message * msg = s->msg_head; 1245 struct HTTP_Message *msg = s->msg_head;
1240 struct HTTP_Message * tmp = s->msg_head; 1246 struct HTTP_Message *tmp = s->msg_head;
1247
1241 while (msg != NULL) 1248 while (msg != NULL)
1242 { 1249 {
1243 tmp = msg->next; 1250 tmp = msg->next;
1244 1251
1245 GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg); 1252 GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
1246 if (msg->transmit_cont != NULL) 1253 if (msg->transmit_cont != NULL)
1247 { 1254 {
1248 msg->transmit_cont(msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); 1255 msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
1249 } 1256 }
1250 GNUNET_free (msg); 1257 GNUNET_free (msg);
1251 msg = tmp; 1258 msg = tmp;
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index a0d5072b8..1ef0bca98 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -267,7 +267,7 @@ struct BroadcastAddress
267 struct BroadcastAddress *next; 267 struct BroadcastAddress *next;
268 struct BroadcastAddress *prev; 268 struct BroadcastAddress *prev;
269 269
270 void * addr; 270 void *addr;
271 socklen_t addrlen; 271 socklen_t addrlen;
272}; 272};
273 273
@@ -540,8 +540,11 @@ destroy_session (void *cls, const GNUNET_HashCode * key, void *value)
540 struct Session *peer_session = value; 540 struct Session *peer_session = value;
541 541
542 GNUNET_assert (GNUNET_YES == 542 GNUNET_assert (GNUNET_YES ==
543 GNUNET_CONTAINER_multihashmap_remove (peer_session->plugin->sessions, 543 GNUNET_CONTAINER_multihashmap_remove (peer_session->
544 &peer_session->target.hashPubKey, peer_session)); 544 plugin->sessions,
545 &peer_session->
546 target.hashPubKey,
547 peer_session));
545 if (peer_session->frag != NULL) 548 if (peer_session->frag != NULL)
546 GNUNET_FRAGMENT_context_destroy (peer_session->frag); 549 GNUNET_FRAGMENT_context_destroy (peer_session->frag);
547 if (GNUNET_SCHEDULER_NO_TASK != peer_session->delayed_cont_task) 550 if (GNUNET_SCHEDULER_NO_TASK != peer_session->delayed_cont_task)
@@ -568,7 +571,8 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value)
568 GNUNET_SCHEDULER_cancel (s->invalidation_task); 571 GNUNET_SCHEDULER_cancel (s->invalidation_task);
569 if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) 572 if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task)
570 GNUNET_SCHEDULER_cancel (s->delayed_cont_task); 573 GNUNET_SCHEDULER_cancel (s->delayed_cont_task);
571 GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions, &s->target.hashPubKey, s); 574 GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions,
575 &s->target.hashPubKey, s);
572 GNUNET_free (s); 576 GNUNET_free (s);
573 return GNUNET_OK; 577 return GNUNET_OK;
574} 578}
@@ -1300,42 +1304,46 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
1300 switch (ntohs (msg->type)) 1304 switch (ntohs (msg->type))
1301 { 1305 {
1302 case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: 1306 case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON:
1307 {
1308 if (fromlen == sizeof (struct sockaddr_in))
1303 { 1309 {
1304 if (fromlen == sizeof (struct sockaddr_in)) 1310 LOG (GNUNET_ERROR_TYPE_DEBUG,
1305 { 1311 "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n",
1306 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n", 1312 ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen));
1307 ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen)); 1313
1308 1314 struct Mstv4Context *mc;
1309 struct Mstv4Context *mc; 1315
1310 mc = GNUNET_malloc (sizeof (struct Mstv4Context)); 1316 mc = GNUNET_malloc (sizeof (struct Mstv4Context));
1311 struct sockaddr_in *av4 = (struct sockaddr_in *) &addr; 1317 struct sockaddr_in *av4 = (struct sockaddr_in *) &addr;
1312 1318
1313 mc->addr.ipv4_addr = av4->sin_addr.s_addr; 1319 mc->addr.ipv4_addr = av4->sin_addr.s_addr;
1314 mc->addr.u4_port = av4->sin_port; 1320 mc->addr.u4_port = av4->sin_port;
1315 if (GNUNET_OK != 1321 if (GNUNET_OK !=
1316 GNUNET_SERVER_mst_receive (plugin->broadcast_ipv4_mst, mc, buf, ret, GNUNET_NO, 1322 GNUNET_SERVER_mst_receive (plugin->broadcast_ipv4_mst, mc, buf, ret,
1317 GNUNET_NO)) 1323 GNUNET_NO, GNUNET_NO))
1318 GNUNET_free (mc); 1324 GNUNET_free (mc);
1319 } 1325 }
1320 else if (fromlen == sizeof (struct sockaddr_in6)) 1326 else if (fromlen == sizeof (struct sockaddr_in6))
1321 { 1327 {
1322 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n", 1328 LOG (GNUNET_ERROR_TYPE_DEBUG,
1323 ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen)); 1329 "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n",
1330 ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen));
1324 1331
1325 struct Mstv6Context *mc; 1332 struct Mstv6Context *mc;
1326 mc = GNUNET_malloc (sizeof (struct Mstv6Context));
1327 struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr;
1328 1333
1329 mc->addr.ipv6_addr = av6->sin6_addr; 1334 mc = GNUNET_malloc (sizeof (struct Mstv6Context));
1330 mc->addr.u6_port = av6->sin6_port; 1335 struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr;
1331 1336
1332 if (GNUNET_OK != 1337 mc->addr.ipv6_addr = av6->sin6_addr;
1333 GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret, GNUNET_NO, 1338 mc->addr.u6_port = av6->sin6_port;
1334 GNUNET_NO)) 1339
1335 GNUNET_free (mc); 1340 if (GNUNET_OK !=
1336 } 1341 GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret,
1337 return; 1342 GNUNET_NO, GNUNET_NO))
1343 GNUNET_free (mc);
1338 } 1344 }
1345 return;
1346 }
1339 case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: 1347 case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE:
1340 if (ntohs (msg->size) < sizeof (struct UDPMessage)) 1348 if (ntohs (msg->size) < sizeof (struct UDPMessage))
1341 { 1349 {
@@ -1489,7 +1497,7 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1489 1497
1490void 1498void
1491broadcast_ipv4_mst_cb (void *cls, void *client, 1499broadcast_ipv4_mst_cb (void *cls, void *client,
1492 const struct GNUNET_MessageHeader *message) 1500 const struct GNUNET_MessageHeader *message)
1493{ 1501{
1494 struct Plugin *plugin = cls; 1502 struct Plugin *plugin = cls;
1495 struct Mstv4Context *mc = client; 1503 struct Mstv4Context *mc = client;
@@ -1517,15 +1525,16 @@ broadcast_ipv4_mst_cb (void *cls, void *client,
1517 (const char *) &mc->addr, sizeof (mc->addr)); 1525 (const char *) &mc->addr, sizeof (mc->addr));
1518 1526
1519 GNUNET_STATISTICS_update (plugin->env->stats, 1527 GNUNET_STATISTICS_update (plugin->env->stats,
1520 _("# IPv4 broadcast HELLO beacons received via udp"), 1, 1528 _
1521 GNUNET_NO); 1529 ("# IPv4 broadcast HELLO beacons received via udp"),
1530 1, GNUNET_NO);
1522 GNUNET_free (mc); 1531 GNUNET_free (mc);
1523} 1532}
1524 1533
1525 1534
1526void 1535void
1527broadcast_ipv6_mst_cb (void *cls, void *client, 1536broadcast_ipv6_mst_cb (void *cls, void *client,
1528 const struct GNUNET_MessageHeader *message) 1537 const struct GNUNET_MessageHeader *message)
1529{ 1538{
1530 1539
1531 struct Plugin *plugin = cls; 1540 struct Plugin *plugin = cls;
@@ -1554,14 +1563,16 @@ broadcast_ipv6_mst_cb (void *cls, void *client,
1554 (const char *) &mc->addr, sizeof (mc->addr)); 1563 (const char *) &mc->addr, sizeof (mc->addr));
1555 1564
1556 GNUNET_STATISTICS_update (plugin->env->stats, 1565 GNUNET_STATISTICS_update (plugin->env->stats,
1557 _("# IPv6 multicast HELLO beacons received via udp"), 1, 1566 _
1558 GNUNET_NO); 1567 ("# IPv6 multicast HELLO beacons received via udp"),
1568 1, GNUNET_NO);
1559 GNUNET_free (mc); 1569 GNUNET_free (mc);
1560} 1570}
1561 1571
1562 1572
1563static void 1573static void
1564udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1574udp_ipv4_broadcast_send (void *cls,
1575 const struct GNUNET_SCHEDULER_TaskContext *tc)
1565{ 1576{
1566 struct Plugin *plugin = cls; 1577 struct Plugin *plugin = cls;
1567 int sent; 1578 int sent;
@@ -1571,7 +1582,7 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
1571 1582
1572 const struct GNUNET_MessageHeader *hello; 1583 const struct GNUNET_MessageHeader *hello;
1573 struct UDP_Beacon_Message *msg; 1584 struct UDP_Beacon_Message *msg;
1574 struct BroadcastAddress * baddr; 1585 struct BroadcastAddress *baddr;
1575 1586
1576 plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK; 1587 plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
1577 1588
@@ -1594,18 +1605,21 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
1594 /* just IPv4 */ 1605 /* just IPv4 */
1595 while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in))) 1606 while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
1596 { 1607 {
1597 struct sockaddr_in * addr = (struct sockaddr_in * ) baddr->addr; 1608 struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr;
1609
1598 addr->sin_port = htons (plugin->port); 1610 addr->sin_port = htons (plugin->port);
1599 1611
1600 sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size, 1612 sent =
1601 (const struct sockaddr *) addr, 1613 GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size,
1602 baddr->addrlen); 1614 (const struct sockaddr *) addr,
1615 baddr->addrlen);
1603 if (sent == GNUNET_SYSERR) 1616 if (sent == GNUNET_SYSERR)
1604 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto"); 1617 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
1605 else 1618 else
1606 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes to address %s\n", 1619 LOG (GNUNET_ERROR_TYPE_DEBUG,
1607 sent, GNUNET_a2s(baddr->addr, baddr->addrlen)); 1620 "Sent HELLO beacon broadcast with %i bytes to address %s\n", sent,
1608 baddr = baddr->next; 1621 GNUNET_a2s (baddr->addr, baddr->addrlen));
1622 baddr = baddr->next;
1609 } 1623 }
1610 1624
1611 plugin->send_ipv4_broadcast_task = 1625 plugin->send_ipv4_broadcast_task =
@@ -1614,7 +1628,8 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
1614} 1628}
1615 1629
1616static void 1630static void
1617udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1631udp_ipv6_broadcast_send (void *cls,
1632 const struct GNUNET_SCHEDULER_TaskContext *tc)
1618{ 1633{
1619 struct Plugin *plugin = cls; 1634 struct Plugin *plugin = cls;
1620 int sent; 1635 int sent;
@@ -1642,14 +1657,19 @@ udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
1642 memcpy (&msg[1], hello, hello_size); 1657 memcpy (&msg[1], hello, hello_size);
1643 sent = 0; 1658 sent = 0;
1644 1659
1645 sent = GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size, 1660 sent =
1646 (const struct sockaddr *) &plugin->ipv6_multicast_address, 1661 GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size,
1647 sizeof(struct sockaddr_in6)); 1662 (const struct sockaddr *)
1663 &plugin->ipv6_multicast_address,
1664 sizeof (struct sockaddr_in6));
1648 if (sent == GNUNET_SYSERR) 1665 if (sent == GNUNET_SYSERR)
1649 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto"); 1666 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
1650 else 1667 else
1651 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n", 1668 LOG (GNUNET_ERROR_TYPE_DEBUG,
1652 sent, GNUNET_a2s((const struct sockaddr *) &plugin->ipv6_multicast_address, sizeof(struct sockaddr_in6))); 1669 "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n",
1670 sent,
1671 GNUNET_a2s ((const struct sockaddr *) &plugin->ipv6_multicast_address,
1672 sizeof (struct sockaddr_in6)));
1653 1673
1654 1674
1655 1675
@@ -1953,33 +1973,33 @@ udp_nat_port_map_callback (void *cls, int add_remove,
1953 1973
1954 1974
1955static int 1975static int
1956iface_proc (void *cls, const char *name, 1976iface_proc (void *cls, const char *name, int isDefault,
1957 int isDefault, 1977 const struct sockaddr *addr, const struct sockaddr *broadcast_addr,
1958 const struct sockaddr * addr, 1978 const struct sockaddr *netmask, socklen_t addrlen)
1959 const struct sockaddr * broadcast_addr,
1960 const struct sockaddr * netmask,
1961 socklen_t addrlen)
1962{ 1979{
1963 struct Plugin *plugin = cls; 1980 struct Plugin *plugin = cls;
1964 1981
1965 if (addr != NULL) 1982 if (addr != NULL)
1966 { 1983 {
1967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ", 1984 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ",
1968 GNUNET_a2s(addr,addrlen), name, addr); 1985 GNUNET_a2s (addr, addrlen), name, addr);
1969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "broadcast address %s for interface %s %p\n ", 1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1970 GNUNET_a2s(broadcast_addr,addrlen), name, broadcast_addr); 1987 "broadcast address %s for interface %s %p\n ",
1988 GNUNET_a2s (broadcast_addr, addrlen), name, broadcast_addr);
1971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ", 1989 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
1972 GNUNET_a2s(netmask,addrlen), name, netmask); 1990 GNUNET_a2s (netmask, addrlen), name, netmask);
1973 1991
1974 1992
1975 /* Collecting broadcast addresses*/ 1993 /* Collecting broadcast addresses */
1976 if (broadcast_addr != NULL) 1994 if (broadcast_addr != NULL)
1977 { 1995 {
1978 struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct BroadcastAddress)); 1996 struct BroadcastAddress *ba =
1979 ba->addr = GNUNET_malloc(addrlen); 1997 GNUNET_malloc (sizeof (struct BroadcastAddress));
1980 memcpy(ba->addr, broadcast_addr, addrlen); 1998 ba->addr = GNUNET_malloc (addrlen);
1999 memcpy (ba->addr, broadcast_addr, addrlen);
1981 ba->addrlen = addrlen; 2000 ba->addrlen = addrlen;
1982 GNUNET_CONTAINER_DLL_insert(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, ba); 2001 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_broadcast_head,
2002 plugin->ipv4_broadcast_tail, ba);
1983 } 2003 }
1984 } 2004 }
1985 return GNUNET_OK; 2005 return GNUNET_OK;
@@ -2225,73 +2245,80 @@ libgnunet_plugin_transport_udp_init (void *cls)
2225 { 2245 {
2226 /* create IPv4 broadcast socket */ 2246 /* create IPv4 broadcast socket */
2227 plugin->broadcast_ipv4 = GNUNET_NO; 2247 plugin->broadcast_ipv4 = GNUNET_NO;
2228 if (plugin->sockv4 != NULL) 2248 if (plugin->sockv4 != NULL)
2229 { 2249 {
2230 int yes = 1; 2250 int yes = 1;
2231 2251
2232 if (GNUNET_NETWORK_socket_setsockopt 2252 if (GNUNET_NETWORK_socket_setsockopt
2233 (plugin->sockv4, SOL_SOCKET, SO_BROADCAST, &yes, sizeof (int)) != GNUNET_OK) 2253 (plugin->sockv4, SOL_SOCKET, SO_BROADCAST, &yes,
2234 { 2254 sizeof (int)) != GNUNET_OK)
2235 LOG (GNUNET_ERROR_TYPE_WARNING, 2255 {
2236 _ 2256 LOG (GNUNET_ERROR_TYPE_WARNING,
2237 ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), 2257 _
2238 ntohs (serverAddrv4.sin_port)); 2258 ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"),
2239 } 2259 ntohs (serverAddrv4.sin_port));
2240 else 2260 }
2241 { 2261 else
2242 GNUNET_OS_network_interfaces_list(iface_proc, plugin); 2262 {
2243 plugin->send_ipv4_broadcast_task = 2263 GNUNET_OS_network_interfaces_list (iface_proc, plugin);
2264 plugin->send_ipv4_broadcast_task =
2244 GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, plugin); 2265 GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, plugin);
2245 2266
2246 plugin->broadcast_ipv4_mst = 2267 plugin->broadcast_ipv4_mst =
2247 GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin); 2268 GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin);
2248 2269
2249 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n"); 2270 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n");
2250 plugin->broadcast_ipv4 = GNUNET_YES; 2271 plugin->broadcast_ipv4 = GNUNET_YES;
2251 }
2252 } 2272 }
2273 }
2253 2274
2254 plugin->broadcast_ipv6 = GNUNET_NO; 2275 plugin->broadcast_ipv6 = GNUNET_NO;
2255 if (plugin->sockv6 != NULL) 2276 if (plugin->sockv6 != NULL)
2277 {
2278 memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6));
2279 GNUNET_assert (1 ==
2280 inet_pton (AF_INET6, "FF05::13B",
2281 &plugin->ipv6_multicast_address.sin6_addr));
2282
2283 plugin->ipv6_multicast_address.sin6_family = AF_INET6;
2284 plugin->ipv6_multicast_address.sin6_port = htons (plugin->port);
2285
2286 plugin->broadcast_ipv6_mst =
2287 GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin);
2288
2289 /* Create IPv6 multicast request */
2290 struct ipv6_mreq multicastRequest;
2291
2292 multicastRequest.ipv6mr_multiaddr =
2293 plugin->ipv6_multicast_address.sin6_addr;
2294 /* TODO: 0 selects the "best" interface, tweak to use all interfaces
2295 *
2296 * http://tools.ietf.org/html/rfc2553#section-5.2:
2297 *
2298 * IPV6_JOIN_GROUP
2299 *
2300 * Join a multicast group on a specified local interface. If the
2301 * interface index is specified as 0, the kernel chooses the local
2302 * interface. For example, some kernels look up the multicast
2303 * group in the normal IPv6 routing table and using the resulting
2304 * interface.
2305 * */
2306 multicastRequest.ipv6mr_interface = 0;
2307
2308 /* Join the multicast group */
2309 if (GNUNET_NETWORK_socket_setsockopt
2310 (plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP,
2311 (char *) &multicastRequest, sizeof (multicastRequest)) == GNUNET_OK)
2256 { 2312 {
2257 memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); 2313 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
2258 GNUNET_assert (1 == inet_pton(AF_INET6, "FF05::13B", &plugin->ipv6_multicast_address.sin6_addr));
2259
2260 plugin->ipv6_multicast_address.sin6_family = AF_INET6;
2261 plugin->ipv6_multicast_address.sin6_port = htons(plugin->port);
2262
2263 plugin->broadcast_ipv6_mst =
2264 GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin);
2265
2266 /* Create IPv6 multicast request */
2267 struct ipv6_mreq multicastRequest;
2268 multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr;
2269 /* TODO: 0 selects the "best" interface, tweak to use all interfaces
2270 *
2271 * http://tools.ietf.org/html/rfc2553#section-5.2:
2272 *
2273 * IPV6_JOIN_GROUP
2274 *
2275 * Join a multicast group on a specified local interface. If the
2276 * interface index is specified as 0, the kernel chooses the local
2277 * interface. For example, some kernels look up the multicast
2278 * group in the normal IPv6 routing table and using the resulting
2279 * interface.
2280 * */
2281 multicastRequest.ipv6mr_interface = 0;
2282
2283 /* Join the multicast group */
2284 if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == GNUNET_OK )
2285 {
2286 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
2287 2314
2288 plugin->send_ipv6_broadcast_task = 2315 plugin->send_ipv6_broadcast_task =
2289 GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin); 2316 GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin);
2290 plugin->broadcast_ipv6 = GNUNET_YES; 2317 plugin->broadcast_ipv6 = GNUNET_YES;
2291 }
2292 else
2293 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n");
2294 } 2318 }
2319 else
2320 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n");
2321 }
2295 } 2322 }
2296 2323
2297 if (sockets_created == 0) 2324 if (sockets_created == 0)
@@ -2351,8 +2378,10 @@ libgnunet_plugin_transport_udp_done (void *cls)
2351 2378
2352 while (plugin->ipv4_broadcast_head != NULL) 2379 while (plugin->ipv4_broadcast_head != NULL)
2353 { 2380 {
2354 struct BroadcastAddress * p= plugin->ipv4_broadcast_head; 2381 struct BroadcastAddress *p = plugin->ipv4_broadcast_head;
2355 GNUNET_CONTAINER_DLL_remove(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, p); 2382
2383 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_broadcast_head,
2384 plugin->ipv4_broadcast_tail, p);
2356 GNUNET_free (p->addr); 2385 GNUNET_free (p->addr);
2357 GNUNET_free (p); 2386 GNUNET_free (p);
2358 } 2387 }
@@ -2362,16 +2391,20 @@ libgnunet_plugin_transport_udp_done (void *cls)
2362 { 2391 {
2363 /* Create IPv6 multicast request */ 2392 /* Create IPv6 multicast request */
2364 struct ipv6_mreq multicastRequest; 2393 struct ipv6_mreq multicastRequest;
2365 multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr; 2394
2395 multicastRequest.ipv6mr_multiaddr =
2396 plugin->ipv6_multicast_address.sin6_addr;
2366 multicastRequest.ipv6mr_interface = 0; 2397 multicastRequest.ipv6mr_interface = 0;
2367 2398
2368 /* Join the multicast address */ 2399 /* Join the multicast address */
2369 if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == 0 ) 2400 if (GNUNET_NETWORK_socket_setsockopt
2401 (plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
2402 (char *) &multicastRequest, sizeof (multicastRequest)) == 0)
2370 { 2403 {
2371 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n"); 2404 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n");
2372 } 2405 }
2373 else 2406 else
2374 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, setsockopt); 2407 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, setsockopt);
2375 2408
2376 if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK) 2409 if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
2377 { 2410 {
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index c7029a579..bf5411d59 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -355,7 +355,7 @@ struct Sessionqueue
355 struct Sessionqueue *prev; 355 struct Sessionqueue *prev;
356 struct Session *content; 356 struct Session *content;
357#if !HAVE_UNALIGNED_64_ACCESS 357#if !HAVE_UNALIGNED_64_ACCESS
358 void *dummy; /* for alignment, see #1909 */ 358 void *dummy; /* for alignment, see #1909 */
359#endif 359#endif
360}; 360};
361 361
@@ -1066,8 +1066,9 @@ set_next_send (struct Plugin *const plugin)
1066 struct GNUNET_TIME_Relative next_send; 1066 struct GNUNET_TIME_Relative next_send;
1067 1067
1068 //abort if helper is not running 1068 //abort if helper is not running
1069 if (plugin->helper_is_running == GNUNET_NO){ 1069 if (plugin->helper_is_running == GNUNET_NO)
1070 return; 1070 {
1071 return;
1071 } 1072 }
1072 1073
1073 //cancel old task 1074 //cancel old task
@@ -1465,12 +1466,13 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1465 const char *filenameloopback = "gnunet-transport-wlan-helper-dummy"; 1466 const char *filenameloopback = "gnunet-transport-wlan-helper-dummy";
1466 char *absolute_filename = NULL; 1467 char *absolute_filename = NULL;
1467 1468
1468 if (plugin->helper_is_running == GNUNET_YES){ 1469 if (plugin->helper_is_running == GNUNET_YES)
1470 {
1469#if DEBUG_wlan 1471#if DEBUG_wlan
1470 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1472 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1471 "wlan_transport_start_wlan_helper not needed, helper already running!"); 1473 "wlan_transport_start_wlan_helper not needed, helper already running!");
1472#endif 1474#endif
1473 return GNUNET_YES; 1475 return GNUNET_YES;
1474 } 1476 }
1475 1477
1476 plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); 1478 plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
@@ -1634,12 +1636,13 @@ wlan_transport_stop_wlan_helper (struct Plugin *plugin)
1634 "Stoping WLAN helper process\n"); 1636 "Stoping WLAN helper process\n");
1635#endif 1637#endif
1636 1638
1637 if (plugin->helper_is_running == GNUNET_NO){ 1639 if (plugin->helper_is_running == GNUNET_NO)
1640 {
1638#if DEBUG_wlan 1641#if DEBUG_wlan
1639 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1642 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1640 "wlan_transport_stop_wlan_helper not needed, helper already stopped!"); 1643 "wlan_transport_stop_wlan_helper not needed, helper already stopped!");
1641#endif 1644#endif
1642 return GNUNET_YES; 1645 return GNUNET_YES;
1643 } 1646 }
1644 1647
1645 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK) 1648 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -2604,13 +2607,15 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2604 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1]; 2607 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
2605 crc = ntohl (wlanheader->crc); 2608 crc = ntohl (wlanheader->crc);
2606 wlanheader->crc = 0; 2609 wlanheader->crc = 0;
2607 if (GNUNET_CRYPTO_crc32_n ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc) 2610 if (GNUNET_CRYPTO_crc32_n
2611 ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
2608 { 2612 {
2609 //wrong crc, dispose message 2613 //wrong crc, dispose message
2610 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, 2614 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
2611 "Wlan message header crc was wrong: %u != %u\n", 2615 "Wlan message header crc was wrong: %u != %u\n",
2612 GNUNET_CRYPTO_crc32_n ((char *) wlanheader, 2616 GNUNET_CRYPTO_crc32_n ((char *) wlanheader,
2613 ntohs (wlanheader->header.size)), crc); 2617 ntohs (wlanheader->header.size)),
2618 crc);
2614 hexdump ((void *) hdr, ntohs (hdr->size)); 2619 hexdump ((void *) hdr, ntohs (hdr->size));
2615 return; 2620 return;
2616 } 2621 }
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 52051954b..1742dd0d3 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -484,8 +484,7 @@ generate_config (char *cfg_file, unsigned long long quota_in,
484 GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out, 484 GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out,
485 cfg_file); 485 cfg_file);
486 GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", fname); 486 GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", fname);
487 GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_IN", 487 GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_IN", quota_in);
488 quota_in);
489 GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_OUT", 488 GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_OUT",
490 quota_out); 489 quota_out);
491 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname)); 490 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname));
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c
index aa6f98027..20005deab 100644
--- a/src/transport/test_transport_api_bidirectional_connect.c
+++ b/src/transport/test_transport_api_bidirectional_connect.c
@@ -312,10 +312,12 @@ start_cb (struct PeerContext *p, void *cls)
312 "Test tries to connect peer %u (`%s') <-> peer %u (`%s')\n", 312 "Test tries to connect peer %u (`%s') <-> peer %u (`%s')\n",
313 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 313 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
314 314
315 cc1 = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb, 315 cc1 =
316 NULL); 316 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
317 cc2 = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 317 NULL);
318 NULL); 318 cc2 =
319 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
320 NULL);
319} 321}
320 322
321static void 323static void
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 7dd9bd913..026ed085a 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -128,7 +128,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
128 128
129 if (cc != NULL) 129 if (cc != NULL)
130 { 130 {
131 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 131 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
132 cc = NULL; 132 cc = NULL;
133 } 133 }
134 134
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 87383bbac..61423a7ee 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -155,10 +155,12 @@ static void
155reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 155reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
156{ 156{
157 struct PeerContext *p = cls; 157 struct PeerContext *p = cls;
158
158 reconnect_task = GNUNET_SCHEDULER_NO_TASK; 159 reconnect_task = GNUNET_SCHEDULER_NO_TASK;
159 160
160 GNUNET_TRANSPORT_try_connect (p->th, &p2->id); 161 GNUNET_TRANSPORT_try_connect (p->th, &p2->id);
161 reconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &reconnect, p); 162 reconnect_task =
163 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
162} 164}
163 165
164static void 166static void
@@ -166,20 +168,17 @@ restart_cb (struct PeerContext *p, void *cls)
166{ 168{
167 169
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
169 "Restarted peer %u (`%4s'), issuing reconnect\n", 171 "Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
170 p->no,
171 GNUNET_i2s (&p->id)); 172 GNUNET_i2s (&p->id));
172 173
173 reconnect_task = GNUNET_SCHEDULER_add_now(&reconnect, p); 174 reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
174} 175}
175 176
176static 177static void
177void restart (struct PeerContext *p , char * cfg_file) 178restart (struct PeerContext *p, char *cfg_file)
178{ 179{
179 GNUNET_assert (p != NULL); 180 GNUNET_assert (p != NULL);
180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no,
181 "Restarting peer %u (`%4s')\n",
182 p->no,
183 GNUNET_i2s (&p->id)); 182 GNUNET_i2s (&p->id));
184 GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p); 183 GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p);
185 return; 184 return;
@@ -200,6 +199,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
200 GNUNET_assert (t != NULL); 199 GNUNET_assert (t != NULL);
201 200
202 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 201 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
202
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
204 "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", 204 "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
205 p->no, ps, ntohs (message->type), ntohs (message->size), t->no, 205 p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
@@ -217,8 +217,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
217 } 217 }
218 else 218 else
219 { 219 {
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
221 "Restarted peers connected, stopping test...\n"); 221 "Restarted peers connected, stopping test...\n");
222 ok = 0; 222 ok = 0;
223 end (); 223 end ();
224 } 224 }
@@ -329,6 +329,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
329 329
330 330
331 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 331 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
332
332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 333 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
333 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, 334 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
334 GNUNET_i2s (peer)); 335 GNUNET_i2s (peer));
@@ -368,6 +369,7 @@ start_cb (struct PeerContext *p, void *cls)
368 return; 369 return;
369 370
370 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 371 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
372
371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
372 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 374 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
373 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 375 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
@@ -451,8 +453,8 @@ main (int argc, char *argv[])
451 tth = GNUNET_TRANSPORT_TESTING_init (); 453 tth = GNUNET_TRANSPORT_TESTING_init ();
452 454
453 455
454 GNUNET_asprintf(&cfg_file_p1,"test_transport_api_tcp_peer1.conf"); 456 GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf");
455 GNUNET_asprintf(&cfg_file_p2,"test_transport_api_tcp_peer2.conf"); 457 GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf");
456 458
457 459
458 ret = check (); 460 ret = check ();
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c
index 44a41614f..67cc90f0e 100644
--- a/src/transport/test_transport_api_restart_2peers.c
+++ b/src/transport/test_transport_api_restart_2peers.c
@@ -155,36 +155,36 @@ static void
155reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 155reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
156{ 156{
157 struct PeerContext *p = cls; 157 struct PeerContext *p = cls;
158
158 reconnect_task = GNUNET_SCHEDULER_NO_TASK; 159 reconnect_task = GNUNET_SCHEDULER_NO_TASK;
159 160
160 GNUNET_TRANSPORT_try_connect (p1->th, &p2->id); 161 GNUNET_TRANSPORT_try_connect (p1->th, &p2->id);
161 reconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &reconnect, p); 162 reconnect_task =
163 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
162} 164}
163 165
164static void 166static void
165restart_cb (struct PeerContext *p, void *cls) 167restart_cb (struct PeerContext *p, void *cls)
166{ 168{
167 static int c; 169 static int c;
170
168 c++; 171 c++;
169 172
170 if (c != 2) 173 if (c != 2)
171 return; 174 return;
172 175
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
174 "Restarted peer %u (`%4s'), issuing reconnect\n", 177 "Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
175 p->no,
176 GNUNET_i2s (&p->id)); 178 GNUNET_i2s (&p->id));
177 179
178 reconnect_task = GNUNET_SCHEDULER_add_now(&reconnect, p); 180 reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
179} 181}
180 182
181static 183static void
182void restart (struct PeerContext *p , char * cfg_file) 184restart (struct PeerContext *p, char *cfg_file)
183{ 185{
184 GNUNET_assert (p != NULL); 186 GNUNET_assert (p != NULL);
185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no,
186 "Restarting peer %u (`%4s')\n",
187 p->no,
188 GNUNET_i2s (&p->id)); 188 GNUNET_i2s (&p->id));
189 GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p); 189 GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p);
190 return; 190 return;
@@ -205,6 +205,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
205 GNUNET_assert (t != NULL); 205 GNUNET_assert (t != NULL);
206 206
207 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 207 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
208
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
209 "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", 210 "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
210 p->no, ps, ntohs (message->type), ntohs (message->size), t->no, 211 p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
@@ -223,8 +224,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
223 } 224 }
224 else 225 else
225 { 226 {
226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
227 "Restarted peers connected, stopping test...\n"); 228 "Restarted peers connected, stopping test...\n");
228 ok = 0; 229 ok = 0;
229 end (); 230 end ();
230 } 231 }
@@ -335,6 +336,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
335 336
336 337
337 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 338 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
339
338 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
339 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, 341 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
340 GNUNET_i2s (peer)); 342 GNUNET_i2s (peer));
@@ -374,6 +376,7 @@ start_cb (struct PeerContext *p, void *cls)
374 return; 376 return;
375 377
376 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 378 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
379
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
378 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 381 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
379 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 382 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
@@ -457,8 +460,8 @@ main (int argc, char *argv[])
457 tth = GNUNET_TRANSPORT_TESTING_init (); 460 tth = GNUNET_TRANSPORT_TESTING_init ();
458 461
459 462
460 GNUNET_asprintf(&cfg_file_p1,"test_transport_api_tcp_peer1.conf"); 463 GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf");
461 GNUNET_asprintf(&cfg_file_p2,"test_transport_api_tcp_peer2.conf"); 464 GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf");
462 465
463 466
464 ret = check (); 467 ret = check ();
@@ -472,4 +475,5 @@ main (int argc, char *argv[])
472 475
473 return ret; 476 return ret;
474} 477}
478
475/* end of test_transport_api_restart_2peers.c */ 479/* end of test_transport_api_restart_2peers.c */
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 90defae02..e52b20f7c 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -229,10 +229,9 @@ get_size (unsigned int iter)
229 229
230#ifndef LINUX 230#ifndef LINUX
231 /* FreeBSD/OSX etc. Unix DGRAMs do not work 231 /* FreeBSD/OSX etc. Unix DGRAMs do not work
232 with large messages */ 232 * with large messages */
233 if (0 == strcmp ("unix", 233 if (0 == strcmp ("unix", test_plugin))
234 test_plugin)) 234 return sizeof (struct TestMessage) + (ret % 1024);
235 return sizeof (struct TestMessage) + (ret % 1024);
236#endif 235#endif
237 return sizeof (struct TestMessage) + (ret % 60000); 236 return sizeof (struct TestMessage) + (ret % 60000);
238} 237}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index e45953239..9f7a99a7b 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -284,22 +284,22 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
284 p->cfg = GNUNET_CONFIGURATION_create (); 284 p->cfg = GNUNET_CONFIGURATION_create ();
285 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 285 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
286 286
287 if (GNUNET_CONFIGURATION_have_value (p-> 287 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
288 cfg, "PATHS", "SERVICEHOME"))
289 GNUNET_assert (GNUNET_OK == 288 GNUNET_assert (GNUNET_OK ==
290 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", 289 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
291 "SERVICEHOME", 290 "SERVICEHOME",
292 &p->servicehome)); 291 &p->servicehome));
293 292
294 if (NULL != p->servicehome) 293 if (NULL != p->servicehome)
295 GNUNET_DISK_directory_remove (p->servicehome); 294 GNUNET_DISK_directory_remove (p->servicehome);
296 295
297 hostkey = get_host_key(tth); 296 hostkey = get_host_key (tth);
298 if (hostkey != NULL) 297 if (hostkey != NULL)
299 { 298 {
300 299
301 GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome); 300 GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome);
302 GNUNET_assert(GNUNET_OK == GNUNET_DISK_directory_create_for_file (p->hostkeyfile)); 301 GNUNET_assert (GNUNET_OK ==
302 GNUNET_DISK_directory_create_for_file (p->hostkeyfile));
303 fn = GNUNET_DISK_file_open (p->hostkeyfile, 303 fn = GNUNET_DISK_file_open (p->hostkeyfile,
304 GNUNET_DISK_OPEN_READWRITE | 304 GNUNET_DISK_OPEN_READWRITE |
305 GNUNET_DISK_OPEN_CREATE, 305 GNUNET_DISK_OPEN_CREATE,
@@ -355,11 +355,11 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
355* @return GNUNET_OK in success otherwise GNUNET_SYSERR 355* @return GNUNET_OK in success otherwise GNUNET_SYSERR
356*/ 356*/
357int 357int
358GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 358GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
359 struct PeerContext *p, 359 *tth, struct PeerContext *p,
360 const char *cfgname, 360 const char *cfgname,
361 GNUNET_TRANSPORT_TESTING_start_cb restart_cb, 361 GNUNET_TRANSPORT_TESTING_start_cb
362 void *cb_cls) 362 restart_cb, void *cb_cls)
363{ 363{
364 struct GNUNET_DISK_FileHandle *fn; 364 struct GNUNET_DISK_FileHandle *fn;
365 365
@@ -370,9 +370,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
370 370
371 /* shutdown */ 371 /* shutdown */
372#if VERBOSE 372#if VERBOSE
373 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 373 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
374 "Stopping peer %u (`%s')\n", p->no, 374 "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
375 GNUNET_i2s (&p->id));
376#endif 375#endif
377 if (p->ghh != NULL) 376 if (p->ghh != NULL)
378 GNUNET_TRANSPORT_get_hello_cancel (p->ghh); 377 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
@@ -400,48 +399,48 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
400 399
401 /* start */ 400 /* start */
402#if VERBOSE 401#if VERBOSE
403 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 402 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
404 "Restarting peer %u (`%s')\n", p->no, 403 "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
405 GNUNET_i2s (&p->id));
406#endif 404#endif
407 405
408 sleep (5); // YUCK! 406 sleep (5); // YUCK!
409 407
410 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 408 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
411 { 409 {
412 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 410 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
413 "File not found: `%s' \n", cfgname); 411 "File not found: `%s' \n", cfgname);
414 goto fail; 412 goto fail;
415 } 413 }
416 414
417 p->cfg = GNUNET_CONFIGURATION_create (); 415 p->cfg = GNUNET_CONFIGURATION_create ();
418 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 416 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
419 417
420 if (! GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 418 if (!GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
421 goto fail; 419 goto fail;
422 420
423 fn = GNUNET_DISK_file_open (p->hostkeyfile, 421 fn = GNUNET_DISK_file_open (p->hostkeyfile,
424 GNUNET_DISK_OPEN_READWRITE | 422 GNUNET_DISK_OPEN_READWRITE |
425 GNUNET_DISK_OPEN_CREATE, 423 GNUNET_DISK_OPEN_CREATE,
426 GNUNET_DISK_PERM_USER_READ | 424 GNUNET_DISK_PERM_USER_READ |
427 GNUNET_DISK_PERM_USER_WRITE); 425 GNUNET_DISK_PERM_USER_WRITE);
428 if (fn == NULL) 426 if (fn == NULL)
429 goto fail; 427 goto fail;
430 if (GNUNET_OK != GNUNET_DISK_file_close (fn)) 428 if (GNUNET_OK != GNUNET_DISK_file_close (fn))
431 goto fail; 429 goto fail;
432 430
433 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 431 p->arm_proc =
434 "gnunet-service-arm", "-c", cfgname, 432 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
435 #if VERBOSE_PEERS 433 "gnunet-service-arm", "-c", cfgname,
436 "-L", "DEBUG", 434#if VERBOSE_PEERS
437 #else 435 "-L", "DEBUG",
438 "-L", "ERROR", 436#else
439 #endif 437 "-L", "ERROR",
440 NULL); 438#endif
439 NULL);
441 440
442 p->th = 441 p->th =
443 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive, 442 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
444 &notify_connect, &notify_disconnect); 443 &notify_connect, &notify_disconnect);
445 GNUNET_assert (p->th != NULL); 444 GNUNET_assert (p->th != NULL);
446 445
447 p->start_cb = restart_cb; 446 p->start_cb = restart_cb;
@@ -451,11 +450,11 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
451 GNUNET_assert (p->ghh != NULL); 450 GNUNET_assert (p->ghh != NULL);
452 return GNUNET_OK; 451 return GNUNET_OK;
453 452
454 fail: 453fail:
455 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 454 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
456 "Restarting peer %u (`%s') failed, removing peer\n", p->no, 455 "Restarting peer %u (`%s') failed, removing peer\n", p->no,
457 GNUNET_i2s (&p->id)); 456 GNUNET_i2s (&p->id));
458 GNUNET_TRANSPORT_TESTING_stop_peer (tth,p); 457 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
459 return GNUNET_SYSERR; 458 return GNUNET_SYSERR;
460} 459}
461 460
@@ -643,11 +642,11 @@ GNUNET_TRANSPORT_TESTING_init ()
643 /* prepare hostkeys */ 642 /* prepare hostkeys */
644 tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); 643 tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
645 tth->hostkey_data = NULL; 644 tth->hostkey_data = NULL;
646 const char * hostkeys_file = "../../contrib/testing_hostkeys.dat"; 645 const char *hostkeys_file = "../../contrib/testing_hostkeys.dat";
646
647 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) 647 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
648 { 648 {
649 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 649 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not read hostkeys file!\n"));
650 _("Could not read hostkeys file!\n"));
651 } 650 }
652 else 651 else
653 { 652 {
@@ -656,8 +655,7 @@ GNUNET_TRANSPORT_TESTING_init ()
656 GNUNET_DISK_PERM_NONE); 655 GNUNET_DISK_PERM_NONE);
657 if (NULL == fd) 656 if (NULL == fd)
658 { 657 {
659 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", 658 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file);
660 hostkeys_file);
661 GNUNET_free (tth); 659 GNUNET_free (tth);
662 return NULL; 660 return NULL;
663 } 661 }
@@ -668,7 +666,7 @@ GNUNET_TRANSPORT_TESTING_init ()
668 if (0 != (fs % HOSTKEYFILESIZE)) 666 if (0 != (fs % HOSTKEYFILESIZE))
669 { 667 {
670 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 668 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
671 "File size %llu seems incorrect for hostkeys...\n", fs); 669 "File size %llu seems incorrect for hostkeys...\n", fs);
672 } 670 }
673 else 671 else
674 { 672 {
@@ -676,7 +674,7 @@ GNUNET_TRANSPORT_TESTING_init ()
676 tth->hostkey_data = GNUNET_malloc_large (fs); 674 tth->hostkey_data = GNUNET_malloc_large (fs);
677 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs)); 675 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs));
678 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 676 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
679 "Read %llu hostkeys from file\n", total_hostkeys); 677 "Read %llu hostkeys from file\n", total_hostkeys);
680 tth->hostkeys_total = total_hostkeys; 678 tth->hostkeys_total = total_hostkeys;
681 } 679 }
682 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); 680 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 883c68837..c77d79381 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -169,11 +169,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
169* @return GNUNET_OK in success otherwise GNUNET_SYSERR 169* @return GNUNET_OK in success otherwise GNUNET_SYSERR
170*/ 170*/
171int 171int
172GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 172GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
173 struct PeerContext *p, 173 *tth, struct PeerContext *p,
174 const char *cfgname, 174 const char *cfgname,
175 GNUNET_TRANSPORT_TESTING_start_cb start_cb, 175 GNUNET_TRANSPORT_TESTING_start_cb
176 void *cb_cls); 176 start_cb, void *cb_cls);
177 177
178/** 178/**
179 * Connect the given peers and call the callback when both peers report the 179 * Connect the given peers and call the callback when both peers report the
diff --git a/src/transport/transport.h b/src/transport/transport.h
index bfcf9fe6e..d2792b92d 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -401,7 +401,7 @@ struct AddressIterateResponseMessage
401 * length of the plugin name 401 * length of the plugin name
402 */ 402 */
403 uint32_t pluginlen GNUNET_PACKED; 403 uint32_t pluginlen GNUNET_PACKED;
404 404
405}; 405};
406 406
407 407
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index 7cd61e896..9ae9b4031 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -93,7 +93,8 @@ peer_address_response_processor (void *cls,
93 return; 93 return;
94 } 94 }
95 size = ntohs (msg->size); 95 size = ntohs (msg->size);
96 GNUNET_break (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); 96 GNUNET_break (ntohs (msg->type) ==
97 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
97 if (size == sizeof (struct GNUNET_MessageHeader)) 98 if (size == sizeof (struct GNUNET_MessageHeader))
98 { 99 {
99 /* done! */ 100 /* done! */
@@ -102,8 +103,11 @@ peer_address_response_processor (void *cls,
102 return; 103 return;
103 } 104 }
104 105
105 if ( (size < sizeof (struct GNUNET_MessageHeader) + sizeof (struct AddressIterateResponseMessage)) || 106 if ((size <
106 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE) ) 107 sizeof (struct GNUNET_MessageHeader) +
108 sizeof (struct AddressIterateResponseMessage)) ||
109 (ntohs (msg->type) !=
110 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE))
107 { 111 {
108 GNUNET_break (0); 112 GNUNET_break (0);
109 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); 113 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
@@ -112,8 +116,8 @@ peer_address_response_processor (void *cls,
112 } 116 }
113 117
114 air_msg = (struct AddressIterateResponseMessage *) msg; 118 air_msg = (struct AddressIterateResponseMessage *) msg;
115 tlen = ntohl(air_msg->pluginlen); 119 tlen = ntohl (air_msg->pluginlen);
116 alen = ntohl(air_msg->addrlen); 120 alen = ntohl (air_msg->addrlen);
117 121
118 if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen) 122 if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen)
119 { 123 {
@@ -126,7 +130,7 @@ peer_address_response_processor (void *cls,
126 addr = (const char *) &air_msg[1]; 130 addr = (const char *) &air_msg[1];
127 transport_name = &addr[alen]; 131 transport_name = &addr[alen];
128 132
129 if (transport_name[tlen-1] != '\0') 133 if (transport_name[tlen - 1] != '\0')
130 { 134 {
131 GNUNET_break_op (0); 135 GNUNET_break_op (0);
132 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); 136 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
@@ -135,13 +139,14 @@ peer_address_response_processor (void *cls,
135 } 139 }
136 140
137 /* expect more replies */ 141 /* expect more replies */
138 GNUNET_CLIENT_receive (pal_ctx->client, 142 GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor,
139 &peer_address_response_processor, pal_ctx, 143 pal_ctx,
140 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); 144 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout));
141 145
142 /* notify client */ 146 /* notify client */
143 address = GNUNET_HELLO_address_allocate (&air_msg->peer, 147 address =
144 transport_name, addr, alen); 148 GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr,
149 alen);
145 pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address); 150 pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address);
146 GNUNET_HELLO_address_free (address); 151 GNUNET_HELLO_address_free (address);
147} 152}
@@ -165,11 +170,13 @@ peer_address_response_processor (void *cls,
165 * @param peer_address_callback_cls closure for peer_address_callback 170 * @param peer_address_callback_cls closure for peer_address_callback
166 */ 171 */
167struct GNUNET_TRANSPORT_PeerIterateContext * 172struct GNUNET_TRANSPORT_PeerIterateContext *
168GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Handle *cfg, 173GNUNET_TRANSPORT_peer_get_active_addresses (const struct
169 const struct GNUNET_PeerIdentity *peer, 174 GNUNET_CONFIGURATION_Handle *cfg,
170 int one_shot, 175 const struct GNUNET_PeerIdentity
176 *peer, int one_shot,
171 struct GNUNET_TIME_Relative timeout, 177 struct GNUNET_TIME_Relative timeout,
172 GNUNET_TRANSPORT_PeerIterateCallback peer_address_callback, 178 GNUNET_TRANSPORT_PeerIterateCallback
179 peer_address_callback,
173 void *peer_address_callback_cls) 180 void *peer_address_callback_cls)
174{ 181{
175 struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx; 182 struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx;
@@ -180,7 +187,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
180 if (GNUNET_YES != one_shot) 187 if (GNUNET_YES != one_shot)
181 { 188 {
182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 189 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
183 "Address monitoring not implemented\n"); 190 "Address monitoring not implemented\n");
184 return NULL; 191 return NULL;
185 } 192 }
186 client = GNUNET_CLIENT_connect ("transport", cfg); 193 client = GNUNET_CLIENT_connect ("transport", cfg);
@@ -192,7 +199,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
192 msg.one_shot = htonl (one_shot); 199 msg.one_shot = htonl (one_shot);
193 msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); 200 msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout);
194 if (peer == NULL) 201 if (peer == NULL)
195 memset (&msg.peer, 0 , sizeof (struct GNUNET_PeerIdentity)); 202 memset (&msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
196 else 203 else
197 msg.peer = *peer; 204 msg.peer = *peer;
198 pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext)); 205 pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext));
@@ -216,8 +223,8 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
216 */ 223 */
217void 224void
218GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct 225GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct
219 GNUNET_TRANSPORT_PeerIterateContext 226 GNUNET_TRANSPORT_PeerIterateContext
220 *alc) 227 *alc)
221{ 228{
222 GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); 229 GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO);
223 GNUNET_free (alc); 230 GNUNET_free (alc);
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c
index 5c44c288b..4d809530a 100644
--- a/src/transport/transport_api_address_to_string.c
+++ b/src/transport/transport_api_address_to_string.c
@@ -76,7 +76,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
76 return; 76 return;
77 } 77 }
78 GNUNET_break (ntohs (msg->type) == 78 GNUNET_break (ntohs (msg->type) ==
79 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); 79 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
80 size = ntohs (msg->size); 80 size = ntohs (msg->size);
81 if (size == sizeof (struct GNUNET_MessageHeader)) 81 if (size == sizeof (struct GNUNET_MessageHeader))
82 { 82 {
@@ -116,12 +116,13 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
116 * @return handle to cancel the operation, NULL on error 116 * @return handle to cancel the operation, NULL on error
117 */ 117 */
118struct GNUNET_TRANSPORT_AddressToStringContext * 118struct GNUNET_TRANSPORT_AddressToStringContext *
119GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg, 119GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle
120 const struct GNUNET_HELLO_Address *address, 120 *cfg,
121 int numeric, 121 const struct GNUNET_HELLO_Address *address,
122 struct GNUNET_TIME_Relative timeout, 122 int numeric,
123 GNUNET_TRANSPORT_AddressToStringCallback aluc, 123 struct GNUNET_TIME_Relative timeout,
124 void *aluc_cls) 124 GNUNET_TRANSPORT_AddressToStringCallback
125 aluc, void *aluc_cls)
125{ 126{
126 size_t len; 127 size_t len;
127 size_t alen; 128 size_t alen;
@@ -145,8 +146,7 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
145 if (client == NULL) 146 if (client == NULL)
146 return NULL; 147 return NULL;
147#if DEBUG_TRANSPORT 148#if DEBUG_TRANSPORT
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_TRANSPORT_address_to_string\n");
149 "GNUNET_TRANSPORT_address_to_string\n");
150#endif 150#endif
151 msg = GNUNET_malloc (len); 151 msg = GNUNET_malloc (len);
152 msg->header.size = htons (len); 152 msg->header.size = htons (len);
@@ -180,8 +180,8 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
180 */ 180 */
181void 181void
182GNUNET_TRANSPORT_address_to_string_cancel (struct 182GNUNET_TRANSPORT_address_to_string_cancel (struct
183 GNUNET_TRANSPORT_AddressToStringContext 183 GNUNET_TRANSPORT_AddressToStringContext
184 *alc) 184 *alc)
185{ 185{
186 GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); 186 GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO);
187 GNUNET_free (alc); 187 GNUNET_free (alc);