diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-06 15:48:55 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-06 15:48:55 +0000 |
commit | c06f842920f131a2bad6d92e178808c570d88af7 (patch) | |
tree | c17b65538a05223a49583b381bde7f012d7189ce /src/transport/plugin_transport_http.c | |
parent | fee3601ae573e7a98419036775b30b53faeec157 (diff) | |
download | gnunet-c06f842920f131a2bad6d92e178808c570d88af7.tar.gz gnunet-c06f842920f131a2bad6d92e178808c570d88af7.zip |
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 60eefd419..d3d1c7928 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -780,6 +780,36 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
780 | } | 780 | } |
781 | } | 781 | } |
782 | 782 | ||
783 | void | ||
784 | http_check_ipv6 (struct Plugin *plugin) | ||
785 | { | ||
786 | struct GNUNET_NETWORK_Handle *desc = NULL; | ||
787 | if (plugin->ipv6 == GNUNET_YES) | ||
788 | { | ||
789 | /* probe IPv6 support */ | ||
790 | desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | ||
791 | if (NULL == desc) | ||
792 | { | ||
793 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || | ||
794 | (errno == EACCES)) | ||
795 | { | ||
796 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | ||
797 | } | ||
798 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name, | ||
799 | _ | ||
800 | ("Disabling IPv6 since it is not supported on this system\n")); | ||
801 | plugin->ipv6 = GNUNET_NO; | ||
802 | } | ||
803 | else | ||
804 | { | ||
805 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
806 | _("Enabling IPv6 on this system\n")); | ||
807 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc)); | ||
808 | desc = NULL; | ||
809 | } | ||
810 | } | ||
811 | } | ||
812 | |||
783 | int | 813 | int |
784 | http_get_addresses (struct Plugin *plugin, | 814 | http_get_addresses (struct Plugin *plugin, |
785 | const char *serviceName, | 815 | const char *serviceName, |
@@ -788,7 +818,6 @@ http_get_addresses (struct Plugin *plugin, | |||
788 | socklen_t ** addr_lens) | 818 | socklen_t ** addr_lens) |
789 | { | 819 | { |
790 | int disablev6; | 820 | int disablev6; |
791 | struct GNUNET_NETWORK_Handle *desc; | ||
792 | unsigned long long port; | 821 | unsigned long long port; |
793 | struct addrinfo hints; | 822 | struct addrinfo hints; |
794 | struct addrinfo *res; | 823 | struct addrinfo *res; |
@@ -803,36 +832,9 @@ http_get_addresses (struct Plugin *plugin, | |||
803 | 832 | ||
804 | *addrs = NULL; | 833 | *addrs = NULL; |
805 | *addr_lens = NULL; | 834 | *addr_lens = NULL; |
806 | desc = NULL; | ||
807 | 835 | ||
808 | disablev6 = !plugin->ipv6; | 836 | disablev6 = !plugin->ipv6; |
809 | 837 | ||
810 | if (!disablev6) | ||
811 | { | ||
812 | /* probe IPv6 support */ | ||
813 | desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | ||
814 | if (NULL == desc) | ||
815 | { | ||
816 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || | ||
817 | (errno == EACCES)) | ||
818 | { | ||
819 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | ||
820 | return GNUNET_SYSERR; | ||
821 | } | ||
822 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
823 | _ | ||
824 | ("Disabling IPv6 since it is not supported on this system\n"), | ||
825 | serviceName, STRERROR (errno)); | ||
826 | disablev6 = GNUNET_YES; | ||
827 | plugin->ipv6 = GNUNET_NO; | ||
828 | } | ||
829 | else | ||
830 | { | ||
831 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc)); | ||
832 | desc = NULL; | ||
833 | } | ||
834 | } | ||
835 | |||
836 | port = 0; | 838 | port = 0; |
837 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) | 839 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) |
838 | { | 840 | { |
@@ -1202,6 +1204,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
1202 | #endif | 1204 | #endif |
1203 | /* Configure plugin from configuration */ | 1205 | /* Configure plugin from configuration */ |
1204 | 1206 | ||
1207 | http_check_ipv6 (plugin); | ||
1208 | |||
1205 | res = configure_plugin (plugin); | 1209 | res = configure_plugin (plugin); |
1206 | if (res == GNUNET_SYSERR) | 1210 | if (res == GNUNET_SYSERR) |
1207 | { | 1211 | { |