Commit ea9d69e8 authored by Colin Granville's avatar Colin Granville Committed by ROOL
Browse files

Make a NULL URL bind to INADDR_ANY and initialise nbio flag

Detail:
  Changed mbedtls_net_bind to accept a NULL url which will bind the socket to INADDR_ANY.
  Changed mbedtls_net_init to initialise nbio to blocking (0) - previously uninitialised.
Admin:
  Tested with demonstration server on ARMX6.

Version 2.22. Tagged as 'mbedTLS-2_22'
parent 3029822c
/* (2.21)
/* (2.22)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.21
#define Module_MajorVersion_CMHG 2.22
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 Dec 2020
#define Module_Date_CMHG 15 Mar 2021
#define Module_MajorVersion "2.21"
#define Module_Version 221
#define Module_MajorVersion "2.22"
#define Module_Version 222
#define Module_MinorVersion ""
#define Module_Date "19 Dec 2020"
#define Module_Date "15 Mar 2021"
#define Module_ApplicationDate "19-Dec-20"
#define Module_ApplicationDate "15-Mar-21"
#define Module_ComponentName "mbedTLS"
#define Module_FullVersion "2.21"
#define Module_HelpVersion "2.21 (19 Dec 2020)"
#define Module_LibraryVersionInfo "2:21"
#define Module_FullVersion "2.22"
#define Module_HelpVersion "2.22 (15 Mar 2021)"
#define Module_LibraryVersionInfo "2:22"
......@@ -136,6 +136,7 @@ static int net_prepare(void)
void mbedtls_net_init(mbedtls_net_context *ctx)
{
ctx->fd = -1;
ctx->nbio = 0; /* Default to blocking */
}
/*
......@@ -221,9 +222,26 @@ int mbedtls_net_bind(mbedtls_net_context *ctx,
const char *url, const char *port, int proto)
{
int n, ret;
struct hostent *host;
char **cur;
struct sockaddr_in addr;
const struct hostent *host;
char **cur;
struct sockaddr_in addr;
static const struct in_addr inaddr_any_addr =
{
INADDR_ANY /* s_addr */
};
static const char *inaddr_any_addr_list[] =
{
(char *)&inaddr_any_addr,
NULL
};
static const struct hostent inaddr_any_host =
{
NULL, /* h_name */
NULL, /* h_aliases */
AF_INET, /* h_addrtype */
sizeof(struct in_addr), /* h_length */
(char **)inaddr_any_addr_list /* h_addr_list */
};
ret = net_prepare();
if (ret != 0)
......@@ -231,27 +249,35 @@ int mbedtls_net_bind(mbedtls_net_context *ctx,
return ret;
}
/* No IPv6 support beneath us yet, resolve name to
* to IPv4 address.
*/
while (1)
if (url == NULL)
{
_kernel_oserror *error;
int errnum;
error = _swix(Resolver_GetHost, _IN(0) | _OUTR(0,1),
url, &errnum, &host);
if (error != NULL)
{
return MBEDTLS_ERR_NET_UNKNOWN_HOST;
}
if (errnum == EINPROGRESS)
/* Bind to INADDR_ANY */
host = &inaddr_any_host;
}
else
{
/* No IPv6 support beneath us yet, resolve name to
* to IPv4 address.
*/
while (1)
{
backoff();
continue;
_kernel_oserror *error;
int errnum;
error = _swix(Resolver_GetHost, _IN(0) | _OUTR(0,1),
url, &errnum, &host);
if (error != NULL)
{
return MBEDTLS_ERR_NET_UNKNOWN_HOST;
}
if (errnum == EINPROGRESS)
{
backoff();
continue;
}
if (errnum == 0) break;
host = NULL; /* Some other error */
}
if (errnum == 0) break;
host = NULL; /* Some other error */
}
if (host == NULL)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment