Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 9938151

Browse files
Yogesh PandeYogesh Pande
authored andcommitted
Fix for IOTCLT-961
This commit fixes issue of mapping of IP addresses for CoAP library is done. The problem was hidden till now, because IP addresses of Bootstrap and mDS were quite different and client was accidently only comparing first 4 characters of the address hence it was identifying them as two different servers. But now the IP addresses are similar to last 2 bytes hence the first 4 byte check always pass even though the IP addresses are different IP Address of Bootstrap is 159.122.226.36 IP Address of mDS is 159.122.226.33 On comparing the first 4 characters now, the CoAP library assumes the requests are still coming for Bootstrap sequence. This commit fixes this issue.
1 parent 3f85743 commit 9938151

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

source/m2mconnectionhandlerpimpl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,16 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
162162
void M2MConnectionHandlerPimpl::dns_handler()
163163
{
164164
tr_debug("M2MConnectionHandlerPimpl::dns_handler()");
165+
if(_socket_address) {
166+
delete _socket_address;
167+
_socket_address = NULL;
168+
}
165169
_socket_address = new SocketAddress(_net_iface,_server_address.c_str(), _server_port);
166170
if(*_socket_address) {
167-
_address._address = (void*)_socket_address->get_ip_address();
171+
_address._length = strlen(_socket_address->get_ip_address());
172+
memcpy(_address._address,_socket_address->get_ip_address(),_address._length);
168173
tr_debug("IP Address %s",_socket_address->get_ip_address());
169-
tr_debug("Port %d",_socket_address->get_port());
170-
_address._length = strlen((char*)_address._address);
174+
tr_debug("Port %d",_socket_address->get_port());
171175
_address._port = _socket_address->get_port();
172176
_address._stack = _network_stack;
173177
} else {

0 commit comments

Comments
 (0)