fix transaction id generation

Incoming messages are matched to nodes in the retransmission
queue by comparing a hash value over (message id, port, ip addr).
For IPv4, the entire sockaddr_in structure was compared which
is potentially wrong (see merge request #7 from Dag Björklund).
Hopefully, this fixes the encountered issue.
This commit is contained in:
Olaf Bergmann committed 2014-07-05 22:07:05 +02:00
1 parent 82223d8a26
commit f769519ace
1 file changed
+5 -3
+5 -3
View File
@@ -488,13 +488,15 @@ coap_transaction_id(const coap_address_t *peer, const coap_pdu_t *pdu,
memset(h, 0, sizeof(coap_key_t));
/* Compare the complete address structure in case of IPv4. For IPv6,
* we need to look at the transport address only. */
/* Compare the transport address. */
#ifdef WITH_POSIX
switch (peer->addr.sa.sa_family) {
case AF_INET:
coap_hash((const unsigned char *)&peer->addr.sa, peer->size, h);
coap_hash((const unsigned char *)&peer->addr.sin.sin_port,
sizeof(peer->addr.sin.sin_port), h);
coap_hash((const unsigned char *)&peer->addr.sin.sin_addr,
sizeof(peer->addr.sin.sin_addr), h);
break;
case AF_INET6:
coap_hash((const unsigned char *)&peer->addr.sin6.sin6_port,