diff options
Diffstat (limited to 'src/transport/plugin_transport_http_new.c')
-rw-r--r-- | src/transport/plugin_transport_http_new.c | 236 |
1 files changed, 83 insertions, 153 deletions
diff --git a/src/transport/plugin_transport_http_new.c b/src/transport/plugin_transport_http_new.c index 5b7da9297..47d4743fd 100644 --- a/src/transport/plugin_transport_http_new.c +++ b/src/transport/plugin_transport_http_new.c | |||
@@ -34,22 +34,6 @@ | |||
34 | #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) | 34 | #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Network format for IPv4 addresses. | ||
38 | */ | ||
39 | struct IPv4HttpAddress | ||
40 | { | ||
41 | /** | ||
42 | * IPv4 address, in network byte order. | ||
43 | */ | ||
44 | uint32_t ipv4_addr GNUNET_PACKED; | ||
45 | |||
46 | /** | ||
47 | * Port number, in network byte order. | ||
48 | */ | ||
49 | uint16_t port GNUNET_PACKED; | ||
50 | }; | ||
51 | |||
52 | /** | ||
53 | * Wrapper to manage IPv4 addresses | 37 | * Wrapper to manage IPv4 addresses |
54 | */ | 38 | */ |
55 | struct IPv4HttpAddressWrapper | 39 | struct IPv4HttpAddressWrapper |
@@ -64,24 +48,7 @@ struct IPv4HttpAddressWrapper | |||
64 | */ | 48 | */ |
65 | struct IPv4HttpAddressWrapper *prev; | 49 | struct IPv4HttpAddressWrapper *prev; |
66 | 50 | ||
67 | struct IPv4HttpAddress *addr; | 51 | struct sockaddr_in addr; |
68 | }; | ||
69 | |||
70 | /** | ||
71 | * Network format for IPv6 addresses. | ||
72 | */ | ||
73 | struct IPv6HttpAddress | ||
74 | { | ||
75 | /** | ||
76 | * IPv6 address. | ||
77 | */ | ||
78 | struct in6_addr ipv6_addr GNUNET_PACKED; | ||
79 | |||
80 | /** | ||
81 | * Port number, in network byte order. | ||
82 | */ | ||
83 | uint16_t port GNUNET_PACKED; | ||
84 | |||
85 | }; | 52 | }; |
86 | 53 | ||
87 | /** | 54 | /** |
@@ -99,7 +66,10 @@ struct IPv6HttpAddressWrapper | |||
99 | */ | 66 | */ |
100 | struct IPv6HttpAddressWrapper *prev; | 67 | struct IPv6HttpAddressWrapper *prev; |
101 | 68 | ||
102 | struct IPv6HttpAddress *addr; | 69 | /** |
70 | * IPv6 address. | ||
71 | */ | ||
72 | struct sockaddr_in6 addr GNUNET_PACKED; | ||
103 | }; | 73 | }; |
104 | 74 | ||
105 | 75 | ||
@@ -188,33 +158,20 @@ http_plugin_address_pretty_printer (void *cls, const char *type, | |||
188 | struct PrettyPrinterContext *ppc; | 158 | struct PrettyPrinterContext *ppc; |
189 | const void *sb; | 159 | const void *sb; |
190 | size_t sbs; | 160 | size_t sbs; |
191 | struct sockaddr_in a4; | 161 | uint16_t port = 0 ; |
192 | struct sockaddr_in6 a6; | ||
193 | const struct IPv4HttpAddress *t4; | ||
194 | const struct IPv6HttpAddress *t6; | ||
195 | uint16_t port; | ||
196 | 162 | ||
197 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 163 | if (addrlen == sizeof (struct sockaddr_in6)) |
198 | { | 164 | { |
199 | t6 = addr; | 165 | sb = addr; |
200 | memset (&a6, 0, sizeof (a6)); | 166 | sbs = sizeof (struct sockaddr_in6); |
201 | a6.sin6_family = AF_INET6; | 167 | |
202 | a6.sin6_port = t6->port; | 168 | port = ntohs (((struct sockaddr_in6 *)addr)->sin6_port); |
203 | memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr)); | ||
204 | port = ntohs (t6->port); | ||
205 | sb = &a6; | ||
206 | sbs = sizeof (a6); | ||
207 | } | 169 | } |
208 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 170 | else if (addrlen == sizeof (struct sockaddr_in)) |
209 | { | 171 | { |
210 | t4 = addr; | 172 | sb = &addr; |
211 | memset (&a4, 0, sizeof (a4)); | 173 | sbs = sizeof (struct sockaddr_in); |
212 | a4.sin_family = AF_INET; | 174 | port = ntohs (((struct sockaddr_in *)addr)->sin_port); |
213 | a4.sin_port = t4->port; | ||
214 | a4.sin_addr.s_addr = t4->ipv4_addr; | ||
215 | port = ntohs (t4->ipv4_addr); | ||
216 | sb = &a4; | ||
217 | sbs = sizeof (a4); | ||
218 | } | 175 | } |
219 | else | 176 | else |
220 | { | 177 | { |
@@ -248,23 +205,21 @@ http_plugin_address_pretty_printer (void *cls, const char *type, | |||
248 | static int | 205 | static int |
249 | http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | 206 | http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) |
250 | { | 207 | { |
208 | |||
251 | struct Plugin *plugin = cls; | 209 | struct Plugin *plugin = cls; |
252 | struct IPv4HttpAddress *v4; | ||
253 | struct IPv6HttpAddress *v6; | ||
254 | struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head; | 210 | struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head; |
255 | struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head; | 211 | struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head; |
256 | 212 | ||
257 | GNUNET_assert (cls != NULL); | 213 | GNUNET_assert (cls != NULL); |
258 | if ((addrlen != sizeof (struct IPv4HttpAddress)) && | 214 | if ((addrlen != sizeof (struct sockaddr_in)) || |
259 | (addrlen != sizeof (struct IPv6HttpAddress))) | 215 | (addrlen != sizeof (struct sockaddr_in6))) |
260 | return GNUNET_SYSERR; | 216 | return GNUNET_SYSERR; |
261 | if (addrlen == sizeof (struct IPv4HttpAddress)) | 217 | |
218 | if (addrlen == sizeof (struct sockaddr_in)) | ||
262 | { | 219 | { |
263 | v4 = (struct IPv4HttpAddress *) addr; | ||
264 | while (w_tv4 != NULL) | 220 | while (w_tv4 != NULL) |
265 | { | 221 | { |
266 | if (0 == | 222 | if (0 == memcmp (&w_tv4->addr, addr, sizeof (struct sockaddr_in))) |
267 | memcmp (&w_tv4->addr->ipv4_addr, &v4->ipv4_addr, sizeof (uint32_t))) | ||
268 | break; | 223 | break; |
269 | w_tv4 = w_tv4->next; | 224 | w_tv4 = w_tv4->next; |
270 | } | 225 | } |
@@ -273,14 +228,13 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
273 | else | 228 | else |
274 | return GNUNET_SYSERR; | 229 | return GNUNET_SYSERR; |
275 | } | 230 | } |
276 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 231 | if (addrlen == sizeof (struct sockaddr_in6)) |
277 | { | 232 | { |
278 | v6 = (struct IPv6HttpAddress *) addr; | ||
279 | while (w_tv6 != NULL) | 233 | while (w_tv6 != NULL) |
280 | { | 234 | { |
281 | if (0 == | 235 | if (0 == |
282 | memcmp (&w_tv6->addr->ipv6_addr, &v6->ipv6_addr, | 236 | memcmp (&w_tv6->addr, addr, |
283 | sizeof (struct in6_addr))) | 237 | sizeof (struct sockaddr_in6))) |
284 | break; | 238 | break; |
285 | w_tv6 = w_tv6->next; | 239 | w_tv6 = w_tv6->next; |
286 | } | 240 | } |
@@ -289,7 +243,7 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
289 | else | 243 | else |
290 | return GNUNET_SYSERR; | 244 | return GNUNET_SYSERR; |
291 | } | 245 | } |
292 | return GNUNET_SYSERR; | 246 | return GNUNET_OK; |
293 | } | 247 | } |
294 | 248 | ||
295 | struct GNUNET_TIME_Relative | 249 | struct GNUNET_TIME_Relative |
@@ -327,30 +281,27 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer, | |||
327 | const char * | 281 | const char * |
328 | http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 282 | http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
329 | { | 283 | { |
330 | const struct IPv4HttpAddress *t4; | 284 | |
331 | const struct IPv6HttpAddress *t6; | 285 | struct sockaddr_in *a4; |
332 | struct sockaddr_in a4; | 286 | struct sockaddr_in6 *a6; |
333 | struct sockaddr_in6 a6; | ||
334 | char *address; | 287 | char *address; |
335 | static char rbuf[INET6_ADDRSTRLEN + 13]; | 288 | static char rbuf[INET6_ADDRSTRLEN + 13]; |
336 | uint16_t port; | 289 | uint16_t port; |
337 | int res = 0; | 290 | int res = 0; |
338 | 291 | ||
339 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 292 | if (addrlen == sizeof (struct sockaddr_in6)) |
340 | { | 293 | { |
294 | a6 = (struct sockaddr_in6 *) addr; | ||
341 | address = GNUNET_malloc (INET6_ADDRSTRLEN); | 295 | address = GNUNET_malloc (INET6_ADDRSTRLEN); |
342 | t6 = addr; | 296 | inet_ntop (AF_INET6, &(a6->sin6_addr), address, INET6_ADDRSTRLEN); |
343 | a6.sin6_addr = t6->ipv6_addr; | 297 | port = ntohs (a6->sin6_port); |
344 | inet_ntop (AF_INET6, &(a6.sin6_addr), address, INET6_ADDRSTRLEN); | ||
345 | port = ntohs (t6->port); | ||
346 | } | 298 | } |
347 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 299 | else if (addrlen == sizeof (struct sockaddr_in)) |
348 | { | 300 | { |
301 | a4 = (struct sockaddr_in *) addr; | ||
349 | address = GNUNET_malloc (INET_ADDRSTRLEN); | 302 | address = GNUNET_malloc (INET_ADDRSTRLEN); |
350 | t4 = addr; | 303 | inet_ntop (AF_INET, &(a4->sin_addr), address, INET_ADDRSTRLEN); |
351 | a4.sin_addr.s_addr = t4->ipv4_addr; | 304 | port = ntohs (a4->sin_port); |
352 | inet_ntop (AF_INET, &(a4.sin_addr), address, INET_ADDRSTRLEN); | ||
353 | port = ntohs (t4->port); | ||
354 | } | 305 | } |
355 | else | 306 | else |
356 | { | 307 | { |
@@ -364,9 +315,9 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
364 | #endif | 315 | #endif |
365 | 316 | ||
366 | GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13)); | 317 | GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13)); |
367 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 318 | if (addrlen == sizeof (struct sockaddr_in6)) |
368 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port); | 319 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port); |
369 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 320 | else if (addrlen == sizeof (struct sockaddr_in)) |
370 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port); | 321 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port); |
371 | 322 | ||
372 | GNUNET_free (address); | 323 | GNUNET_free (address); |
@@ -392,11 +343,6 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
392 | e_peer = GNUNET_NO; | 343 | e_peer = GNUNET_NO; |
393 | e_addr = GNUNET_NO; | 344 | e_addr = GNUNET_NO; |
394 | 345 | ||
395 | #if DEBUG_HTTP | ||
396 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
397 | "Comparing session %X <-> %X\n", session, t); | ||
398 | #endif | ||
399 | |||
400 | if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity))) | 346 | if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity))) |
401 | { | 347 | { |
402 | e_peer = GNUNET_YES; | 348 | e_peer = GNUNET_YES; |
@@ -409,32 +355,16 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
409 | } | 355 | } |
410 | if ((t == session)) | 356 | if ((t == session)) |
411 | { | 357 | { |
412 | #if DEBUG_HTTP | ||
413 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
414 | "Session %X: %s: \n", t, GNUNET_a2s (t->addr, t->addrlen)); | ||
415 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
416 | "Session %X: %s: \n", session, GNUNET_a2s (session->addr, session->addrlen)); | ||
417 | |||
418 | #endif | ||
419 | if(t->addrlen == session->addrlen) | 358 | if(t->addrlen == session->addrlen) |
420 | { | 359 | { |
421 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
422 | "length ok\n"); | ||
423 | if (0 == memcmp (session->addr, t->addr, t->addrlen)) | 360 | if (0 == memcmp (session->addr, t->addr, t->addrlen)) |
424 | { | 361 | { |
425 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
426 | "equal\n"); | ||
427 | e_addr = GNUNET_YES; | 362 | e_addr = GNUNET_YES; |
428 | } | 363 | } |
429 | } | 364 | } |
430 | } | 365 | } |
431 | } | 366 | } |
432 | 367 | ||
433 | #if DEBUG_HTTP | ||
434 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
435 | "Session %X: E_PEER YES : %i E_ADDR: %i force %u: \n", t, e_peer, e_addr, force_address); | ||
436 | #endif | ||
437 | |||
438 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO)) | 368 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO)) |
439 | { | 369 | { |
440 | s = t; | 370 | s = t; |
@@ -443,10 +373,6 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
443 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES)) | 373 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES)) |
444 | { | 374 | { |
445 | s = t; | 375 | s = t; |
446 | #if DEBUG_HTTP | ||
447 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
448 | "Session %X: HERE!\n", t, e_addr, s); | ||
449 | #endif | ||
450 | break; | 376 | break; |
451 | } | 377 | } |
452 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR)) | 378 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR)) |
@@ -557,7 +483,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
557 | #if DEBUG_HTTP | 483 | #if DEBUG_HTTP |
558 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 484 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
559 | "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size, | 485 | "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size, |
560 | GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), session, force_address); | 486 | GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, force_address); |
561 | #endif | 487 | #endif |
562 | 488 | ||
563 | struct Session *s = NULL; | 489 | struct Session *s = NULL; |
@@ -613,7 +539,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
613 | { | 539 | { |
614 | #if DEBUG_HTTP | 540 | #if DEBUG_HTTP |
615 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 541 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
616 | "Using client session to send to `%s'\n", | 542 | "Using outbound client session to send to `%s'\n", |
617 | GNUNET_i2s (target)); | 543 | GNUNET_i2s (target)); |
618 | #endif | 544 | #endif |
619 | client_send (s, msg); | 545 | client_send (s, msg); |
@@ -625,7 +551,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
625 | res = msgbuf_size; | 551 | res = msgbuf_size; |
626 | #if DEBUG_HTTP | 552 | #if DEBUG_HTTP |
627 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 553 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
628 | "Using server session to send to `%s'\n", | 554 | "Using inbound server session to send to `%s'\n", |
629 | GNUNET_i2s (target)); | 555 | GNUNET_i2s (target)); |
630 | #endif | 556 | #endif |
631 | 557 | ||
@@ -670,9 +596,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
670 | socklen_t addrlen) | 596 | socklen_t addrlen) |
671 | { | 597 | { |
672 | struct Plugin *plugin = cls; | 598 | struct Plugin *plugin = cls; |
673 | struct IPv4HttpAddress *t4 = NULL; | ||
674 | struct IPv4HttpAddressWrapper *w_t4 = NULL; | 599 | struct IPv4HttpAddressWrapper *w_t4 = NULL; |
675 | struct IPv6HttpAddress *t6 = NULL; | ||
676 | struct IPv6HttpAddressWrapper *w_t6 = NULL; | 600 | struct IPv6HttpAddressWrapper *w_t6 = NULL; |
677 | int af; | 601 | int af; |
678 | 602 | ||
@@ -683,9 +607,9 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
683 | w_t4 = plugin->ipv4_addr_head; | 607 | w_t4 = plugin->ipv4_addr_head; |
684 | while (w_t4 != NULL) | 608 | while (w_t4 != NULL) |
685 | { | 609 | { |
686 | int res = memcmp (&w_t4->addr->ipv4_addr, | 610 | int res = memcmp (&w_t4->addr, |
687 | &((struct sockaddr_in *) addr)->sin_addr, | 611 | (struct sockaddr_in *) addr, |
688 | sizeof (struct in_addr)); | 612 | sizeof (struct sockaddr_in)); |
689 | 613 | ||
690 | if (0 == res) | 614 | if (0 == res) |
691 | break; | 615 | break; |
@@ -694,27 +618,27 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
694 | if (w_t4 == NULL) | 618 | if (w_t4 == NULL) |
695 | { | 619 | { |
696 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); | 620 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); |
697 | t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); | 621 | memcpy (&w_t4->addr, (struct sockaddr_in *) addr, |
698 | memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr, | 622 | sizeof (struct sockaddr_in)); |
699 | sizeof (struct in_addr)); | ||
700 | t4->port = htons (plugin->port); | ||
701 | |||
702 | w_t4->addr = t4; | ||
703 | 623 | ||
704 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, | 624 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, |
705 | plugin->ipv4_addr_tail, w_t4); | 625 | plugin->ipv4_addr_tail, w_t4); |
706 | } | 626 | } |
707 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, | 627 | #if DEBUG_HTTP |
708 | sizeof (struct IPv4HttpAddress)); | 628 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
629 | "Notifying transport to add IPv4 address `%s'\n", | ||
630 | http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in))); | ||
631 | #endif | ||
632 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, sizeof (struct sockaddr_in)); | ||
709 | 633 | ||
710 | break; | 634 | break; |
711 | case AF_INET6: | 635 | case AF_INET6: |
712 | w_t6 = plugin->ipv6_addr_head; | 636 | w_t6 = plugin->ipv6_addr_head; |
713 | while (w_t6) | 637 | while (w_t6) |
714 | { | 638 | { |
715 | int res = memcmp (&w_t6->addr->ipv6_addr, | 639 | int res = memcmp (&w_t6->addr, |
716 | &((struct sockaddr_in6 *) addr)->sin6_addr, | 640 | (struct sockaddr_in6 *) addr, |
717 | sizeof (struct in6_addr)); | 641 | sizeof (struct sockaddr_in6)); |
718 | 642 | ||
719 | if (0 == res) | 643 | if (0 == res) |
720 | break; | 644 | break; |
@@ -723,19 +647,18 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
723 | if (w_t6 == NULL) | 647 | if (w_t6 == NULL) |
724 | { | 648 | { |
725 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); | 649 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); |
726 | t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); | 650 | memcpy (&w_t6->addr, (struct sockaddr_in6 *) addr, |
727 | 651 | sizeof (struct sockaddr_in6)); | |
728 | memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, | ||
729 | sizeof (struct in6_addr)); | ||
730 | t6->port = htons (plugin->port); | ||
731 | |||
732 | w_t6->addr = t6; | ||
733 | 652 | ||
734 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, | 653 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, |
735 | plugin->ipv6_addr_tail, w_t6); | 654 | plugin->ipv6_addr_tail, w_t6); |
736 | } | 655 | } |
737 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, | 656 | #if DEBUG_HTTP |
738 | sizeof (struct IPv6HttpAddress)); | 657 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
658 | "Notifying transport to add IPv6 address `%s'\n", | ||
659 | http_plugin_address_to_string(NULL, &w_t6->addr, sizeof (struct sockaddr_in))); | ||
660 | #endif | ||
661 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr, sizeof (struct sockaddr_in6)); | ||
739 | break; | 662 | break; |
740 | default: | 663 | default: |
741 | return; | 664 | return; |
@@ -759,7 +682,7 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
759 | w_t4 = plugin->ipv4_addr_head; | 682 | w_t4 = plugin->ipv4_addr_head; |
760 | while (w_t4 != NULL) | 683 | while (w_t4 != NULL) |
761 | { | 684 | { |
762 | int res = memcmp (&w_t4->addr->ipv4_addr, | 685 | int res = memcmp (&(w_t4->addr.sin_addr), |
763 | &((struct sockaddr_in *) addr)->sin_addr, | 686 | &((struct sockaddr_in *) addr)->sin_addr, |
764 | sizeof (struct in_addr)); | 687 | sizeof (struct in_addr)); |
765 | 688 | ||
@@ -769,19 +692,24 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
769 | } | 692 | } |
770 | if (w_t4 == NULL) | 693 | if (w_t4 == NULL) |
771 | return; | 694 | return; |
772 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, | 695 | |
773 | sizeof (struct IPv4HttpAddress)); | 696 | #if DEBUG_HTTP |
697 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
698 | "Notifying transport to remove IPv4 address `%s'\n", | ||
699 | http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in))); | ||
700 | #endif | ||
701 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, | ||
702 | sizeof (struct sockaddr_in)); | ||
774 | 703 | ||
775 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, | 704 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, |
776 | w_t4); | 705 | w_t4); |
777 | GNUNET_free (w_t4->addr); | ||
778 | GNUNET_free (w_t4); | 706 | GNUNET_free (w_t4); |
779 | break; | 707 | break; |
780 | case AF_INET6: | 708 | case AF_INET6: |
781 | w_t6 = plugin->ipv6_addr_head; | 709 | w_t6 = plugin->ipv6_addr_head; |
782 | while (w_t6 != NULL) | 710 | while (w_t6 != NULL) |
783 | { | 711 | { |
784 | int res = memcmp (&w_t6->addr->ipv6_addr, | 712 | int res = memcmp (&(w_t6->addr.sin6_addr), |
785 | &((struct sockaddr_in6 *) addr)->sin6_addr, | 713 | &((struct sockaddr_in6 *) addr)->sin6_addr, |
786 | sizeof (struct in6_addr)); | 714 | sizeof (struct in6_addr)); |
787 | 715 | ||
@@ -791,12 +719,16 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
791 | } | 719 | } |
792 | if (w_t6 == NULL) | 720 | if (w_t6 == NULL) |
793 | return; | 721 | return; |
794 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, | 722 | #if DEBUG_HTTP |
795 | sizeof (struct IPv6HttpAddress)); | 723 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
724 | "Notifying transport to remove IPv6 address `%s'\n", | ||
725 | http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in))); | ||
726 | #endif | ||
727 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr, | ||
728 | sizeof (struct sockaddr_in6 )); | ||
796 | 729 | ||
797 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, | 730 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, |
798 | w_t6); | 731 | w_t6); |
799 | GNUNET_free (w_t6->addr); | ||
800 | GNUNET_free (w_t6); | 732 | GNUNET_free (w_t6); |
801 | break; | 733 | break; |
802 | default: | 734 | default: |
@@ -820,7 +752,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
820 | { | 752 | { |
821 | GNUNET_assert (cls != NULL); | 753 | GNUNET_assert (cls != NULL); |
822 | struct Plugin *plugin = cls; | 754 | struct Plugin *plugin = cls; |
823 | static int limit; | 755 | //static int limit; |
824 | #if DEBUG_HTTP | 756 | #if DEBUG_HTTP |
825 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 757 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
826 | "NPMC called %s to address `%s'\n", | 758 | "NPMC called %s to address `%s'\n", |
@@ -832,9 +764,9 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
832 | { | 764 | { |
833 | case GNUNET_YES: | 765 | case GNUNET_YES: |
834 | // FIXME DEBUGGING | 766 | // FIXME DEBUGGING |
835 | if (limit < 1) | 767 | //if (limit < 1) |
836 | nat_add_address (cls, add_remove, addr, addrlen); | 768 | nat_add_address (cls, add_remove, addr, addrlen); |
837 | limit++; | 769 | //limit++; |
838 | // FIXME END | 770 | // FIXME END |
839 | break; | 771 | break; |
840 | case GNUNET_NO: | 772 | case GNUNET_NO: |
@@ -895,7 +827,6 @@ stop_report_addresses (struct Plugin *plugin) | |||
895 | w_t4 = plugin->ipv4_addr_head; | 827 | w_t4 = plugin->ipv4_addr_head; |
896 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, | 828 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, |
897 | w_t4); | 829 | w_t4); |
898 | GNUNET_free (w_t4->addr); | ||
899 | GNUNET_free (w_t4); | 830 | GNUNET_free (w_t4); |
900 | } | 831 | } |
901 | 832 | ||
@@ -904,7 +835,6 @@ stop_report_addresses (struct Plugin *plugin) | |||
904 | w_t6 = plugin->ipv6_addr_head; | 835 | w_t6 = plugin->ipv6_addr_head; |
905 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, | 836 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, |
906 | w_t6); | 837 | w_t6); |
907 | GNUNET_free (w_t6->addr); | ||
908 | GNUNET_free (w_t6); | 838 | GNUNET_free (w_t6); |
909 | } | 839 | } |
910 | } | 840 | } |