From f769519ace02b5424ef62d39251a7eb3aa392733 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Sat, 5 Jul 2014 22:07:05 +0200 Subject: [PATCH] fix transaction id generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- net.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net.c b/net.c index 580d588a..07479b38 100644 --- a/net.c +++ b/net.c @@ -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,