aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-08-22 13:36:42 +0000
committerChristian Grothoff <christian@grothoff.org>2010-08-22 13:36:42 +0000
commit51a6531fa5c68eed968b314a5124a2fdfb3556d2 (patch)
tree31f043188b8a7e92d6e6f6c001fadc410499c138
parentb4e21c6afcb6cd772c66b2c0ae3199f193c972c7 (diff)
downloadgnunet-51a6531fa5c68eed968b314a5124a2fdfb3556d2.tar.gz
gnunet-51a6531fa5c68eed968b314a5124a2fdfb3556d2.zip
whitespace
-rw-r--r--src/transport/gnunet-nat-client-windows.c128
-rw-r--r--src/transport/gnunet-nat-server-windows.c144
-rw-r--r--src/transport/gnunet-service-transport.c366
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c6
-rw-r--r--src/transport/plugin_transport_https.c4
-rw-r--r--src/transport/plugin_transport_tcp.c102
-rw-r--r--src/transport/plugin_transport_template.c8
-rw-r--r--src/transport/plugin_transport_udp.c82
-rw-r--r--src/transport/test_plugin_transport_http.c2
-rw-r--r--src/transport/test_plugin_transport_https.c2
-rw-r--r--src/transport/test_transport_api.c10
-rw-r--r--src/transport/test_transport_api_reliability.c14
-rw-r--r--src/transport/transport_api.c64
-rw-r--r--src/transport/transport_api_address_lookup.c16
-rw-r--r--src/transport/transport_api_blacklist.c10
15 files changed, 479 insertions, 479 deletions
diff --git a/src/transport/gnunet-nat-client-windows.c b/src/transport/gnunet-nat-client-windows.c
index 3d3127157..2507a96b4 100644
--- a/src/transport/gnunet-nat-client-windows.c
+++ b/src/transport/gnunet-nat-client-windows.c
@@ -70,65 +70,65 @@
70/** 70/**
71 * IPv4 header. 71 * IPv4 header.
72 */ 72 */
73struct ip_header 73struct ip_header
74{ 74{
75 75
76 /** 76 /**
77 * Version (4 bits) + Internet header length (4 bits) 77 * Version (4 bits) + Internet header length (4 bits)
78 */ 78 */
79 uint8_t vers_ihl; 79 uint8_t vers_ihl;
80 80
81 /** 81 /**
82 * Type of service 82 * Type of service
83 */ 83 */
84 uint8_t tos; 84 uint8_t tos;
85 85
86 /** 86 /**
87 * Total length 87 * Total length
88 */ 88 */
89 uint16_t pkt_len; 89 uint16_t pkt_len;
90 90
91 /** 91 /**
92 * Identification 92 * Identification
93 */ 93 */
94 uint16_t id; 94 uint16_t id;
95 95
96 /** 96 /**
97 * Flags (3 bits) + Fragment offset (13 bits) 97 * Flags (3 bits) + Fragment offset (13 bits)
98 */ 98 */
99 uint16_t flags_frag_offset; 99 uint16_t flags_frag_offset;
100 100
101 /** 101 /**
102 * Time to live 102 * Time to live
103 */ 103 */
104 uint8_t ttl; 104 uint8_t ttl;
105 105
106 /** 106 /**
107 * Protocol 107 * Protocol
108 */ 108 */
109 uint8_t proto; 109 uint8_t proto;
110 110
111 /** 111 /**
112 * Header checksum 112 * Header checksum
113 */ 113 */
114 uint16_t checksum; 114 uint16_t checksum;
115 115
116 /** 116 /**
117 * Source address 117 * Source address
118 */ 118 */
119 uint32_t src_ip; 119 uint32_t src_ip;
120 120
121 /** 121 /**
122 * Destination address 122 * Destination address
123 */ 123 */
124 uint32_t dst_ip; 124 uint32_t dst_ip;
125}; 125};
126 126
127 127
128/** 128/**
129 * Format of ICMP packet. 129 * Format of ICMP packet.
130 */ 130 */
131struct icmp_ttl_exceeded_header 131struct icmp_ttl_exceeded_header
132{ 132{
133 uint8_t type; 133 uint8_t type;
134 134
@@ -179,7 +179,7 @@ static struct in_addr dummy;
179 179
180/** 180/**
181 * Port we are listening on (communicated to the server). 181 * Port we are listening on (communicated to the server).
182 */ 182 */
183static uint16_t port; 183static uint16_t port;
184 184
185 185
@@ -192,17 +192,17 @@ static uint16_t port;
192 * @param buf where to write the address result 192 * @param buf where to write the address result
193 * @return 1 on success 193 * @return 1 on success
194 */ 194 */
195static int 195static int
196inet_pton (int af, 196inet_pton (int af,
197 const char *cp, 197 const char *cp,
198 struct in_addr *buf) 198 struct in_addr *buf)
199{ 199{
200 buf->s_addr = inet_addr(cp); 200 buf->s_addr = inet_addr(cp);
201 if (buf->s_addr == INADDR_NONE) 201 if (buf->s_addr == INADDR_NONE)
202 { 202 {
203 fprintf(stderr, 203 fprintf(stderr,
204 "Error %d handling address %s", 204 "Error %d handling address %s",
205 WSAGetLastError(), 205 WSAGetLastError(),
206 cp); 206 cp);
207 return 0; 207 return 0;
208 } 208 }
@@ -217,16 +217,16 @@ inet_pton (int af,
217 * @param bytes number of bytes in data (must be multiple of 2) 217 * @param bytes number of bytes in data (must be multiple of 2)
218 * @return the CRC 16. 218 * @return the CRC 16.
219 */ 219 */
220static uint16_t 220static uint16_t
221calc_checksum(const uint16_t *data, 221calc_checksum(const uint16_t *data,
222 unsigned int bytes) 222 unsigned int bytes)
223{ 223{
224 uint32_t sum; 224 uint32_t sum;
225 unsigned int i; 225 unsigned int i;
226 226
227 sum = 0; 227 sum = 0;
228 for (i=0;i<bytes/2;i++) 228 for (i=0;i<bytes/2;i++)
229 sum += data[i]; 229 sum += data[i];
230 sum = (sum & 0xffff) + (sum >> 16); 230 sum = (sum & 0xffff) + (sum >> 16);
231 sum = htons(0xffff - sum); 231 sum = htons(0xffff - sum);
232 return sum; 232 return sum;
@@ -244,7 +244,7 @@ send_icmp_udp (const struct in_addr *my_ip,
244 const struct in_addr *other) 244 const struct in_addr *other)
245{ 245{
246 char packet[sizeof(struct ip_header) * 2 + 246 char packet[sizeof(struct ip_header) * 2 +
247 sizeof(struct icmp_ttl_exceeded_header) + 247 sizeof(struct icmp_ttl_exceeded_header) +
248 sizeof(struct udp_header)]; 248 sizeof(struct udp_header)];
249 struct ip_header ip_pkt; 249 struct ip_header ip_pkt;
250 struct icmp_ttl_exceeded_header icmp_pkt; 250 struct icmp_ttl_exceeded_header icmp_pkt;
@@ -265,10 +265,10 @@ send_icmp_udp (const struct in_addr *my_ip,
265 ip_pkt.checksum = 0; 265 ip_pkt.checksum = 0;
266 ip_pkt.src_ip = my_ip->s_addr; 266 ip_pkt.src_ip = my_ip->s_addr;
267 ip_pkt.dst_ip = other->s_addr; 267 ip_pkt.dst_ip = other->s_addr;
268 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, 268 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
269 sizeof (struct ip_header))); 269 sizeof (struct ip_header)));
270 memcpy(&packet[off], 270 memcpy(&packet[off],
271 &ip_pkt, 271 &ip_pkt,
272 sizeof(struct ip_header)); 272 sizeof(struct ip_header));
273 off += sizeof(struct ip_header); 273 off += sizeof(struct ip_header);
274 274
@@ -277,7 +277,7 @@ send_icmp_udp (const struct in_addr *my_ip,
277 icmp_pkt.checksum = 0; 277 icmp_pkt.checksum = 0;
278 icmp_pkt.unused = 0; 278 icmp_pkt.unused = 0;
279 memcpy(&packet[off], 279 memcpy(&packet[off],
280 &icmp_pkt, 280 &icmp_pkt,
281 sizeof(struct icmp_ttl_exceeded_header)); 281 sizeof(struct icmp_ttl_exceeded_header));
282 off += sizeof(struct icmp_ttl_exceeded_header); 282 off += sizeof(struct icmp_ttl_exceeded_header);
283 283
@@ -293,32 +293,32 @@ send_icmp_udp (const struct in_addr *my_ip,
293 ip_pkt.checksum = 0; 293 ip_pkt.checksum = 0;
294 ip_pkt.src_ip = other->s_addr; 294 ip_pkt.src_ip = other->s_addr;
295 ip_pkt.dst_ip = dummy.s_addr; 295 ip_pkt.dst_ip = dummy.s_addr;
296 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, 296 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
297 sizeof (struct ip_header))); 297 sizeof (struct ip_header)));
298 memcpy(&packet[off], 298 memcpy(&packet[off],
299 &ip_pkt, 299 &ip_pkt,
300 sizeof(struct ip_header)); 300 sizeof(struct ip_header));
301 off += sizeof(struct ip_header); 301 off += sizeof(struct ip_header);
302 302
303 /* build UDP header */ 303 /* build UDP header */
304 udp_pkt.src_port = htons(NAT_TRAV_PORT); 304 udp_pkt.src_port = htons(NAT_TRAV_PORT);
305 udp_pkt.dst_port = htons(NAT_TRAV_PORT); 305 udp_pkt.dst_port = htons(NAT_TRAV_PORT);
306 udp_pkt.length = htons (port); 306 udp_pkt.length = htons (port);
307 udp_pkt.crc = 0; 307 udp_pkt.crc = 0;
308 memcpy(&packet[off], 308 memcpy(&packet[off],
309 &udp_pkt, 309 &udp_pkt,
310 sizeof(struct udp_header)); 310 sizeof(struct udp_header));
311 off += sizeof(struct udp_header); 311 off += sizeof(struct udp_header);
312 312
313 /* no go back to calculate ICMP packet checksum */ 313 /* no go back to calculate ICMP packet checksum */
314 icmp_pkt.checksum = htons(calc_checksum((uint16_t*)&packet[off], 314 icmp_pkt.checksum = htons(calc_checksum((uint16_t*)&packet[off],
315 sizeof (struct icmp_ttl_exceeded_header) + 315 sizeof (struct icmp_ttl_exceeded_header) +
316 sizeof (struct ip_header) + 316 sizeof (struct ip_header) +
317 sizeof (struct udp_header))); 317 sizeof (struct udp_header)));
318 memcpy (&packet[sizeof (struct ip_header)], 318 memcpy (&packet[sizeof (struct ip_header)],
319 &icmp_pkt, 319 &icmp_pkt,
320 sizeof (struct icmp_ttl_exceeded_header)); 320 sizeof (struct icmp_ttl_exceeded_header));
321 321
322 memset (&dst, 0, sizeof (dst)); 322 memset (&dst, 0, sizeof (dst));
323 dst.sin_family = AF_INET; 323 dst.sin_family = AF_INET;
324 dst.sin_addr = *other; 324 dst.sin_addr = *other;
@@ -354,8 +354,8 @@ send_icmp (const struct in_addr *my_ip,
354 struct icmp_ttl_exceeded_header icmp_ttl; 354 struct icmp_ttl_exceeded_header icmp_ttl;
355 struct icmp_echo_header icmp_echo; 355 struct icmp_echo_header icmp_echo;
356 struct sockaddr_in dst; 356 struct sockaddr_in dst;
357 char packet[sizeof (struct ip_header) * 2 + 357 char packet[sizeof (struct ip_header) * 2 +
358 sizeof (struct icmp_ttl_exceeded_header) + 358 sizeof (struct icmp_ttl_exceeded_header) +
359 sizeof(struct icmp_echo_header)]; 359 sizeof(struct icmp_echo_header)];
360 size_t off; 360 size_t off;
361 int err; 361 int err;
@@ -365,11 +365,11 @@ send_icmp (const struct in_addr *my_ip,
365 ip_pkt.vers_ihl = 0x45; 365 ip_pkt.vers_ihl = 0x45;
366 ip_pkt.tos = 0; 366 ip_pkt.tos = 0;
367 ip_pkt.pkt_len = htons (sizeof (packet)); 367 ip_pkt.pkt_len = htons (sizeof (packet));
368 ip_pkt.id = htons(256); 368 ip_pkt.id = htons(256);
369 ip_pkt.flags_frag_offset = 0; 369 ip_pkt.flags_frag_offset = 0;
370 ip_pkt.ttl = IPDEFTTL; 370 ip_pkt.ttl = IPDEFTTL;
371 ip_pkt.proto = IPPROTO_ICMP; 371 ip_pkt.proto = IPPROTO_ICMP;
372 ip_pkt.checksum = 0; 372 ip_pkt.checksum = 0;
373 ip_pkt.src_ip = my_ip->s_addr; 373 ip_pkt.src_ip = my_ip->s_addr;
374 ip_pkt.dst_ip = other->s_addr; 374 ip_pkt.dst_ip = other->s_addr;
375 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, 375 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
@@ -381,7 +381,7 @@ send_icmp (const struct in_addr *my_ip,
381 381
382 /* icmp reply: time exceeded */ 382 /* icmp reply: time exceeded */
383 icmp_ttl.type = ICMP_TIME_EXCEEDED; 383 icmp_ttl.type = ICMP_TIME_EXCEEDED;
384 icmp_ttl.code = 0; 384 icmp_ttl.code = 0;
385 icmp_ttl.reserved = 0; 385 icmp_ttl.reserved = 0;
386 icmp_ttl.checksum = 0; 386 icmp_ttl.checksum = 0;
387 memcpy (&packet[off], 387 memcpy (&packet[off],
@@ -393,7 +393,7 @@ send_icmp (const struct in_addr *my_ip,
393 ip_pkt.vers_ihl = 0x45; 393 ip_pkt.vers_ihl = 0x45;
394 ip_pkt.tos = 0; 394 ip_pkt.tos = 0;
395 ip_pkt.pkt_len = (sizeof (struct ip_header) + sizeof (struct icmp_echo_header)); 395 ip_pkt.pkt_len = (sizeof (struct ip_header) + sizeof (struct icmp_echo_header));
396 ip_pkt.id = htons (256); 396 ip_pkt.id = htons (256);
397 ip_pkt.flags_frag_offset = 0; 397 ip_pkt.flags_frag_offset = 0;
398 ip_pkt.ttl = 1; /* real TTL would be 1 on a time exceeded packet */ 398 ip_pkt.ttl = 1; /* real TTL would be 1 on a time exceeded packet */
399 ip_pkt.proto = IPPROTO_ICMP; 399 ip_pkt.proto = IPPROTO_ICMP;
@@ -401,9 +401,9 @@ send_icmp (const struct in_addr *my_ip,
401 ip_pkt.dst_ip = dummy.s_addr; 401 ip_pkt.dst_ip = dummy.s_addr;
402 ip_pkt.checksum = 0; 402 ip_pkt.checksum = 0;
403 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, 403 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
404 sizeof (struct ip_header))); 404 sizeof (struct ip_header)));
405 memcpy (&packet[off], 405 memcpy (&packet[off],
406 &ip_pkt, 406 &ip_pkt,
407 sizeof (struct ip_header)); 407 sizeof (struct ip_header));
408 off += sizeof (struct ip_header); 408 off += sizeof (struct ip_header);
409 409
@@ -412,17 +412,17 @@ send_icmp (const struct in_addr *my_ip,
412 icmp_echo.reserved = 0; 412 icmp_echo.reserved = 0;
413 icmp_echo.checksum = 0; 413 icmp_echo.checksum = 0;
414 icmp_echo.data = htons(port); 414 icmp_echo.data = htons(port);
415 icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo, 415 icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
416 sizeof (struct icmp_echo_header))); 416 sizeof (struct icmp_echo_header)));
417 memcpy (&packet[off], 417 memcpy (&packet[off],
418 &icmp_echo, 418 &icmp_echo,
419 sizeof(struct icmp_echo_header)); 419 sizeof(struct icmp_echo_header));
420 420
421 /* no go back to calculate ICMP packet checksum */ 421 /* no go back to calculate ICMP packet checksum */
422 off = sizeof (struct ip_header); 422 off = sizeof (struct ip_header);
423 icmp_ttl.checksum = htons(calc_checksum((uint16_t*) &packet[off], 423 icmp_ttl.checksum = htons(calc_checksum((uint16_t*) &packet[off],
424 sizeof (struct icmp_ttl_exceeded_header) + 424 sizeof (struct icmp_ttl_exceeded_header) +
425 sizeof (struct ip_header) + 425 sizeof (struct ip_header) +
426 sizeof (struct icmp_echo_header))); 426 sizeof (struct icmp_echo_header)));
427 memcpy (&packet[off], 427 memcpy (&packet[off],
428 &icmp_ttl, 428 &icmp_ttl,
@@ -432,18 +432,18 @@ send_icmp (const struct in_addr *my_ip,
432 dst.sin_family = AF_INET; 432 dst.sin_family = AF_INET;
433 dst.sin_addr = *other; 433 dst.sin_addr = *other;
434 434
435 err = sendto(rawsock, 435 err = sendto(rawsock,
436 packet, 436 packet,
437 sizeof (packet), 0, 437 sizeof (packet), 0,
438 (struct sockaddr*)&dst, 438 (struct sockaddr*)&dst,
439 sizeof(dst)); 439 sizeof(dst));
440 440
441 if (err < 0) 441 if (err < 0)
442 { 442 {
443 fprintf(stderr, 443 fprintf(stderr,
444 "sendto failed: %s\n", strerror(errno)); 444 "sendto failed: %s\n", strerror(errno));
445 } 445 }
446 else if (sizeof (packet) != (size_t) err) 446 else if (sizeof (packet) != (size_t) err)
447 { 447 {
448 fprintf(stderr, 448 fprintf(stderr,
449 "Error: partial send of ICMP message\n"); 449 "Error: partial send of ICMP message\n");
@@ -470,10 +470,10 @@ make_raw_socket ()
470 "Error opening RAW socket: %s\n", 470 "Error opening RAW socket: %s\n",
471 strerror (errno)); 471 strerror (errno));
472 return INVALID_SOCKET; 472 return INVALID_SOCKET;
473 } 473 }
474 if (0 != setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, bOptLen)) 474 if (0 != setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, bOptLen))
475 { 475 {
476 fprintf(stderr, 476 fprintf(stderr,
477 "Error setting SO_BROADCAST to ON: %s\n", 477 "Error setting SO_BROADCAST to ON: %s\n",
478 strerror (errno)); 478 strerror (errno));
479 closesocket(rawsock); 479 closesocket(rawsock);
@@ -482,7 +482,7 @@ make_raw_socket ()
482 482
483 if (0 != setsockopt(ret, IPPROTO_IP, IP_HDRINCL, (char*)&bOptVal, bOptLen)) 483 if (0 != setsockopt(ret, IPPROTO_IP, IP_HDRINCL, (char*)&bOptVal, bOptLen))
484 { 484 {
485 fprintf(stderr, 485 fprintf(stderr,
486 "Error setting IP_HDRINCL to ON: %s\n", 486 "Error setting IP_HDRINCL to ON: %s\n",
487 strerror (errno)); 487 strerror (errno));
488 closesocket(rawsock); 488 closesocket(rawsock);
@@ -531,7 +531,7 @@ main (int argc, char *const *argv)
531 fprintf (stderr, "Failed to find Winsock 2.1 or better.\n"); 531 fprintf (stderr, "Failed to find Winsock 2.1 or better.\n");
532 return 2; 532 return 2;
533 } 533 }
534 if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy)) 534 if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
535 { 535 {
536 fprintf (stderr, 536 fprintf (stderr,
537 "Internal error converting dummy IP to binary.\n"); 537 "Internal error converting dummy IP to binary.\n");
diff --git a/src/transport/gnunet-nat-server-windows.c b/src/transport/gnunet-nat-server-windows.c
index 11c63aa9d..f882641e9 100644
--- a/src/transport/gnunet-nat-server-windows.c
+++ b/src/transport/gnunet-nat-server-windows.c
@@ -82,64 +82,64 @@
82/** 82/**
83 * IPv4 header. 83 * IPv4 header.
84 */ 84 */
85struct ip_header 85struct ip_header
86{ 86{
87 87
88 /** 88 /**
89 * Version (4 bits) + Internet header length (4 bits) 89 * Version (4 bits) + Internet header length (4 bits)
90 */ 90 */
91 uint8_t vers_ihl; 91 uint8_t vers_ihl;
92 92
93 /** 93 /**
94 * Type of service 94 * Type of service
95 */ 95 */
96 uint8_t tos; 96 uint8_t tos;
97 97
98 /** 98 /**
99 * Total length 99 * Total length
100 */ 100 */
101 uint16_t pkt_len; 101 uint16_t pkt_len;
102 102
103 /** 103 /**
104 * Identification 104 * Identification
105 */ 105 */
106 uint16_t id; 106 uint16_t id;
107 107
108 /** 108 /**
109 * Flags (3 bits) + Fragment offset (13 bits) 109 * Flags (3 bits) + Fragment offset (13 bits)
110 */ 110 */
111 uint16_t flags_frag_offset; 111 uint16_t flags_frag_offset;
112 112
113 /** 113 /**
114 * Time to live 114 * Time to live
115 */ 115 */
116 uint8_t ttl; 116 uint8_t ttl;
117 117
118 /** 118 /**
119 * Protocol 119 * Protocol
120 */ 120 */
121 uint8_t proto; 121 uint8_t proto;
122 122
123 /** 123 /**
124 * Header checksum 124 * Header checksum
125 */ 125 */
126 uint16_t checksum; 126 uint16_t checksum;
127 127
128 /** 128 /**
129 * Source address 129 * Source address
130 */ 130 */
131 uint32_t src_ip; 131 uint32_t src_ip;
132 132
133 /** 133 /**
134 * Destination address 134 * Destination address
135 */ 135 */
136 uint32_t dst_ip; 136 uint32_t dst_ip;
137}; 137};
138 138
139/** 139/**
140 * Format of ICMP packet. 140 * Format of ICMP packet.
141 */ 141 */
142struct icmp_ttl_exceeded_header 142struct icmp_ttl_exceeded_header
143{ 143{
144 uint8_t type; 144 uint8_t type;
145 145
@@ -205,16 +205,16 @@ static struct in_addr dummy;
205 * @param bytes number of bytes in data (must be multiple of 2) 205 * @param bytes number of bytes in data (must be multiple of 2)
206 * @return the CRC 16. 206 * @return the CRC 16.
207 */ 207 */
208static uint16_t 208static uint16_t
209calc_checksum(const uint16_t *data, 209calc_checksum(const uint16_t *data,
210 unsigned int bytes) 210 unsigned int bytes)
211{ 211{
212 uint32_t sum; 212 uint32_t sum;
213 unsigned int i; 213 unsigned int i;
214 214
215 sum = 0; 215 sum = 0;
216 for (i=0;i<bytes/2;i++) 216 for (i=0;i<bytes/2;i++)
217 sum += data[i]; 217 sum += data[i];
218 sum = (sum & 0xffff) + (sum >> 16); 218 sum = (sum & 0xffff) + (sum >> 16);
219 sum = htons(0xffff - sum); 219 sum = htons(0xffff - sum);
220 return sum; 220 return sum;
@@ -229,17 +229,17 @@ calc_checksum(const uint16_t *data,
229 * @param buf where to write the address result 229 * @param buf where to write the address result
230 * @return 1 on success 230 * @return 1 on success
231 */ 231 */
232static int 232static int
233inet_pton (int af, 233inet_pton (int af,
234 const char *cp, 234 const char *cp,
235 struct in_addr *buf) 235 struct in_addr *buf)
236{ 236{
237 buf->s_addr = inet_addr(cp); 237 buf->s_addr = inet_addr(cp);
238 if (buf->s_addr == INADDR_NONE) 238 if (buf->s_addr == INADDR_NONE)
239 { 239 {
240 fprintf(stderr, 240 fprintf(stderr,
241 "Error %d handling address %s", 241 "Error %d handling address %s",
242 WSAGetLastError(), 242 WSAGetLastError(),
243 cp); 243 cp);
244 return 0; 244 return 0;
245 } 245 }
@@ -275,8 +275,8 @@ send_icmp_echo (const struct in_addr *my_ip)
275 ip_pkt.dst_ip = dummy.s_addr; 275 ip_pkt.dst_ip = dummy.s_addr;
276 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, 276 ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
277 sizeof (struct ip_header))); 277 sizeof (struct ip_header)));
278 memcpy (&packet[off], 278 memcpy (&packet[off],
279 &ip_pkt, 279 &ip_pkt,
280 sizeof (struct ip_header)); 280 sizeof (struct ip_header));
281 off += sizeof (struct ip_header); 281 off += sizeof (struct ip_header);
282 282
@@ -284,28 +284,28 @@ send_icmp_echo (const struct in_addr *my_ip)
284 icmp_echo.code = 0; 284 icmp_echo.code = 0;
285 icmp_echo.reserved = 0; 285 icmp_echo.reserved = 0;
286 icmp_echo.checksum = 0; 286 icmp_echo.checksum = 0;
287 icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo, 287 icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
288 sizeof (struct icmp_echo_header))); 288 sizeof (struct icmp_echo_header)));
289 memcpy (&packet[off], 289 memcpy (&packet[off],
290 &icmp_echo, 290 &icmp_echo,
291 sizeof (struct icmp_echo_header)); 291 sizeof (struct icmp_echo_header));
292 off += sizeof (struct icmp_echo_header); 292 off += sizeof (struct icmp_echo_header);
293 293
294 memset (&dst, 0, sizeof (dst)); 294 memset (&dst, 0, sizeof (dst));
295 dst.sin_family = AF_INET; 295 dst.sin_family = AF_INET;
296 dst.sin_addr = dummy; 296 dst.sin_addr = dummy;
297 err = sendto(rawsock, 297 err = sendto(rawsock,
298 packet, off, 0, 298 packet, off, 0,
299 (struct sockaddr*)&dst, 299 (struct sockaddr*)&dst,
300 sizeof(dst)); 300 sizeof(dst));
301 if (err < 0) 301 if (err < 0)
302 { 302 {
303#if VERBOSE 303#if VERBOSE
304 fprintf(stderr, 304 fprintf(stderr,
305 "sendto failed: %s\n", strerror(errno)); 305 "sendto failed: %s\n", strerror(errno));
306#endif 306#endif
307 } 307 }
308 else if (err != off) 308 else if (err != off)
309 { 309 {
310 fprintf(stderr, 310 fprintf(stderr,
311 "Error: partial send of ICMP message\n"); 311 "Error: partial send of ICMP message\n");
@@ -321,23 +321,23 @@ send_udp ()
321{ 321{
322 struct sockaddr_in dst; 322 struct sockaddr_in dst;
323 ssize_t err; 323 ssize_t err;
324 324
325 memset (&dst, 0, sizeof (dst)); 325 memset (&dst, 0, sizeof (dst));
326 dst.sin_family = AF_INET; 326 dst.sin_family = AF_INET;
327 dst.sin_addr = dummy; 327 dst.sin_addr = dummy;
328 dst.sin_port = htons (NAT_TRAV_PORT); 328 dst.sin_port = htons (NAT_TRAV_PORT);
329 err = sendto(udpsock, 329 err = sendto(udpsock,
330 NULL, 0, 0, 330 NULL, 0, 0,
331 (struct sockaddr*)&dst, 331 (struct sockaddr*)&dst,
332 sizeof(dst)); 332 sizeof(dst));
333 if (err < 0) 333 if (err < 0)
334 { 334 {
335#if VERBOSE 335#if VERBOSE
336 fprintf(stderr, 336 fprintf(stderr,
337 "sendto failed: %s\n", strerror(errno)); 337 "sendto failed: %s\n", strerror(errno));
338#endif 338#endif
339 } 339 }
340 else if (0 != err) 340 else if (0 != err)
341 { 341 {
342 fprintf(stderr, 342 fprintf(stderr,
343 "Error: partial send of ICMP message\n"); 343 "Error: partial send of ICMP message\n");
@@ -368,7 +368,7 @@ process_icmp_response ()
368 fprintf (stderr, 368 fprintf (stderr,
369 "Error reading raw socket: %s\n", 369 "Error reading raw socket: %s\n",
370 strerror (errno)); 370 strerror (errno));
371 return; 371 return;
372 } 372 }
373 have_port = 0; 373 have_port = 0;
374#if VERBOSE 374#if VERBOSE
@@ -383,17 +383,17 @@ process_icmp_response ()
383 } 383 }
384 off = 0; 384 off = 0;
385 memcpy (&ip_pkt, 385 memcpy (&ip_pkt,
386 &buf[off], 386 &buf[off],
387 sizeof (struct ip_header)); 387 sizeof (struct ip_header));
388 off += sizeof (struct ip_header); 388 off += sizeof (struct ip_header);
389 memcpy(&source_ip, 389 memcpy(&source_ip,
390 &ip_pkt.src_ip, 390 &ip_pkt.src_ip,
391 sizeof (source_ip)); 391 sizeof (source_ip));
392 memcpy (&icmp_ttl, 392 memcpy (&icmp_ttl,
393 &buf[off], 393 &buf[off],
394 sizeof (struct icmp_ttl_exceeded_header)); 394 sizeof (struct icmp_ttl_exceeded_header));
395 off += sizeof (struct icmp_ttl_exceeded_header); 395 off += sizeof (struct icmp_ttl_exceeded_header);
396 if ( (ICMP_TIME_EXCEEDED != icmp_ttl.type) || 396 if ( (ICMP_TIME_EXCEEDED != icmp_ttl.type) ||
397 (0 != icmp_ttl.code) ) 397 (0 != icmp_ttl.code) )
398 { 398 {
399 /* different type than what we want */ 399 /* different type than what we want */
@@ -401,15 +401,15 @@ process_icmp_response ()
401 } 401 }
402 /* skip 2nd IP header */ 402 /* skip 2nd IP header */
403 memcpy (&ip_pkt, 403 memcpy (&ip_pkt,
404 &buf[off], 404 &buf[off],
405 sizeof (struct ip_header)); 405 sizeof (struct ip_header));
406 off += sizeof (struct ip_header); 406 off += sizeof (struct ip_header);
407 407
408 switch (ip_pkt.proto) 408 switch (ip_pkt.proto)
409 { 409 {
410 case IPPROTO_ICMP: 410 case IPPROTO_ICMP:
411 if (have != (sizeof (struct ip_header) * 2 + 411 if (have != (sizeof (struct ip_header) * 2 +
412 sizeof (struct icmp_ttl_exceeded_header) + 412 sizeof (struct icmp_ttl_exceeded_header) +
413 sizeof (struct icmp_echo_header)) ) 413 sizeof (struct icmp_echo_header)) )
414 { 414 {
415 /* malformed */ 415 /* malformed */
@@ -422,8 +422,8 @@ process_icmp_response ()
422 port = (uint16_t) ntohl (icmp_echo.reserved); 422 port = (uint16_t) ntohl (icmp_echo.reserved);
423 break; 423 break;
424 case IPPROTO_UDP: 424 case IPPROTO_UDP:
425 if (have != (sizeof (struct ip_header) * 2 + 425 if (have != (sizeof (struct ip_header) * 2 +
426 sizeof (struct icmp_ttl_exceeded_header) + 426 sizeof (struct icmp_ttl_exceeded_header) +
427 sizeof (struct udp_header)) ) 427 sizeof (struct udp_header)) )
428 { 428 {
429 /* malformed */ 429 /* malformed */
@@ -435,16 +435,16 @@ process_icmp_response ()
435 sizeof (struct udp_header)); 435 sizeof (struct udp_header));
436 port = ntohs (udp_pkt.length); 436 port = ntohs (udp_pkt.length);
437 break; 437 break;
438 default: 438 default:
439 /* different type than what we want */ 439 /* different type than what we want */
440 return; 440 return;
441 } 441 }
442 442
443 ssize = sizeof(buf); 443 ssize = sizeof(buf);
444 WSAAddressToString((LPSOCKADDR)&source_ip, 444 WSAAddressToString((LPSOCKADDR)&source_ip,
445 sizeof(source_ip), 445 sizeof(source_ip),
446 NULL, 446 NULL,
447 buf, 447 buf,
448 &ssize); 448 &ssize);
449 if (port == 0) 449 if (port == 0)
450 fprintf (stdout, 450 fprintf (stdout,
@@ -476,7 +476,7 @@ make_icmp_socket ()
476 "Error opening RAW socket: %s\n", 476 "Error opening RAW socket: %s\n",
477 strerror (errno)); 477 strerror (errno));
478 return INVALID_SOCKET; 478 return INVALID_SOCKET;
479 } 479 }
480 return ret; 480 return ret;
481} 481}
482 482
@@ -501,23 +501,23 @@ make_raw_socket ()
501 return INVALID_SOCKET; 501 return INVALID_SOCKET;
502 } 502 }
503 503
504 if (0 != setsockopt(rawsock, 504 if (0 != setsockopt(rawsock,
505 SOL_SOCKET, 505 SOL_SOCKET,
506 SO_BROADCAST, 506 SO_BROADCAST,
507 (char*)&bOptVal, bOptLen)) 507 (char*)&bOptVal, bOptLen))
508 { 508 {
509 fprintf(stderr, 509 fprintf(stderr,
510 "Error setting SO_BROADCAST to ON: %s\n", 510 "Error setting SO_BROADCAST to ON: %s\n",
511 strerror (errno)); 511 strerror (errno));
512 closesocket(rawsock); 512 closesocket(rawsock);
513 return INVALID_SOCKET; 513 return INVALID_SOCKET;
514 } 514 }
515 if (0 != setsockopt(rawsock, 515 if (0 != setsockopt(rawsock,
516 IPPROTO_IP, 516 IPPROTO_IP,
517 IP_HDRINCL, 517 IP_HDRINCL,
518 (char*)&bOptVal, bOptLen)) 518 (char*)&bOptVal, bOptLen))
519 { 519 {
520 fprintf(stderr, 520 fprintf(stderr,
521 "Error setting IP_HDRINCL to ON: %s\n", 521 "Error setting IP_HDRINCL to ON: %s\n",
522 strerror (errno)); 522 strerror (errno));
523 closesocket(rawsock); 523 closesocket(rawsock);
@@ -566,7 +566,7 @@ make_udp_socket (const struct in_addr *my_ip)
566 566
567 567
568int 568int
569main (int argc, 569main (int argc,
570 char *const *argv) 570 char *const *argv)
571{ 571{
572 struct in_addr external; 572 struct in_addr external;
@@ -588,7 +588,7 @@ main (int argc,
588 argv[1], strerror (errno)); 588 argv[1], strerror (errno));
589 return 1; 589 return 1;
590 } 590 }
591 if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy)) 591 if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
592 { 592 {
593 fprintf (stderr, 593 fprintf (stderr,
594 "Internal error converting dummy IP to binary.\n"); 594 "Internal error converting dummy IP to binary.\n");
@@ -601,25 +601,25 @@ main (int argc,
601 } 601 }
602 if (INVALID_SOCKET == (icmpsock = make_icmp_socket())) 602 if (INVALID_SOCKET == (icmpsock = make_icmp_socket()))
603 { 603 {
604 return 3; 604 return 3;
605 } 605 }
606 if (INVALID_SOCKET == (make_raw_socket())) 606 if (INVALID_SOCKET == (make_raw_socket()))
607 { 607 {
608 closesocket (icmpsock); 608 closesocket (icmpsock);
609 return 3; 609 return 3;
610 } 610 }
611 if (INVALID_SOCKET == (udpsock = make_udp_socket(&external))) 611 if (INVALID_SOCKET == (udpsock = make_udp_socket(&external)))
612 { 612 {
613 closesocket (icmpsock); 613 closesocket (icmpsock);
614 closesocket (rawsock); 614 closesocket (rawsock);
615 return 3; 615 return 3;
616 } 616 }
617 while (1) 617 while (1)
618 { 618 {
619 FD_ZERO (&rs); 619 FD_ZERO (&rs);
620 FD_SET (icmpsock, &rs); 620 FD_SET (icmpsock, &rs);
621 tv.tv_sec = 0; 621 tv.tv_sec = 0;
622 tv.tv_usec = ICMP_SEND_FREQUENCY_MS * 1000; 622 tv.tv_usec = ICMP_SEND_FREQUENCY_MS * 1000;
623 if (-1 == select (icmpsock + 1, &rs, NULL, NULL, &tv)) 623 if (-1 == select (icmpsock + 1, &rs, NULL, NULL, &tv))
624 { 624 {
625 if (errno == EINTR) 625 if (errno == EINTR)
@@ -641,7 +641,7 @@ main (int argc,
641 closesocket(rawsock); 641 closesocket(rawsock);
642 closesocket(udpsock); 642 closesocket(udpsock);
643 WSACleanup (); 643 WSACleanup ();
644 return 4; 644 return 4;
645} 645}
646 646
647 647
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index ae88b4f6f..de25666fa 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -78,8 +78,8 @@
78#define MAX_CONNECT_RETRY 3 78#define MAX_CONNECT_RETRY 3
79 79
80/** 80/**
81 * Limit on the number of ready-to-run tasks when validating 81 * Limit on the number of ready-to-run tasks when validating
82 * HELLOs. If more tasks are ready to run, we will drop 82 * HELLOs. If more tasks are ready to run, we will drop
83 * HELLOs instead of validating them. 83 * HELLOs instead of validating them.
84 */ 84 */
85#define MAX_HELLO_LOAD 4 85#define MAX_HELLO_LOAD 4
@@ -206,7 +206,7 @@ struct ForeignAddressList
206 unsigned int connect_attempts; 206 unsigned int connect_attempts;
207 207
208 /** 208 /**
209 * DV distance to this peer (1 if no DV is used). 209 * DV distance to this peer (1 if no DV is used).
210 * FIXME: need to set this from transport plugins! 210 * FIXME: need to set this from transport plugins!
211 */ 211 */
212 uint32_t distance; 212 uint32_t distance;
@@ -228,7 +228,7 @@ struct ForeignAddressList
228 * successfully transmit or receive data to a peer via a particular 228 * successfully transmit or receive data to a peer via a particular
229 * address, we set this to GNUNET_YES. If we later get an error 229 * address, we set this to GNUNET_YES. If we later get an error
230 * (disconnect notification, transmission failure, timeout), we set 230 * (disconnect notification, transmission failure, timeout), we set
231 * it back to GNUNET_NO. 231 * it back to GNUNET_NO.
232 */ 232 */
233 int8_t connected; 233 int8_t connected;
234 234
@@ -479,7 +479,7 @@ struct NeighbourList
479 * Buffer for at most one payload message used when we receive 479 * Buffer for at most one payload message used when we receive
480 * payload data before our PING-PONG has succeeded. We then 480 * payload data before our PING-PONG has succeeded. We then
481 * store such messages in this intermediary buffer until the 481 * store such messages in this intermediary buffer until the
482 * connection is fully up. 482 * connection is fully up.
483 */ 483 */
484 struct GNUNET_MessageHeader *pre_connect_message_buffer; 484 struct GNUNET_MessageHeader *pre_connect_message_buffer;
485 485
@@ -547,7 +547,7 @@ struct NeighbourList
547 unsigned int quota_violation_count; 547 unsigned int quota_violation_count;
548 548
549 /** 549 /**
550 * DV distance to this peer (1 if no DV is used). 550 * DV distance to this peer (1 if no DV is used).
551 */ 551 */
552 uint32_t distance; 552 uint32_t distance;
553 553
@@ -643,7 +643,7 @@ struct TransportPongMessage
643 643
644 /** 644 /**
645 * Size of address appended to this message (part of what is 645 * Size of address appended to this message (part of what is
646 * being signed, hence not redundant). 646 * being signed, hence not redundant).
647 */ 647 */
648 uint32_t addrlen; 648 uint32_t addrlen;
649 649
@@ -698,7 +698,7 @@ struct TransportClient
698 698
699 /** 699 /**
700 * Current transmit request handle. 700 * Current transmit request handle.
701 */ 701 */
702 struct GNUNET_CONNECTION_TransmitHandle *th; 702 struct GNUNET_CONNECTION_TransmitHandle *th;
703 703
704 /** 704 /**
@@ -807,7 +807,7 @@ struct CheckHelloValidatedContext
807 * NULL after we are done processing peerinfo's information. 807 * NULL after we are done processing peerinfo's information.
808 */ 808 */
809 struct GNUNET_PEERINFO_IteratorContext *piter; 809 struct GNUNET_PEERINFO_IteratorContext *piter;
810 810
811 /** 811 /**
812 * Was a HELLO known for this peer to peerinfo? 812 * Was a HELLO known for this peer to peerinfo?
813 */ 813 */
@@ -924,7 +924,7 @@ static void try_transmission_to_peer (struct NeighbourList *neighbour);
924 924
925/** 925/**
926 * Find an entry in the neighbour list for a particular peer. 926 * Find an entry in the neighbour list for a particular peer.
927 * 927 *
928 * @return NULL if not found. 928 * @return NULL if not found.
929 */ 929 */
930static struct NeighbourList * 930static struct NeighbourList *
@@ -990,11 +990,11 @@ add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, char *transport_name)
990 plugin = find_transport(transport_name); 990 plugin = find_transport(transport_name);
991 if (plugin == NULL) /* Nothing to do */ 991 if (plugin == NULL) /* Nothing to do */
992 return; 992 return;
993 if (plugin->blacklist == NULL) 993 if (plugin->blacklist == NULL)
994 plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE); 994 plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE);
995 GNUNET_assert(plugin->blacklist != NULL); 995 GNUNET_assert(plugin->blacklist != NULL);
996 GNUNET_CONTAINER_multihashmap_put(plugin->blacklist, &peer->hashPubKey, 996 GNUNET_CONTAINER_multihashmap_put(plugin->blacklist, &peer->hashPubKey,
997 NULL, 997 NULL,
998 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 998 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
999} 999}
1000 1000
@@ -1196,7 +1196,7 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
1196 GNUNET_STATISTICS_update (stats, 1196 GNUNET_STATISTICS_update (stats,
1197 gettext_noop ("# bytes discarded (could not transmit to client)"), 1197 gettext_noop ("# bytes discarded (could not transmit to client)"),
1198 ntohs (((const struct GNUNET_MessageHeader*)&q[1])->size), 1198 ntohs (((const struct GNUNET_MessageHeader*)&q[1])->size),
1199 GNUNET_NO); 1199 GNUNET_NO);
1200 GNUNET_CONTAINER_DLL_remove (client->message_queue_head, 1200 GNUNET_CONTAINER_DLL_remove (client->message_queue_head,
1201 client->message_queue_tail, 1201 client->message_queue_tail,
1202 q); 1202 q);
@@ -1263,7 +1263,7 @@ a2s (const char *plugin,
1263 return p->api->address_to_string (p->api->cls, 1263 return p->api->address_to_string (p->api->cls,
1264 addr, 1264 addr,
1265 addr_len); 1265 addr_len);
1266} 1266}
1267 1267
1268 1268
1269/** 1269/**
@@ -1340,7 +1340,7 @@ transmit_to_client (struct TransportClient *client,
1340 ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), 1340 ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"),
1341 ntohs (msg->type), 1341 ntohs (msg->type),
1342 ntohs (msg->size), 1342 ntohs (msg->size),
1343 client->message_count, 1343 client->message_count,
1344 MAX_PENDING); 1344 MAX_PENDING);
1345 GNUNET_STATISTICS_update (stats, 1345 GNUNET_STATISTICS_update (stats,
1346 gettext_noop ("# messages dropped due to slow client"), 1346 gettext_noop ("# messages dropped due to slow client"),
@@ -1355,7 +1355,7 @@ transmit_to_client (struct TransportClient *client,
1355 GNUNET_CONTAINER_DLL_insert_after (client->message_queue_head, 1355 GNUNET_CONTAINER_DLL_insert_after (client->message_queue_head,
1356 client->message_queue_tail, 1356 client->message_queue_tail,
1357 client->message_queue_tail, 1357 client->message_queue_tail,
1358 q); 1358 q);
1359 client->message_count++; 1359 client->message_count++;
1360 if (client->th == NULL) 1360 if (client->th == NULL)
1361 { 1361 {
@@ -1389,7 +1389,7 @@ transmit_send_ok (struct TransportClient *client,
1389 send_ok_msg.success = htonl (result); 1389 send_ok_msg.success = htonl (result);
1390 send_ok_msg.latency = GNUNET_TIME_relative_hton (n->latency); 1390 send_ok_msg.latency = GNUNET_TIME_relative_hton (n->latency);
1391 send_ok_msg.peer = n->id; 1391 send_ok_msg.peer = n->id;
1392 transmit_to_client (client, &send_ok_msg.header, GNUNET_NO); 1392 transmit_to_client (client, &send_ok_msg.header, GNUNET_NO);
1393} 1393}
1394 1394
1395 1395
@@ -1414,7 +1414,7 @@ transmit_send_continuation (void *cls,
1414{ 1414{
1415 struct MessageQueue *mq = cls; 1415 struct MessageQueue *mq = cls;
1416 struct NeighbourList *n; 1416 struct NeighbourList *n;
1417 1417
1418 GNUNET_STATISTICS_update (stats, 1418 GNUNET_STATISTICS_update (stats,
1419 gettext_noop ("# bytes pending with plugins"), 1419 gettext_noop ("# bytes pending with plugins"),
1420 - (int64_t) mq->message_buf_size, 1420 - (int64_t) mq->message_buf_size,
@@ -1424,27 +1424,27 @@ transmit_send_continuation (void *cls,
1424 GNUNET_STATISTICS_update (stats, 1424 GNUNET_STATISTICS_update (stats,
1425 gettext_noop ("# bytes successfully transmitted by plugins"), 1425 gettext_noop ("# bytes successfully transmitted by plugins"),
1426 mq->message_buf_size, 1426 mq->message_buf_size,
1427 GNUNET_NO); 1427 GNUNET_NO);
1428 } 1428 }
1429 else 1429 else
1430 { 1430 {
1431 GNUNET_STATISTICS_update (stats, 1431 GNUNET_STATISTICS_update (stats,
1432 gettext_noop ("# bytes with transmission failure by plugins"), 1432 gettext_noop ("# bytes with transmission failure by plugins"),
1433 mq->message_buf_size, 1433 mq->message_buf_size,
1434 GNUNET_NO); 1434 GNUNET_NO);
1435 } 1435 }
1436 n = find_neighbour(&mq->neighbour_id); 1436 n = find_neighbour(&mq->neighbour_id);
1437 GNUNET_assert (n != NULL); 1437 GNUNET_assert (n != NULL);
1438 if (mq->specific_address != NULL) 1438 if (mq->specific_address != NULL)
1439 { 1439 {
1440 if (result == GNUNET_OK) 1440 if (result == GNUNET_OK)
1441 { 1441 {
1442 mq->specific_address->timeout = 1442 mq->specific_address->timeout =
1443 GNUNET_TIME_relative_to_absolute 1443 GNUNET_TIME_relative_to_absolute
1444 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1444 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
1445 if (mq->specific_address->validated == GNUNET_YES) 1445 if (mq->specific_address->validated == GNUNET_YES)
1446 mark_address_connected (mq->specific_address); 1446 mark_address_connected (mq->specific_address);
1447 } 1447 }
1448 else 1448 else
1449 { 1449 {
1450 if (mq->specific_address->connected != GNUNET_NO) 1450 if (mq->specific_address->connected != GNUNET_NO)
@@ -1462,8 +1462,8 @@ transmit_send_continuation (void *cls,
1462 GNUNET_NO); 1462 GNUNET_NO);
1463 mq->specific_address->connected = GNUNET_NO; 1463 mq->specific_address->connected = GNUNET_NO;
1464 } 1464 }
1465 } 1465 }
1466 if (! mq->internal_msg) 1466 if (! mq->internal_msg)
1467 mq->specific_address->in_transmit = GNUNET_NO; 1467 mq->specific_address->in_transmit = GNUNET_NO;
1468 } 1468 }
1469 if (mq->client != NULL) 1469 if (mq->client != NULL)
@@ -1496,7 +1496,7 @@ find_ready_address(struct NeighbourList *neighbour)
1496 addresses = head->addresses; 1496 addresses = head->addresses;
1497 while (addresses != NULL) 1497 while (addresses != NULL)
1498 { 1498 {
1499 if ( (addresses->timeout.value < now.value) && 1499 if ( (addresses->timeout.value < now.value) &&
1500 (addresses->connected == GNUNET_YES) ) 1500 (addresses->connected == GNUNET_YES) )
1501 { 1501 {
1502#if DEBUG_TRANSPORT 1502#if DEBUG_TRANSPORT
@@ -1531,13 +1531,13 @@ find_ready_address(struct NeighbourList *neighbour)
1531 (unsigned long long) addresses->timeout.value, 1531 (unsigned long long) addresses->timeout.value,
1532 (unsigned int) addresses->distance); 1532 (unsigned int) addresses->distance);
1533#endif 1533#endif
1534 if ( ( (best_address == NULL) || 1534 if ( ( (best_address == NULL) ||
1535 (addresses->connected == GNUNET_YES) || 1535 (addresses->connected == GNUNET_YES) ||
1536 (best_address->connected == GNUNET_NO) ) && 1536 (best_address->connected == GNUNET_NO) ) &&
1537 (addresses->in_transmit == GNUNET_NO) && 1537 (addresses->in_transmit == GNUNET_NO) &&
1538 ( (best_address == NULL) || 1538 ( (best_address == NULL) ||
1539 (addresses->latency.value < best_address->latency.value)) ) 1539 (addresses->latency.value < best_address->latency.value)) )
1540 best_address = addresses; 1540 best_address = addresses;
1541 /* FIXME: also give lower-latency addresses that are not 1541 /* FIXME: also give lower-latency addresses that are not
1542 connected a chance some times... */ 1542 connected a chance some times... */
1543 addresses = addresses->next; 1543 addresses = addresses->next;
@@ -1549,7 +1549,7 @@ find_ready_address(struct NeighbourList *neighbour)
1549#if DEBUG_TRANSPORT 1549#if DEBUG_TRANSPORT
1550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1551 "Best address found (`%s') has latency of %llu ms.\n", 1551 "Best address found (`%s') has latency of %llu ms.\n",
1552 (best_address->addrlen > 0) 1552 (best_address->addrlen > 0)
1553 ? a2s (best_address->ready_list->plugin->short_name, 1553 ? a2s (best_address->ready_list->plugin->short_name,
1554 best_address->addr, 1554 best_address->addr,
1555 best_address->addrlen) 1555 best_address->addrlen)
@@ -1613,11 +1613,11 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1613 force_address = GNUNET_YES; 1613 force_address = GNUNET_YES;
1614 if (mq->specific_address == NULL) 1614 if (mq->specific_address == NULL)
1615 { 1615 {
1616 mq->specific_address = find_ready_address(neighbour); 1616 mq->specific_address = find_ready_address(neighbour);
1617 GNUNET_STATISTICS_update (stats, 1617 GNUNET_STATISTICS_update (stats,
1618 gettext_noop ("# transport selected peer address freely"), 1618 gettext_noop ("# transport selected peer address freely"),
1619 1, 1619 1,
1620 GNUNET_NO); 1620 GNUNET_NO);
1621 force_address = GNUNET_NO; 1621 force_address = GNUNET_NO;
1622 } 1622 }
1623 if (mq->specific_address == NULL) 1623 if (mq->specific_address == NULL)
@@ -1625,7 +1625,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1625 GNUNET_STATISTICS_update (stats, 1625 GNUNET_STATISTICS_update (stats,
1626 gettext_noop ("# transport failed to selected peer address"), 1626 gettext_noop ("# transport failed to selected peer address"),
1627 1, 1627 1,
1628 GNUNET_NO); 1628 GNUNET_NO);
1629 timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout); 1629 timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout);
1630 if (timeout.value == 0) 1630 if (timeout.value == 0)
1631 { 1631 {
@@ -1642,14 +1642,14 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1642 GNUNET_STATISTICS_update (stats, 1642 GNUNET_STATISTICS_update (stats,
1643 gettext_noop ("# bytes discarded (no destination address available)"), 1643 gettext_noop ("# bytes discarded (no destination address available)"),
1644 mq->message_buf_size, 1644 mq->message_buf_size,
1645 GNUNET_NO); 1645 GNUNET_NO);
1646 if (mq->client != NULL) 1646 if (mq->client != NULL)
1647 transmit_send_ok (mq->client, neighbour, GNUNET_NO); 1647 transmit_send_ok (mq->client, neighbour, GNUNET_NO);
1648 GNUNET_CONTAINER_DLL_remove (neighbour->messages_head, 1648 GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
1649 neighbour->messages_tail, 1649 neighbour->messages_tail,
1650 mq); 1650 mq);
1651 GNUNET_free (mq); 1651 GNUNET_free (mq);
1652 return; /* nobody ready */ 1652 return; /* nobody ready */
1653 } 1653 }
1654 GNUNET_STATISTICS_update (stats, 1654 GNUNET_STATISTICS_update (stats,
1655 gettext_noop ("# message delivery deferred (no address)"), 1655 gettext_noop ("# message delivery deferred (no address)"),
@@ -1671,7 +1671,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1671#endif 1671#endif
1672 /* FIXME: might want to trigger peerinfo lookup here 1672 /* FIXME: might want to trigger peerinfo lookup here
1673 (unless that's already pending...) */ 1673 (unless that's already pending...) */
1674 return; 1674 return;
1675 } 1675 }
1676 GNUNET_CONTAINER_DLL_remove (neighbour->messages_head, 1676 GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
1677 neighbour->messages_tail, 1677 neighbour->messages_tail,
@@ -1686,7 +1686,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1687 "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", 1687 "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n",
1688 mq->message_buf_size, 1688 mq->message_buf_size,
1689 GNUNET_i2s (&neighbour->id), 1689 GNUNET_i2s (&neighbour->id),
1690 (mq->specific_address->addr != NULL) 1690 (mq->specific_address->addr != NULL)
1691 ? a2s (mq->plugin->short_name, 1691 ? a2s (mq->plugin->short_name,
1692 mq->specific_address->addr, 1692 mq->specific_address->addr,
@@ -1717,7 +1717,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1717 { 1717 {
1718 /* failure, but 'send' would not call continuation in this case, 1718 /* failure, but 'send' would not call continuation in this case,
1719 so we need to do it here! */ 1719 so we need to do it here! */
1720 transmit_send_continuation (mq, 1720 transmit_send_continuation (mq,
1721 &mq->neighbour_id, 1721 &mq->neighbour_id,
1722 GNUNET_SYSERR); 1722 GNUNET_SYSERR);
1723 } 1723 }
@@ -1781,7 +1781,7 @@ transmit_to_peer (struct TransportClient *client,
1781 mq->internal_msg = is_internal; 1781 mq->internal_msg = is_internal;
1782 mq->priority = priority; 1782 mq->priority = priority;
1783 mq->timeout = GNUNET_TIME_relative_to_absolute (timeout); 1783 mq->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1784 if (is_internal) 1784 if (is_internal)
1785 GNUNET_CONTAINER_DLL_insert (neighbour->messages_head, 1785 GNUNET_CONTAINER_DLL_insert (neighbour->messages_head,
1786 neighbour->messages_tail, 1786 neighbour->messages_tail,
1787 mq); 1787 mq);
@@ -1883,7 +1883,7 @@ refresh_hello ()
1883 GNUNET_NO); 1883 GNUNET_NO);
1884 transmit_to_peer (NULL, NULL, 0, 1884 transmit_to_peer (NULL, NULL, 0,
1885 HELLO_ADDRESS_EXPIRATION, 1885 HELLO_ADDRESS_EXPIRATION,
1886 (const char *) our_hello, 1886 (const char *) our_hello,
1887 GNUNET_HELLO_size(our_hello), 1887 GNUNET_HELLO_size(our_hello),
1888 GNUNET_NO, npos); 1888 GNUNET_NO, npos);
1889 npos = npos->next; 1889 npos = npos->next;
@@ -1940,7 +1940,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
1940 if (prev == NULL) 1940 if (prev == NULL)
1941 plugin->addresses = pos->next; 1941 plugin->addresses = pos->next;
1942 else 1942 else
1943 prev->next = pos->next; 1943 prev->next = pos->next;
1944 GNUNET_free (pos); 1944 GNUNET_free (pos);
1945 } 1945 }
1946 else 1946 else
@@ -1994,7 +1994,7 @@ expire_address_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1994 * @param value value in the hash map ('struct ValidationEntry*') 1994 * @param value value in the hash map ('struct ValidationEntry*')
1995 * @return GNUNET_YES (we should continue to iterate) 1995 * @return GNUNET_YES (we should continue to iterate)
1996 */ 1996 */
1997static int 1997static int
1998remove_session_validations (void *cls, 1998remove_session_validations (void *cls,
1999 const GNUNET_HashCode * key, 1999 const GNUNET_HashCode * key,
2000 void *value) 2000 void *value)
@@ -2010,7 +2010,7 @@ remove_session_validations (void *cls,
2010 2010
2011/** 2011/**
2012 * We've been disconnected from the other peer (for some 2012 * We've been disconnected from the other peer (for some
2013 * connection-oriented transport). Either quickly 2013 * connection-oriented transport). Either quickly
2014 * re-establish the connection or signal the disconnect 2014 * re-establish the connection or signal the disconnect
2015 * to the CORE. 2015 * to the CORE.
2016 * 2016 *
@@ -2036,7 +2036,7 @@ try_fast_reconnect (struct TransportPlugin *p,
2036 1) ideally: our own willingness / need to connect 2036 1) ideally: our own willingness / need to connect
2037 2) prior failures to connect to this peer (by plugin) 2037 2) prior failures to connect to this peer (by plugin)
2038 3) ideally: reasons why other peer terminated (as far as knowable) 2038 3) ideally: reasons why other peer terminated (as far as knowable)
2039 2039
2040 Most importantly, it must be POSSIBLE for another peer to terminate 2040 Most importantly, it must be POSSIBLE for another peer to terminate
2041 a connection for a while (without us instantly re-establishing it). 2041 a connection for a while (without us instantly re-establishing it).
2042 Similarly, if another peer is gone we should quickly notify CORE. 2042 Similarly, if another peer is gone we should quickly notify CORE.
@@ -2044,7 +2044,7 @@ try_fast_reconnect (struct TransportPlugin *p,
2044 on the other end), we should reconnect in such a way that BOTH CORE 2044 on the other end), we should reconnect in such a way that BOTH CORE
2045 services never even notice. 2045 services never even notice.
2046 Furthermore, the same mechanism (or small variation) could be used 2046 Furthermore, the same mechanism (or small variation) could be used
2047 to switch to a better-performing plugin (ATS). 2047 to switch to a better-performing plugin (ATS).
2048 2048
2049 Finally, this needs to be tested throughly... */ 2049 Finally, this needs to be tested throughly... */
2050 2050
@@ -2071,9 +2071,9 @@ try_fast_reconnect (struct TransportPlugin *p,
2071 * discard all of those sessions as well. Plugins that do not 2071 * discard all of those sessions as well. Plugins that do not
2072 * use sessions can simply omit calling this function and always 2072 * use sessions can simply omit calling this function and always
2073 * use NULL wherever a session pointer is needed. 2073 * use NULL wherever a session pointer is needed.
2074 * 2074 *
2075 * @param cls closure 2075 * @param cls closure
2076 * @param peer which peer was the session for 2076 * @param peer which peer was the session for
2077 * @param session which session is being destoyed 2077 * @param session which session is being destoyed
2078 */ 2078 */
2079static void 2079static void
@@ -2336,7 +2336,7 @@ static struct ForeignAddressList *
2336add_peer_address (struct NeighbourList *neighbour, 2336add_peer_address (struct NeighbourList *neighbour,
2337 const char *tname, 2337 const char *tname,
2338 struct Session *session, 2338 struct Session *session,
2339 const char *addr, 2339 const char *addr,
2340 uint16_t addrlen) 2340 uint16_t addrlen)
2341{ 2341{
2342 struct ReadyList *head; 2342 struct ReadyList *head;
@@ -2372,7 +2372,7 @@ add_peer_address (struct NeighbourList *neighbour,
2372 ret->latency = GNUNET_TIME_relative_get_forever(); 2372 ret->latency = GNUNET_TIME_relative_get_forever();
2373 ret->distance = -1; 2373 ret->distance = -1;
2374 ret->timeout = GNUNET_TIME_relative_to_absolute 2374 ret->timeout = GNUNET_TIME_relative_to_absolute
2375 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2375 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2376 ret->ready_list = head; 2376 ret->ready_list = head;
2377 ret->next = head->addresses; 2377 ret->next = head->addresses;
2378 head->addresses = ret; 2378 head->addresses = ret;
@@ -2510,7 +2510,7 @@ check_address_exists (void *cls,
2510 * @param value value in the hash map (validation to abort) 2510 * @param value value in the hash map (validation to abort)
2511 * @return GNUNET_YES (always) 2511 * @return GNUNET_YES (always)
2512 */ 2512 */
2513static int 2513static int
2514abort_validation (void *cls, 2514abort_validation (void *cls,
2515 const GNUNET_HashCode * key, 2515 const GNUNET_HashCode * key,
2516 void *value) 2516 void *value)
@@ -2620,7 +2620,7 @@ add_to_foreign_address_list (void *cls,
2620 GNUNET_STATISTICS_update (stats, 2620 GNUNET_STATISTICS_update (stats,
2621 gettext_noop ("# valid peer addresses returned by PEERINFO"), 2621 gettext_noop ("# valid peer addresses returned by PEERINFO"),
2622 1, 2622 1,
2623 GNUNET_NO); 2623 GNUNET_NO);
2624 try = GNUNET_NO; 2624 try = GNUNET_NO;
2625 fal = find_peer_address (n, tname, NULL, addr, addrlen); 2625 fal = find_peer_address (n, tname, NULL, addr, addrlen);
2626 if (fal == NULL) 2626 if (fal == NULL)
@@ -2639,7 +2639,7 @@ add_to_foreign_address_list (void *cls,
2639 GNUNET_STATISTICS_update (stats, 2639 GNUNET_STATISTICS_update (stats,
2640 gettext_noop ("# previously validated addresses lacking transport"), 2640 gettext_noop ("# previously validated addresses lacking transport"),
2641 1, 2641 1,
2642 GNUNET_NO); 2642 GNUNET_NO);
2643 } 2643 }
2644 else 2644 else
2645 { 2645 {
@@ -2663,11 +2663,11 @@ add_to_foreign_address_list (void *cls,
2663 } 2663 }
2664 if (fal->validated == GNUNET_NO) 2664 if (fal->validated == GNUNET_NO)
2665 { 2665 {
2666 fal->validated = GNUNET_YES; 2666 fal->validated = GNUNET_YES;
2667 GNUNET_STATISTICS_update (stats, 2667 GNUNET_STATISTICS_update (stats,
2668 gettext_noop ("# peer addresses considered valid"), 2668 gettext_noop ("# peer addresses considered valid"),
2669 1, 2669 1,
2670 GNUNET_NO); 2670 GNUNET_NO);
2671 } 2671 }
2672 if (try == GNUNET_YES) 2672 if (try == GNUNET_YES)
2673 { 2673 {
@@ -2702,7 +2702,7 @@ add_hello_for_peer (void *cls,
2702 GNUNET_NO); 2702 GNUNET_NO);
2703 n->piter = NULL; 2703 n->piter = NULL;
2704 return; 2704 return;
2705 } 2705 }
2706 if (h == NULL) 2706 if (h == NULL)
2707 return; /* no HELLO available */ 2707 return; /* no HELLO available */
2708#if DEBUG_TRANSPORT 2708#if DEBUG_TRANSPORT
@@ -2725,7 +2725,7 @@ add_hello_for_peer (void *cls,
2725 2725
2726/** 2726/**
2727 * Create a fresh entry in our neighbour list for the given peer. 2727 * Create a fresh entry in our neighbour list for the given peer.
2728 * Will try to transmit our current HELLO to the new neighbour. 2728 * Will try to transmit our current HELLO to the new neighbour.
2729 * Do not call this function directly, use 'setup_peer_check_blacklist. 2729 * Do not call this function directly, use 'setup_peer_check_blacklist.
2730 * 2730 *
2731 * @param peer the peer for which we create the entry 2731 * @param peer the peer for which we create the entry
@@ -2803,7 +2803,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
2803 2803
2804/** 2804/**
2805 * Function called after we have checked if communicating 2805 * Function called after we have checked if communicating
2806 * with a given peer is acceptable. 2806 * with a given peer is acceptable.
2807 * 2807 *
2808 * @param cls closure 2808 * @param cls closure
2809 * @param n NULL if communication is not acceptable 2809 * @param n NULL if communication is not acceptable
@@ -2857,12 +2857,12 @@ static struct Blacklisters *bl_tail;
2857 */ 2857 */
2858struct BlacklistCheck 2858struct BlacklistCheck
2859{ 2859{
2860 2860
2861 /** 2861 /**
2862 * This is a linked list. 2862 * This is a linked list.
2863 */ 2863 */
2864 struct BlacklistCheck *next; 2864 struct BlacklistCheck *next;
2865 2865
2866 /** 2866 /**
2867 * This is a linked list. 2867 * This is a linked list.
2868 */ 2868 */
@@ -2921,7 +2921,7 @@ static struct BlacklistCheck *bc_tail;
2921 * Perform next action in the blacklist check. 2921 * Perform next action in the blacklist check.
2922 * 2922 *
2923 * @param cls the 'struct BlacklistCheck*' 2923 * @param cls the 'struct BlacklistCheck*'
2924 * @param tc unused 2924 * @param tc unused
2925 */ 2925 */
2926static void 2926static void
2927do_blacklist_check (void *cls, 2927do_blacklist_check (void *cls,
@@ -2959,7 +2959,7 @@ transmit_blacklist_message (void *cls,
2959 bm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY); 2959 bm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY);
2960 bm.is_allowed = htonl (0); 2960 bm.is_allowed = htonl (0);
2961 bm.peer = bc->peer; 2961 bm.peer = bc->peer;
2962 memcpy (buf, &bm, sizeof (bm)); 2962 memcpy (buf, &bm, sizeof (bm));
2963 GNUNET_SERVER_receive_done (bl->client, GNUNET_OK); 2963 GNUNET_SERVER_receive_done (bl->client, GNUNET_OK);
2964 return sizeof (bm); 2964 return sizeof (bm);
2965} 2965}
@@ -2969,7 +2969,7 @@ transmit_blacklist_message (void *cls,
2969 * Perform next action in the blacklist check. 2969 * Perform next action in the blacklist check.
2970 * 2970 *
2971 * @param cls the 'struct BlacklistCheck*' 2971 * @param cls the 'struct BlacklistCheck*'
2972 * @param tc unused 2972 * @param tc unused
2973 */ 2973 */
2974static void 2974static void
2975do_blacklist_check (void *cls, 2975do_blacklist_check (void *cls,
@@ -2987,14 +2987,14 @@ do_blacklist_check (void *cls,
2987 GNUNET_free (bc); 2987 GNUNET_free (bc);
2988 return; 2988 return;
2989 } 2989 }
2990 if (bl->bc == NULL) 2990 if (bl->bc == NULL)
2991 { 2991 {
2992 bl->bc = bc; 2992 bl->bc = bc;
2993 bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, 2993 bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client,
2994 sizeof (struct BlacklistMessage), 2994 sizeof (struct BlacklistMessage),
2995 GNUNET_TIME_UNIT_FOREVER_REL, 2995 GNUNET_TIME_UNIT_FOREVER_REL,
2996 &transmit_blacklist_message, 2996 &transmit_blacklist_message,
2997 bc); 2997 bc);
2998 } 2998 }
2999} 2999}
3000 3000
@@ -3046,7 +3046,7 @@ setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer,
3046 3046
3047 3047
3048/** 3048/**
3049 * Function called with the result of querying a new blacklister about 3049 * Function called with the result of querying a new blacklister about
3050 * it being allowed (or not) to continue to talk to an existing neighbour. 3050 * it being allowed (or not) to continue to talk to an existing neighbour.
3051 * 3051 *
3052 * @param cls the original 'struct NeighbourList' 3052 * @param cls the original 'struct NeighbourList'
@@ -3139,16 +3139,16 @@ handle_blacklist_reply (void *cls,
3139 bl = bl_head; 3139 bl = bl_head;
3140 while ( (bl != NULL) && 3140 while ( (bl != NULL) &&
3141 (bl->client != client) ) 3141 (bl->client != client) )
3142 bl = bl->next; 3142 bl = bl->next;
3143 if (bl == NULL) 3143 if (bl == NULL)
3144 { 3144 {
3145 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 3145 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
3146 return; 3146 return;
3147 } 3147 }
3148 bc = bl->bc; 3148 bc = bl->bc;
3149 bl->bc = NULL; 3149 bl->bc = NULL;
3150 if (ntohl (msg->is_allowed) == GNUNET_SYSERR) 3150 if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
3151 { 3151 {
3152 bc->cont (bc->cont_cls, NULL); 3152 bc->cont (bc->cont_cls, NULL);
3153 GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc); 3153 GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc);
3154 GNUNET_free (bc); 3154 GNUNET_free (bc);
@@ -3158,7 +3158,7 @@ handle_blacklist_reply (void *cls,
3158 bc->bl_pos = bc->bl_pos->next; 3158 bc->bl_pos = bc->bl_pos->next;
3159 bc->task = GNUNET_SCHEDULER_add_now (sched, 3159 bc->task = GNUNET_SCHEDULER_add_now (sched,
3160 &do_blacklist_check, 3160 &do_blacklist_check,
3161 bc); 3161 bc);
3162 } 3162 }
3163 /* check if any other bc's are waiting for this blacklister */ 3163 /* check if any other bc's are waiting for this blacklister */
3164 bc = bc_head; 3164 bc = bc_head;
@@ -3168,7 +3168,7 @@ handle_blacklist_reply (void *cls,
3168 (GNUNET_SCHEDULER_NO_TASK == bc->task) ) 3168 (GNUNET_SCHEDULER_NO_TASK == bc->task) )
3169 bc->task = GNUNET_SCHEDULER_add_now (sched, 3169 bc->task = GNUNET_SCHEDULER_add_now (sched,
3170 &do_blacklist_check, 3170 &do_blacklist_check,
3171 bc); 3171 bc);
3172 bc = bc->next; 3172 bc = bc->next;
3173 } 3173 }
3174} 3174}
@@ -3180,8 +3180,8 @@ handle_blacklist_reply (void *cls,
3180 * @param cls our 'struct PeriodicValidationContext*' 3180 * @param cls our 'struct PeriodicValidationContext*'
3181 * @param tc task context 3181 * @param tc task context
3182 */ 3182 */
3183static void 3183static void
3184send_periodic_ping (void *cls, 3184send_periodic_ping (void *cls,
3185 const struct GNUNET_SCHEDULER_TaskContext *tc) 3185 const struct GNUNET_SCHEDULER_TaskContext *tc)
3186{ 3186{
3187 struct ForeignAddressList *peer_address = cls; 3187 struct ForeignAddressList *peer_address = cls;
@@ -3197,13 +3197,13 @@ send_periodic_ping (void *cls,
3197 3197
3198 peer_address->revalidate_task = GNUNET_SCHEDULER_NO_TASK; 3198 peer_address->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
3199 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 3199 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
3200 return; 3200 return;
3201 tp = peer_address->ready_list->plugin; 3201 tp = peer_address->ready_list->plugin;
3202 neighbour = peer_address->ready_list->neighbour; 3202 neighbour = peer_address->ready_list->neighbour;
3203 if (GNUNET_YES != neighbour->public_key_valid) 3203 if (GNUNET_YES != neighbour->public_key_valid)
3204 { 3204 {
3205 /* no public key yet, try again later */ 3205 /* no public key yet, try again later */
3206 schedule_next_ping (peer_address); 3206 schedule_next_ping (peer_address);
3207 return; 3207 return;
3208 } 3208 }
3209 caec.addr = peer_address->addr; 3209 caec.addr = peer_address->addr;
@@ -3231,7 +3231,7 @@ send_periodic_ping (void *cls,
3231 tp->short_name, 3231 tp->short_name,
3232 GNUNET_i2s (&neighbour->id)); 3232 GNUNET_i2s (&neighbour->id));
3233#endif 3233#endif
3234 schedule_next_ping (peer_address); 3234 schedule_next_ping (peer_address);
3235 return; 3235 return;
3236 } 3236 }
3237 va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen); 3237 va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen);
@@ -3247,7 +3247,7 @@ send_periodic_ping (void *cls,
3247 va->addrlen = peer_address->addrlen; 3247 va->addrlen = peer_address->addrlen;
3248 } 3248 }
3249 memcpy(&va->publicKey, 3249 memcpy(&va->publicKey,
3250 &neighbour->publicKey, 3250 &neighbour->publicKey,
3251 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 3251 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
3252 3252
3253 va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 3253 va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
@@ -3276,14 +3276,14 @@ send_periodic_ping (void *cls,
3276 memcpy(message_buf, our_hello, hello_size); 3276 memcpy(message_buf, our_hello, hello_size);
3277 if (peer_address->addr != NULL) 3277 if (peer_address->addr != NULL)
3278 { 3278 {
3279 ping.header.size = htons(sizeof(struct TransportPingMessage) + 3279 ping.header.size = htons(sizeof(struct TransportPingMessage) +
3280 peer_address->addrlen + 3280 peer_address->addrlen +
3281 slen); 3281 slen);
3282 memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage)], 3282 memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage)],
3283 tp->short_name, 3283 tp->short_name,
3284 slen); 3284 slen);
3285 memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage) + slen], 3285 memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage) + slen],
3286 peer_address->addr, 3286 peer_address->addr,
3287 peer_address->addrlen); 3287 peer_address->addrlen);
3288 } 3288 }
3289 else 3289 else
@@ -3297,7 +3297,7 @@ send_periodic_ping (void *cls,
3297#if DEBUG_TRANSPORT_REVALIDATION 3297#if DEBUG_TRANSPORT_REVALIDATION
3298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3299 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n", 3299 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n",
3300 (peer_address->addr != NULL) 3300 (peer_address->addr != NULL)
3301 ? a2s (peer_address->plugin->short_name, 3301 ? a2s (peer_address->plugin->short_name,
3302 peer_address->addr, 3302 peer_address->addr,
3303 peer_address->addrlen) 3303 peer_address->addrlen)
@@ -3342,12 +3342,12 @@ schedule_next_ping (struct ForeignAddressList *fal)
3342 { 3342 {
3343 delay = GNUNET_TIME_UNIT_ZERO; 3343 delay = GNUNET_TIME_UNIT_ZERO;
3344 fal->estimated = GNUNET_YES; 3344 fal->estimated = GNUNET_YES;
3345 } 3345 }
3346 if (GNUNET_YES == fal->connected) 3346 if (GNUNET_YES == fal->connected)
3347 { 3347 {
3348 delay = GNUNET_TIME_relative_min (delay, 3348 delay = GNUNET_TIME_relative_min (delay,
3349 CONNECTED_LATENCY_EVALUATION_MAX_DELAY); 3349 CONNECTED_LATENCY_EVALUATION_MAX_DELAY);
3350 } 3350 }
3351 /* FIXME: also adjust delay based on how close the last 3351 /* FIXME: also adjust delay based on how close the last
3352 observed latency is to the latency of the best alternative */ 3352 observed latency is to the latency of the best alternative */
3353 /* bound how fast we can go */ 3353 /* bound how fast we can go */
@@ -3355,9 +3355,9 @@ schedule_next_ping (struct ForeignAddressList *fal)
3355 GNUNET_TIME_UNIT_SECONDS); 3355 GNUNET_TIME_UNIT_SECONDS);
3356 /* randomize a bit (to avoid doing all at the same time) */ 3356 /* randomize a bit (to avoid doing all at the same time) */
3357 delay.value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); 3357 delay.value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
3358 fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched, 3358 fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched,
3359 delay, 3359 delay,
3360 &send_periodic_ping, 3360 &send_periodic_ping,
3361 fal); 3361 fal);
3362} 3362}
3363 3363
@@ -3396,8 +3396,8 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3396#if DEBUG_TRANSPORT 3396#if DEBUG_TRANSPORT
3397 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3397 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3398 "Received message of type %u and size %u from `%4s', sending to all clients.\n", 3398 "Received message of type %u and size %u from `%4s', sending to all clients.\n",
3399 ntohs (message->type), 3399 ntohs (message->type),
3400 ntohs (message->size), 3400 ntohs (message->size),
3401 GNUNET_i2s (&n->id)); 3401 GNUNET_i2s (&n->id));
3402#endif 3402#endif
3403 if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, 3403 if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
@@ -3405,8 +3405,8 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3405 { 3405 {
3406 n->quota_violation_count++; 3406 n->quota_violation_count++;
3407#if DEBUG_TRANSPORT 3407#if DEBUG_TRANSPORT
3408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3409 "Bandwidth quota (%u b/s) violation detected (total of %u).\n", 3409 "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
3410 n->in_tracker.available_bytes_per_s__, 3410 n->in_tracker.available_bytes_per_s__,
3411 n->quota_violation_count); 3411 n->quota_violation_count);
3412#endif 3412#endif
@@ -3414,7 +3414,7 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3414 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, 3414 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
3415 - 32 * 1024); 3415 - 32 * 1024);
3416 } 3416 }
3417 else 3417 else
3418 { 3418 {
3419 if (n->quota_violation_count > 0) 3419 if (n->quota_violation_count > 0)
3420 { 3420 {
@@ -3488,8 +3488,8 @@ check_pending_validation (void *cls,
3488 if ( (ps - sizeof (struct TransportPongMessage) != ve->addrlen + slen) || 3488 if ( (ps - sizeof (struct TransportPongMessage) != ve->addrlen + slen) ||
3489 (ve->challenge != challenge) || 3489 (ve->challenge != challenge) ||
3490 (addr[slen-1] != '\0') || 3490 (addr[slen-1] != '\0') ||
3491 (0 != strcmp (addr, ve->transport_name)) || 3491 (0 != strcmp (addr, ve->transport_name)) ||
3492 (ntohl (pong->purpose.size) 3492 (ntohl (pong->purpose.size)
3493 != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 3493 != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
3494 sizeof (uint32_t) + 3494 sizeof (uint32_t) +
3495 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 3495 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
@@ -3511,16 +3511,16 @@ check_pending_validation (void *cls,
3511 } 3511 }
3512 if (0 != memcmp (&pong->pid, 3512 if (0 != memcmp (&pong->pid,
3513 key, 3513 key,
3514 sizeof (struct GNUNET_PeerIdentity))) 3514 sizeof (struct GNUNET_PeerIdentity)))
3515 { 3515 {
3516 GNUNET_break_op (0); 3516 GNUNET_break_op (0);
3517 return GNUNET_NO; 3517 return GNUNET_NO;
3518 } 3518 }
3519 if (GNUNET_OK != 3519 if (GNUNET_OK !=
3520 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, 3520 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
3521 &pong->purpose, 3521 &pong->purpose,
3522 &pong->signature, 3522 &pong->signature,
3523 &ve->publicKey)) 3523 &ve->publicKey))
3524 { 3524 {
3525 GNUNET_break_op (0); 3525 GNUNET_break_op (0);
3526 return GNUNET_NO; 3526 return GNUNET_NO;
@@ -3537,7 +3537,7 @@ check_pending_validation (void *cls,
3537#endif 3537#endif
3538 break; 3538 break;
3539 case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: 3539 case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING:
3540 if (ve->addrlen != 0) 3540 if (ve->addrlen != 0)
3541 { 3541 {
3542 return GNUNET_YES; /* different entry, keep trying */ 3542 return GNUNET_YES; /* different entry, keep trying */
3543 } 3543 }
@@ -3572,13 +3572,13 @@ check_pending_validation (void *cls,
3572 a2s (ve->transport_name, 3572 a2s (ve->transport_name,
3573 &addr[slen], 3573 &addr[slen],
3574 alen)); 3574 alen));
3575 return GNUNET_NO; 3575 return GNUNET_NO;
3576 } 3576 }
3577 if (GNUNET_OK != 3577 if (GNUNET_OK !=
3578 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, 3578 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING,
3579 &pong->purpose, 3579 &pong->purpose,
3580 &pong->signature, 3580 &pong->signature,
3581 &ve->publicKey)) 3581 &ve->publicKey))
3582 { 3582 {
3583 GNUNET_break_op (0); 3583 GNUNET_break_op (0);
3584 return GNUNET_NO; 3584 return GNUNET_NO;
@@ -3640,7 +3640,7 @@ check_pending_validation (void *cls,
3640 GNUNET_STATISTICS_update (stats, 3640 GNUNET_STATISTICS_update (stats,
3641 gettext_noop ("# peer addresses considered valid"), 3641 gettext_noop ("# peer addresses considered valid"),
3642 1, 3642 1,
3643 GNUNET_NO); 3643 GNUNET_NO);
3644 fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); 3644 fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
3645 schedule_next_ping (fal); 3645 schedule_next_ping (fal);
3646 if (n->latency.value == GNUNET_TIME_UNIT_FOREVER_REL.value) 3646 if (n->latency.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
@@ -3778,7 +3778,7 @@ transmit_hello_and_ping (void *cls,
3778 { 3778 {
3779 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3779 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3780 "Failed to add peer `%4s' for plugin `%s'\n", 3780 "Failed to add peer `%4s' for plugin `%s'\n",
3781 GNUNET_i2s (&neighbour->id), 3781 GNUNET_i2s (&neighbour->id),
3782 va->transport_name); 3782 va->transport_name);
3783 GNUNET_break (GNUNET_OK == 3783 GNUNET_break (GNUNET_OK ==
3784 GNUNET_CONTAINER_multihashmap_remove (validation_map, 3784 GNUNET_CONTAINER_multihashmap_remove (validation_map,
@@ -3808,7 +3808,7 @@ transmit_hello_and_ping (void *cls,
3808#if DEBUG_TRANSPORT 3808#if DEBUG_TRANSPORT
3809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3810 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", 3810 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n",
3811 (va->addrlen == 0) 3811 (va->addrlen == 0)
3812 ? "<inbound>" 3812 ? "<inbound>"
3813 : a2s (va->transport_name, 3813 : a2s (va->transport_name,
3814 (const void*) &va[1], va->addrlen), 3814 (const void*) &va[1], va->addrlen),
@@ -3821,7 +3821,7 @@ transmit_hello_and_ping (void *cls,
3821 GNUNET_STATISTICS_update (stats, 3821 GNUNET_STATISTICS_update (stats,
3822 gettext_noop ("# PING messages sent for initial validation"), 3822 gettext_noop ("# PING messages sent for initial validation"),
3823 1, 3823 1,
3824 GNUNET_NO); 3824 GNUNET_NO);
3825 transmit_to_peer (NULL, peer_address, 3825 transmit_to_peer (NULL, peer_address,
3826 GNUNET_SCHEDULER_PRIORITY_DEFAULT, 3826 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
3827 HELLO_VERIFICATION_TIMEOUT, 3827 HELLO_VERIFICATION_TIMEOUT,
@@ -3847,7 +3847,7 @@ static int
3847run_validation (void *cls, 3847run_validation (void *cls,
3848 const char *tname, 3848 const char *tname,
3849 struct GNUNET_TIME_Absolute expiration, 3849 struct GNUNET_TIME_Absolute expiration,
3850 const void *addr, 3850 const void *addr,
3851 uint16_t addrlen) 3851 uint16_t addrlen)
3852{ 3852{
3853 struct CheckHelloValidatedContext *chvc = cls; 3853 struct CheckHelloValidatedContext *chvc = cls;
@@ -3863,7 +3863,7 @@ run_validation (void *cls,
3863 GNUNET_STATISTICS_update (stats, 3863 GNUNET_STATISTICS_update (stats,
3864 gettext_noop ("# peer addresses scheduled for validation"), 3864 gettext_noop ("# peer addresses scheduled for validation"),
3865 1, 3865 1,
3866 GNUNET_NO); 3866 GNUNET_NO);
3867 tp = find_transport (tname); 3867 tp = find_transport (tname);
3868 if (tp == NULL) 3868 if (tp == NULL)
3869 { 3869 {
@@ -3875,7 +3875,7 @@ run_validation (void *cls,
3875 GNUNET_STATISTICS_update (stats, 3875 GNUNET_STATISTICS_update (stats,
3876 gettext_noop ("# peer addresses not validated (plugin not available)"), 3876 gettext_noop ("# peer addresses not validated (plugin not available)"),
3877 1, 3877 1,
3878 GNUNET_NO); 3878 GNUNET_NO);
3879 return GNUNET_OK; 3879 return GNUNET_OK;
3880 } 3880 }
3881 /* check if this is one of our own addresses */ 3881 /* check if this is one of our own addresses */
@@ -3891,7 +3891,7 @@ run_validation (void *cls,
3891 GNUNET_STATISTICS_update (stats, 3891 GNUNET_STATISTICS_update (stats,
3892 gettext_noop ("# peer addresses not validated (loopback)"), 3892 gettext_noop ("# peer addresses not validated (loopback)"),
3893 1, 3893 1,
3894 GNUNET_NO); 3894 GNUNET_NO);
3895 return GNUNET_OK; 3895 return GNUNET_OK;
3896 } 3896 }
3897 oal = oal->next; 3897 oal = oal->next;
@@ -3906,8 +3906,8 @@ run_validation (void *cls,
3906 { 3906 {
3907#if DEBUG_TRANSPORT 3907#if DEBUG_TRANSPORT
3908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3909 "Attempted to validate blacklisted peer `%s' using `%s'!\n", 3909 "Attempted to validate blacklisted peer `%s' using `%s'!\n",
3910 GNUNET_i2s(&id), 3910 GNUNET_i2s(&id),
3911 tname); 3911 tname);
3912#endif 3912#endif
3913 return GNUNET_OK; 3913 return GNUNET_OK;
@@ -3937,7 +3937,7 @@ run_validation (void *cls,
3937 GNUNET_STATISTICS_update (stats, 3937 GNUNET_STATISTICS_update (stats,
3938 gettext_noop ("# peer addresses not validated (in progress)"), 3938 gettext_noop ("# peer addresses not validated (in progress)"),
3939 1, 3939 1,
3940 GNUNET_NO); 3940 GNUNET_NO);
3941 return GNUNET_OK; 3941 return GNUNET_OK;
3942 } 3942 }
3943 va = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen); 3943 va = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen);
@@ -4002,7 +4002,7 @@ check_hello_validated (void *cls,
4002 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 4002 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
4003 &target.hashPubKey); 4003 &target.hashPubKey);
4004 plain_hello = GNUNET_HELLO_create (&pk, 4004 plain_hello = GNUNET_HELLO_create (&pk,
4005 NULL, 4005 NULL,
4006 NULL); 4006 NULL);
4007 GNUNET_PEERINFO_add_peer (peerinfo, plain_hello); 4007 GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
4008 GNUNET_free (plain_hello); 4008 GNUNET_free (plain_hello);
@@ -4015,10 +4015,10 @@ check_hello_validated (void *cls,
4015 GNUNET_STATISTICS_update (stats, 4015 GNUNET_STATISTICS_update (stats,
4016 gettext_noop ("# new HELLOs requiring full validation"), 4016 gettext_noop ("# new HELLOs requiring full validation"),
4017 1, 4017 1,
4018 GNUNET_NO); 4018 GNUNET_NO);
4019 GNUNET_HELLO_iterate_addresses (chvc->hello, 4019 GNUNET_HELLO_iterate_addresses (chvc->hello,
4020 GNUNET_NO, 4020 GNUNET_NO,
4021 &run_validation, 4021 &run_validation,
4022 chvc); 4022 chvc);
4023 } 4023 }
4024 else 4024 else
@@ -4026,7 +4026,7 @@ check_hello_validated (void *cls,
4026 GNUNET_STATISTICS_update (stats, 4026 GNUNET_STATISTICS_update (stats,
4027 gettext_noop ("# duplicate HELLO (peer known)"), 4027 gettext_noop ("# duplicate HELLO (peer known)"),
4028 1, 4028 1,
4029 GNUNET_NO); 4029 GNUNET_NO);
4030 } 4030 }
4031 chvc->ve_count--; 4031 chvc->ve_count--;
4032 if (chvc->ve_count == 0) 4032 if (chvc->ve_count == 0)
@@ -4034,10 +4034,10 @@ check_hello_validated (void *cls,
4034 GNUNET_CONTAINER_DLL_remove (chvc_head, 4034 GNUNET_CONTAINER_DLL_remove (chvc_head,
4035 chvc_tail, 4035 chvc_tail,
4036 chvc); 4036 chvc);
4037 GNUNET_free (chvc); 4037 GNUNET_free (chvc);
4038 } 4038 }
4039 return; 4039 return;
4040 } 4040 }
4041 if (h == NULL) 4041 if (h == NULL)
4042 return; 4042 return;
4043#if DEBUG_TRANSPORT 4043#if DEBUG_TRANSPORT
@@ -4061,16 +4061,16 @@ check_hello_validated (void *cls,
4061 GNUNET_STATISTICS_update (stats, 4061 GNUNET_STATISTICS_update (stats,
4062 gettext_noop ("# no existing neighbour record (validating HELLO)"), 4062 gettext_noop ("# no existing neighbour record (validating HELLO)"),
4063 1, 4063 1,
4064 GNUNET_NO); 4064 GNUNET_NO);
4065 } 4065 }
4066 GNUNET_STATISTICS_update (stats, 4066 GNUNET_STATISTICS_update (stats,
4067 gettext_noop ("# HELLO validations (update case)"), 4067 gettext_noop ("# HELLO validations (update case)"),
4068 1, 4068 1,
4069 GNUNET_NO); 4069 GNUNET_NO);
4070 GNUNET_HELLO_iterate_new_addresses (chvc->hello, 4070 GNUNET_HELLO_iterate_new_addresses (chvc->hello,
4071 h, 4071 h,
4072 GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME), 4072 GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME),
4073 &run_validation, 4073 &run_validation,
4074 chvc); 4074 chvc);
4075} 4075}
4076 4076
@@ -4104,7 +4104,7 @@ process_hello (struct TransportPlugin *plugin,
4104 GNUNET_STATISTICS_update (stats, 4104 GNUNET_STATISTICS_update (stats,
4105 gettext_noop ("# HELLOs received for validation"), 4105 gettext_noop ("# HELLOs received for validation"),
4106 1, 4106 1,
4107 GNUNET_NO); 4107 GNUNET_NO);
4108 4108
4109 /* first, check if load is too high */ 4109 /* first, check if load is too high */
4110 if (GNUNET_SCHEDULER_get_load (sched, 4110 if (GNUNET_SCHEDULER_get_load (sched,
@@ -4113,7 +4113,7 @@ process_hello (struct TransportPlugin *plugin,
4113 GNUNET_STATISTICS_update (stats, 4113 GNUNET_STATISTICS_update (stats,
4114 gettext_noop ("# HELLOs ignored due to high load"), 4114 gettext_noop ("# HELLOs ignored due to high load"),
4115 1, 4115 1,
4116 GNUNET_NO); 4116 GNUNET_NO);
4117#if DEBUG_TRANSPORT_HELLO 4117#if DEBUG_TRANSPORT_HELLO
4118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4119 "Ignoring `%s' for `%4s', load too high.\n", 4119 "Ignoring `%s' for `%4s', load too high.\n",
@@ -4146,8 +4146,8 @@ process_hello (struct TransportPlugin *plugin,
4146 GNUNET_STATISTICS_update (stats, 4146 GNUNET_STATISTICS_update (stats,
4147 gettext_noop ("# HELLOs ignored for validation (is my own HELLO)"), 4147 gettext_noop ("# HELLOs ignored for validation (is my own HELLO)"),
4148 1, 4148 1,
4149 GNUNET_NO); 4149 GNUNET_NO);
4150 return GNUNET_OK; 4150 return GNUNET_OK;
4151 } 4151 }
4152 chvc = chvc_head; 4152 chvc = chvc_head;
4153 while (NULL != chvc) 4153 while (NULL != chvc)
@@ -4159,7 +4159,7 @@ process_hello (struct TransportPlugin *plugin,
4159#if DEBUG_TRANSPORT_HELLO 4159#if DEBUG_TRANSPORT_HELLO
4160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4161 "Received duplicate `%s' message for `%4s'; ignored\n", 4161 "Received duplicate `%s' message for `%4s'; ignored\n",
4162 "HELLO", 4162 "HELLO",
4163 GNUNET_i2s (&target)); 4163 GNUNET_i2s (&target));
4164#endif 4164#endif
4165 return GNUNET_OK; /* validation already pending */ 4165 return GNUNET_OK; /* validation already pending */
@@ -4287,12 +4287,12 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4287 GNUNET_STATISTICS_update (stats, 4287 GNUNET_STATISTICS_update (stats,
4288 gettext_noop ("# connected addresses"), 4288 gettext_noop ("# connected addresses"),
4289 -1, 4289 -1,
4290 GNUNET_NO); 4290 GNUNET_NO);
4291 if (GNUNET_YES == peer_pos->validated) 4291 if (GNUNET_YES == peer_pos->validated)
4292 GNUNET_STATISTICS_update (stats, 4292 GNUNET_STATISTICS_update (stats,
4293 gettext_noop ("# peer addresses considered valid"), 4293 gettext_noop ("# peer addresses considered valid"),
4294 -1, 4294 -1,
4295 GNUNET_NO); 4295 GNUNET_NO);
4296 if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task) 4296 if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task)
4297 { 4297 {
4298 GNUNET_SCHEDULER_cancel (sched, 4298 GNUNET_SCHEDULER_cancel (sched,
@@ -4318,7 +4318,7 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4318 GNUNET_CONTAINER_DLL_remove (n->messages_head, 4318 GNUNET_CONTAINER_DLL_remove (n->messages_head,
4319 n->messages_tail, 4319 n->messages_tail,
4320 mq); 4320 mq);
4321 GNUNET_assert (0 == memcmp(&mq->neighbour_id, 4321 GNUNET_assert (0 == memcmp(&mq->neighbour_id,
4322 &n->id, 4322 &n->id,
4323 sizeof(struct GNUNET_PeerIdentity))); 4323 sizeof(struct GNUNET_PeerIdentity)));
4324 GNUNET_free (mq); 4324 GNUNET_free (mq);
@@ -4354,9 +4354,9 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4354 4354
4355/** 4355/**
4356 * We have received a PING message from someone. Need to send a PONG message 4356 * We have received a PING message from someone. Need to send a PONG message
4357 * in response to the peer by any means necessary. 4357 * in response to the peer by any means necessary.
4358 */ 4358 */
4359static int 4359static int
4360handle_ping(void *cls, const struct GNUNET_MessageHeader *message, 4360handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4361 const struct GNUNET_PeerIdentity *peer, 4361 const struct GNUNET_PeerIdentity *peer,
4362 struct Session *session, 4362 struct Session *session,
@@ -4387,17 +4387,17 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4387 sizeof (struct GNUNET_PeerIdentity))) 4387 sizeof (struct GNUNET_PeerIdentity)))
4388 { 4388 {
4389 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4389 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
4390 _("Received `%s' message not destined for me!\n"), 4390 _("Received `%s' message not destined for me!\n"),
4391 "PING"); 4391 "PING");
4392 return GNUNET_SYSERR; 4392 return GNUNET_SYSERR;
4393 } 4393 }
4394#if DEBUG_PING_PONG 4394#if DEBUG_PING_PONG
4395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 4395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
4396 "Processing `%s' from `%s'\n", 4396 "Processing `%s' from `%s'\n",
4397 "PING", 4397 "PING",
4398 (sender_address != NULL) 4398 (sender_address != NULL)
4399 ? a2s (plugin->short_name, 4399 ? a2s (plugin->short_name,
4400 (const struct sockaddr *)sender_address, 4400 (const struct sockaddr *)sender_address,
4401 sender_address_len) 4401 sender_address_len)
4402 : "<inbound>"); 4402 : "<inbound>");
4403#endif 4403#endif
@@ -4409,7 +4409,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4409 alen = ntohs (message->size) - sizeof (struct TransportPingMessage); 4409 alen = ntohs (message->size) - sizeof (struct TransportPingMessage);
4410 slen = strlen (plugin->short_name) + 1; 4410 slen = strlen (plugin->short_name) + 1;
4411 if (alen == 0) 4411 if (alen == 0)
4412 { 4412 {
4413 /* peer wants to confirm that we have an outbound connection to him */ 4413 /* peer wants to confirm that we have an outbound connection to him */
4414 if (session == NULL) 4414 if (session == NULL)
4415 { 4415 {
@@ -4429,14 +4429,14 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4429 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING); 4429 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING);
4430 pong->challenge = ping->challenge; 4430 pong->challenge = ping->challenge;
4431 pong->addrlen = htonl(sender_address_len + slen); 4431 pong->addrlen = htonl(sender_address_len + slen);
4432 memcpy(&pong->pid, 4432 memcpy(&pong->pid,
4433 peer, 4433 peer,
4434 sizeof(struct GNUNET_PeerIdentity)); 4434 sizeof(struct GNUNET_PeerIdentity));
4435 memcpy (&pong[1], 4435 memcpy (&pong[1],
4436 plugin->short_name, 4436 plugin->short_name,
4437 slen); 4437 slen);
4438 memcpy (&((char*)&pong[1])[slen], 4438 memcpy (&((char*)&pong[1])[slen],
4439 sender_address, 4439 sender_address,
4440 sender_address_len); 4440 sender_address_len);
4441 if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires).value < PONG_SIGNATURE_LIFETIME.value / 4) 4441 if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires).value < PONG_SIGNATURE_LIFETIME.value / 4)
4442 { 4442 {
@@ -4458,7 +4458,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4458 } 4458 }
4459 memcpy (&pong->signature, 4459 memcpy (&pong->signature,
4460 &session_header->pong_signature, 4460 &session_header->pong_signature,
4461 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4461 sizeof (struct GNUNET_CRYPTO_RsaSignature));
4462 4462
4463 4463
4464 } 4464 }
@@ -4500,8 +4500,8 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4500 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); 4500 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
4501 pong->challenge = ping->challenge; 4501 pong->challenge = ping->challenge;
4502 pong->addrlen = htonl(alen + slen); 4502 pong->addrlen = htonl(alen + slen);
4503 memcpy(&pong->pid, 4503 memcpy(&pong->pid,
4504 &my_identity, 4504 &my_identity,
4505 sizeof(struct GNUNET_PeerIdentity)); 4505 sizeof(struct GNUNET_PeerIdentity));
4506 memcpy (&pong[1], plugin->short_name, slen); 4506 memcpy (&pong[1], plugin->short_name, slen);
4507 memcpy (&((char*)&pong[1])[slen], addr, alen); 4507 memcpy (&((char*)&pong[1])[slen], addr, alen);
@@ -4519,10 +4519,10 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4519 GNUNET_assert (GNUNET_OK == 4519 GNUNET_assert (GNUNET_OK ==
4520 GNUNET_CRYPTO_rsa_sign (my_private_key, 4520 GNUNET_CRYPTO_rsa_sign (my_private_key,
4521 &pong->purpose, 4521 &pong->purpose,
4522 &oal->pong_signature)); 4522 &oal->pong_signature));
4523 memcpy (&pong->signature, 4523 memcpy (&pong->signature,
4524 &oal->pong_signature, 4524 &oal->pong_signature,
4525 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4525 sizeof (struct GNUNET_CRYPTO_RsaSignature));
4526 } 4526 }
4527 else if (oal == NULL) 4527 else if (oal == NULL)
4528 { 4528 {
@@ -4531,7 +4531,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4531 GNUNET_assert (GNUNET_OK == 4531 GNUNET_assert (GNUNET_OK ==
4532 GNUNET_CRYPTO_rsa_sign (my_private_key, 4532 GNUNET_CRYPTO_rsa_sign (my_private_key,
4533 &pong->purpose, 4533 &pong->purpose,
4534 &pong->signature)); 4534 &pong->signature));
4535 } 4535 }
4536 else 4536 else
4537 { 4537 {
@@ -4539,7 +4539,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4539 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); 4539 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires);
4540 memcpy (&pong->signature, 4540 memcpy (&pong->signature,
4541 &oal->pong_signature, 4541 &oal->pong_signature,
4542 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4542 sizeof (struct GNUNET_CRYPTO_RsaSignature));
4543 } 4543 }
4544 } 4544 }
4545 n = find_neighbour(peer); 4545 n = find_neighbour(peer);
@@ -4555,7 +4555,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4555 peer, 4555 peer,
4556 (const char*) pong, 4556 (const char*) pong,
4557 ntohs (pong->header.size), 4557 ntohs (pong->header.size),
4558 TRANSPORT_PONG_PRIORITY, 4558 TRANSPORT_PONG_PRIORITY,
4559 HELLO_VERIFICATION_TIMEOUT, 4559 HELLO_VERIFICATION_TIMEOUT,
4560 fal->session, 4560 fal->session,
4561 fal->addr, 4561 fal->addr,
@@ -4567,7 +4567,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4567 GNUNET_STATISTICS_update (stats, 4567 GNUNET_STATISTICS_update (stats,
4568 gettext_noop ("# PONGs unicast via reliable transport"), 4568 gettext_noop ("# PONGs unicast via reliable transport"),
4569 1, 4569 1,
4570 GNUNET_NO); 4570 GNUNET_NO);
4571 GNUNET_free (pong); 4571 GNUNET_free (pong);
4572 return GNUNET_OK; 4572 return GNUNET_OK;
4573 } 4573 }
@@ -4579,7 +4579,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4579 GNUNET_STATISTICS_update (stats, 4579 GNUNET_STATISTICS_update (stats,
4580 gettext_noop ("# PONGs multicast to all available addresses"), 4580 gettext_noop ("# PONGs multicast to all available addresses"),
4581 1, 4581 1,
4582 GNUNET_NO); 4582 GNUNET_NO);
4583 rl = n->plugins; 4583 rl = n->plugins;
4584 while (rl != NULL) 4584 while (rl != NULL)
4585 { 4585 {
@@ -4587,11 +4587,11 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
4587 while (fal != NULL) 4587 while (fal != NULL)
4588 { 4588 {
4589 transmit_to_peer(NULL, fal, 4589 transmit_to_peer(NULL, fal,
4590 TRANSPORT_PONG_PRIORITY, 4590 TRANSPORT_PONG_PRIORITY,
4591 HELLO_VERIFICATION_TIMEOUT, 4591 HELLO_VERIFICATION_TIMEOUT,
4592 (const char *)pong, 4592 (const char *)pong,
4593 ntohs(pong->header.size), 4593 ntohs(pong->header.size),
4594 GNUNET_YES, 4594 GNUNET_YES,
4595 n); 4595 n);
4596 fal = fal->next; 4596 fal = fal->next;
4597 } 4597 }
@@ -4648,11 +4648,11 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4648 { 4648 {
4649 if ( (session != NULL) || 4649 if ( (session != NULL) ||
4650 (sender_address != NULL) ) 4650 (sender_address != NULL) )
4651 peer_address = add_peer_address (n, 4651 peer_address = add_peer_address (n,
4652 plugin->short_name, 4652 plugin->short_name,
4653 session, 4653 session,
4654 sender_address, 4654 sender_address,
4655 sender_address_len); 4655 sender_address_len);
4656 if (peer_address != NULL) 4656 if (peer_address != NULL)
4657 { 4657 {
4658 peer_address->distance = distance; 4658 peer_address->distance = distance;
@@ -4665,7 +4665,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4665 schedule_next_ping (peer_address); 4665 schedule_next_ping (peer_address);
4666 } 4666 }
4667 /* update traffic received amount ... */ 4667 /* update traffic received amount ... */
4668 msize = ntohs (message->size); 4668 msize = ntohs (message->size);
4669 GNUNET_STATISTICS_update (stats, 4669 GNUNET_STATISTICS_update (stats,
4670 gettext_noop ("# bytes received from other peers"), 4670 gettext_noop ("# bytes received from other peers"),
4671 msize, 4671 msize,
@@ -4686,7 +4686,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4686 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | 4686 GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
4687 GNUNET_ERROR_TYPE_BULK, 4687 GNUNET_ERROR_TYPE_BULK,
4688 _ 4688 _
4689 ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"), 4689 ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"),
4690 n->in_tracker.available_bytes_per_s__, 4690 n->in_tracker.available_bytes_per_s__,
4691 n->quota_violation_count); 4691 n->quota_violation_count);
4692 GNUNET_STATISTICS_update (stats, 4692 GNUNET_STATISTICS_update (stats,
@@ -4699,8 +4699,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4699#if DEBUG_PING_PONG 4699#if DEBUG_PING_PONG
4700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4701 "Received message of type %u and size %u from `%4s', sending to all clients.\n", 4701 "Received message of type %u and size %u from `%4s', sending to all clients.\n",
4702 ntohs (message->type), 4702 ntohs (message->type),
4703 ntohs (message->size), 4703 ntohs (message->size),
4704 GNUNET_i2s (peer)); 4704 GNUNET_i2s (peer));
4705#endif 4705#endif
4706 switch (ntohs (message->type)) 4706 switch (ntohs (message->type))
@@ -4722,7 +4722,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4722 handle_payload_message (message, n); 4722 handle_payload_message (message, n);
4723 break; 4723 break;
4724 } 4724 }
4725 } 4725 }
4726 ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); 4726 ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
4727 if (ret.value > 0) 4727 if (ret.value > 0)
4728 { 4728 {
@@ -4734,7 +4734,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4734 GNUNET_STATISTICS_update (stats, 4734 GNUNET_STATISTICS_update (stats,
4735 gettext_noop ("# ms throttling suggested"), 4735 gettext_noop ("# ms throttling suggested"),
4736 (int64_t) ret.value, 4736 (int64_t) ret.value,
4737 GNUNET_NO); 4737 GNUNET_NO);
4738 } 4738 }
4739 return ret; 4739 return ret;
4740} 4740}
@@ -4783,7 +4783,7 @@ handle_start (void *cls,
4783 _("Rejecting control connection from peer `%s', which is not me!\n"), 4783 _("Rejecting control connection from peer `%s', which is not me!\n"),
4784 GNUNET_i2s (&start->self)); 4784 GNUNET_i2s (&start->self));
4785 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 4785 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
4786 return; 4786 return;
4787 } 4787 }
4788 c = GNUNET_malloc (sizeof (struct TransportClient)); 4788 c = GNUNET_malloc (sizeof (struct TransportClient));
4789 c->next = clients; 4789 c->next = clients;
@@ -4801,7 +4801,7 @@ handle_start (void *cls,
4801 /* tell new client about all existing connections */ 4801 /* tell new client about all existing connections */
4802 cim.header.size = htons (sizeof (struct ConnectInfoMessage)); 4802 cim.header.size = htons (sizeof (struct ConnectInfoMessage));
4803 cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 4803 cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
4804 n = neighbours; 4804 n = neighbours;
4805 while (n != NULL) 4805 while (n != NULL)
4806 { 4806 {
4807 if (GNUNET_YES == n->received_pong) 4807 if (GNUNET_YES == n->received_pong)
@@ -4835,7 +4835,7 @@ handle_hello (void *cls,
4835 GNUNET_STATISTICS_update (stats, 4835 GNUNET_STATISTICS_update (stats,
4836 gettext_noop ("# HELLOs received from clients"), 4836 gettext_noop ("# HELLOs received from clients"),
4837 1, 4837 1,
4838 GNUNET_NO); 4838 GNUNET_NO);
4839 ret = process_hello (NULL, message); 4839 ret = process_hello (NULL, message);
4840 GNUNET_SERVER_receive_done (client, ret); 4840 GNUNET_SERVER_receive_done (client, ret);
4841} 4841}
@@ -4845,7 +4845,7 @@ handle_hello (void *cls,
4845 * Closure for 'transmit_client_message'; followed by 4845 * Closure for 'transmit_client_message'; followed by
4846 * 'msize' bytes of the actual message. 4846 * 'msize' bytes of the actual message.
4847 */ 4847 */
4848struct TransmitClientMessageContext 4848struct TransmitClientMessageContext
4849{ 4849{
4850 /** 4850 /**
4851 * Client on whom's behalf we are sending. 4851 * Client on whom's behalf we are sending.
@@ -4856,7 +4856,7 @@ struct TransmitClientMessageContext
4856 * Timeout for the transmission. 4856 * Timeout for the transmission.
4857 */ 4857 */
4858 struct GNUNET_TIME_Absolute timeout; 4858 struct GNUNET_TIME_Absolute timeout;
4859 4859
4860 /** 4860 /**
4861 * Message priority. 4861 * Message priority.
4862 */ 4862 */
@@ -4864,7 +4864,7 @@ struct TransmitClientMessageContext
4864 4864
4865 /** 4865 /**
4866 * Size of the message in bytes. 4866 * Size of the message in bytes.
4867 */ 4867 */
4868 uint16_t msize; 4868 uint16_t msize;
4869}; 4869};
4870 4870
@@ -4888,7 +4888,7 @@ transmit_client_message (void *cls,
4888 4888
4889 if (n != NULL) 4889 if (n != NULL)
4890 { 4890 {
4891 transmit_to_peer (tc, NULL, tcmc->priority, 4891 transmit_to_peer (tc, NULL, tcmc->priority,
4892 GNUNET_TIME_absolute_get_remaining (tcmc->timeout), 4892 GNUNET_TIME_absolute_get_remaining (tcmc->timeout),
4893 (char *)&tcmc[1], 4893 (char *)&tcmc[1],
4894 tcmc->msize, GNUNET_NO, n); 4894 tcmc->msize, GNUNET_NO, n);
@@ -4928,7 +4928,7 @@ handle_send (void *cls,
4928 GNUNET_STATISTICS_update (stats, 4928 GNUNET_STATISTICS_update (stats,
4929 gettext_noop ("# payload received for other peers"), 4929 gettext_noop ("# payload received for other peers"),
4930 size, 4930 size,
4931 GNUNET_NO); 4931 GNUNET_NO);
4932 obm = (const struct OutboundMessage *) message; 4932 obm = (const struct OutboundMessage *) message;
4933 obmm = (const struct GNUNET_MessageHeader *) &obm[1]; 4933 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
4934 msize = size - sizeof (struct OutboundMessage); 4934 msize = size - sizeof (struct OutboundMessage);
@@ -4968,11 +4968,11 @@ handle_set_quota (void *cls,
4968 const struct QuotaSetMessage *qsm = 4968 const struct QuotaSetMessage *qsm =
4969 (const struct QuotaSetMessage *) message; 4969 (const struct QuotaSetMessage *) message;
4970 struct NeighbourList *n; 4970 struct NeighbourList *n;
4971 4971
4972 GNUNET_STATISTICS_update (stats, 4972 GNUNET_STATISTICS_update (stats,
4973 gettext_noop ("# SET QUOTA messages received"), 4973 gettext_noop ("# SET QUOTA messages received"),
4974 1, 4974 1,
4975 GNUNET_NO); 4975 GNUNET_NO);
4976 n = find_neighbour (&qsm->peer); 4976 n = find_neighbour (&qsm->peer);
4977 if (n == NULL) 4977 if (n == NULL)
4978 { 4978 {
@@ -4980,20 +4980,20 @@ handle_set_quota (void *cls,
4980 GNUNET_STATISTICS_update (stats, 4980 GNUNET_STATISTICS_update (stats,
4981 gettext_noop ("# SET QUOTA messages ignored (no such peer)"), 4981 gettext_noop ("# SET QUOTA messages ignored (no such peer)"),
4982 1, 4982 1,
4983 GNUNET_NO); 4983 GNUNET_NO);
4984 return; 4984 return;
4985 } 4985 }
4986#if DEBUG_TRANSPORT 4986#if DEBUG_TRANSPORT
4987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4988 "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n", 4988 "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n",
4989 "SET_QUOTA", 4989 "SET_QUOTA",
4990 (unsigned int) ntohl (qsm->quota.value__), 4990 (unsigned int) ntohl (qsm->quota.value__),
4991 (unsigned int) n->in_tracker.available_bytes_per_s__, 4991 (unsigned int) n->in_tracker.available_bytes_per_s__,
4992 GNUNET_i2s (&qsm->peer)); 4992 GNUNET_i2s (&qsm->peer));
4993#endif 4993#endif
4994 GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, 4994 GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker,
4995 qsm->quota); 4995 qsm->quota);
4996 if (0 == ntohl (qsm->quota.value__)) 4996 if (0 == ntohl (qsm->quota.value__))
4997 { 4997 {
4998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4999 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id), 4999 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id),
@@ -5007,7 +5007,7 @@ handle_set_quota (void *cls,
5007/** 5007/**
5008 * Take the given address and append it to the set of results sent back to 5008 * Take the given address and append it to the set of results sent back to
5009 * the client. 5009 * the client.
5010 * 5010 *
5011 * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*') 5011 * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
5012 * @param address the resolved name, NULL to indicate the last response 5012 * @param address the resolved name, NULL to indicate the last response
5013 */ 5013 */
@@ -5090,7 +5090,7 @@ handle_address_lookup (void *cls,
5090 tc = GNUNET_SERVER_transmit_context_create (client); 5090 tc = GNUNET_SERVER_transmit_context_create (client);
5091 lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, 5091 lsPlugin->api->address_pretty_printer (lsPlugin->api->cls,
5092 nameTransport, 5092 nameTransport,
5093 address, addressLen, 5093 address, addressLen,
5094 numeric, 5094 numeric,
5095 rtimeout, 5095 rtimeout,
5096 &transmit_address_to_client, tc); 5096 &transmit_address_to_client, tc);
@@ -5120,7 +5120,7 @@ create_environment (struct TransportPlugin *plug)
5120 * Start the specified transport (load the plugin). 5120 * Start the specified transport (load the plugin).
5121 */ 5121 */
5122static void 5122static void
5123start_transport (struct GNUNET_SERVER_Handle *server, 5123start_transport (struct GNUNET_SERVER_Handle *server,
5124 const char *name) 5124 const char *name)
5125{ 5125{
5126 struct TransportPlugin *plug; 5126 struct TransportPlugin *plug;
@@ -5186,7 +5186,7 @@ client_disconnect_notification (void *cls,
5186 if (bc->th != NULL) 5186 if (bc->th != NULL)
5187 { 5187 {
5188 GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th); 5188 GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th);
5189 bc->th = NULL; 5189 bc->th = NULL;
5190 } 5190 }
5191 if (bc->task == GNUNET_SCHEDULER_NO_TASK) 5191 if (bc->task == GNUNET_SCHEDULER_NO_TASK)
5192 bc->task = GNUNET_SCHEDULER_add_now (sched, 5192 bc->task = GNUNET_SCHEDULER_add_now (sched,
@@ -5272,7 +5272,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5272 plugins = plug->next; 5272 plugins = plug->next;
5273 if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK) 5273 if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK)
5274 { 5274 {
5275 GNUNET_SCHEDULER_cancel (plug->env.sched, 5275 GNUNET_SCHEDULER_cancel (plug->env.sched,
5276 plug->address_update_task); 5276 plug->address_update_task);
5277 plug->address_update_task = GNUNET_SCHEDULER_NO_TASK; 5277 plug->address_update_task = GNUNET_SCHEDULER_NO_TASK;
5278 } 5278 }
@@ -5403,7 +5403,7 @@ run (void *cls,
5403 if (peerinfo == NULL) 5403 if (peerinfo == NULL)
5404 { 5404 {
5405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 5405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5406 _("Could not access PEERINFO service. Exiting.\n")); 5406 _("Could not access PEERINFO service. Exiting.\n"));
5407 GNUNET_SCHEDULER_shutdown (s); 5407 GNUNET_SCHEDULER_shutdown (s);
5408 if (stats != NULL) 5408 if (stats != NULL)
5409 { 5409 {
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 47bea007e..152dbd801 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -21,13 +21,13 @@
21/** 21/**
22 * @file src/transport/gnunet-wlan.c 22 * @file src/transport/gnunet-wlan.c
23 * @brief wlan layer two server; must run as root (SUID will do) 23 * @brief wlan layer two server; must run as root (SUID will do)
24 * This code will work under GNU/Linux only. 24 * This code will work under GNU/Linux only.
25 * @author David Brodski 25 * @author David Brodski
26 * 26 *
27 * This program serves as the mediator between the wlan interface and 27 * This program serves as the mediator between the wlan interface and
28 * gnunet 28 * gnunet
29 */ 29 */
30 30
31#include "gnunet-transport-wlan-helper.h" 31#include "gnunet-transport-wlan-helper.h"
32#include <pcap/pcap.h> 32#include <pcap/pcap.h>
33 33
diff --git a/src/transport/plugin_transport_https.c b/src/transport/plugin_transport_https.c
index 1d90c77f1..ab39eb046 100644
--- a/src/transport/plugin_transport_https.c
+++ b/src/transport/plugin_transport_https.c
@@ -370,7 +370,7 @@ struct Plugin
370 370
371 /* The private key MHD uses as an \0 terminated string */ 371 /* The private key MHD uses as an \0 terminated string */
372 char * key; 372 char * key;
373 373
374 char * crypto_init; 374 char * crypto_init;
375}; 375};
376 376
@@ -2462,7 +2462,7 @@ libgnunet_plugin_transport_https_init (void *cls)
2462 plugin->bind4_address = NULL; 2462 plugin->bind4_address = NULL;
2463 } 2463 }
2464 } 2464 }
2465 2465
2466 /* Get crypto init string from config */ 2466 /* Get crypto init string from config */
2467 if (GNUNET_CONFIGURATION_have_value (env->cfg, 2467 if (GNUNET_CONFIGURATION_have_value (env->cfg,
2468 "transport-https", "CRYPTO_INIT")) 2468 "transport-https", "CRYPTO_INIT"))
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index f38c08c65..d382b5108 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -155,7 +155,7 @@ struct Plugin;
155 */ 155 */
156struct LocalAddrList 156struct LocalAddrList
157{ 157{
158 158
159 /** 159 /**
160 * This is a doubly linked list. 160 * This is a doubly linked list.
161 */ 161 */
@@ -393,10 +393,10 @@ struct Plugin
393 * List of our IP addresses. 393 * List of our IP addresses.
394 */ 394 */
395 struct LocalAddrList *lal_head; 395 struct LocalAddrList *lal_head;
396 396
397 /** 397 /**
398 * Tail of our IP address list. 398 * Tail of our IP address list.
399 */ 399 */
400 struct LocalAddrList *lal_tail; 400 struct LocalAddrList *lal_tail;
401 401
402 /** 402 /**
@@ -480,16 +480,16 @@ check_local_addr (struct Plugin *plugin,
480 480
481/** 481/**
482 * Function called for a quick conversion of the binary address to 482 * Function called for a quick conversion of the binary address to
483 * a numeric address. Note that the caller must not free the 483 * a numeric address. Note that the caller must not free the
484 * address and that the next call to this function is allowed 484 * address and that the next call to this function is allowed
485 * to override the address again. 485 * to override the address again.
486 * 486 *
487 * @param cls closure ('struct Plugin*') 487 * @param cls closure ('struct Plugin*')
488 * @param addr binary address 488 * @param addr binary address
489 * @param addrlen length of the address 489 * @param addrlen length of the address
490 * @return string representing the same address 490 * @return string representing the same address
491 */ 491 */
492static const char* 492static const char*
493tcp_address_to_string (void *cls, 493tcp_address_to_string (void *cls,
494 const void *addr, 494 const void *addr,
495 size_t addrlen) 495 size_t addrlen)
@@ -611,7 +611,7 @@ create_session (struct Plugin *plugin,
611 GNUNET_STATISTICS_update (plugin->env->stats, 611 GNUNET_STATISTICS_update (plugin->env->stats,
612 gettext_noop ("# bytes currently in TCP buffers"), 612 gettext_noop ("# bytes currently in TCP buffers"),
613 pm->message_size, 613 pm->message_size,
614 GNUNET_NO); 614 GNUNET_NO);
615 GNUNET_CONTAINER_DLL_insert (ret->pending_messages_head, 615 GNUNET_CONTAINER_DLL_insert (ret->pending_messages_head,
616 ret->pending_messages_tail, 616 ret->pending_messages_tail,
617 pm); 617 pm);
@@ -689,7 +689,7 @@ do_transmit (void *cls, size_t size, void *buf)
689 /* do this call before callbacks (so that if callbacks destroy 689 /* do this call before callbacks (so that if callbacks destroy
690 session, they have a chance to cancel actions done by this 690 session, they have a chance to cancel actions done by this
691 call) */ 691 call) */
692 process_pending_messages (session); 692 process_pending_messages (session);
693 pid = session->target; 693 pid = session->target;
694 /* no do callbacks and do not use session again since 694 /* no do callbacks and do not use session again since
695 the callbacks may abort the session */ 695 the callbacks may abort the session */
@@ -704,11 +704,11 @@ do_transmit (void *cls, size_t size, void *buf)
704 GNUNET_STATISTICS_update (plugin->env->stats, 704 GNUNET_STATISTICS_update (plugin->env->stats,
705 gettext_noop ("# bytes currently in TCP buffers"), 705 gettext_noop ("# bytes currently in TCP buffers"),
706 - (int64_t) ret, 706 - (int64_t) ret,
707 GNUNET_NO); 707 GNUNET_NO);
708 GNUNET_STATISTICS_update (plugin->env->stats, 708 GNUNET_STATISTICS_update (plugin->env->stats,
709 gettext_noop ("# bytes discarded by TCP (timeout)"), 709 gettext_noop ("# bytes discarded by TCP (timeout)"),
710 ret, 710 ret,
711 GNUNET_NO); 711 GNUNET_NO);
712 return 0; 712 return 0;
713 } 713 }
714 /* copy all pending messages that would fit */ 714 /* copy all pending messages that would fit */
@@ -716,9 +716,9 @@ do_transmit (void *cls, size_t size, void *buf)
716 cbuf = buf; 716 cbuf = buf;
717 hd = NULL; 717 hd = NULL;
718 tl = NULL; 718 tl = NULL;
719 while (NULL != (pos = session->pending_messages_head)) 719 while (NULL != (pos = session->pending_messages_head))
720 { 720 {
721 if (ret + pos->message_size > size) 721 if (ret + pos->message_size > size)
722 break; 722 break;
723 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, 723 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
724 session->pending_messages_tail, 724 session->pending_messages_tail,
@@ -734,7 +734,7 @@ do_transmit (void *cls, size_t size, void *buf)
734 /* schedule 'continuation' before callbacks so that callbacks that 734 /* schedule 'continuation' before callbacks so that callbacks that
735 cancel everything don't cause us to use a session that no longer 735 cancel everything don't cause us to use a session that no longer
736 exists... */ 736 exists... */
737 process_pending_messages (session); 737 process_pending_messages (session);
738 session->last_activity = GNUNET_TIME_absolute_get (); 738 session->last_activity = GNUNET_TIME_absolute_get ();
739 pid = session->target; 739 pid = session->target;
740 /* we'll now call callbacks that may cancel the session; hence 740 /* we'll now call callbacks that may cancel the session; hence
@@ -756,11 +756,11 @@ do_transmit (void *cls, size_t size, void *buf)
756 GNUNET_STATISTICS_update (plugin->env->stats, 756 GNUNET_STATISTICS_update (plugin->env->stats,
757 gettext_noop ("# bytes currently in TCP buffers"), 757 gettext_noop ("# bytes currently in TCP buffers"),
758 - (int64_t) ret, 758 - (int64_t) ret,
759 GNUNET_NO); 759 GNUNET_NO);
760 GNUNET_STATISTICS_update (plugin->env->stats, 760 GNUNET_STATISTICS_update (plugin->env->stats,
761 gettext_noop ("# bytes transmitted via TCP"), 761 gettext_noop ("# bytes transmitted via TCP"),
762 ret, 762 ret,
763 GNUNET_NO); 763 GNUNET_NO);
764 return ret; 764 return ret;
765} 765}
766 766
@@ -812,7 +812,7 @@ disconnect_session (struct Session *session)
812 (session->connect_addr != NULL) ? 812 (session->connect_addr != NULL) ?
813 tcp_address_to_string (session->plugin, 813 tcp_address_to_string (session->plugin,
814 session->connect_addr, 814 session->connect_addr,
815 session->connect_alen) : "*", 815 session->connect_alen) : "*",
816 session); 816 session);
817#endif 817#endif
818 /* remove from session list */ 818 /* remove from session list */
@@ -851,11 +851,11 @@ disconnect_session (struct Session *session)
851 GNUNET_STATISTICS_update (session->plugin->env->stats, 851 GNUNET_STATISTICS_update (session->plugin->env->stats,
852 gettext_noop ("# bytes currently in TCP buffers"), 852 gettext_noop ("# bytes currently in TCP buffers"),
853 - (int64_t) pm->message_size, 853 - (int64_t) pm->message_size,
854 GNUNET_NO); 854 GNUNET_NO);
855 GNUNET_STATISTICS_update (session->plugin->env->stats, 855 GNUNET_STATISTICS_update (session->plugin->env->stats,
856 gettext_noop ("# bytes discarded by TCP (disconnect)"), 856 gettext_noop ("# bytes discarded by TCP (disconnect)"),
857 pm->message_size, 857 pm->message_size,
858 GNUNET_NO); 858 GNUNET_NO);
859 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, 859 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
860 session->pending_messages_tail, 860 session->pending_messages_tail,
861 pm); 861 pm);
@@ -870,15 +870,15 @@ disconnect_session (struct Session *session)
870 GNUNET_SCHEDULER_cancel (session->plugin->env->sched, 870 GNUNET_SCHEDULER_cancel (session->plugin->env->sched,
871 session->receive_delay_task); 871 session->receive_delay_task);
872 if (session->client != NULL) 872 if (session->client != NULL)
873 GNUNET_SERVER_receive_done (session->client, 873 GNUNET_SERVER_receive_done (session->client,
874 GNUNET_SYSERR); 874 GNUNET_SYSERR);
875 } 875 }
876 if (session->client != NULL) 876 if (session->client != NULL)
877 GNUNET_SERVER_client_drop (session->client); 877 GNUNET_SERVER_client_drop (session->client);
878 GNUNET_STATISTICS_update (session->plugin->env->stats, 878 GNUNET_STATISTICS_update (session->plugin->env->stats,
879 gettext_noop ("# TCP sessions active"), 879 gettext_noop ("# TCP sessions active"),
880 -1, 880 -1,
881 GNUNET_NO); 881 GNUNET_NO);
882 GNUNET_free_non_null (session->connect_addr); 882 GNUNET_free_non_null (session->connect_addr);
883 GNUNET_free (session); 883 GNUNET_free (session);
884} 884}
@@ -886,7 +886,7 @@ disconnect_session (struct Session *session)
886 886
887/** 887/**
888 * Given two otherwise equivalent sessions, pick the better one. 888 * Given two otherwise equivalent sessions, pick the better one.
889 * 889 *
890 * @param s1 one session (also default) 890 * @param s1 one session (also default)
891 * @param s2 other session 891 * @param s2 other session
892 * @return "better" session (more active) 892 * @return "better" session (more active)
@@ -1043,7 +1043,7 @@ tcp_plugin_send (void *cls,
1043 GNUNET_STATISTICS_update (plugin->env->stats, 1043 GNUNET_STATISTICS_update (plugin->env->stats,
1044 gettext_noop ("# bytes TCP was asked to transmit"), 1044 gettext_noop ("# bytes TCP was asked to transmit"),
1045 msgbuf_size, 1045 msgbuf_size,
1046 GNUNET_NO); 1046 GNUNET_NO);
1047 /* FIXME: we could do this cheaper with a hash table 1047 /* FIXME: we could do this cheaper with a hash table
1048 where we could restrict the iteration to entries that match 1048 where we could restrict the iteration to entries that match
1049 the target peer... */ 1049 the target peer... */
@@ -1052,17 +1052,17 @@ tcp_plugin_send (void *cls,
1052 { 1052 {
1053 cand_session = NULL; 1053 cand_session = NULL;
1054 next = plugin->sessions; 1054 next = plugin->sessions;
1055 while (NULL != (session = next)) 1055 while (NULL != (session = next))
1056 { 1056 {
1057 next = session->next; 1057 next = session->next;
1058 GNUNET_assert (session->client != NULL); 1058 GNUNET_assert (session->client != NULL);
1059 if (0 != memcmp (target, 1059 if (0 != memcmp (target,
1060 &session->target, 1060 &session->target,
1061 sizeof (struct GNUNET_PeerIdentity))) 1061 sizeof (struct GNUNET_PeerIdentity)))
1062 continue; 1062 continue;
1063 if ( ( (GNUNET_SYSERR == force_address) && 1063 if ( ( (GNUNET_SYSERR == force_address) &&
1064 (session->expecting_welcome == GNUNET_NO) ) || 1064 (session->expecting_welcome == GNUNET_NO) ) ||
1065 (GNUNET_NO == force_address) ) 1065 (GNUNET_NO == force_address) )
1066 { 1066 {
1067 cand_session = select_better_session (cand_session, 1067 cand_session = select_better_session (cand_session,
1068 session); 1068 session);
@@ -1076,7 +1076,7 @@ tcp_plugin_send (void *cls,
1076 GNUNET_break (0); 1076 GNUNET_break (0);
1077 break; 1077 break;
1078 } 1078 }
1079 if (session->inbound == GNUNET_YES) 1079 if (session->inbound == GNUNET_YES)
1080 continue; 1080 continue;
1081 if (addrlen != session->connect_alen) 1081 if (addrlen != session->connect_alen)
1082 continue; 1082 continue;
@@ -1085,7 +1085,7 @@ tcp_plugin_send (void *cls,
1085 addrlen)) 1085 addrlen))
1086 continue; 1086 continue;
1087 cand_session = select_better_session (cand_session, 1087 cand_session = select_better_session (cand_session,
1088 session); 1088 session);
1089 } 1089 }
1090 session = cand_session; 1090 session = cand_session;
1091 } 1091 }
@@ -1100,7 +1100,7 @@ tcp_plugin_send (void *cls,
1100 GNUNET_STATISTICS_update (plugin->env->stats, 1100 GNUNET_STATISTICS_update (plugin->env->stats,
1101 gettext_noop ("# bytes discarded by TCP (no address and no connection)"), 1101 gettext_noop ("# bytes discarded by TCP (no address and no connection)"),
1102 msgbuf_size, 1102 msgbuf_size,
1103 GNUNET_NO); 1103 GNUNET_NO);
1104 return -1; 1104 return -1;
1105 } 1105 }
1106 if (session == NULL) 1106 if (session == NULL)
@@ -1119,7 +1119,7 @@ tcp_plugin_send (void *cls,
1119 is_natd = GNUNET_YES; 1119 is_natd = GNUNET_YES;
1120 memcpy (&a6.sin6_addr, 1120 memcpy (&a6.sin6_addr,
1121 &t6->ipv6_addr, 1121 &t6->ipv6_addr,
1122 sizeof (struct in6_addr)); 1122 sizeof (struct in6_addr));
1123 sb = &a6; 1123 sb = &a6;
1124 sbs = sizeof (a6); 1124 sbs = sizeof (a6);
1125 } 1125 }
@@ -1167,8 +1167,8 @@ tcp_plugin_send (void *cls,
1167 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size); 1167 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
1168 /* FIXME: the memset of this malloc can be up to 2% of our total runtime */ 1168 /* FIXME: the memset of this malloc can be up to 2% of our total runtime */
1169 pm->msg = (const char*) &pm[1]; 1169 pm->msg = (const char*) &pm[1];
1170 memcpy (&pm[1], msg, msgbuf_size); 1170 memcpy (&pm[1], msg, msgbuf_size);
1171 /* FIXME: this memcpy can be up to 7% of our total run-time 1171 /* FIXME: this memcpy can be up to 7% of our total run-time
1172 (for transport service) */ 1172 (for transport service) */
1173 pm->message_size = msgbuf_size; 1173 pm->message_size = msgbuf_size;
1174 pm->timeout = GNUNET_TIME_relative_to_absolute (timeout); 1174 pm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
@@ -1209,7 +1209,7 @@ tcp_plugin_send (void *cls,
1209 GNUNET_STATISTICS_update (plugin->env->stats, 1209 GNUNET_STATISTICS_update (plugin->env->stats,
1210 gettext_noop ("# bytes discarded by TCP (failed to connect)"), 1210 gettext_noop ("# bytes discarded by TCP (failed to connect)"),
1211 msgbuf_size, 1211 msgbuf_size,
1212 GNUNET_NO); 1212 GNUNET_NO);
1213 return -1; 1213 return -1;
1214 } 1214 }
1215#if DEBUG_TCP 1215#if DEBUG_TCP
@@ -1233,7 +1233,7 @@ tcp_plugin_send (void *cls,
1233 GNUNET_STATISTICS_update (plugin->env->stats, 1233 GNUNET_STATISTICS_update (plugin->env->stats,
1234 gettext_noop ("# bytes currently in TCP buffers"), 1234 gettext_noop ("# bytes currently in TCP buffers"),
1235 msgbuf_size, 1235 msgbuf_size,
1236 GNUNET_NO); 1236 GNUNET_NO);
1237 /* create new message entry */ 1237 /* create new message entry */
1238 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size); 1238 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
1239 pm->msg = (const char*) &pm[1]; 1239 pm->msg = (const char*) &pm[1];
@@ -1397,7 +1397,7 @@ tcp_plugin_address_pretty_printer (void *cls,
1397 a6.sin6_port = t6->t6_port; 1397 a6.sin6_port = t6->t6_port;
1398 memcpy (&a6.sin6_addr, 1398 memcpy (&a6.sin6_addr,
1399 &t6->ipv6_addr, 1399 &t6->ipv6_addr,
1400 sizeof (struct in6_addr)); 1400 sizeof (struct in6_addr));
1401 port = ntohs (t6->t6_port); 1401 port = ntohs (t6->t6_port);
1402 sb = &a6; 1402 sb = &a6;
1403 sbs = sizeof (a6); 1403 sbs = sizeof (a6);
@@ -1457,7 +1457,7 @@ check_port (struct Plugin *plugin, uint16_t in_port)
1457} 1457}
1458 1458
1459 1459
1460/** 1460/**
1461 * Function that will be called to check if a binary address for this 1461 * Function that will be called to check if a binary address for this
1462 * plugin is well-formed and corresponds to an address for THIS peer 1462 * plugin is well-formed and corresponds to an address for THIS peer
1463 * (as per our configuration). Naturally, if absolutely necessary, 1463 * (as per our configuration). Naturally, if absolutely necessary,
@@ -1473,8 +1473,8 @@ check_port (struct Plugin *plugin, uint16_t in_port)
1473 * and transport, GNUNET_SYSERR if not 1473 * and transport, GNUNET_SYSERR if not
1474 */ 1474 */
1475static int 1475static int
1476tcp_plugin_check_address (void *cls, 1476tcp_plugin_check_address (void *cls,
1477 const void *addr, 1477 const void *addr,
1478 size_t addrlen) 1478 size_t addrlen)
1479{ 1479{
1480 struct Plugin *plugin = cls; 1480 struct Plugin *plugin = cls;
@@ -1507,7 +1507,7 @@ tcp_plugin_check_address (void *cls,
1507 GNUNET_break_op (0); 1507 GNUNET_break_op (0);
1508 return GNUNET_SYSERR; 1508 return GNUNET_SYSERR;
1509 } 1509 }
1510 if (GNUNET_OK != 1510 if (GNUNET_OK !=
1511 check_port (plugin, ntohs (v6->t6_port))) 1511 check_port (plugin, ntohs (v6->t6_port)))
1512 return GNUNET_SYSERR; 1512 return GNUNET_SYSERR;
1513 if (GNUNET_OK != 1513 if (GNUNET_OK !=
@@ -1661,14 +1661,14 @@ handle_tcp_welcome (void *cls,
1661 1661
1662#if DEBUG_TCP 1662#if DEBUG_TCP
1663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1664 "Received %s message from a `%4s/%p'.\n", 1664 "Received %s message from a `%4s/%p'.\n",
1665 "WELCOME", 1665 "WELCOME",
1666 GNUNET_i2s (&wm->clientIdentity), client); 1666 GNUNET_i2s (&wm->clientIdentity), client);
1667#endif 1667#endif
1668 GNUNET_STATISTICS_update (plugin->env->stats, 1668 GNUNET_STATISTICS_update (plugin->env->stats,
1669 gettext_noop ("# TCP WELCOME messages received"), 1669 gettext_noop ("# TCP WELCOME messages received"),
1670 1, 1670 1,
1671 GNUNET_NO); 1671 GNUNET_NO);
1672 session = find_session_by_client (plugin, client); 1672 session = find_session_by_client (plugin, client);
1673 if (session == NULL) 1673 if (session == NULL)
1674 { 1674 {
@@ -1749,13 +1749,13 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1749 session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; 1749 session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK;
1750 delay = session->plugin->env->receive (session->plugin->env->cls, 1750 delay = session->plugin->env->receive (session->plugin->env->cls,
1751 &session->target, 1751 &session->target,
1752 NULL, 0, 1752 NULL, 0,
1753 session, 1753 session,
1754 NULL, 0); 1754 NULL, 0);
1755 if (delay.value == 0) 1755 if (delay.value == 0)
1756 GNUNET_SERVER_receive_done (session->client, GNUNET_OK); 1756 GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
1757 else 1757 else
1758 session->receive_delay_task = 1758 session->receive_delay_task =
1759 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, 1759 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
1760 delay, &delayed_done, session); 1760 delay, &delayed_done, session);
1761} 1761}
@@ -1782,8 +1782,8 @@ handle_tcp_data (void *cls,
1782 { 1782 {
1783 /* We don't want to propagate WELCOME and NAT Probe messages up! */ 1783 /* We don't want to propagate WELCOME and NAT Probe messages up! */
1784 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1784 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1785 return; 1785 return;
1786 } 1786 }
1787 session = find_session_by_client (plugin, client); 1787 session = find_session_by_client (plugin, client);
1788 if ( (NULL == session) || (GNUNET_YES == session->expecting_welcome)) 1788 if ( (NULL == session) || (GNUNET_YES == session->expecting_welcome))
1789 { 1789 {
@@ -1794,22 +1794,22 @@ handle_tcp_data (void *cls,
1794#if DEBUG_TCP 1794#if DEBUG_TCP
1795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1796 "Passing %u bytes of type %u from `%4s' to transport service.\n", 1796 "Passing %u bytes of type %u from `%4s' to transport service.\n",
1797 (unsigned int) ntohs (message->size), 1797 (unsigned int) ntohs (message->size),
1798 (unsigned int) ntohs (message->type), 1798 (unsigned int) ntohs (message->type),
1799 GNUNET_i2s (&session->target)); 1799 GNUNET_i2s (&session->target));
1800#endif 1800#endif
1801 GNUNET_STATISTICS_update (plugin->env->stats, 1801 GNUNET_STATISTICS_update (plugin->env->stats,
1802 gettext_noop ("# bytes received via TCP"), 1802 gettext_noop ("# bytes received via TCP"),
1803 ntohs (message->size), 1803 ntohs (message->size),
1804 GNUNET_NO); 1804 GNUNET_NO);
1805 delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1, 1805 delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1,
1806 session, 1806 session,
1807 (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, 1807 (GNUNET_YES == session->inbound) ? NULL : session->connect_addr,
1808 (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); 1808 (GNUNET_YES == session->inbound) ? 0 : session->connect_alen);
1809 if (delay.value == 0) 1809 if (delay.value == 0)
1810 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1810 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1811 else 1811 else
1812 session->receive_delay_task = 1812 session->receive_delay_task =
1813 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, 1813 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
1814 delay, &delayed_done, session); 1814 delay, &delayed_done, session);
1815} 1815}
@@ -1823,7 +1823,7 @@ handle_tcp_data (void *cls,
1823 * @param client identification of the client 1823 * @param client identification of the client
1824 */ 1824 */
1825static void 1825static void
1826disconnect_notify (void *cls, 1826disconnect_notify (void *cls,
1827 struct GNUNET_SERVER_Client *client) 1827 struct GNUNET_SERVER_Client *client)
1828{ 1828{
1829 struct Plugin *plugin = cls; 1829 struct Plugin *plugin = cls;
@@ -2445,7 +2445,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2445 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2445 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2446 _("TCP transport advertises itself as being on port %llu\n"), 2446 _("TCP transport advertises itself as being on port %llu\n"),
2447 aport); 2447 aport);
2448 GNUNET_SERVER_disconnect_notify (plugin->server, 2448 GNUNET_SERVER_disconnect_notify (plugin->server,
2449 &disconnect_notify, 2449 &disconnect_notify,
2450 plugin); 2450 plugin);
2451 GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-tcp", "BINDTO", &plugin->bind_address); 2451 GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-tcp", "BINDTO", &plugin->bind_address);
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c
index f6a02fe87..6a9b8612b 100644
--- a/src/transport/plugin_transport_template.c
+++ b/src/transport/plugin_transport_template.c
@@ -133,7 +133,7 @@ struct Plugin
133 * @param priority how important is the message 133 * @param priority how important is the message
134 * @param msgbuf the message to transmit 134 * @param msgbuf the message to transmit
135 * @param msgbuf_size number of bytes in 'msgbuf' 135 * @param msgbuf_size number of bytes in 'msgbuf'
136 * @param timeout when should we time out 136 * @param timeout when should we time out
137 * @param session which session must be used (or NULL for "any") 137 * @param session which session must be used (or NULL for "any")
138 * @param addr the address to use (can be NULL if the plugin 138 * @param addr the address to use (can be NULL if the plugin
139 * is "on its own" (i.e. re-use existing TCP connection)) 139 * is "on its own" (i.e. re-use existing TCP connection))
@@ -245,16 +245,16 @@ template_plugin_address_suggested (void *cls,
245 245
246/** 246/**
247 * Function called for a quick conversion of the binary address to 247 * Function called for a quick conversion of the binary address to
248 * a numeric address. Note that the caller must not free the 248 * a numeric address. Note that the caller must not free the
249 * address and that the next call to this function is allowed 249 * address and that the next call to this function is allowed
250 * to override the address again. 250 * to override the address again.
251 * 251 *
252 * @param cls closure 252 * @param cls closure
253 * @param addr binary address 253 * @param addr binary address
254 * @param addrlen length of the address 254 * @param addrlen length of the address
255 * @return string representing the same address 255 * @return string representing the same address
256 */ 256 */
257static const char* 257static const char*
258template_plugin_address_to_string (void *cls, 258template_plugin_address_to_string (void *cls,
259 const void *addr, 259 const void *addr,
260 size_t addrlen) 260 size_t addrlen)
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 791272e19..f8c68244a 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -217,7 +217,7 @@ struct UDP_NAT_ProbeMessageConfirmation
217 */ 217 */
218struct LocalAddrList 218struct LocalAddrList
219{ 219{
220 220
221 /** 221 /**
222 * This is a doubly linked list. 222 * This is a doubly linked list.
223 */ 223 */
@@ -334,12 +334,12 @@ struct UDP_NAT_Probes
334struct UDP_Sock_Info 334struct UDP_Sock_Info
335{ 335{
336 /** 336 /**
337 * The network handle 337 * The network handle
338 */ 338 */
339 struct GNUNET_NETWORK_Handle *desc; 339 struct GNUNET_NETWORK_Handle *desc;
340 340
341 /** 341 /**
342 * The port we bound to 342 * The port we bound to
343 */ 343 */
344 uint16_t port; 344 uint16_t port;
345}; 345};
@@ -410,10 +410,10 @@ struct Plugin
410 * List of our IP addresses. 410 * List of our IP addresses.
411 */ 411 */
412 struct LocalAddrList *lal_head; 412 struct LocalAddrList *lal_head;
413 413
414 /** 414 /**
415 * Tail of our IP address list. 415 * Tail of our IP address list.
416 */ 416 */
417 struct LocalAddrList *lal_tail; 417 struct LocalAddrList *lal_tail;
418 418
419 /** 419 /**
@@ -537,7 +537,7 @@ udp_transport_server_stop (void *cls)
537 537
538 538
539struct PeerSession * 539struct PeerSession *
540find_session (struct Plugin *plugin, 540find_session (struct Plugin *plugin,
541 const struct GNUNET_PeerIdentity *peer) 541 const struct GNUNET_PeerIdentity *peer)
542{ 542{
543 struct PeerSession *pos; 543 struct PeerSession *pos;
@@ -669,7 +669,7 @@ udp_real_send (void *cls,
669 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 669 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
670 "UDP transmit %u-byte message to %s (%d: %s)\n", 670 "UDP transmit %u-byte message to %s (%d: %s)\n",
671 (unsigned int) ssize, 671 (unsigned int) ssize,
672 GNUNET_a2s (sb, sbs), 672 GNUNET_a2s (sb, sbs),
673 (int) sent, 673 (int) sent,
674 (sent < 0) ? STRERROR (errno) : "ok"); 674 (sent < 0) ? STRERROR (errno) : "ok");
675 if (cont != NULL) 675 if (cont != NULL)
@@ -833,7 +833,7 @@ udp_plugin_send (void *cls,
833 target, 833 target,
834 msgbuf, msgbuf_size, 834 msgbuf, msgbuf_size,
835 priority, timeout, 835 priority, timeout,
836 peer_session->connect_addr, peer_session->connect_alen, 836 peer_session->connect_addr, peer_session->connect_alen,
837 cont, cont_cls); 837 cont, cont_cls);
838 } 838 }
839 else /* Haven't gotten a response from this peer, queue message */ 839 else /* Haven't gotten a response from this peer, queue message */
@@ -852,11 +852,11 @@ udp_plugin_send (void *cls,
852 } 852 }
853 else if (other_peer_natd == GNUNET_NO) /* Other peer not behind a NAT, so we can just send the message as is */ 853 else if (other_peer_natd == GNUNET_NO) /* Other peer not behind a NAT, so we can just send the message as is */
854 { 854 {
855 sent = udp_real_send(cls, 855 sent = udp_real_send(cls,
856 (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc, 856 (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc,
857 target, 857 target,
858 msgbuf, msgbuf_size, 858 msgbuf, msgbuf_size,
859 priority, timeout, addr, addrlen, 859 priority, timeout, addr, addrlen,
860 cont, cont_cls); 860 cont, cont_cls);
861 } 861 }
862 else /* Other peer is NAT'd, but we don't want to play with them (or can't!) */ 862 else /* Other peer is NAT'd, but we don't want to play with them (or can't!) */
@@ -1008,12 +1008,12 @@ process_interfaces (void *cls,
1008 GNUNET_break (0); 1008 GNUNET_break (0);
1009 return GNUNET_OK; 1009 return GNUNET_OK;
1010 } 1010 }
1011 1011
1012 GNUNET_log (GNUNET_ERROR_TYPE_INFO | 1012 GNUNET_log (GNUNET_ERROR_TYPE_INFO |
1013 GNUNET_ERROR_TYPE_BULK, 1013 GNUNET_ERROR_TYPE_BULK,
1014 _("Found address `%s' (%s)\n"), 1014 _("Found address `%s' (%s)\n"),
1015 GNUNET_a2s (addr, addrlen), name); 1015 GNUNET_a2s (addr, addrlen), name);
1016 1016
1017 if (addr_nat != NULL) 1017 if (addr_nat != NULL)
1018 { 1018 {
1019 plugin->env->notify_address (plugin->env->cls, 1019 plugin->env->notify_address (plugin->env->cls,
@@ -1083,11 +1083,11 @@ send_udp_probe_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
1083 _("Sending a probe to port %d\n"), ntohs(probe->addr.u_port)); 1083 _("Sending a probe to port %d\n"), ntohs(probe->addr.u_port));
1084#endif 1084#endif
1085 probe->count++; 1085 probe->count++;
1086 udp_real_send(plugin, 1086 udp_real_send(plugin,
1087 plugin->udp_sockv4.desc, 1087 plugin->udp_sockv4.desc,
1088 NULL, 1088 NULL,
1089 (char *)&message, ntohs(message.header.size), 0, 1089 (char *)&message, ntohs(message.header.size), 0,
1090 GNUNET_TIME_relative_get_unit(), 1090 GNUNET_TIME_relative_get_unit(),
1091 &probe->addr, sizeof(struct IPv4UdpAddress), 1091 &probe->addr, sizeof(struct IPv4UdpAddress),
1092 &udp_probe_continuation, probe); 1092 &udp_probe_continuation, probe);
1093} 1093}
@@ -1329,7 +1329,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
1329 if (fromlen == sizeof(struct IPv4UdpAddress)) 1329 if (fromlen == sizeof(struct IPv4UdpAddress))
1330 { 1330 {
1331 memset(&addr_buf, 0, sizeof(addr_buf)); 1331 memset(&addr_buf, 0, sizeof(addr_buf));
1332 if (NULL == inet_ntop (AF_INET, 1332 if (NULL == inet_ntop (AF_INET,
1333 &((struct IPv4UdpAddress *) sender_addr)->ipv4_addr, addr_buf, 1333 &((struct IPv4UdpAddress *) sender_addr)->ipv4_addr, addr_buf,
1334 INET_ADDRSTRLEN)) 1334 INET_ADDRSTRLEN))
1335 { 1335 {
@@ -1346,10 +1346,10 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
1346 outgoing_probe_confirmation = GNUNET_malloc(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); 1346 outgoing_probe_confirmation = GNUNET_malloc(sizeof(struct UDP_NAT_ProbeMessageConfirmation));
1347 outgoing_probe_confirmation->header.size = htons(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); 1347 outgoing_probe_confirmation->header.size = htons(sizeof(struct UDP_NAT_ProbeMessageConfirmation));
1348 outgoing_probe_confirmation->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_CONFIRM); 1348 outgoing_probe_confirmation->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_CONFIRM);
1349 udp_real_send(plugin, sockinfo->desc, NULL, 1349 udp_real_send(plugin, sockinfo->desc, NULL,
1350 (char *)outgoing_probe_confirmation, 1350 (char *)outgoing_probe_confirmation,
1351 ntohs(outgoing_probe_confirmation->header.size), 0, 1351 ntohs(outgoing_probe_confirmation->header.size), 0,
1352 GNUNET_TIME_relative_get_unit(), 1352 GNUNET_TIME_relative_get_unit(),
1353 sender_addr, fromlen, NULL, NULL); 1353 sender_addr, fromlen, NULL, NULL);
1354 1354
1355 if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) 1355 if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK)
@@ -1476,7 +1476,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
1476 "Sending message type %d to transport!\n", 1476 "Sending message type %d to transport!\n",
1477 ntohs(currhdr->type)); 1477 ntohs(currhdr->type));
1478#endif 1478#endif
1479 plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, 1479 plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE,
1480 NULL, sender_addr, fromlen); 1480 NULL, sender_addr, fromlen);
1481 } 1481 }
1482 1482
@@ -1637,10 +1637,10 @@ udp_transport_server_start (void *cls)
1637 plugin->internal_address); 1637 plugin->internal_address);
1638#endif 1638#endif
1639 /* Start the server process */ 1639 /* Start the server process */
1640 plugin->server_pid = GNUNET_OS_start_process(NULL, 1640 plugin->server_pid = GNUNET_OS_start_process(NULL,
1641 plugin->server_stdout, 1641 plugin->server_stdout,
1642 "gnunet-nat-server", 1642 "gnunet-nat-server",
1643 "gnunet-nat-server", 1643 "gnunet-nat-server",
1644 plugin->internal_address, NULL); 1644 plugin->internal_address, NULL);
1645 if (plugin->server_pid == GNUNET_SYSERR) 1645 if (plugin->server_pid == GNUNET_SYSERR)
1646 { 1646 {
@@ -1652,7 +1652,7 @@ udp_transport_server_start (void *cls)
1652 } 1652 }
1653 /* Close the write end of the read pipe */ 1653 /* Close the write end of the read pipe */
1654 GNUNET_DISK_pipe_close_end(plugin->server_stdout, GNUNET_DISK_PIPE_END_WRITE); 1654 GNUNET_DISK_pipe_close_end(plugin->server_stdout, GNUNET_DISK_PIPE_END_WRITE);
1655 1655
1656 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); 1656 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ);
1657 plugin->server_read_task = 1657 plugin->server_read_task =
1658 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1658 GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
@@ -1689,7 +1689,7 @@ udp_transport_server_start (void *cls)
1689 serverAddr = (struct sockaddr *) &serverAddrv6; 1689 serverAddr = (struct sockaddr *) &serverAddrv6;
1690#if DEBUG_UDP 1690#if DEBUG_UDP
1691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1692 "Binding to IPv6 port %d\n", 1692 "Binding to IPv6 port %d\n",
1693 ntohs(serverAddrv6.sin6_port)); 1693 ntohs(serverAddrv6.sin6_port));
1694#endif 1694#endif
1695 tries = 0; 1695 tries = 0;
@@ -1699,7 +1699,7 @@ udp_transport_server_start (void *cls)
1699 serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ 1699 serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
1700#if DEBUG_UDP 1700#if DEBUG_UDP
1701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1702 "IPv6 Binding failed, trying new port %d\n", 1702 "IPv6 Binding failed, trying new port %d\n",
1703 ntohs(serverAddrv6.sin6_port)); 1703 ntohs(serverAddrv6.sin6_port));
1704#endif 1704#endif
1705 tries++; 1705 tries++;
@@ -1708,7 +1708,7 @@ udp_transport_server_start (void *cls)
1708 GNUNET_NETWORK_socket_close (plugin->udp_sockv6.desc); 1708 GNUNET_NETWORK_socket_close (plugin->udp_sockv6.desc);
1709 plugin->udp_sockv6.desc = NULL; 1709 plugin->udp_sockv6.desc = NULL;
1710 break; 1710 break;
1711 } 1711 }
1712 } 1712 }
1713 if (plugin->udp_sockv6.desc != NULL) 1713 if (plugin->udp_sockv6.desc != NULL)
1714 { 1714 {
@@ -1741,7 +1741,7 @@ udp_transport_server_start (void *cls)
1741 serverAddr = (struct sockaddr *) &serverAddrv4; 1741 serverAddr = (struct sockaddr *) &serverAddrv4;
1742#if DEBUG_UDP 1742#if DEBUG_UDP
1743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1744 "Binding to IPv4 port %d\n", 1744 "Binding to IPv4 port %d\n",
1745 ntohs(serverAddrv4.sin_port)); 1745 ntohs(serverAddrv4.sin_port));
1746#endif 1746#endif
1747 tries = 0; 1747 tries = 0;
@@ -1751,7 +1751,7 @@ udp_transport_server_start (void *cls)
1751 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ 1751 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
1752#if DEBUG_UDP 1752#if DEBUG_UDP
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1754 "IPv4 Binding failed, trying new port %d\n", 1754 "IPv4 Binding failed, trying new port %d\n",
1755 ntohs(serverAddrv4.sin_port)); 1755 ntohs(serverAddrv4.sin_port));
1756#endif 1756#endif
1757 tries++; 1757 tries++;
@@ -1760,7 +1760,7 @@ udp_transport_server_start (void *cls)
1760 GNUNET_NETWORK_socket_close (plugin->udp_sockv4.desc); 1760 GNUNET_NETWORK_socket_close (plugin->udp_sockv4.desc);
1761 plugin->udp_sockv4.desc = NULL; 1761 plugin->udp_sockv4.desc = NULL;
1762 break; 1762 break;
1763 } 1763 }
1764 } 1764 }
1765 if (plugin->udp_sockv4.desc != NULL) 1765 if (plugin->udp_sockv4.desc != NULL)
1766 { 1766 {
@@ -1772,10 +1772,10 @@ udp_transport_server_start (void *cls)
1772 plugin->rs = GNUNET_NETWORK_fdset_create (); 1772 plugin->rs = GNUNET_NETWORK_fdset_create ();
1773 GNUNET_NETWORK_fdset_zero (plugin->rs); 1773 GNUNET_NETWORK_fdset_zero (plugin->rs);
1774 if (NULL != plugin->udp_sockv4.desc) 1774 if (NULL != plugin->udp_sockv4.desc)
1775 GNUNET_NETWORK_fdset_set (plugin->rs, 1775 GNUNET_NETWORK_fdset_set (plugin->rs,
1776 plugin->udp_sockv4.desc); 1776 plugin->udp_sockv4.desc);
1777 if (NULL != plugin->udp_sockv6.desc) 1777 if (NULL != plugin->udp_sockv6.desc)
1778 GNUNET_NETWORK_fdset_set (plugin->rs, 1778 GNUNET_NETWORK_fdset_set (plugin->rs,
1779 plugin->udp_sockv6.desc); 1779 plugin->udp_sockv6.desc);
1780 1780
1781 plugin->select_task = 1781 plugin->select_task =
@@ -1806,7 +1806,7 @@ check_port (struct Plugin *plugin, uint16_t in_port)
1806 if ( (plugin->only_nat_addresses == GNUNET_YES) && 1806 if ( (plugin->only_nat_addresses == GNUNET_YES) &&
1807 (plugin->behind_nat == GNUNET_YES) ) 1807 (plugin->behind_nat == GNUNET_YES) )
1808 return GNUNET_SYSERR; /* odd case... */ 1808 return GNUNET_SYSERR; /* odd case... */
1809 if (in_port == plugin->port) 1809 if (in_port == plugin->port)
1810 return GNUNET_OK; 1810 return GNUNET_OK;
1811 return GNUNET_SYSERR; 1811 return GNUNET_SYSERR;
1812} 1812}
@@ -1829,8 +1829,8 @@ check_port (struct Plugin *plugin, uint16_t in_port)
1829 * 1829 *
1830 */ 1830 */
1831static int 1831static int
1832udp_check_address (void *cls, 1832udp_check_address (void *cls,
1833 const void *addr, 1833 const void *addr,
1834 size_t addrlen) 1834 size_t addrlen)
1835{ 1835{
1836 struct Plugin *plugin = cls; 1836 struct Plugin *plugin = cls;
@@ -1873,7 +1873,7 @@ udp_check_address (void *cls,
1873 GNUNET_break_op (0); 1873 GNUNET_break_op (0);
1874 return GNUNET_SYSERR; 1874 return GNUNET_SYSERR;
1875 } 1875 }
1876 if (GNUNET_OK != 1876 if (GNUNET_OK !=
1877 check_port (plugin, ntohs (v6->u6_port))) 1877 check_port (plugin, ntohs (v6->u6_port)))
1878 return GNUNET_SYSERR; 1878 return GNUNET_SYSERR;
1879 if (GNUNET_OK != 1879 if (GNUNET_OK !=
@@ -2226,7 +2226,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2226 GNUNET_SERVICE_stop (service); 2226 GNUNET_SERVICE_stop (service);
2227 GNUNET_free_non_null(external_address); 2227 GNUNET_free_non_null(external_address);
2228 GNUNET_free_non_null(internal_address); 2228 GNUNET_free_non_null(internal_address);
2229 return NULL; 2229 return NULL;
2230 } 2230 }
2231 2231
2232 mtu = 1240; 2232 mtu = 1240;
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 6dd6e4ef7..27b3e87b3 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -857,7 +857,7 @@ notify_address (void *cls,
857 addrlen); 857 addrlen);
858 return; 858 return;
859 } 859 }
860 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 860 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
861 _("Transport plugin notification for address: `%s':%u\n"), 861 _("Transport plugin notification for address: `%s':%u\n"),
862 address, 862 address,
863 port); 863 port);
diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c
index 735bab920..6e33a1675 100644
--- a/src/transport/test_plugin_transport_https.c
+++ b/src/transport/test_plugin_transport_https.c
@@ -884,7 +884,7 @@ notify_address (void *cls,
884 addrlen); 884 addrlen);
885 return; 885 return;
886 } 886 }
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
888 _("Transport plugin notification for address: `%s':%u\n"), 888 _("Transport plugin notification for address: `%s':%u\n"),
889 address, 889 address,
890 port); 890 port);
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 7e08ebd4b..7bd63414d 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -193,7 +193,7 @@ notify_connect (void *cls,
193 { 193 {
194 GNUNET_SCHEDULER_cancel (sched, die_task); 194 GNUNET_SCHEDULER_cancel (sched, die_task);
195 die_task = GNUNET_SCHEDULER_add_delayed (sched, 195 die_task = GNUNET_SCHEDULER_add_delayed (sched,
196 TIMEOUT_TRANSMIT, 196 TIMEOUT_TRANSMIT,
197 &end_badly, NULL); 197 &end_badly, NULL);
198 198
199 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 199 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
@@ -347,7 +347,7 @@ run (void *cls,
347 OKPP; 347 OKPP;
348 sched = s; 348 sched = s;
349 die_task = GNUNET_SCHEDULER_add_delayed (sched, 349 die_task = GNUNET_SCHEDULER_add_delayed (sched,
350 TIMEOUT, 350 TIMEOUT,
351 &end_badly, NULL); 351 &end_badly, NULL);
352 352
353 if (is_udp) 353 if (is_udp)
@@ -490,7 +490,7 @@ get_path_from_PATH ()
490} 490}
491 491
492 492
493static int 493static int
494check_gnunet_nat_server() 494check_gnunet_nat_server()
495{ 495{
496 struct stat statbuf; 496 struct stat statbuf;
@@ -505,8 +505,8 @@ check_gnunet_nat_server()
505 return GNUNET_SYSERR; 505 return GNUNET_SYSERR;
506 } 506 }
507 GNUNET_free (p); 507 GNUNET_free (p);
508 if ( (0 != (statbuf.st_mode & S_ISUID)) && 508 if ( (0 != (statbuf.st_mode & S_ISUID)) &&
509 (statbuf.st_uid == 0) ) 509 (statbuf.st_uid == 0) )
510 return GNUNET_YES; 510 return GNUNET_YES;
511 return GNUNET_NO; 511 return GNUNET_NO;
512} 512}
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index a18175bf4..03bef3b4e 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -119,7 +119,7 @@ end ()
119 GNUNET_TRANSPORT_disconnect (p1.th); 119 GNUNET_TRANSPORT_disconnect (p1.th);
120 GNUNET_TRANSPORT_disconnect (p2.th); 120 GNUNET_TRANSPORT_disconnect (p2.th);
121#if VERBOSE 121#if VERBOSE
122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
123 "Transports disconnected, returning success!\n"); 123 "Transports disconnected, returning success!\n");
124#endif 124#endif
125 delta = GNUNET_TIME_absolute_get_duration (start_time).value; 125 delta = GNUNET_TIME_absolute_get_duration (start_time).value;
@@ -155,7 +155,7 @@ end_badly (void *cls,
155} 155}
156 156
157 157
158struct TestMessage 158struct TestMessage
159{ 159{
160 struct GNUNET_MessageHeader header; 160 struct GNUNET_MessageHeader header;
161 uint32_t num; 161 uint32_t num;
@@ -241,7 +241,7 @@ notify_receive (void *cls,
241 die_task = GNUNET_SCHEDULER_add_delayed (sched, 241 die_task = GNUNET_SCHEDULER_add_delayed (sched,
242 TIMEOUT, 242 TIMEOUT,
243 &end_badly, 243 &end_badly,
244 NULL); 244 NULL);
245 } 245 }
246 if (n == TOTAL_MSGS) 246 if (n == TOTAL_MSGS)
247 end (); 247 end ();
@@ -295,7 +295,7 @@ notify_ready (void *cls, size_t size, void *buf)
295 if (n < TOTAL_MSGS) 295 if (n < TOTAL_MSGS)
296 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 296 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
297 &p2.id, 297 &p2.id,
298 s, 0, TIMEOUT, 298 s, 0, TIMEOUT,
299 &notify_ready, 299 &notify_ready,
300 NULL); 300 NULL);
301 if (n % 5000 == 0) 301 if (n % 5000 == 0)
@@ -368,7 +368,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
368{ 368{
369 p->cfg = GNUNET_CONFIGURATION_create (); 369 p->cfg = GNUNET_CONFIGURATION_create ();
370#if START_ARM 370#if START_ARM
371 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, 371 p->arm_pid = GNUNET_OS_start_process (NULL, NULL,
372 "gnunet-service-arm", 372 "gnunet-service-arm",
373 "gnunet-service-arm", 373 "gnunet-service-arm",
374#if VERBOSE_ARM 374#if VERBOSE_ARM
@@ -438,7 +438,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
438 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, 438 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL,
439 p, 439 p,
440 &notify_receive, 440 &notify_receive,
441 &notify_connect, 441 &notify_connect,
442 &notify_disconnect); 442 &notify_disconnect);
443 GNUNET_assert (p->th != NULL); 443 GNUNET_assert (p->th != NULL);
444} 444}
@@ -487,7 +487,7 @@ exchange_hello (void *cls,
487 487
488#if VERBOSE 488#if VERBOSE
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
490 "Received HELLO size %d\n", 490 "Received HELLO size %d\n",
491 GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message)); 491 GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
492#endif 492#endif
493 GNUNET_TRANSPORT_offer_hello (p2.th, message); 493 GNUNET_TRANSPORT_offer_hello (p2.th, message);
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index db96d1800..fa06f7fdb 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -278,7 +278,7 @@ struct GNUNET_TRANSPORT_Handle
278 /** 278 /**
279 * Closure for the callbacks. 279 * Closure for the callbacks.
280 */ 280 */
281 void *cls; 281 void *cls;
282 282
283 /** 283 /**
284 * Function to call for received data. 284 * Function to call for received data.
@@ -361,7 +361,7 @@ struct GNUNET_TRANSPORT_Handle
361 * Delay until we try to reconnect. 361 * Delay until we try to reconnect.
362 */ 362 */
363 struct GNUNET_TIME_Relative reconnect_delay; 363 struct GNUNET_TIME_Relative reconnect_delay;
364 364
365 /** 365 /**
366 * Set once we are in the process of disconnecting from the 366 * Set once we are in the process of disconnecting from the
367 * service. 367 * service.
@@ -467,14 +467,14 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
467#if DEBUG_TRANSPORT 467#if DEBUG_TRANSPORT
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
469 "Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n", 469 "Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n",
470 duration.value, 470 duration.value,
471 GNUNET_i2s (&n->id)); 471 GNUNET_i2s (&n->id));
472#endif 472#endif
473 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 473 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
474 { 474 {
475 GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); 475 GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task);
476 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 476 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
477 } 477 }
478 n->transmit_stage = TS_NEW; 478 n->transmit_stage = TS_NEW;
479 if (NULL != th->notify) 479 if (NULL != th->notify)
480 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); 480 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
@@ -487,7 +487,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
487 "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n", 487 "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n",
488 (unsigned int) n->out_tracker.available_bytes_per_s__, 488 (unsigned int) n->out_tracker.available_bytes_per_s__,
489 (unsigned int) th->notify_size - sizeof (struct OutboundMessage), 489 (unsigned int) th->notify_size - sizeof (struct OutboundMessage),
490 GNUNET_i2s (&n->id), 490 GNUNET_i2s (&n->id),
491 duration.value); 491 duration.value);
492#endif 492#endif
493 retry_time = GNUNET_TIME_relative_min (retry_time, 493 retry_time = GNUNET_TIME_relative_min (retry_time,
@@ -516,7 +516,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
516/** 516/**
517 * Transmit message(s) to service. 517 * Transmit message(s) to service.
518 * 518 *
519 * @param cls handle to transport 519 * @param cls handle to transport
520 * @param size number of bytes available in buf 520 * @param size number of bytes available in buf
521 * @param buf where to copy the message 521 * @param buf where to copy the message
522 * @return number of bytes copied to buf 522 * @return number of bytes copied to buf
@@ -556,7 +556,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
556 } 556 }
557 GNUNET_CONTAINER_DLL_remove (h->control_head, 557 GNUNET_CONTAINER_DLL_remove (h->control_head,
558 h->control_tail, 558 h->control_tail,
559 cm); 559 cm);
560 nret = cm->notify (cm->notify_cls, size, &cbuf[ret]); 560 nret = cm->notify (cm->notify_cls, size, &cbuf[ret]);
561#if DEBUG_TRANSPORT 561#if DEBUG_TRANSPORT
562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -595,14 +595,14 @@ transport_notify_ready (void *cls, size_t size, void *buf)
595 GNUNET_break (0); 595 GNUNET_break (0);
596 } 596 }
597 GNUNET_assert (size >= sizeof (struct OutboundMessage)); 597 GNUNET_assert (size >= sizeof (struct OutboundMessage));
598 mret = th->notify (th->notify_cls, 598 mret = th->notify (th->notify_cls,
599 size - sizeof (struct OutboundMessage), 599 size - sizeof (struct OutboundMessage),
600 &cbuf[ret + sizeof (struct OutboundMessage)]); 600 &cbuf[ret + sizeof (struct OutboundMessage)]);
601 GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); 601 GNUNET_assert (mret <= size - sizeof (struct OutboundMessage));
602#if DEBUG_TRANSPORT 602#if DEBUG_TRANSPORT
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
604 "Message of %u bytes with timeout %llums constructed for `%4s'\n", 604 "Message of %u bytes with timeout %llums constructed for `%4s'\n",
605 (unsigned int) mret, 605 (unsigned int) mret,
606 (unsigned long long) GNUNET_TIME_absolute_get_remaining (th->timeout).value, 606 (unsigned long long) GNUNET_TIME_absolute_get_remaining (th->timeout).value,
607 GNUNET_i2s (&n->id)); 607 GNUNET_i2s (&n->id));
608#endif 608#endif
@@ -655,7 +655,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
655 */ 655 */
656static void 656static void
657schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) 657schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
658{ 658{
659 size_t size; 659 size_t size;
660 struct GNUNET_TIME_Relative timeout; 660 struct GNUNET_TIME_Relative timeout;
661 struct GNUNET_TRANSPORT_TransmitHandle *th; 661 struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -668,7 +668,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
668 _("Could not yet schedule transmission: we are not yet connected to the transport service!\n")); 668 _("Could not yet schedule transmission: we are not yet connected to the transport service!\n"));
669 return; /* not yet connected */ 669 return; /* not yet connected */
670 } 670 }
671 if (NULL != h->control_head) 671 if (NULL != h->control_head)
672 { 672 {
673 size = h->control_head->notify_size; 673 size = h->control_head->notify_size;
674 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 674 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -688,7 +688,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
688 size = th->notify_size; 688 size = th->notify_size;
689 timeout = GNUNET_TIME_absolute_get_remaining (th->timeout); 689 timeout = GNUNET_TIME_absolute_get_remaining (th->timeout);
690 } 690 }
691 h->network_handle = 691 h->network_handle =
692 GNUNET_CLIENT_notify_transmit_ready (h->client, 692 GNUNET_CLIENT_notify_transmit_ready (h->client,
693 size, 693 size,
694 timeout, 694 timeout,
@@ -756,7 +756,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
756 th->notify_delay_task 756 th->notify_delay_task
757 = GNUNET_SCHEDULER_add_delayed (h->sched, 757 = GNUNET_SCHEDULER_add_delayed (h->sched,
758 timeout, &control_transmit_timeout, th); 758 timeout, &control_transmit_timeout, th);
759 if (at_head) 759 if (at_head)
760 GNUNET_CONTAINER_DLL_insert (h->control_head, 760 GNUNET_CONTAINER_DLL_insert (h->control_head,
761 h->control_tail, 761 h->control_tail,
762 th); 762 th);
@@ -811,7 +811,7 @@ send_set_quota (void *cls, size_t size, void *buf)
811#if DEBUG_TRANSPORT 811#if DEBUG_TRANSPORT
812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
813 "Transmitting `%s' request with respect to `%4s'.\n", 813 "Transmitting `%s' request with respect to `%4s'.\n",
814 "SET_QUOTA", 814 "SET_QUOTA",
815 GNUNET_i2s (&sqc->target)); 815 GNUNET_i2s (&sqc->target));
816#endif 816#endif
817 GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); 817 GNUNET_assert (size >= sizeof (struct QuotaSetMessage));
@@ -920,7 +920,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
920 hwl->rec = rec; 920 hwl->rec = rec;
921 hwl->rec_cls = rec_cls; 921 hwl->rec_cls = rec_cls;
922 if (handle->my_hello == NULL) 922 if (handle->my_hello == NULL)
923 return; 923 return;
924 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello); 924 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
925} 925}
926 926
@@ -1023,7 +1023,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1023 GNUNET_break (0); 1023 GNUNET_break (0);
1024 return; 1024 return;
1025 } 1025 }
1026#if DEBUG_TRANSPORT 1026#if DEBUG_TRANSPORT
1027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1028 "Offering `%s' message of `%4s' to transport for validation.\n", 1028 "Offering `%s' message of `%4s' to transport for validation.\n",
1029 "HELLO", 1029 "HELLO",
@@ -1076,8 +1076,8 @@ send_start (void *cls, size_t size, void *buf)
1076 1076
1077 1077
1078/** 1078/**
1079 * Free neighbour. 1079 * Free neighbour.
1080 * 1080 *
1081 * @param n the entry to free 1081 * @param n the entry to free
1082 */ 1082 */
1083static void 1083static void
@@ -1112,8 +1112,8 @@ neighbour_free (struct NeighbourList *n)
1112 1112
1113 1113
1114/** 1114/**
1115 * Mark neighbour as disconnected. 1115 * Mark neighbour as disconnected.
1116 * 1116 *
1117 * @param n the entry to mark as disconnected 1117 * @param n the entry to mark as disconnected
1118 */ 1118 */
1119static void 1119static void
@@ -1151,7 +1151,7 @@ static void demultiplexer (void *cls,
1151 * @param tc scheduler context 1151 * @param tc scheduler context
1152 */ 1152 */
1153static void 1153static void
1154reconnect (void *cls, 1154reconnect (void *cls,
1155 const struct GNUNET_SCHEDULER_TaskContext *tc) 1155 const struct GNUNET_SCHEDULER_TaskContext *tc)
1156{ 1156{
1157 struct GNUNET_TRANSPORT_Handle *h = cls; 1157 struct GNUNET_TRANSPORT_Handle *h = cls;
@@ -1179,7 +1179,7 @@ reconnect (void *cls,
1179 n = next; 1179 n = next;
1180 } 1180 }
1181#if DEBUG_TRANSPORT 1181#if DEBUG_TRANSPORT
1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1183 "Connecting to transport service.\n"); 1183 "Connecting to transport service.\n");
1184#endif 1184#endif
1185 GNUNET_assert (h->client == NULL); 1185 GNUNET_assert (h->client == NULL);
@@ -1237,7 +1237,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
1237 { 1237 {
1238 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; 1238 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
1239 } 1239 }
1240 else 1240 else
1241 { 1241 {
1242 h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); 1242 h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2);
1243 h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, 1243 h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
@@ -1267,7 +1267,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
1267 } 1267 }
1268#if DEBUG_TRANSPORT 1268#if DEBUG_TRANSPORT
1269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1270 "Creating entry for neighbour `%4s'.\n", 1270 "Creating entry for neighbour `%4s'.\n",
1271 GNUNET_i2s (pid)); 1271 GNUNET_i2s (pid));
1272#endif 1272#endif
1273 n = GNUNET_malloc (sizeof (struct NeighbourList)); 1273 n = GNUNET_malloc (sizeof (struct NeighbourList));
@@ -1277,7 +1277,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
1277 MAX_BANDWIDTH_CARRY_S); 1277 MAX_BANDWIDTH_CARRY_S);
1278 n->next = h->neighbours; 1278 n->next = h->neighbours;
1279 n->h = h; 1279 n->h = h;
1280 h->neighbours = n; 1280 h->neighbours = n;
1281 return n; 1281 return n;
1282} 1282}
1283 1283
@@ -1358,7 +1358,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1358 th->notify_delay_task); 1358 th->notify_delay_task);
1359 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 1359 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
1360 } 1360 }
1361 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); 1361 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
1362 break; 1362 break;
1363 default: 1363 default:
1364 GNUNET_break (0); 1364 GNUNET_break (0);
@@ -1456,7 +1456,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1456 GNUNET_free (h); 1456 GNUNET_free (h);
1457 return; 1457 return;
1458 } 1458 }
1459 if (msg == NULL) 1459 if (msg == NULL)
1460 { 1460 {
1461#if DEBUG_TRANSPORT 1461#if DEBUG_TRANSPORT
1462 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1462 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1530,7 +1530,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1530 n->is_connected = GNUNET_YES; 1530 n->is_connected = GNUNET_YES;
1531 if (h->nc_cb != NULL) 1531 if (h->nc_cb != NULL)
1532 h->nc_cb (h->cls, &n->id, 1532 h->nc_cb (h->cls, &n->id,
1533 GNUNET_TIME_relative_ntoh (cim->latency), 1533 GNUNET_TIME_relative_ntoh (cim->latency),
1534 ntohl (cim->distance)); 1534 ntohl (cim->distance));
1535 break; 1535 break;
1536 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: 1536 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
@@ -1547,7 +1547,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1547 GNUNET_i2s (&dim->peer)); 1547 GNUNET_i2s (&dim->peer));
1548#endif 1548#endif
1549 n = neighbour_find (h, &dim->peer); 1549 n = neighbour_find (h, &dim->peer);
1550 GNUNET_break (n != NULL); 1550 GNUNET_break (n != NULL);
1551 if (n != NULL) 1551 if (n != NULL)
1552 neighbour_disconnect (n); 1552 neighbour_disconnect (n);
1553 break; 1553 break;
@@ -1607,7 +1607,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1608 "Received message of type %u from `%4s'.\n", 1608 "Received message of type %u from `%4s'.\n",
1609 ntohs (imm->type), GNUNET_i2s (&im->peer)); 1609 ntohs (imm->type), GNUNET_i2s (&im->peer));
1610#endif 1610#endif
1611 n = neighbour_find (h, &im->peer); 1611 n = neighbour_find (h, &im->peer);
1612 if (n == NULL) 1612 if (n == NULL)
1613 { 1613 {
@@ -1659,7 +1659,7 @@ peer_transmit_timeout (void *cls,
1659 "Triggering timeout for request to transmit to `%4s' (%d)\n", 1659 "Triggering timeout for request to transmit to `%4s' (%d)\n",
1660 GNUNET_i2s (&n->id), 1660 GNUNET_i2s (&n->id),
1661 n->transmit_stage); 1661 n->transmit_stage);
1662#endif 1662#endif
1663 notify = th->notify; 1663 notify = th->notify;
1664 notify_cls = th->notify_cls; 1664 notify_cls = th->notify_cls;
1665 switch (n->transmit_stage) 1665 switch (n->transmit_stage)
@@ -1738,7 +1738,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
1738 n = neighbour_find (handle, target); 1738 n = neighbour_find (handle, target);
1739 if (n == NULL) 1739 if (n == NULL)
1740 n = neighbour_add (handle, target); 1740 n = neighbour_add (handle, target);
1741 if (n == NULL) 1741 if (n == NULL)
1742 { 1742 {
1743 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1743 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1744 "Could not create neighbour entry for peer `%s'\n", 1744 "Could not create neighbour entry for peer `%s'\n",
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index da723d71c..cb15f0565 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -29,7 +29,7 @@
29 29
30/** 30/**
31 * Context for the address lookup. 31 * Context for the address lookup.
32 */ 32 */
33struct AddressLookupCtx 33struct AddressLookupCtx
34{ 34{
35 /** 35 /**
@@ -62,7 +62,7 @@ struct AddressLookupCtx
62 * message with the human-readable address 62 * message with the human-readable address
63 */ 63 */
64static void 64static void
65address_response_processor (void *cls, 65address_response_processor (void *cls,
66 const struct GNUNET_MessageHeader *msg) 66 const struct GNUNET_MessageHeader *msg)
67{ 67{
68 struct AddressLookupCtx *alucb = cls; 68 struct AddressLookupCtx *alucb = cls;
@@ -100,7 +100,7 @@ address_response_processor (void *cls,
100 GNUNET_CLIENT_receive (alucb->client, 100 GNUNET_CLIENT_receive (alucb->client,
101 &address_response_processor, alucb, 101 &address_response_processor, alucb,
102 GNUNET_TIME_absolute_get_remaining 102 GNUNET_TIME_absolute_get_remaining
103 (alucb->timeout)); 103 (alucb->timeout));
104 alucb->cb (alucb->cb_cls, address); 104 alucb->cb (alucb->cb_cls, address);
105} 105}
106 106
@@ -112,7 +112,7 @@ address_response_processor (void *cls,
112 * @param cfg configuration to use 112 * @param cfg configuration to use
113 * @param address address to convert (binary format) 113 * @param address address to convert (binary format)
114 * @param addressLen number of bytes in address 114 * @param addressLen number of bytes in address
115 * @param numeric should (IP) addresses be displayed in numeric form 115 * @param numeric should (IP) addresses be displayed in numeric form
116 * (otherwise do reverse DNS lookup) 116 * (otherwise do reverse DNS lookup)
117 * @param nameTrans name of the transport to which the address belongs 117 * @param nameTrans name of the transport to which the address belongs
118 * @param timeout how long is the lookup allowed to take at most 118 * @param timeout how long is the lookup allowed to take at most
@@ -121,8 +121,8 @@ address_response_processor (void *cls,
121 */ 121 */
122void 122void
123GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, 123GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
124 const struct GNUNET_CONFIGURATION_Handle *cfg, 124 const struct GNUNET_CONFIGURATION_Handle *cfg,
125 const char *address, 125 const char *address,
126 size_t addressLen, 126 size_t addressLen,
127 int numeric, 127 int numeric,
128 const char *nameTrans, 128 const char *nameTrans,
@@ -168,8 +168,8 @@ GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
168 aluCB->timeout = abs_timeout; 168 aluCB->timeout = abs_timeout;
169 aluCB->client = client; 169 aluCB->client = client;
170 GNUNET_assert (GNUNET_OK == 170 GNUNET_assert (GNUNET_OK ==
171 GNUNET_CLIENT_transmit_and_get_response (client, 171 GNUNET_CLIENT_transmit_and_get_response (client,
172 &msg->header, 172 &msg->header,
173 timeout, 173 timeout,
174 GNUNET_YES, 174 GNUNET_YES,
175 &address_response_processor, 175 &address_response_processor,
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c
index 919845c51..1025edef4 100644
--- a/src/transport/transport_api_blacklist.c
+++ b/src/transport/transport_api_blacklist.c
@@ -56,7 +56,7 @@ struct GNUNET_TRANSPORT_Blacklist
56 56
57 /** 57 /**
58 * Pending handle for the current request. 58 * Pending handle for the current request.
59 */ 59 */
60 struct GNUNET_CLIENT_TransmitHandle *th; 60 struct GNUNET_CLIENT_TransmitHandle *th;
61 61
62 /** 62 /**
@@ -68,7 +68,7 @@ struct GNUNET_TRANSPORT_Blacklist
68 /** 68 /**
69 * Closure for 'cb'. 69 * Closure for 'cb'.
70 */ 70 */
71 void *cb_cls; 71 void *cb_cls;
72 72
73 /** 73 /**
74 * Peer currently under consideration. 74 * Peer currently under consideration.
@@ -108,7 +108,7 @@ query_handler (void *cls,
108{ 108{
109 struct GNUNET_TRANSPORT_Blacklist *br = cls; 109 struct GNUNET_TRANSPORT_Blacklist *br = cls;
110 const struct BlacklistMessage *bm; 110 const struct BlacklistMessage *bm;
111 111
112 if ( (ntohs(msg->size) != sizeof (struct BlacklistMessage)) || 112 if ( (ntohs(msg->size) != sizeof (struct BlacklistMessage)) ||
113 (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY) ) 113 (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY) )
114 { 114 {
@@ -118,7 +118,7 @@ query_handler (void *cls,
118 bm = (const struct BlacklistMessage *)msg; 118 bm = (const struct BlacklistMessage *)msg;
119 GNUNET_break (0 == ntohl (bm->is_allowed)); 119 GNUNET_break (0 == ntohl (bm->is_allowed));
120 br->peer = bm->peer; 120 br->peer = bm->peer;
121 reply (br); 121 reply (br);
122} 122}
123 123
124 124
@@ -276,7 +276,7 @@ GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched,
276 GNUNET_TIME_UNIT_FOREVER_REL, 276 GNUNET_TIME_UNIT_FOREVER_REL,
277 GNUNET_YES, 277 GNUNET_YES,
278 &transmit_blacklist_init, 278 &transmit_blacklist_init,
279 ret); 279 ret);
280 return ret; 280 return ret;
281} 281}
282 282