Make HAVE_IPV6 non-optional
diff --git a/ChangeLog b/ChangeLog
index 4ad8aba..40adc69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
to override the whole module.
API Changes
+ * Configuration option POLARSSL_HAVE_IPV6 was removed (always enabled).
* All public identifiers moved to the mbedtls_* or MBEDTLS_* namespace.
* ecdsa_write_signature() gained an addtional md_alg argument and
ecdsa_write_signature_det() was deprecated.
@@ -57,6 +58,7 @@
custom config.h
Changes
+ * The NET layer now unconditionnaly relies on getaddrinfo().
* Remove test program o_p_test, the script compat.sh does more.
* Remove test program ssl_test, superseded by ssl-opt.sh.
* Remove helper script active-config.pl
diff --git a/configs/config-ccm-psk-tls1_2.h b/configs/config-ccm-psk-tls1_2.h
index 3f9d9cd..72a0360 100644
--- a/configs/config-ccm-psk-tls1_2.h
+++ b/configs/config-ccm-psk-tls1_2.h
@@ -12,7 +12,6 @@
#define MBEDTLS_CONFIG_H
/* System support */
-//#define MBEDTLS_HAVE_IPV6 /* Optional */
//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */
/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */
diff --git a/configs/config-mini-tls1_1.h b/configs/config-mini-tls1_1.h
index 69200f7..512fc40 100644
--- a/configs/config-mini-tls1_1.h
+++ b/configs/config-mini-tls1_1.h
@@ -11,7 +11,6 @@
/* System support */
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
-#define MBEDTLS_HAVE_IPV6
/* mbed TLS feature support */
#define MBEDTLS_CIPHER_MODE_CBC
diff --git a/configs/config-picocoin.h b/configs/config-picocoin.h
index 90879b8..c5f974c 100644
--- a/configs/config-picocoin.h
+++ b/configs/config-picocoin.h
@@ -16,7 +16,6 @@
#define MBEDTLS_HAVE_LONGLONG
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
-#define MBEDTLS_HAVE_IPV6
/* mbed TLS feature support */
#define MBEDTLS_CIPHER_MODE_CBC
diff --git a/configs/config-suite-b.h b/configs/config-suite-b.h
index 0be7155..78b89e5 100644
--- a/configs/config-suite-b.h
+++ b/configs/config-suite-b.h
@@ -18,7 +18,6 @@
/* System support */
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
-#define MBEDTLS_HAVE_IPV6
/* mbed TLS feature support */
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h
index edae8d7..cc06b4a 100644
--- a/include/mbedtls/compat-1.3.h
+++ b/include/mbedtls/compat-1.3.h
@@ -246,9 +246,6 @@
#if defined MBEDTLS_HAVE_INT8
#define POLARSSL_HAVE_INT8 MBEDTLS_HAVE_INT8
#endif
-#if defined MBEDTLS_HAVE_IPV6
-#define POLARSSL_HAVE_IPV6 MBEDTLS_HAVE_IPV6
-#endif
#if defined MBEDTLS_HAVE_LONGLONG
#define POLARSSL_HAVE_LONGLONG MBEDTLS_HAVE_LONGLONG
#endif
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index c6cdc00..3cd2889 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -100,18 +100,6 @@
#define MBEDTLS_HAVE_TIME
/**
- * \def MBEDTLS_HAVE_IPV6
- *
- * System supports the basic socket interface for IPv6 (RFC 3493),
- * specifically getaddrinfo(), freeaddrinfo() and struct sockaddr_storage.
- *
- * Note: on Windows/MingW, XP or higher is required.
- *
- * Comment if your system does not support the IPv6 socket interface
- */
-#define MBEDTLS_HAVE_IPV6
-
-/**
* \def MBEDTLS_PLATFORM_MEMORY
*
* Enable the memory allocation layer.
diff --git a/library/net.c b/library/net.c
index cd53d80..0db8834 100644
--- a/library/net.c
+++ b/library/net.c
@@ -35,14 +35,12 @@
#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
!defined(EFI32)
-#if defined(MBEDTLS_HAVE_IPV6)
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
/* Enables getaddrinfo() & Co */
#define _WIN32_WINNT 0x0501
#include <ws2tcpip.h>
-#endif
#include <winsock2.h>
#include <windows.h>
@@ -97,46 +95,6 @@
#include <inttypes.h>
#endif
-#if !defined(MBEDTLS_HAVE_IPV6)
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
- defined(__DragonFly__)
-#include <sys/endian.h>
-#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H) || \
- defined(EFIX64) || defined(EFI32)
-#include <machine/endian.h>
-#elif defined(sun)
-#include <sys/isa_defs.h>
-#elif defined(_AIX) || defined(HAVE_ARPA_NAMESER_COMPAT_H)
-#include <arpa/nameser_compat.h>
-#else
-#include <endian.h>
-#endif
-
-/*
- * htons() is not always available.
- * By default go for LITTLE_ENDIAN variant. Otherwise hope for _BYTE_ORDER and
- * __BIG_ENDIAN to help determine endianness.
- */
-#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
- __BYTE_ORDER == __BIG_ENDIAN
-static unsigned short net_htons( unsigned short n ) { return( n ); }
-static unsigned long net_htonl( unsigned long n ) { return( n ); }
-#else
-static unsigned short net_htons( unsigned short n )
-{
- return( (((unsigned short) n & 0xFF ) << 8 ) |
- (((unsigned short) n & 0xFF00 ) >> 8 ) );
-}
-static unsigned long net_htonl( unsigned long n )
-{
- return( (((unsigned long ) n & 0xFF ) << 24) |
- (((unsigned long ) n & 0xFF00 ) << 8 ) |
- (((unsigned long ) n & 0xFF0000 ) >> 8 ) |
- (((unsigned long ) n & 0xFF000000) >> 24) );
-}
-#endif
-#endif /* !MBEDTLS_HAVE_IPV6 */
-
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
@@ -172,7 +130,6 @@
*/
int mbedtls_net_connect( int *fd, const char *host, int port, int proto )
{
-#if defined(MBEDTLS_HAVE_IPV6)
int ret;
struct addrinfo hints, *addr_list, *cur;
char port_str[6];
@@ -218,41 +175,6 @@
freeaddrinfo( addr_list );
return( ret );
-
-#else
- /* Legacy IPv4-only version */
-
- int ret;
- struct sockaddr_in server_addr;
- struct hostent *server_host;
-
- if( ( ret = net_prepare() ) != 0 )
- return( ret );
-
- if( ( server_host = gethostbyname( host ) ) == NULL )
- return( MBEDTLS_ERR_NET_UNKNOWN_HOST );
-
- if( ( *fd = (int) socket( AF_INET,
- proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM,
- proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP ) ) < 0 )
- return( MBEDTLS_ERR_NET_SOCKET_FAILED );
-
- memcpy( (void *) &server_addr.sin_addr,
- (void *) server_host->h_addr,
- server_host->h_length );
-
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = net_htons( port );
-
- if( connect( *fd, (struct sockaddr *) &server_addr,
- sizeof( server_addr ) ) < 0 )
- {
- close( *fd );
- return( MBEDTLS_ERR_NET_CONNECT_FAILED );
- }
-
- return( 0 );
-#endif /* MBEDTLS_HAVE_IPV6 */
}
/*
@@ -260,7 +182,6 @@
*/
int mbedtls_net_bind( int *fd, const char *bind_ip, int port, int proto )
{
-#if defined(MBEDTLS_HAVE_IPV6)
int n, ret;
struct addrinfo hints, *addr_list, *cur;
char port_str[6];
@@ -331,64 +252,6 @@
return( ret );
-#else
- /* Legacy IPv4-only version */
-
- int ret, n, c[4];
- struct sockaddr_in server_addr;
-
- if( ( ret = net_prepare() ) != 0 )
- return( ret );
-
- if( ( *fd = (int) socket( AF_INET,
- proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM,
- proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP ) ) < 0 )
- return( MBEDTLS_ERR_NET_SOCKET_FAILED );
-
- n = 1;
- setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR,
- (const char *) &n, sizeof( n ) );
-
- server_addr.sin_addr.s_addr = net_htonl( INADDR_ANY );
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = net_htons( port );
-
- if( bind_ip != NULL )
- {
- memset( c, 0, sizeof( c ) );
- sscanf( bind_ip, "%d.%d.%d.%d", &c[0], &c[1], &c[2], &c[3] );
-
- for( n = 0; n < 4; n++ )
- if( c[n] < 0 || c[n] > 255 )
- break;
-
- if( n == 4 )
- server_addr.sin_addr.s_addr = net_htonl(
- ( (uint32_t) c[0] << 24 ) |
- ( (uint32_t) c[1] << 16 ) |
- ( (uint32_t) c[2] << 8 ) |
- ( (uint32_t) c[3] ) );
- }
-
- if( bind( *fd, (struct sockaddr *) &server_addr,
- sizeof( server_addr ) ) < 0 )
- {
- close( *fd );
- return( MBEDTLS_ERR_NET_BIND_FAILED );
- }
-
- /* Listen only makes sense for TCP */
- if( proto == MBEDTLS_NET_PROTO_TCP )
- {
- if( listen( *fd, MBEDTLS_NET_LISTEN_BACKLOG ) != 0 )
- {
- close( *fd );
- return( MBEDTLS_ERR_NET_LISTEN_FAILED );
- }
- }
-
- return( 0 );
-#endif /* MBEDTLS_HAVE_IPV6 */
}
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
@@ -439,11 +302,7 @@
int ret;
int type;
-#if defined(MBEDTLS_HAVE_IPV6)
struct sockaddr_storage client_addr;
-#else
- struct sockaddr_in client_addr;
-#endif
#if defined(__socklen_t_defined) || defined(_SOCKLEN_T) || \
defined(_SOCKLEN_T_DECLARED)
@@ -495,7 +354,6 @@
if( client_ip != NULL )
{
-#if defined(MBEDTLS_HAVE_IPV6)
if( client_addr.ss_family == AF_INET )
{
struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr;
@@ -508,10 +366,6 @@
memcpy( client_ip, &addr6->sin6_addr.s6_addr,
sizeof( addr6->sin6_addr.s6_addr ) );
}
-#else
- memcpy( client_ip, &client_addr.sin_addr.s_addr,
- sizeof( client_addr.sin_addr.s_addr ) );
-#endif /* MBEDTLS_HAVE_IPV6 */
}
return( 0 );
diff --git a/library/version_features.c b/library/version_features.c
index e03dfbe..bc3a370 100644
--- a/library/version_features.c
+++ b/library/version_features.c
@@ -57,9 +57,6 @@
#if defined(MBEDTLS_HAVE_TIME)
"MBEDTLS_HAVE_TIME",
#endif /* MBEDTLS_HAVE_TIME */
-#if defined(MBEDTLS_HAVE_IPV6)
- "MBEDTLS_HAVE_IPV6",
-#endif /* MBEDTLS_HAVE_IPV6 */
#if defined(MBEDTLS_PLATFORM_MEMORY)
"MBEDTLS_PLATFORM_MEMORY",
#endif /* MBEDTLS_PLATFORM_MEMORY */