mirror of https://github.com/ARMmbed/mbed-os.git
Multihoming change parameter orded in gethostbyname
parent
00feb5313a
commit
641189c357
|
|
@ -58,7 +58,7 @@ void MULTIHOMING_ASYNCHRONOUS_DNS()
|
||||||
for (unsigned int j = 0; j < interface_num; j++) {
|
for (unsigned int j = 0; j < interface_num; j++) {
|
||||||
|
|
||||||
nsapi_error_t err = get_interface()->gethostbyname_async(dns_test_hosts[i],
|
nsapi_error_t err = get_interface()->gethostbyname_async(dns_test_hosts[i],
|
||||||
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data), interface_name[j]);
|
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data), NSAPI_UNSPEC, interface_name[j]);
|
||||||
TEST_ASSERT(err >= 0);
|
TEST_ASSERT(err >= 0);
|
||||||
|
|
||||||
semaphore.wait();
|
semaphore.wait();
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void MULTIHOMING_SYNCHRONOUS_DNS()
|
||||||
SocketAddress address;
|
SocketAddress address;
|
||||||
for (unsigned int j = 0; j < interface_num; j++) {
|
for (unsigned int j = 0; j < interface_num; j++) {
|
||||||
|
|
||||||
nsapi_error_t err = get_interface()->gethostbyname(dns_test_hosts[i], &address, interface_name[j]);
|
nsapi_error_t err = get_interface()->gethostbyname(dns_test_hosts[i], &address, NSAPI_UNSPEC, interface_name[j]);
|
||||||
printf("DNS: query interface_name %s %d \n", interface_name[j], j);
|
printf("DNS: query interface_name %s %d \n", interface_name[j], j);
|
||||||
|
|
||||||
if (err == NSAPI_ERROR_OK) {
|
if (err == NSAPI_ERROR_OK) {
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ TEST_F(TestNetworkInterface, set_dhcp)
|
||||||
TEST_F(TestNetworkInterface, gethostbyname)
|
TEST_F(TestNetworkInterface, gethostbyname)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(iface->gethostbyname("host", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
EXPECT_EQ(iface->gethostbyname("host", &a, NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ static void my_callback(nsapi_error_t result, SocketAddress *address)
|
||||||
TEST_F(TestNetworkInterface, gethostbyname_async)
|
TEST_F(TestNetworkInterface, gethostbyname_async)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(iface->gethostbyname_async("host", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
EXPECT_EQ(iface->gethostbyname_async("host", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
||||||
EXPECT_EQ(iface->gethostbyname_async_cancel(1), NSAPI_ERROR_OK);
|
EXPECT_EQ(iface->gethostbyname_async_cancel(1), NSAPI_ERROR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,31 +153,31 @@ TEST_F(TestNetworkStack, gethostbyname)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
stack->ip_address = std::string("127.0.0.1");
|
stack->ip_address = std::string("127.0.0.1");
|
||||||
EXPECT_EQ(stack->gethostbyname("host", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
EXPECT_EQ(stack->gethostbyname("host", &a, NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestNetworkStack, gethostbyname_simple_address)
|
TEST_F(TestNetworkStack, gethostbyname_simple_address)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_UNSPEC), NSAPI_ERROR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestNetworkStack, gethostbyname_simple_address_right_version)
|
TEST_F(TestNetworkStack, gethostbyname_simple_address_right_version)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_IPv4), NSAPI_ERROR_OK);
|
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_IPv4), NSAPI_ERROR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestNetworkStack, gethostbyname_simple_address_wrong_version)
|
TEST_F(TestNetworkStack, gethostbyname_simple_address_wrong_version)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
|
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestNetworkStack, gethostbyname_empty_host)
|
TEST_F(TestNetworkStack, gethostbyname_empty_host)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(stack->gethostbyname("", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
|
EXPECT_EQ(stack->gethostbyname("", &a, NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gethostbyname_async */
|
/* gethostbyname_async */
|
||||||
|
|
@ -190,7 +190,7 @@ TEST_F(TestNetworkStack, gethostbyname_async_delay)
|
||||||
struct equeue_event ptr;
|
struct equeue_event ptr;
|
||||||
equeue_stub.void_ptr = &ptr;
|
equeue_stub.void_ptr = &ptr;
|
||||||
equeue_stub.call_cb_immediately = true;
|
equeue_stub.call_cb_immediately = true;
|
||||||
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
||||||
EXPECT_EQ(callin_callback(1, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
|
EXPECT_EQ(callin_callback(1, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
|
||||||
EXPECT_TRUE(noarg_callback_is_called);
|
EXPECT_TRUE(noarg_callback_is_called);
|
||||||
EXPECT_FALSE(callback_is_called);
|
EXPECT_FALSE(callback_is_called);
|
||||||
|
|
@ -204,7 +204,7 @@ TEST_F(TestNetworkStack, gethostbyname_async)
|
||||||
struct equeue_event ptr;
|
struct equeue_event ptr;
|
||||||
equeue_stub.void_ptr = &ptr;
|
equeue_stub.void_ptr = &ptr;
|
||||||
equeue_stub.call_cb_immediately = true;
|
equeue_stub.call_cb_immediately = true;
|
||||||
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
|
||||||
EXPECT_EQ(callin_callback(0, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
|
EXPECT_EQ(callin_callback(0, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
|
||||||
EXPECT_TRUE(noarg_callback_is_called);
|
EXPECT_TRUE(noarg_callback_is_called);
|
||||||
EXPECT_FALSE(callback_is_called);
|
EXPECT_FALSE(callback_is_called);
|
||||||
|
|
@ -214,9 +214,9 @@ TEST_F(TestNetworkStack, gethostbyname_async_eventqueue_simple_address)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
stack->ip_address = std::string("127.0.0.1");
|
stack->ip_address = std::string("127.0.0.1");
|
||||||
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), "", NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
|
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
|
||||||
EXPECT_FALSE(callback_is_called);
|
EXPECT_FALSE(callback_is_called);
|
||||||
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), "", NSAPI_IPv4), NSAPI_ERROR_OK);
|
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), NSAPI_IPv4), NSAPI_ERROR_OK);
|
||||||
EXPECT_TRUE(callback_is_called);
|
EXPECT_TRUE(callback_is_called);
|
||||||
EXPECT_EQ(result_received, NSAPI_ERROR_OK);
|
EXPECT_EQ(result_received, NSAPI_ERROR_OK);
|
||||||
EXPECT_EQ(std::string(address_received.get_ip_address()), stack->ip_address);
|
EXPECT_EQ(std::string(address_received.get_ip_address()), stack->ip_address);
|
||||||
|
|
@ -225,7 +225,7 @@ TEST_F(TestNetworkStack, gethostbyname_async_eventqueue_simple_address)
|
||||||
TEST_F(TestNetworkStack, gethostbyname_async_empty_host)
|
TEST_F(TestNetworkStack, gethostbyname_async_empty_host)
|
||||||
{
|
{
|
||||||
SocketAddress a;
|
SocketAddress a;
|
||||||
EXPECT_EQ(stack->gethostbyname_async("", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
|
EXPECT_EQ(stack->gethostbyname_async("", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestNetworkStack, getstackopt)
|
TEST_F(TestNetworkStack, getstackopt)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ nsapi_error_t NetworkInterface::set_dhcp(bool dhcp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS operations go through the underlying stack by default
|
// DNS operations go through the underlying stack by default
|
||||||
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ nsapi_error_t NetworkInterface::set_blocking(bool blocking)
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const *, mbed::Callback<void (int, SocketAddress *)>, const char *interface_name, nsapi_version)
|
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const *, mbed::Callback<void (int, SocketAddress *)>, nsapi_version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
// Default NetworkStack operations
|
// Default NetworkStack operations
|
||||||
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_OK;
|
return NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -68,8 +68,8 @@ NetworkStack *nsapi_create_stack(NetworkStack *stack)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name,
|
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version,
|
||||||
nsapi_version_t version)
|
const char *interface_name)
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ public:
|
||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
}
|
}
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name,
|
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version,
|
||||||
nsapi_version_t version)
|
const char *interface_name)
|
||||||
{
|
{
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -468,7 +468,7 @@ const char *UBLOX_AT_CellularStack::get_ip_address()
|
||||||
return _ip;
|
return _ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
char ipAddress[NSAPI_IP_SIZE];
|
char ipAddress[NSAPI_IP_SIZE];
|
||||||
nsapi_error_t err = NSAPI_ERROR_NO_CONNECTION;
|
nsapi_error_t err = NSAPI_ERROR_NO_CONNECTION;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public:
|
||||||
virtual const char *get_ip_address();
|
virtual const char *get_ip_address();
|
||||||
|
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC);
|
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
|
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param host Hostname to resolve.
|
* @param host Hostname to resolve.
|
||||||
* @param address Pointer to a SocketAddress to store the result.
|
* @param address Pointer to a SocketAddress to store the result.
|
||||||
* @param interface_name Network interface name
|
|
||||||
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
||||||
|
* @param interface_name Network interface name
|
||||||
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL) = 0;
|
||||||
/** Hostname translation callback for gethostbyname_async.
|
/** Hostname translation callback for gethostbyname_async.
|
||||||
*
|
*
|
||||||
* The callback is called after DNS resolution completes, or a failure occurs.
|
* The callback is called after DNS resolution completes, or a failure occurs.
|
||||||
|
|
@ -72,16 +72,16 @@ public:
|
||||||
*
|
*
|
||||||
* @param host Hostname to resolve.
|
* @param host Hostname to resolve.
|
||||||
* @param callback Callback that is called to return the result.
|
* @param callback Callback that is called to return the result.
|
||||||
* @param interface_name Network interface name
|
|
||||||
* @param version IP version of address to resolve. NSAPI_UNSPEC indicates that the
|
* @param version IP version of address to resolve. NSAPI_UNSPEC indicates that the
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
||||||
|
* @param interface_name Network interface name
|
||||||
* @return NSAPI_ERROR_OK on immediate success,
|
* @return NSAPI_ERROR_OK on immediate success,
|
||||||
* negative error code on immediate failure or
|
* negative error code on immediate failure or
|
||||||
* a positive unique ID that represents the hostname translation operation
|
* a positive unique ID that represents the hostname translation operation
|
||||||
* and can be passed to cancel.
|
* and can be passed to cancel.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name = NULL,
|
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
|
||||||
nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
const char *interface_name = NULL) = 0;
|
||||||
|
|
||||||
/** Cancel asynchronous hostname translation.
|
/** Cancel asynchronous hostname translation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,14 @@ nsapi_error_t NetworkInterface::set_dhcp(bool dhcp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return get_stack()->gethostbyname(name, address, interface_name, version);
|
return get_stack()->gethostbyname(name, address, version, interface_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name, nsapi_version_t version)
|
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
return get_stack()->gethostbyname_async(host, callback, interface_name, version);
|
return get_stack()->gethostbyname_async(host, callback, version, interface_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t NetworkInterface::gethostbyname_async_cancel(int id)
|
nsapi_error_t NetworkInterface::gethostbyname_async_cancel(int id)
|
||||||
|
|
|
||||||
|
|
@ -194,13 +194,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param host Hostname to resolve.
|
* @param host Hostname to resolve.
|
||||||
* @param address Pointer to a SocketAddress to store the result.
|
* @param address Pointer to a SocketAddress to store the result.
|
||||||
* @param interface_name Network interface name
|
|
||||||
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
||||||
|
* @param interface_name Network interface name
|
||||||
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC);
|
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
|
||||||
|
|
||||||
/** Hostname translation callback (for use with gethostbyname_async()).
|
/** Hostname translation callback (for use with gethostbyname_async()).
|
||||||
*
|
*
|
||||||
|
|
@ -232,16 +232,16 @@ public:
|
||||||
*
|
*
|
||||||
* @param host Hostname to resolve.
|
* @param host Hostname to resolve.
|
||||||
* @param callback Callback that is called for result.
|
* @param callback Callback that is called for result.
|
||||||
* @param interface_name Network interface name
|
|
||||||
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
|
||||||
|
* @param interface_name Network interface name
|
||||||
* @return 0 on immediate success,
|
* @return 0 on immediate success,
|
||||||
* negative error code on immediate failure or
|
* negative error code on immediate failure or
|
||||||
* a positive unique id that represents the hostname translation operation
|
* a positive unique id that represents the hostname translation operation
|
||||||
* and can be passed to cancel.
|
* and can be passed to cancel.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name = NULL,
|
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
|
||||||
nsapi_version_t version = NSAPI_UNSPEC);
|
const char *interface_name = NULL);
|
||||||
|
|
||||||
/** Cancel asynchronous hostname translation.
|
/** Cancel asynchronous hostname translation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ const char *NetworkStack::get_ip_address_if(const char *interface_name)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
if (name[0] == '\0') {
|
if (name[0] == '\0') {
|
||||||
return NSAPI_ERROR_PARAMETER;
|
return NSAPI_ERROR_PARAMETER;
|
||||||
|
|
@ -61,7 +61,7 @@ nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *addre
|
||||||
return nsapi_dns_query(this, name, address, interface_name, version);
|
return nsapi_dns_query(this, name, address, interface_name, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *name, hostbyname_cb_t callback, const char *interface_name, nsapi_version_t version)
|
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *name, hostbyname_cb_t callback, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
SocketAddress address;
|
SocketAddress address;
|
||||||
|
|
||||||
|
|
@ -184,10 +184,10 @@ public:
|
||||||
return address->get_ip_address();
|
return address->get_ip_address();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsapi_error_t gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
|
virtual nsapi_error_t gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
|
||||||
{
|
{
|
||||||
if (!_stack_api()->gethostbyname) {
|
if (!_stack_api()->gethostbyname) {
|
||||||
return NetworkStack::gethostbyname(name, address, interface_name, version);
|
return NetworkStack::gethostbyname(name, address, version, interface_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_addr_t addr = {NSAPI_UNSPEC, 0};
|
nsapi_addr_t addr = {NSAPI_UNSPEC, 0};
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,12 @@ public:
|
||||||
* @param host Hostname to resolve
|
* @param host Hostname to resolve
|
||||||
* @param address Pointer to a SocketAddress to store the result.
|
* @param address Pointer to a SocketAddress to store the result.
|
||||||
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
||||||
* @param interface_name Network interface_name
|
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC)
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC)
|
||||||
|
* @param interface_name Network interface_name
|
||||||
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC);
|
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
|
||||||
|
|
||||||
/** Hostname translation callback (asynchronous)
|
/** Hostname translation callback (asynchronous)
|
||||||
*
|
*
|
||||||
|
|
@ -104,16 +104,16 @@ public:
|
||||||
*
|
*
|
||||||
* @param host Hostname to resolve
|
* @param host Hostname to resolve
|
||||||
* @param callback Callback that is called for result
|
* @param callback Callback that is called for result
|
||||||
* @param interface_name Network interface name
|
|
||||||
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
|
||||||
* version is chosen by the stack (defaults to NSAPI_UNSPEC)
|
* version is chosen by the stack (defaults to NSAPI_UNSPEC)
|
||||||
|
* @param interface_name Network interface_name
|
||||||
* @return 0 on immediate success,
|
* @return 0 on immediate success,
|
||||||
* negative error code on immediate failure or
|
* negative error code on immediate failure or
|
||||||
* a positive unique id that represents the hostname translation operation
|
* a positive unique id that represents the hostname translation operation
|
||||||
* and can be passed to cancel
|
* and can be passed to cancel
|
||||||
*/
|
*/
|
||||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name = NULL,
|
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
|
||||||
nsapi_version_t version = NSAPI_UNSPEC);
|
const char *interface_name = NULL);
|
||||||
|
|
||||||
/** Cancels asynchronous hostname translation
|
/** Cancels asynchronous hostname translation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ void SocketAddress::_SocketAddress(NetworkStack *iface, const char *host, uint16
|
||||||
_ip_address = NULL;
|
_ip_address = NULL;
|
||||||
|
|
||||||
// gethostbyname must check for literals, so can call it directly
|
// gethostbyname must check for literals, so can call it directly
|
||||||
int err = iface->gethostbyname(host, this, NULL);
|
int err = iface->gethostbyname(host, this);
|
||||||
_port = port;
|
_port = port;
|
||||||
if (err) {
|
if (err) {
|
||||||
_addr = nsapi_addr_t();
|
_addr = nsapi_addr_t();
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ nsapi_error_t TCPSocket::connect(const char *host, uint16_t port)
|
||||||
if (!strcmp(_interface_name, "")) {
|
if (!strcmp(_interface_name, "")) {
|
||||||
err = _stack->gethostbyname(host, &address);
|
err = _stack->gethostbyname(host, &address);
|
||||||
} else {
|
} else {
|
||||||
err = _stack->gethostbyname(host, &address, _interface_name);
|
err = _stack->gethostbyname(host, &address, NSAPI_UNSPEC, _interface_name);
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
return NSAPI_ERROR_DNS_FAILURE;
|
return NSAPI_ERROR_DNS_FAILURE;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ nsapi_size_or_error_t UDPSocket::sendto(const char *host, uint16_t port, const v
|
||||||
if (!strcmp(_interface_name, "")) {
|
if (!strcmp(_interface_name, "")) {
|
||||||
err = _stack->gethostbyname(host, &address);
|
err = _stack->gethostbyname(host, &address);
|
||||||
} else {
|
} else {
|
||||||
err = _stack->gethostbyname(host, &address, _interface_name);
|
err = _stack->gethostbyname(host, &address, NSAPI_UNSPEC, _interface_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue