diff options
Diffstat (limited to 'src/transport/plugin_transport_http_common.c')
-rw-r--r-- | src/transport/plugin_transport_http_common.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index 77558a49b..13f01f713 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c | |||
@@ -854,8 +854,10 @@ http_common_address_get_size (const struct HttpAddress * addr) | |||
854 | * @return #GNUNET_YES if equal, #GNUNET_NO if not, #GNUNET_SYSERR on error | 854 | * @return #GNUNET_YES if equal, #GNUNET_NO if not, #GNUNET_SYSERR on error |
855 | */ | 855 | */ |
856 | size_t | 856 | size_t |
857 | http_common_cmp_addresses (const void *addr1, size_t addrlen1, | 857 | http_common_cmp_addresses (const void *addr1, |
858 | const void *addr2, size_t addrlen2) | 858 | size_t addrlen1, |
859 | const void *addr2, | ||
860 | size_t addrlen2) | ||
859 | { | 861 | { |
860 | const char *a1 = addr1; | 862 | const char *a1 = addr1; |
861 | const char *a2 = addr2; | 863 | const char *a2 = addr2; |
@@ -888,4 +890,49 @@ http_common_cmp_addresses (const void *addr1, size_t addrlen1, | |||
888 | return GNUNET_NO; | 890 | return GNUNET_NO; |
889 | } | 891 | } |
890 | 892 | ||
893 | |||
894 | /** | ||
895 | * Function obtain the network type for an address. | ||
896 | * | ||
897 | * @param env the environment | ||
898 | * @param address the address | ||
899 | * @return the network type | ||
900 | */ | ||
901 | enum GNUNET_ATS_Network_Type | ||
902 | http_common_get_network_for_address (struct GNUNET_TRANSPORT_PluginEnvironment *env, | ||
903 | const struct GNUNET_HELLO_Address *address) | ||
904 | { | ||
905 | |||
906 | struct sockaddr *sa; | ||
907 | enum GNUNET_ATS_Network_Type net_type; | ||
908 | size_t salen = 0; | ||
909 | int res; | ||
910 | |||
911 | net_type = GNUNET_ATS_NET_UNSPECIFIED; | ||
912 | sa = http_common_socket_from_address (address->address, | ||
913 | address->address_length, | ||
914 | &res); | ||
915 | if (GNUNET_SYSERR == res) | ||
916 | return net_type; | ||
917 | if (GNUNET_YES == res) | ||
918 | { | ||
919 | GNUNET_assert (NULL != sa); | ||
920 | if (AF_INET == sa->sa_family) | ||
921 | { | ||
922 | salen = sizeof (struct sockaddr_in); | ||
923 | } | ||
924 | else if (AF_INET6 == sa->sa_family) | ||
925 | { | ||
926 | salen = sizeof (struct sockaddr_in6); | ||
927 | } | ||
928 | net_type = env->get_address_type (env->cls, | ||
929 | sa, | ||
930 | salen); | ||
931 | GNUNET_free (sa); | ||
932 | } | ||
933 | return net_type; | ||
934 | } | ||
935 | |||
936 | |||
937 | |||
891 | /* end of plugin_transport_http_common.c */ | 938 | /* end of plugin_transport_http_common.c */ |