From 2e6cb55a5049bd6c314bd22ffe8546b73583f494 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Mon, 15 Feb 2021 09:47:02 +0000 Subject: [PATCH] message id: Report everywhere the hex value for consistency coap_show_pdu() reports the Message ID (mid) as a hex value prefixes by i:. Elsewhere it is reported as an integer or unsigned making those entries difficult to match up with the reported PDU. examples/coap-rd.c: examples/etsi_iot_01.c: src/async.c: src/coap_session.c: src/net.c: Replace tid=%d, message %d and transaction %d with mid=0x%x for clarity. --- examples/coap-rd.c | 4 ++-- examples/etsi_iot_01.c | 2 +- src/async.c | 2 +- src/coap_session.c | 8 ++++---- src/net.c | 30 +++++++++++++++--------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/coap-rd.c b/examples/coap-rd.c index 2310d721..4f862bba 100644 --- a/examples/coap-rd.c +++ b/examples/coap-rd.c @@ -208,7 +208,7 @@ hnd_put_resource(coap_context_t *ctx UNUSED_PARAM, response = coap_pdu_init(type, code, request->hdr->id, size); if (!response) { - coap_log(LOG_DEBUG, "cannot create response for message %d\n", + coap_log(LOG_DEBUG, "cannot create response for mid=0x%x\n", request->hdr->id); return; } @@ -217,7 +217,7 @@ hnd_put_resource(coap_context_t *ctx UNUSED_PARAM, coap_add_token(response, request->hdr->token_length, request->hdr->token); if (coap_send(ctx, peer, response) == COAP_INVALID_TID) { - coap_log(LOG_DEBUG, "hnd_get_rd: cannot send response for message %d\n", + coap_log(LOG_DEBUG, "hnd_get_rd: cannot send response for mid=0x%x\n", request->hdr->id); } #endif diff --git a/examples/etsi_iot_01.c b/examples/etsi_iot_01.c index f4719685..7f2a0e02 100644 --- a/examples/etsi_iot_01.c +++ b/examples/etsi_iot_01.c @@ -454,7 +454,7 @@ check_async(coap_context_t *ctx, coap_add_data(response, 4, (const uint8_t *)"done"); if (coap_send(async->session, response) == COAP_INVALID_TID) { - coap_log(LOG_DEBUG, "check_async: cannot send response for message %d\n", + coap_log(LOG_DEBUG, "check_async: cannot send response for mid=0x%x\n", response->tid); } coap_remove_async(ctx, async->session, async->id, &tmp); diff --git a/src/async.c b/src/async.c index 39277e5a..e6f3cfbc 100644 --- a/src/async.c +++ b/src/async.c @@ -38,7 +38,7 @@ coap_register_async(coap_context_t *context, coap_session_t *session, /* We must return NULL here as the caller must know that he is * responsible for releasing @p data. */ coap_log(LOG_DEBUG, - "asynchronous state for transaction %d already registered\n", id); + "asynchronous state for mid=0x%x already registered\n", id); return NULL; } diff --git a/src/coap_session.c b/src/coap_session.c index d4f0ee28..19226b2f 100644 --- a/src/coap_session.c +++ b/src/coap_session.c @@ -289,7 +289,7 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, /* Check that the same tid is not getting re-used in violation of RFC7252 */ LL_FOREACH(session->delayqueue, q) { if (q->id == pdu->tid) { - coap_log(LOG_ERR, "** %s: tid=%d: already in-use - dropped\n", coap_session_str(session), pdu->tid); + coap_log(LOG_ERR, "** %s: mid=0x%x: already in-use - dropped\n", coap_session_str(session), pdu->tid); return COAP_INVALID_TID; } } @@ -306,7 +306,7 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, } } LL_APPEND(session->delayqueue, node); - coap_log(LOG_DEBUG, "** %s: tid=%d: delayed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: delayed\n", coap_session_str(session), node->id); return COAP_PDU_DELAYED; } @@ -391,7 +391,7 @@ void coap_session_connected(coap_session_t *session) { session->delayqueue = q->next; q->next = NULL; - coap_log(LOG_DEBUG, "** %s: tid=%d: transmitted after delay\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: transmitted after delay\n", coap_session_str(session), (int)q->pdu->tid); bytes_written = coap_session_send_pdu(session, q->pdu); if (q->pdu->type == COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(session->proto)) { @@ -456,7 +456,7 @@ void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reaso coap_queue_t *q = session->delayqueue; session->delayqueue = q->next; q->next = NULL; - coap_log(LOG_DEBUG, "** %s: tid=%d: not transmitted after disconnect\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: not transmitted after disconnect\n", coap_session_str(session), q->id); if (q->pdu->type==COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(session->proto) diff --git a/src/net.c b/src/net.c index 0f9d9d99..eac92573 100644 --- a/src/net.c +++ b/src/net.c @@ -970,7 +970,7 @@ coap_wait_ack(coap_context_t *context, coap_session_t *session, } #endif /* WITH_CONTIKI */ - coap_log(LOG_DEBUG, "** %s: tid=%d: added to retransmit queue (%ums)\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: added to retransmit queue (%ums)\n", coap_session_str(node->session), node->id, (unsigned)(node->t * 1000 / COAP_TICKS_PER_SECOND)); @@ -1212,7 +1212,7 @@ coap_retransmit(coap_context_t *context, coap_queue_t *node) { coap_retransmittimer_restart(context); #endif - coap_log(LOG_DEBUG, "** %s: tid=%d: retransmission #%d\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: retransmission #%d\n", coap_session_str(node->session), node->id, node->retransmit_cnt); if (node->session->con_active) @@ -1234,7 +1234,7 @@ coap_retransmit(coap_context_t *context, coap_queue_t *node) { /* no more retransmissions, remove node from system */ #ifndef WITH_CONTIKI - coap_log(LOG_DEBUG, "** %s: tid=%d: give up after %d attempts\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: give up after %d attempts\n", coap_session_str(node->session), node->id, node->retransmit_cnt); #endif @@ -1344,7 +1344,7 @@ coap_write_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now while (session->delayqueue) { ssize_t bytes_written; coap_queue_t *q = session->delayqueue; - coap_log(LOG_DEBUG, "** %s: tid=%d: transmitted after delay\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: transmitted after delay\n", coap_session_str(session), (int)q->pdu->tid); assert(session->partial_write < q->pdu->used_size + q->pdu->hdr_size); switch (session->proto) { @@ -1797,7 +1797,7 @@ coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_tid_t (*queue)->t += (*node)->t; } (*node)->next = NULL; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), id); return 1; } @@ -1816,7 +1816,7 @@ coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_tid_t } q->next = NULL; *node = q; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), id); return 1; } @@ -1839,7 +1839,7 @@ coap_cancel_session_messages(coap_context_t *context, coap_session_t *session, while (context->sendqueue && context->sendqueue->session == session) { q = context->sendqueue; context->sendqueue = q->next; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), q->id); if (q->pdu->type == COAP_MESSAGE_CON && context->nack_handler) context->nack_handler(context, session, q->pdu, reason, q->id); @@ -1855,7 +1855,7 @@ coap_cancel_session_messages(coap_context_t *context, coap_session_t *session, while (q) { if (q->session == session) { p->next = q->next; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), q->id); if (q->pdu->type == COAP_MESSAGE_CON && context->nack_handler) context->nack_handler(context, session, q->pdu, reason, q->id); @@ -1881,7 +1881,7 @@ coap_cancel_all_messages(coap_context_t *context, coap_session_t *session, context->sendqueue->pdu->token_length)) { q = context->sendqueue; context->sendqueue = q->next; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), q->id); coap_delete_node(q); } @@ -1898,7 +1898,7 @@ coap_cancel_all_messages(coap_context_t *context, coap_session_t *session, token_match(token, token_length, q->pdu->token, q->pdu->token_length)) { p->next = q->next; - coap_log(LOG_DEBUG, "** %s: tid=%d: removed\n", + coap_log(LOG_DEBUG, "** %s: mid=0x%x: removed\n", coap_session_str(session), q->id); coap_delete_node(q); q = p->next; @@ -2495,7 +2495,7 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu if (!resource) { if (response && (no_response(pdu, response) != RESPONSE_DROP)) { if (coap_send(session, response) == COAP_INVALID_TID) - coap_log(LOG_WARNING, "cannot send response for transaction %u\n", + coap_log(LOG_WARNING, "cannot send response for mid=0x%x\n", pdu->tid); } else { coap_delete_pdu(response); @@ -2600,7 +2600,7 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu && !coap_mcast_interface(&node->local_if)))) { if (coap_send(session, response) == COAP_INVALID_TID) - coap_log(LOG_DEBUG, "cannot send response for message %d\n", + coap_log(LOG_DEBUG, "cannot send response for mid=0x%x\n", pdu->tid); } else { coap_delete_pdu(response); @@ -2626,7 +2626,7 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu if (response && (no_response(pdu, response) != RESPONSE_DROP)) { if (coap_send(session, response) == COAP_INVALID_TID) - coap_log(LOG_DEBUG, "cannot send response for transaction %d\n", + coap_log(LOG_DEBUG, "cannot send response for mid=0x%x\n", pdu->tid); } else { coap_delete_pdu(response); @@ -2644,7 +2644,7 @@ fail_response: opt_filter); if (response) { if (coap_send(session, response) == COAP_INVALID_TID) - coap_log(LOG_WARNING, "cannot send response for transaction %u\n", + coap_log(LOG_WARNING, "cannot send response for mid=0x%x\n", pdu->tid); } } @@ -2767,7 +2767,7 @@ coap_dispatch(coap_context_t *context, coap_session_t *session, is_ping_rst = 1; if (!is_ping_rst) - coap_log(LOG_ALERT, "got RST for message %d\n", pdu->tid); + coap_log(LOG_ALERT, "got RST for mid=0x%x\n", pdu->tid); if (session->con_active) { session->con_active--;