Skip to content

Commit 2135c8f

Browse files
committed
NanostackInterface: Remove string round-trips
Older versions of SocketAddress required conversion via string - this is no longer the case.
1 parent b2834b9 commit 2135c8f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

features/nanostack/FEATURE_NANOSTACK/nanostack-interface/NanostackInterface.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "mesh_system.h" // from inside mbed-mesh-api
2929
#include "socket_api.h"
3030
#include "net_interface.h"
31-
#include "ip6string.h"
3231
// Uncomment to enable trace
3332
//#define HAVE_DEBUG
3433
#include "ns_trace.h"
@@ -126,16 +125,13 @@ static void convert_mbed_addr_to_ns(ns_address_t *ns_addr,
126125
{
127126
ns_addr->type = ADDRESS_IPV6;
128127
ns_addr->identifier = s_addr->get_port();
129-
const char *str = s_addr->get_ip_address();
130-
stoip6(str, strlen(str), ns_addr->address);
128+
memcpy(ns_addr->address, s_addr->get_ip_bytes(), 16);
131129
}
132130

133131
static void convert_ns_addr_to_mbed(SocketAddress *s_addr, const ns_address_t *ns_addr)
134132
{
135-
char str[40];
136-
ip6tos(ns_addr->address, str);
137133
s_addr->set_port(ns_addr->identifier);
138-
s_addr->set_ip_address(str);
134+
s_addr->set_ip_bytes(ns_addr->address, NSAPI_IPv6);
139135
}
140136

141137
void* NanostackSocket::operator new(std::size_t sz) {

0 commit comments

Comments
 (0)