mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-22 23:35:13 +03:00
coap_session.[hc]: make message id session-local
The message id in the CoAP header is used for reliability when transferring a CoAP PDU over a non-reliable transport protocol such as UDP. For message de-duplication, it is useful to have a monotonously increasing number space within a session. Therefore, the context-global value has been moved to coap_session_t. The function coap_new_message_id() now takes a coap_session_t object as its argument.
This commit is contained in:
1 parent
d7ebf14395
commit
5c079b72d9
6 files changed
+16
-9
No files matched your search
@@ -60,6 +60,7 @@ typedef struct coap_session_t {
|
||||
struct coap_endpoint_t *endpoint; /**< session's endpoint */
|
||||
struct coap_context_t *context; /**< session's context */
|
||||
void *tls; /**< security parameters */
|
||||
uint16_t tx_mid; /**< the last message id that was used in this session */
|
||||
struct coap_queue_t *sendqueue; /**< list of messages waiting to be sent */
|
||||
coap_tick_t last_rx_tx;
|
||||
uint8_t *psk_identity;
|
||||
|
||||
+5
-5
@@ -215,13 +215,13 @@ void coap_context_set_psk( coap_context_t *ctx, const char *hint,
|
||||
*
|
||||
* @return Incremented message id in network byte order.
|
||||
*/
|
||||
COAP_STATIC_INLINE unsigned short
|
||||
coap_new_message_id(coap_context_t *context) {
|
||||
context->message_id++;
|
||||
COAP_STATIC_INLINE uint16_t
|
||||
coap_new_message_id(coap_session_t *session) {
|
||||
session->tx_mid++;
|
||||
#ifndef WITH_CONTIKI
|
||||
return htons(context->message_id);
|
||||
return htons(session->tx_mid);
|
||||
#else /* WITH_CONTIKI */
|
||||
return uip_htons(context->message_id);
|
||||
return uip_htons(session->tx_mid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user