Skip to content

Commit 641189c

Browse files
tymoteuszblochmobicaSeppo Takalo
authored andcommitted
Multihoming change parameter orded in gethostbyname
1 parent 00feb53 commit 641189c

File tree

17 files changed

+50
-50
lines changed

17 files changed

+50
-50
lines changed

TESTS/network/multihoming/multihoming_asynchronous_dns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void MULTIHOMING_ASYNCHRONOUS_DNS()
5858
for (unsigned int j = 0; j < interface_num; j++) {
5959

6060
nsapi_error_t err = get_interface()->gethostbyname_async(dns_test_hosts[i],
61-
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data), interface_name[j]);
61+
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data), NSAPI_UNSPEC, interface_name[j]);
6262
TEST_ASSERT(err >= 0);
6363

6464
semaphore.wait();

TESTS/network/multihoming/multihoming_synchronous_dns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void MULTIHOMING_SYNCHRONOUS_DNS()
4646
SocketAddress address;
4747
for (unsigned int j = 0; j < interface_num; j++) {
4848

49-
nsapi_error_t err = get_interface()->gethostbyname(dns_test_hosts[i], &address, interface_name[j]);
49+
nsapi_error_t err = get_interface()->gethostbyname(dns_test_hosts[i], &address, NSAPI_UNSPEC, interface_name[j]);
5050
printf("DNS: query interface_name %s %d \n", interface_name[j], j);
5151

5252
if (err == NSAPI_ERROR_OK) {

UNITTESTS/features/netsocket/NetworkInterface/test_NetworkInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ TEST_F(TestNetworkInterface, set_dhcp)
106106
TEST_F(TestNetworkInterface, gethostbyname)
107107
{
108108
SocketAddress a;
109-
EXPECT_EQ(iface->gethostbyname("host", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
109+
EXPECT_EQ(iface->gethostbyname("host", &a, NSAPI_UNSPEC), NSAPI_ERROR_OK);
110110
}
111111

112112

@@ -121,7 +121,7 @@ static void my_callback(nsapi_error_t result, SocketAddress *address)
121121
TEST_F(TestNetworkInterface, gethostbyname_async)
122122
{
123123
SocketAddress a;
124-
EXPECT_EQ(iface->gethostbyname_async("host", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
124+
EXPECT_EQ(iface->gethostbyname_async("host", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_OK);
125125
EXPECT_EQ(iface->gethostbyname_async_cancel(1), NSAPI_ERROR_OK);
126126
}
127127

UNITTESTS/features/netsocket/NetworkStack/test_NetworkStack.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,31 +153,31 @@ TEST_F(TestNetworkStack, gethostbyname)
153153
{
154154
SocketAddress a;
155155
stack->ip_address = std::string("127.0.0.1");
156-
EXPECT_EQ(stack->gethostbyname("host", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
156+
EXPECT_EQ(stack->gethostbyname("host", &a, NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
157157
}
158158

159159
TEST_F(TestNetworkStack, gethostbyname_simple_address)
160160
{
161161
SocketAddress a;
162-
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_OK);
162+
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_UNSPEC), NSAPI_ERROR_OK);
163163
}
164164

165165
TEST_F(TestNetworkStack, gethostbyname_simple_address_right_version)
166166
{
167167
SocketAddress a;
168-
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_IPv4), NSAPI_ERROR_OK);
168+
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_IPv4), NSAPI_ERROR_OK);
169169
}
170170

171171
TEST_F(TestNetworkStack, gethostbyname_simple_address_wrong_version)
172172
{
173173
SocketAddress a;
174-
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, "", NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
174+
EXPECT_EQ(stack->gethostbyname("127.0.0.1", &a, NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
175175
}
176176

177177
TEST_F(TestNetworkStack, gethostbyname_empty_host)
178178
{
179179
SocketAddress a;
180-
EXPECT_EQ(stack->gethostbyname("", &a, "", NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
180+
EXPECT_EQ(stack->gethostbyname("", &a, NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
181181
}
182182

183183
/* gethostbyname_async */
@@ -190,7 +190,7 @@ TEST_F(TestNetworkStack, gethostbyname_async_delay)
190190
struct equeue_event ptr;
191191
equeue_stub.void_ptr = &ptr;
192192
equeue_stub.call_cb_immediately = true;
193-
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
193+
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
194194
EXPECT_EQ(callin_callback(1, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
195195
EXPECT_TRUE(noarg_callback_is_called);
196196
EXPECT_FALSE(callback_is_called);
@@ -204,7 +204,7 @@ TEST_F(TestNetworkStack, gethostbyname_async)
204204
struct equeue_event ptr;
205205
equeue_stub.void_ptr = &ptr;
206206
equeue_stub.call_cb_immediately = true;
207-
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
207+
EXPECT_EQ(stack->gethostbyname_async("localhost", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_DNS_FAILURE);
208208
EXPECT_EQ(callin_callback(0, mbed::callback(noarg_callback)), NSAPI_ERROR_OK);
209209
EXPECT_TRUE(noarg_callback_is_called);
210210
EXPECT_FALSE(callback_is_called);
@@ -214,9 +214,9 @@ TEST_F(TestNetworkStack, gethostbyname_async_eventqueue_simple_address)
214214
{
215215
SocketAddress a;
216216
stack->ip_address = std::string("127.0.0.1");
217-
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), "", NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
217+
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), NSAPI_IPv6), NSAPI_ERROR_DNS_FAILURE);
218218
EXPECT_FALSE(callback_is_called);
219-
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), "", NSAPI_IPv4), NSAPI_ERROR_OK);
219+
EXPECT_EQ(stack->gethostbyname_async("127.0.0.1", mbed::callback(my_callback), NSAPI_IPv4), NSAPI_ERROR_OK);
220220
EXPECT_TRUE(callback_is_called);
221221
EXPECT_EQ(result_received, NSAPI_ERROR_OK);
222222
EXPECT_EQ(std::string(address_received.get_ip_address()), stack->ip_address);
@@ -225,7 +225,7 @@ TEST_F(TestNetworkStack, gethostbyname_async_eventqueue_simple_address)
225225
TEST_F(TestNetworkStack, gethostbyname_async_empty_host)
226226
{
227227
SocketAddress a;
228-
EXPECT_EQ(stack->gethostbyname_async("", mbed::callback(my_callback), "", NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
228+
EXPECT_EQ(stack->gethostbyname_async("", mbed::callback(my_callback), NSAPI_UNSPEC), NSAPI_ERROR_PARAMETER);
229229
}
230230

231231
TEST_F(TestNetworkStack, getstackopt)

UNITTESTS/stubs/NetworkInterface_stub.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ nsapi_error_t NetworkInterface::set_dhcp(bool dhcp)
5252
}
5353

5454
// DNS operations go through the underlying stack by default
55-
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
55+
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
5656
{
5757
return NSAPI_ERROR_UNSUPPORTED;
5858
}
@@ -77,7 +77,7 @@ nsapi_error_t NetworkInterface::set_blocking(bool blocking)
7777
return NSAPI_ERROR_UNSUPPORTED;
7878
}
7979

80-
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const *, mbed::Callback<void (int, SocketAddress *)>, const char *interface_name, nsapi_version)
80+
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const *, mbed::Callback<void (int, SocketAddress *)>, nsapi_version, const char *interface_name)
8181
{
8282
return NSAPI_ERROR_UNSUPPORTED;
8383
}

UNITTESTS/stubs/NetworkStack_stub.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <new>
2323

2424
// Default NetworkStack operations
25-
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, const char *interface_name, nsapi_version_t version)
25+
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
2626
{
2727
return NSAPI_ERROR_OK;
2828
}
@@ -68,8 +68,8 @@ NetworkStack *nsapi_create_stack(NetworkStack *stack)
6868
return NULL;
6969
}
7070

71-
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name,
72-
nsapi_version_t version)
71+
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version,
72+
const char *interface_name)
7373
{
7474
return NSAPI_ERROR_UNSUPPORTED;
7575
}

UNITTESTS/stubs/NetworkStack_stub.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ class NetworkStackstub : public NetworkStack {
3737
return "127.0.0.1";
3838
}
3939
virtual nsapi_error_t gethostbyname(const char *host,
40-
SocketAddress *address, const char *interface_name, nsapi_version_t version)
40+
SocketAddress *address, nsapi_version_t version, const char *interface_name)
4141
{
4242
return return_value;
4343
}
44-
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name,
45-
nsapi_version_t version)
44+
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version,
45+
const char *interface_name)
4646
{
4747
return return_value;
4848
}

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ const char *UBLOX_AT_CellularStack::get_ip_address()
468468
return _ip;
469469
}
470470

