diff --git a/examples/coap-client.c b/examples/coap-client.c index 31532038..cdd27180 100644 --- a/examples/coap-client.c +++ b/examples/coap-client.c @@ -373,6 +373,10 @@ event_handler(coap_session_t *session COAP_UNUSED, case COAP_EVENT_BAD_PACKET: quit = 1; break; + case COAP_EVENT_FIRST_PDU_FAIL: + quit = 1; + coap_log_err("cannot send CoAP pdu\n"); + break; case COAP_EVENT_SERVER_SESSION_CONNECTED: #if COAP_SERVER_SUPPORT call_home_session = session; diff --git a/examples/coap-server.c b/examples/coap-server.c index 139a0169..e1c487e1 100644 --- a/examples/coap-server.c +++ b/examples/coap-server.c @@ -1047,6 +1047,7 @@ proxy_event_handler(coap_session_t *session COAP_UNUSED, case COAP_EVENT_SERVER_SESSION_CONNECTED: case COAP_EVENT_BAD_PACKET: case COAP_EVENT_MSG_RETRANSMITTED: + case COAP_EVENT_FIRST_PDU_FAIL: case COAP_EVENT_WS_CONNECTED: case COAP_EVENT_KEEPALIVE_FAILURE: case COAP_EVENT_RECONNECT_FAILED: diff --git a/include/coap3/coap_event.h b/include/coap3/coap_event.h index 054221f7..3981bdda 100644 --- a/include/coap3/coap_event.h +++ b/include/coap3/coap_event.h @@ -110,6 +110,8 @@ typedef enum { COAP_EVENT_BAD_PACKET = 0x5001, /** Triggered when a message is retransmitted */ COAP_EVENT_MSG_RETRANSMITTED = 0x5002, + /** Triggered when the initial app PDU cannot be transmitted */ + COAP_EVENT_FIRST_PDU_FAIL = 0x5003, /* * OSCORE events diff --git a/include/coap3/coap_net_internal.h b/include/coap3/coap_net_internal.h index 50818ddc..3e6a7b11 100644 --- a/include/coap3/coap_net_internal.h +++ b/include/coap3/coap_net_internal.h @@ -1001,6 +1001,14 @@ coap_mid_t coap_send_rst_lkd(coap_session_t *session, const coap_pdu_t *request) void coap_call_response_handler(coap_session_t *session, coap_pdu_t *sent, coap_pdu_t *rcvd, void *body_free); +/** + * Reset doing the first packet state when testing for optional functionality. + * This causes any pending PDU to be transmitted. + * + * @param session The CoAP session. + */ +void coap_reset_doing_first(coap_session_t *session); + /**@}*/ extern int coap_started; diff --git a/include/coap3/coap_pdu_internal.h b/include/coap3/coap_pdu_internal.h index 04a42507..318772e0 100644 --- a/include/coap3/coap_pdu_internal.h +++ b/include/coap3/coap_pdu_internal.h @@ -142,6 +142,7 @@ extern "C" { */ struct coap_pdu_t { + struct coap_pdu_t *next; /**< Next PDU in a delay chain */ coap_pdu_type_t type; /**< message type */ coap_pdu_code_t code; /**< request method (value 1--31) or response code (value 64-255) */ diff --git a/include/coap3/coap_session_internal.h b/include/coap3/coap_session_internal.h index f28c0fdd..5dd52ac7 100644 --- a/include/coap3/coap_session_internal.h +++ b/include/coap3/coap_session_internal.h @@ -191,7 +191,9 @@ struct coap_session_t { uint32_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ uint8_t csm_bert_rem_support; /**< CSM TCP BERT blocks supported (remote) */ uint8_t csm_bert_loc_support; /**< CSM TCP BERT blocks supported (local) */ +#if COAP_CLIENT_SUPPORT uint8_t doing_first; /**< Set if doing client's first request */ +#endif /* COAP_CLIENT_SUPPORT */ uint8_t proxy_session; /**< Set if this is an ongoing proxy session */ uint8_t delay_recursive; /**< Set if in coap_client_delay_first() */ uint8_t no_observe_cancel; /**< Set if do not cancel observe on session @@ -222,6 +224,8 @@ struct coap_session_t { uint8_t session_failed; /**< Set if session failed and can try re-connect */ uint8_t client_initiated; /**< Session initially started as a client */ uint8_t retry_count; /**< Number of retries trying to re-connect */ + coap_tick_t doing_first_timeout; /**< If doing_first, when to timeout */ + coap_pdu_t *doing_first_pdu; /**< If doing fist, PDU to retry sending */ #endif /* COAP_CLIENT_SUPPORT */ coap_mid_t remote_test_mid; /**< mid used for checking remote support */ diff --git a/man/coap_call_home.txt.in b/man/coap_call_home.txt.in index 97819712..a8adbaef 100644 --- a/man/coap_call_home.txt.in +++ b/man/coap_call_home.txt.in @@ -128,6 +128,7 @@ event_handler(coap_session_t *session COAP_UNUSED, case COAP_EVENT_WS_PACKET_SIZE: case COAP_EVENT_WS_CLOSED: case COAP_EVENT_BAD_PACKET: + case COAP_EVENT_FIRST_PDU_FAIL: case COAP_EVENT_RECONNECT_NO_MORE: quit = 1; break; diff --git a/man/coap_handler.txt.in b/man/coap_handler.txt.in index 3cbc642e..f29dda64 100644 --- a/man/coap_handler.txt.in +++ b/man/coap_handler.txt.in @@ -365,6 +365,8 @@ typedef enum { COAP_EVENT_BAD_PACKET = 0x5001, /** Triggered when a message is retransmitted */ COAP_EVENT_MSG_RETRANSMITTED = 0x5002, + /** Triggered when the initial app PDU cannot be transmitted */ + COAP_EVENT_FIRST_PDU_FAIL = 0x5003, /* * OSCORE events @@ -381,6 +383,7 @@ typedef enum { COAP_EVENT_OSCORE_INTERNAL_ERROR, /** Triggered when there is an OSCORE decode of OSCORE option failure */ COAP_EVENT_OSCORE_DECODE_ERROR, + /* * WebSocket events */ @@ -390,11 +393,13 @@ typedef enum { COAP_EVENT_WS_CONNECTED, /** Triggered when the WebSockets layer is closed */ COAP_EVENT_WS_CLOSED, + /* * Keepalive events */ /** Triggered when no response to a keep alive (ping) packet */ COAP_EVENT_KEEPALIVE_FAILURE = 0x8001, + /* * Reconnect events */ diff --git a/src/coap_io.c b/src/coap_io.c index 200f3e9c..9940167c 100644 --- a/src/coap_io.c +++ b/src/coap_io.c @@ -304,6 +304,23 @@ coap_check_need_reconnect(coap_context_t *ctx, coap_session_t *s, coap_tick_t no } return timeout; } + +void +coap_reset_doing_first(coap_session_t *session) { + if (session->doing_first) { + session->doing_first = 0; + while (!session->doing_first && session->doing_first_pdu) { + coap_pdu_t *k_pdu = session->doing_first_pdu; + + LL_DELETE(session->doing_first_pdu, session->doing_first_pdu); + coap_log_debug("** %s: mid=0x%04x: released\n", + coap_session_str(session), k_pdu->mid); + if (coap_send_lkd(session, k_pdu) == COAP_INVALID_MID) { + coap_handle_event_lkd(session->context, COAP_EVENT_FIRST_PDU_FAIL, session); + } + } + } +} #endif /* COAP_CLIENT_SUPPORT */ /* @@ -607,6 +624,77 @@ release_1: timeout = s_timeout; } } + if (s->doing_first && s->doing_first_timeout) { + if ((s->doing_first_timeout + 5 * COAP_TICKS_PER_SECOND) > now) { + s_timeout = s->doing_first_timeout + 5 * COAP_TICKS_PER_SECOND - now; + if (s_timeout < timeout) + timeout = s_timeout; + } else { + /* Session set up has failed */ + coap_queue_t *sent; + coap_queue_t *p = NULL; + coap_queue_t *q; + coap_queue_t *tmp; + + if (s->state == COAP_SESSION_STATE_CSM) { + coap_log_debug("** %s: timeout waiting for CSM response\n", + coap_session_str(s)); + s->csm_not_seen = 1; + } else { + coap_log_debug("** %s: timeout waiting for first response\n", + coap_session_str(s)); + } +#if COAP_Q_BLOCK_SUPPORT + /* Check if testing for Q-Block */ + if (s->block_mode & COAP_BLOCK_PROBE_Q_BLOCK) { + coap_log_debug("Q-Block support assumed not available\n"); + set_block_mode_drop_q(s->block_mode); + } +#endif /* COAP_Q_BLOCK_SUPPORT */ + /* Check if testing for Extended Token */ + if (s->max_token_checked == COAP_EXT_T_CHECKING) { + s->max_token_size = COAP_TOKEN_DEFAULT_MAX; + s->max_token_checked = COAP_EXT_T_CHECKED; + coap_log_debug("Extended Token support assumed not available\n"); + } + /* + * Remove the test packet to stop re-transmission. + * The test packet may be in the delayqueue ((D)TLS has not been set up), + * or in the sendqueue if sent and is pending re-transmission. + */ + LL_FOREACH_SAFE(s->delayqueue, q, tmp) { + if (q->pdu->mid == s->remote_test_mid) { + if (q->pdu->type==COAP_MESSAGE_CON) { + coap_handle_nack(s, q->pdu, + s->proto == COAP_PROTO_DTLS ? + COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE, + q->id); + } + coap_log_debug("** %s: mid=0x%04x: removed\n", + coap_session_str(s), q->pdu->mid); + if (p) { + p->next = q->next; + } else { + s->delayqueue = q->next; + } + coap_delete_node_lkd(q); + break; + } + p = q; + } + coap_remove_from_queue(&ctx->sendqueue, s, s->remote_test_mid, &sent); + if (sent && sent->pdu && sent->pdu->type == COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(s->proto)) { + if (s->con_active) + s->con_active--; + } + coap_reset_doing_first(s); + if (s->state == COAP_SESSION_STATE_ESTABLISHED) { + /* Flush out any entries on session->delayqueue */ + coap_session_connected(s); + } + } + } + #if COAP_Q_BLOCK_SUPPORT /* * Check if any client large transmits have hit MAX_PAYLOAD and need diff --git a/src/coap_net.c b/src/coap_net.c index ade2be34..95ed9ca3 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -1344,6 +1344,10 @@ coap_send_test_extended_token(coap_session_t *session) { } #endif /* COAP_CLIENT_SUPPORT */ +/* + * Return: 0 Something failed + * 1 Success + */ int coap_client_delay_first(coap_session_t *session) { #if COAP_CLIENT_SUPPORT @@ -1365,7 +1369,7 @@ coap_client_delay_first(coap_session_t *session) { int result = coap_io_process_lkd(session->context, 1000); if (result < 0) { - session->doing_first = 0; + coap_reset_doing_first(session); session->delay_recursive = 0; coap_session_release_lkd(session); return 0; @@ -1385,16 +1389,16 @@ coap_client_delay_first(coap_session_t *session) { } else { if (session->doing_first == 1) { /* Timeout failure of some sort with first request */ - session->doing_first = 0; if (session->state == COAP_SESSION_STATE_CSM) { coap_log_debug("** %s: timeout waiting for CSM response\n", coap_session_str(session)); session->csm_not_seen = 1; - coap_session_connected(session); } else { coap_log_debug("** %s: timeout waiting for first response\n", coap_session_str(session)); } + coap_reset_doing_first(session); + coap_session_connected(session); } } } @@ -1506,13 +1510,13 @@ coap_send_lkd(coap_session_t *session, coap_pdu_t *pdu) { coap_log_debug("coap_send: Socket closed\n"); goto error; } - /* - * If this is not the first client request and are waiting for a response - * to the first client request, then drop sending out this next request - * until all is properly established. - */ - if (!coap_client_delay_first(session)) { - goto error; + + if (session->doing_first) { + LL_APPEND(session->doing_first_pdu, pdu); + coap_show_pdu(COAP_LOG_DEBUG, pdu); + coap_log_debug("** %s: mid=0x%04x: queued\n", + coap_session_str(session), pdu->mid); + return pdu->mid; } /* Indicate support for Extended Tokens if appropriate */ @@ -1531,13 +1535,49 @@ coap_send_lkd(coap_session_t *session, coap_pdu_t *pdu) { } /* * For reliable protocols, this will get cleared after CSM exchanged - * in coap_session_connected() + * in coap_session_connected() where Token size support is indicated in the CSM. */ session->doing_first = 1; - if (!coap_client_delay_first(session)) { + coap_ticks(&session->doing_first_timeout); + LL_PREPEND(session->doing_first_pdu, pdu); + if (session->proto != COAP_PROTO_UDP) { + /* In case the next handshake / CSM is already in */ + coap_io_process_lkd(session->context, COAP_IO_NO_WAIT); + } + /* + * Once Extended Token support size is determined, coap_send_lkd(session, pdu) + * will get called again. + */ + coap_show_pdu(COAP_LOG_DEBUG, pdu); + coap_log_debug("** %s: mid=0x%04x: queued\n", + coap_session_str(session), pdu->mid); + return pdu->mid; + } +#if COAP_Q_BLOCK_SUPPORT + /* Indicate support for Q-Block if appropriate */ + if (session->block_mode & COAP_BLOCK_TRY_Q_BLOCK && + session->type == COAP_SESSION_TYPE_CLIENT && + COAP_PDU_IS_REQUEST(pdu)) { + if (coap_block_test_q_block(session, pdu) == COAP_INVALID_MID) { goto error; } + session->doing_first = 1; + coap_ticks(&session->doing_first_timeout); + LL_PREPEND(session->doing_first_pdu, pdu); + if (session->proto != COAP_PROTO_UDP) { + /* In case the next handshake / CSM is already in */ + coap_io_process_lkd(session->context, COAP_IO_NO_WAIT); + } + /* + * Once Extended Token support size is determined, coap_send_lkd(session, pdu) + * will get called again. + */ + coap_show_pdu(COAP_LOG_DEBUG, pdu); + coap_log_debug("** %s: mid=0x%04x: queued\n", + coap_session_str(session), pdu->mid); + return pdu->mid; } +#endif /* COAP_Q_BLOCK_SUPPORT */ /* * Check validity of token length @@ -1649,23 +1689,6 @@ coap_send_lkd(coap_session_t *session, coap_pdu_t *pdu) { memset(&block, 0, sizeof(block)); } -#if COAP_Q_BLOCK_SUPPORT - /* Indicate support for Q-Block if appropriate */ - if (session->block_mode & COAP_BLOCK_TRY_Q_BLOCK && - session->type == COAP_SESSION_TYPE_CLIENT && - COAP_PDU_IS_REQUEST(pdu)) { - if (coap_block_test_q_block(session, pdu) == COAP_INVALID_MID) { - goto error; - } - session->doing_first = 1; - if (!coap_client_delay_first(session)) { - /* Q-Block test Session has failed for some reason */ - set_block_mode_drop_q(session->block_mode); - goto error; - } - } -#endif /* COAP_Q_BLOCK_SUPPORT */ - #if COAP_Q_BLOCK_SUPPORT if (!(session->block_mode & COAP_BLOCK_HAS_Q_BLOCK)) #endif /* COAP_Q_BLOCK_SUPPORT */ @@ -2973,8 +2996,10 @@ coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_mid_t coap_queue_t **node) { coap_queue_t *p, *q; - if (!queue || !*queue) + if (!queue || !*queue) { + *node = NULL; return 0; + } /* replace queue head if PDU's time is less than head's time */ @@ -3009,6 +3034,7 @@ coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_mid_t return 1; } + *node = NULL; return 0; } @@ -4249,7 +4275,7 @@ handle_response(coap_context_t *context, coap_session_t *session, coap_block_delete_lg_crcv(session, lg_crcv); } coap_send_ack_lkd(session, rcvd); - session->doing_first = 0; + coap_reset_doing_first(session); return; } #if COAP_Q_BLOCK_SUPPORT @@ -4272,9 +4298,8 @@ handle_response(coap_context_t *context, coap_session_t *session, set_block_mode_drop_q(session->block_mode); } } - session->doing_first = 0; - if (rcvd->type == COAP_MESSAGE_CON) - coap_send_ack_lkd(session, rcvd); + coap_send_ack_lkd(session, rcvd); + coap_reset_doing_first(session); return; } #endif /* COAP_Q_BLOCK_SUPPORT */ @@ -4294,8 +4319,7 @@ handle_response(coap_context_t *context, coap_session_t *session, return; } } - if (session->doing_first) - session->doing_first = 0; + coap_reset_doing_first(session); /* Call application-specific response handler when available. */ coap_call_response_handler(session, sent, rcvd, NULL); @@ -4426,7 +4450,7 @@ coap_dispatch(coap_context_t *context, coap_session_t *session, coap_opt_iterator_t opt_iter; coap_pdu_t *dec_pdu = NULL; #endif /* COAP_OSCORE_SUPPORT */ - int is_ext_token_rst; + int is_ext_token_rst = 0; int oscore_invalid = 0; pdu->session = session; @@ -4699,25 +4723,27 @@ coap_dispatch(coap_context_t *context, coap_session_t *session, session->last_ping > 0) is_ping_rst = 1; +#if COAP_CLIENT_SUPPORT #if COAP_Q_BLOCK_SUPPORT /* Check to see if checking out Q-Block support */ if (session->block_mode & COAP_BLOCK_PROBE_Q_BLOCK && session->remote_test_mid == pdu->mid) { coap_log_debug("Q-Block support not available\n"); set_block_mode_drop_q(session->block_mode); + coap_reset_doing_first(session); } #endif /* COAP_Q_BLOCK_SUPPORT */ /* Check to see if checking out extended token support */ - is_ext_token_rst = 0; if (session->max_token_checked == COAP_EXT_T_CHECKING && session->remote_test_mid == pdu->mid) { coap_log_debug("Extended Token support not available\n"); session->max_token_size = COAP_TOKEN_DEFAULT_MAX; session->max_token_checked = COAP_EXT_T_CHECKED; - session->doing_first = 0; + coap_reset_doing_first(session); is_ext_token_rst = 1; } +#endif /* COAP_CLIENT_SUPPORT */ if (!is_ping_rst && !is_ext_token_rst) coap_log_alert("got RST for mid=0x%04x\n", pdu->mid); @@ -4914,6 +4940,8 @@ coap_event_name(coap_event_t event) { return "COAP_EVENT_BAD_PACKET"; case COAP_EVENT_MSG_RETRANSMITTED: return "COAP_EVENT_MSG_RETRANSMITTED"; + case COAP_EVENT_FIRST_PDU_FAIL: + return "COAP_EVENT_FIRST_PDU_FAIL"; case COAP_EVENT_OSCORE_DECRYPTION_FAILURE: return "COAP_EVENT_OSCORE_DECRYPTION_FAILURE"; case COAP_EVENT_OSCORE_NOT_ENABLED: @@ -4986,6 +5014,7 @@ coap_handle_event_lkd(coap_context_t *context, coap_event_t event, case COAP_EVENT_WS_PACKET_SIZE: case COAP_EVENT_WS_CLOSED: case COAP_EVENT_BAD_PACKET: + case COAP_EVENT_FIRST_PDU_FAIL: case COAP_EVENT_RECONNECT_NO_MORE: /* Those that are deemed fatal to end sending a request */ session->doing_send_recv = 0; diff --git a/src/coap_pdu.c b/src/coap_pdu.c index 98b2e3c1..ddc2464f 100644 --- a/src/coap_pdu.c +++ b/src/coap_pdu.c @@ -236,7 +236,9 @@ coap_pdu_duplicate_lkd(const coap_pdu_t *old_pdu, size_t token_length, const uint8_t *token, coap_opt_filter_t *drop_options) { +#if COAP_CLIENT_SUPPORT uint8_t doing_first = session->doing_first; +#endif /* COAP_CLIENT_SUPPORT */ coap_pdu_t *pdu; coap_lock_check_locked(); @@ -246,13 +248,17 @@ coap_pdu_duplicate_lkd(const coap_pdu_t *old_pdu, * that indicates BERT size (TCP/TLS only) as this may be called early * the OSCORE logic. */ +#if COAP_CLIENT_SUPPORT session->doing_first = 0; +#endif /* COAP_CLIENT_SUPPORT */ pdu = coap_pdu_init(old_pdu->type, old_pdu->code, coap_new_message_id_lkd(session), max(old_pdu->max_size, coap_session_max_pdu_size_lkd(session))); +#if COAP_CLIENT_SUPPORT /* Restore any pending waits */ session->doing_first = doing_first; +#endif /* COAP_CLIENT_SUPPORT */ if (pdu == NULL) return NULL; diff --git a/src/coap_session.c b/src/coap_session.c index dc92b11b..03aeeb09 100644 --- a/src/coap_session.c +++ b/src/coap_session.c @@ -572,6 +572,21 @@ coap_session_mfree(coap_session_t *session) { } coap_delete_node_lkd(q); } + +#if COAP_CLIENT_SUPPORT + coap_pdu_t *p, *ptmp; + + LL_FOREACH_SAFE(session->doing_first_pdu, p, ptmp) { + if (p->type==COAP_MESSAGE_CON) { + coap_handle_nack(session, p, + session->proto == COAP_PROTO_DTLS ? + COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE, + p->mid); + } + coap_delete_pdu_lkd(p); + } +#endif /* COAP_CLIENT_SUPPORT */ + if (session->partial_pdu) coap_delete_pdu_lkd(session->partial_pdu); if (session->sock.lfunc[COAP_LAYER_SESSION].l_close) @@ -755,20 +770,24 @@ coap_session_max_pdu_size_lkd(const coap_session_t *session) { coap_lock_check_locked(); #if COAP_CLIENT_SUPPORT - /* - * Delay if session->doing_first is set. - * E.g. Reliable and CSM not in yet for checking block support - */ - coap_session_t *session_rw; + if (COAP_PROTO_RELIABLE(session->proto) && + session->type == COAP_SESSION_TYPE_CLIENT && + session->doing_first) { + /* + * Delay if session->doing_first is set. + * E.g. Reliable and CSM not in yet for checking block support + */ + coap_session_t *session_rw; - /* - * Need to do this to not get a compiler warning about const parameters - * but need to maintain source code backward compatibility - */ - memcpy(&session_rw, &session, sizeof(session_rw)); - if (coap_client_delay_first(session_rw) == 0) { - coap_log_debug("coap_client_delay_first: timeout\n"); - /* Have to go with the defaults */ + /* + * Need to do this to not get a compiler warning about const parameters + * but need to maintain source code backward compatibility + */ + memcpy(&session_rw, &session, sizeof(session_rw)); + if (coap_client_delay_first(session_rw) == 0) { + coap_log_debug("coap_client_delay_first: timeout\n"); + /* Have to go with the defaults */ + } } #endif /* COAP_CLIENT_SUPPORT */ @@ -829,6 +848,7 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, coap_address_copy(&node->remote, &session->addr_info.remote); } LL_APPEND(session->delayqueue, node); + coap_show_pdu(COAP_LOG_DEBUG, node->pdu); coap_log_debug("** %s: mid=0x%04x: delayed\n", coap_session_str(session), node->id); return COAP_PDU_DELAYED; @@ -931,9 +951,8 @@ coap_session_connected(coap_session_t *session) { coap_handle_event_lkd(session->context, COAP_EVENT_SESSION_CONNECTED, session); #if COAP_CLIENT_SUPPORT coap_session_reestablished(session); + coap_reset_doing_first(session); #endif /* COAP_CLIENT_SUPPORT */ - if (session->doing_first) - session->doing_first = 0; } } @@ -1024,7 +1043,11 @@ coap_handle_nack(coap_session_t *session, coap_pdu_t *sent, const coap_nack_reason_t reason, const coap_mid_t mid) { - if (session->context->nack_handler) { + if (session->context->nack_handler +#if COAP_CLIENT_SUPPORT + && !session->doing_first_pdu +#endif /* COAP_CLIENT_SUPPORT */ + ) { coap_bin_const_t token = {0, NULL}; if (sent) { @@ -1186,9 +1209,8 @@ coap_session_disconnected_lkd(coap_session_t *session, coap_nack_reason_t reason state == COAP_SESSION_STATE_ESTABLISHED ? COAP_EVENT_SESSION_CLOSED : COAP_EVENT_SESSION_FAILED, session); } + coap_reset_doing_first(session); #endif /* COAP_CLIENT_SUPPORT */ - if (session->doing_first) - session->doing_first = 0; } #endif /* !COAP_DISABLE_TCP */ if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)