From c92c7b162998e135db284eb8f2324efbce1c9dac Mon Sep 17 00:00:00 2001 From: Jin-Seong Kim Date: Mon, 15 May 2017 16:50:04 +0900 Subject: [PATCH] netutils/libcoap : patch for coap_transaction_id function This commit is patch to coap_transaction_id function problem - coap_hash function uses structure addr.sa to create tid - when coap message is received, tid, which is in received coap message, is used to comparing sender's tid - unmatched case occurs, when addr.sa is used to create tid - in this case, sender cannot find coap response message which has same tid of sender so infinite retransmission happens on application solution - uses addr and port value to create tid similar to IPv6 Change-Id: I1665577394d772bacb0d923dfeb7094db99e4a3b Signed-off-by: Jin-Seong Kim --- apps/netutils/libcoap/net.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/netutils/libcoap/net.c b/apps/netutils/libcoap/net.c index f5ff6f4..5a87ecf 100644 --- a/apps/netutils/libcoap/net.c +++ b/apps/netutils/libcoap/net.c @@ -509,7 +509,13 @@ void coap_transaction_id(const coap_address_t *peer, const coap_pdu_t *pdu, coap #ifdef WITH_POSIX switch (peer->addr.sa.sa_family) { case AF_INET: +#if defined (__TINYARA__) + /* Local Fixes : Make hash value using IPv4 addr and port only */ + coap_hash((const unsigned char *)&peer->addr.sin.sin_addr, sizeof(peer->addr.sin.sin_addr), h); + coap_hash((const unsigned char *)&peer->addr.sin.sin_port, sizeof(peer->addr.sin.sin_port), h); +#else coap_hash((const unsigned char *)&peer->addr.sa, peer->size, h); +#endif break; case AF_INET6: coap_hash((const unsigned char *)&peer->addr.sin6.sin6_port, sizeof(peer->addr.sin6.sin6_port), h); -- 2.7.4