471-
nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddress *address, const char *interface_name, nsapi_version_t version)
471+
nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version, const char *interface_name)
472472
{
473473
char ipAddress[NSAPI_IP_SIZE];
474474
nsapi_error_t err = NSAPI_ERROR_NO_CONNECTION;

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UBLOX_AT_CellularStack : public AT_CellularStack {
3333
virtual const char *get_ip_address();
3434

3535
virtual nsapi_error_t gethostbyname(const char *host,
36-
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC);
36+
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
3737

3838
protected:
3939
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);

features/netsocket/DNS.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class DNS {
3535
*
3636
* @param host Hostname to resolve.
3737
* @param address Pointer to a SocketAddress to store the result.
38-
* @param interface_name Network interface name
3938
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
4039
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
40+
* @param interface_name Network interface name
4141
* @return NSAPI_ERROR_OK on success, negative error code on failure.
4242
*/
4343
virtual nsapi_error_t gethostbyname(const char *host,
44-
SocketAddress *address, const char *interface_name = NULL, nsapi_version_t version = NSAPI_UNSPEC) = 0;
44+
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL) = 0;
4545
/** Hostname translation callback for gethostbyname_async.
4646
*
4747
* The callback is called after DNS resolution completes, or a failure occurs.
@@ -72,16 +72,16 @@ class DNS {
7272
*
7373
* @param host Hostname to resolve.
7474
* @param callback Callback that is called to return the result.
75-
* @param interface_name Network interface name
7675
* @param version IP version of address to resolve. NSAPI_UNSPEC indicates that the
7776
* version is chosen by the stack (defaults to NSAPI_UNSPEC).
77+
* @param interface_name Network interface name
7878
* @return NSAPI_ERROR_OK on immediate success,
7979
* negative error code on immediate failure or
8080
* a positive unique ID that represents the hostname translation operation
8181
* and can be passed to cancel.
8282
*/
83-
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, const char *interface_name = NULL,
84-
nsapi_version_t version = NSAPI_UNSPEC) = 0;
83+
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
84+
const char *interface_name = NULL) = 0;
8585

8686
/** Cancel asynchronous hostname translation.
8787
*

0 commit comments

Comments
 (0)