diff options
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index d55cdb76b..d99f531b7 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -268,13 +268,10 @@ http_plugin_address_pretty_printer (void *cls, const char *type, | |||
268 | static int | 268 | static int |
269 | http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | 269 | http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) |
270 | { | 270 | { |
271 | |||
272 | struct Plugin *plugin = cls; | 271 | struct Plugin *plugin = cls; |
273 | struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head; | 272 | struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head; |
274 | struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head; | 273 | struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head; |
275 | 274 | ||
276 | |||
277 | |||
278 | GNUNET_assert (cls != NULL); | 275 | GNUNET_assert (cls != NULL); |
279 | if ((addrlen != sizeof (struct sockaddr_in)) || | 276 | if ((addrlen != sizeof (struct sockaddr_in)) || |
280 | (addrlen != sizeof (struct sockaddr_in6))) | 277 | (addrlen != sizeof (struct sockaddr_in6))) |
@@ -358,11 +355,12 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
358 | * @param added length of created address | 355 | * @param added length of created address |
359 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 356 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
360 | */ | 357 | */ |
361 | int http_string_to_address (void *cls, | 358 | int |
362 | const char *addr, | 359 | http_string_to_address (void *cls, |
363 | uint16_t addrlen, | 360 | const char *addr, |
364 | void **buf, | 361 | uint16_t addrlen, |
365 | size_t *added) | 362 | void **buf, |
363 | size_t *added) | ||
366 | { | 364 | { |
367 | #if !BUILD_HTTPS | 365 | #if !BUILD_HTTPS |
368 | char *protocol = "http"; | 366 | char *protocol = "http"; |
@@ -425,7 +423,7 @@ int http_string_to_address (void *cls, | |||
425 | (*added) = sizeof (struct IPv4HttpAddress); | 423 | (*added) = sizeof (struct IPv4HttpAddress); |
426 | return GNUNET_OK; | 424 | return GNUNET_OK; |
427 | } | 425 | } |
428 | else if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv6(addr_str, strlen(addr_str), &addr_6)) | 426 | if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv6(addr_str, strlen(addr_str), &addr_6)) |
429 | { | 427 | { |
430 | http_6addr = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); | 428 | http_6addr = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); |
431 | http_6addr->u6_port = addr_6.sin6_port; | 429 | http_6addr->u6_port = addr_6.sin6_port; |
@@ -434,18 +432,14 @@ int http_string_to_address (void *cls, | |||
434 | (*added) = sizeof (struct IPv6HttpAddress); | 432 | (*added) = sizeof (struct IPv6HttpAddress); |
435 | return GNUNET_OK; | 433 | return GNUNET_OK; |
436 | } | 434 | } |
437 | else | 435 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
438 | { | 436 | "Invalid address string `%s' to convert to address\n", |
439 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 437 | addr_str); |
440 | "Invalid address string `%s' to convert to address\n", | 438 | GNUNET_break (0); |
441 | addr_str); | 439 | return GNUNET_SYSERR; |
442 | GNUNET_break (0); | ||
443 | return GNUNET_SYSERR; | ||
444 | } | ||
445 | } | 440 | } |
446 | 441 | ||
447 | 442 | ||
448 | |||
449 | /** | 443 | /** |
450 | * Function called for a quick conversion of the binary address to | 444 | * Function called for a quick conversion of the binary address to |
451 | * a numeric address. Note that the caller must not free the | 445 | * a numeric address. Note that the caller must not free the |
@@ -513,6 +507,7 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
513 | return rbuf; | 507 | return rbuf; |
514 | } | 508 | } |
515 | 509 | ||
510 | |||
516 | struct Session * | 511 | struct Session * |
517 | lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 512 | lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
518 | struct Session *session, const void *addr, size_t addrlen, | 513 | struct Session *session, const void *addr, size_t addrlen, |
@@ -526,11 +521,11 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar | |||
526 | { | 521 | { |
527 | #if 0 | 522 | #if 0 |
528 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 523 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
529 | "Comparing peer `%s' address `%s' len %i session %X to \n", | 524 | "Comparing peer `%s' address `%s' len %i session %p to \n", |
530 | GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), addrlen, | 525 | GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), addrlen, |
531 | session); | 526 | session); |
532 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 527 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
533 | "peer `%s' address `%s' len %i session %X \n\n", | 528 | "peer `%s' address `%s' len %i session %p \n\n", |
534 | GNUNET_i2s (&t->target), GNUNET_a2s (t->addr, t->addrlen), | 529 | GNUNET_i2s (&t->target), GNUNET_a2s (t->addr, t->addrlen), |
535 | t->addrlen, t); | 530 | t->addrlen, t); |
536 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "memcmp %i \n", | 531 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "memcmp %i \n", |
@@ -558,6 +553,7 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar | |||
558 | return NULL; | 553 | return NULL; |
559 | } | 554 | } |
560 | 555 | ||
556 | |||
561 | struct Session * | 557 | struct Session * |
562 | lookup_session (struct Plugin *plugin, | 558 | lookup_session (struct Plugin *plugin, |
563 | const struct GNUNET_HELLO_Address *address) | 559 | const struct GNUNET_HELLO_Address *address) |
@@ -572,6 +568,7 @@ lookup_session (struct Plugin *plugin, | |||
572 | return NULL; | 568 | return NULL; |
573 | } | 569 | } |
574 | 570 | ||
571 | |||
575 | int | 572 | int |
576 | exist_session (struct Plugin *plugin, struct Session *s) | 573 | exist_session (struct Plugin *plugin, struct Session *s) |
577 | { | 574 | { |
@@ -589,7 +586,6 @@ exist_session (struct Plugin *plugin, struct Session *s) | |||
589 | } | 586 | } |
590 | 587 | ||
591 | 588 | ||
592 | |||
593 | void | 589 | void |
594 | delete_session (struct Session *s) | 590 | delete_session (struct Session *s) |
595 | { | 591 | { |
@@ -606,6 +602,7 @@ delete_session (struct Session *s) | |||
606 | GNUNET_free (s); | 602 | GNUNET_free (s); |
607 | } | 603 | } |
608 | 604 | ||
605 | |||
609 | struct Session * | 606 | struct Session * |
610 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 607 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
611 | const void *addr, size_t addrlen) | 608 | const void *addr, size_t addrlen) |
@@ -626,7 +623,6 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
626 | } | 623 | } |
627 | 624 | ||
628 | 625 | ||
629 | |||
630 | void | 626 | void |
631 | notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | 627 | notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, |
632 | struct Session *s) | 628 | struct Session *s) |
@@ -638,6 +634,7 @@ notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
638 | delete_session (s); | 634 | delete_session (s); |
639 | } | 635 | } |
640 | 636 | ||
637 | |||
641 | /** | 638 | /** |
642 | * Creates a new outbound session the transport service will use to send data to the | 639 | * Creates a new outbound session the transport service will use to send data to the |
643 | * peer | 640 | * peer |
@@ -646,7 +643,6 @@ notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
646 | * @param address the address | 643 | * @param address the address |
647 | * @return the session or NULL of max connections exceeded | 644 | * @return the session or NULL of max connections exceeded |
648 | */ | 645 | */ |
649 | |||
650 | static struct Session * | 646 | static struct Session * |
651 | http_get_session (void *cls, | 647 | http_get_session (void *cls, |
652 | const struct GNUNET_HELLO_Address *address) | 648 | const struct GNUNET_HELLO_Address *address) |
@@ -730,6 +726,7 @@ http_get_session (void *cls, | |||
730 | return s; | 726 | return s; |
731 | } | 727 | } |
732 | 728 | ||
729 | |||
733 | /** | 730 | /** |
734 | * Function that can be used by the transport service to transmit | 731 | * Function that can be used by the transport service to transmit |
735 | * a message using the plugin. Note that in the case of a | 732 | * a message using the plugin. Note that in the case of a |
@@ -791,7 +788,6 @@ http_plugin_send (void *cls, | |||
791 | } | 788 | } |
792 | 789 | ||
793 | /* create new message and schedule */ | 790 | /* create new message and schedule */ |
794 | |||
795 | msg = GNUNET_malloc (sizeof (struct HTTP_Message) + msgbuf_size); | 791 | msg = GNUNET_malloc (sizeof (struct HTTP_Message) + msgbuf_size); |
796 | msg->next = NULL; | 792 | msg->next = NULL; |
797 | msg->size = msgbuf_size; | 793 | msg->size = msgbuf_size; |
@@ -875,6 +871,7 @@ http_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
875 | } | 871 | } |
876 | } | 872 | } |
877 | 873 | ||
874 | |||
878 | static void * | 875 | static void * |
879 | find_address (struct Plugin *plugin, const struct sockaddr *addr, socklen_t addrlen) | 876 | find_address (struct Plugin *plugin, const struct sockaddr *addr, socklen_t addrlen) |
880 | { | 877 | { |
@@ -933,6 +930,7 @@ find_address (struct Plugin *plugin, const struct sockaddr *addr, socklen_t addr | |||
933 | return NULL; | 930 | return NULL; |
934 | } | 931 | } |
935 | 932 | ||
933 | |||
936 | static void | 934 | static void |
937 | nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | 935 | nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, |
938 | socklen_t addrlen) | 936 | socklen_t addrlen) |
@@ -993,6 +991,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
993 | 991 | ||
994 | } | 992 | } |
995 | 993 | ||
994 | |||
996 | static void | 995 | static void |
997 | nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | 996 | nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, |
998 | socklen_t addrlen) | 997 | socklen_t addrlen) |
@@ -1044,9 +1043,9 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
1044 | default: | 1043 | default: |
1045 | return; | 1044 | return; |
1046 | } | 1045 | } |
1047 | |||
1048 | } | 1046 | } |
1049 | 1047 | ||
1048 | |||
1050 | /** | 1049 | /** |
1051 | * Our external IP address/port mapping has changed. | 1050 | * Our external IP address/port mapping has changed. |
1052 | * | 1051 | * |
@@ -1079,6 +1078,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
1079 | } | 1078 | } |
1080 | } | 1079 | } |
1081 | 1080 | ||
1081 | |||
1082 | void | 1082 | void |
1083 | http_check_ipv6 (struct Plugin *plugin) | 1083 | http_check_ipv6 (struct Plugin *plugin) |
1084 | { | 1084 | { |
@@ -1112,6 +1112,7 @@ http_check_ipv6 (struct Plugin *plugin) | |||
1112 | } | 1112 | } |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | |||
1115 | int | 1116 | int |
1116 | http_get_addresses (struct Plugin *plugin, const char *serviceName, | 1117 | http_get_addresses (struct Plugin *plugin, const char *serviceName, |
1117 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1118 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -1322,6 +1323,7 @@ start_report_addresses (struct Plugin *plugin) | |||
1322 | } | 1323 | } |
1323 | } | 1324 | } |
1324 | 1325 | ||
1326 | |||
1325 | static void | 1327 | static void |
1326 | stop_report_addresses (struct Plugin *plugin) | 1328 | stop_report_addresses (struct Plugin *plugin) |
1327 | { | 1329 | { |
@@ -1349,6 +1351,7 @@ stop_report_addresses (struct Plugin *plugin) | |||
1349 | } | 1351 | } |
1350 | } | 1352 | } |
1351 | 1353 | ||
1354 | |||
1352 | static int | 1355 | static int |
1353 | configure_plugin (struct Plugin *plugin) | 1356 | configure_plugin (struct Plugin *plugin) |
1354 | { | 1357 | { |
@@ -1504,6 +1507,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1504 | 1507 | ||
1505 | } | 1508 | } |
1506 | 1509 | ||
1510 | |||
1507 | /** | 1511 | /** |
1508 | * Start session timeout | 1512 | * Start session timeout |
1509 | */ | 1513 | */ |
@@ -1521,6 +1525,7 @@ start_session_timeout (struct Session *s) | |||
1521 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1525 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1522 | } | 1526 | } |
1523 | 1527 | ||
1528 | |||
1524 | /** | 1529 | /** |
1525 | * Increment session timeout due to activity | 1530 | * Increment session timeout due to activity |
1526 | */ | 1531 | */ |
@@ -1539,6 +1544,7 @@ reschedule_session_timeout (struct Session *s) | |||
1539 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1544 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1540 | } | 1545 | } |
1541 | 1546 | ||
1547 | |||
1542 | /** | 1548 | /** |
1543 | * Cancel timeout | 1549 | * Cancel timeout |
1544 | */ | 1550 | */ |