mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-08 18:32:53 +03:00
bugfix for transaction id == 0
coap_tid_t now is of type int, COAP_INVALID_HASHKEY now is outside the unsigned short scope coap_send() and coap_send_confirmed() now DO NOT generate transaction ids any more
This commit is contained in:
1 parent
97749a13d8
commit
f20d5f8eaf
3 files changed
+6
-9
No files matched your search
@@ -86,6 +86,7 @@ coap_new_request( method_t m, coap_list_t *options ) {
|
||||
return NULL;
|
||||
|
||||
pdu->hdr->type = COAP_MESSAGE_CON;
|
||||
pdu->hdr->id = rand(); /* use a random transaction id */
|
||||
pdu->hdr->code = m;
|
||||
|
||||
for (opt = options; opt; opt = opt->next) {
|
||||
@@ -95,6 +96,8 @@ coap_new_request( method_t m, coap_list_t *options ) {
|
||||
}
|
||||
|
||||
if (payload.length) {
|
||||
/* TODO: must handle block */
|
||||
|
||||
coap_add_data(pdu, payload.length, payload.s);
|
||||
}
|
||||
|
||||
|
||||
@@ -305,12 +305,8 @@ coap_send_impl( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pd
|
||||
return ntohs(pdu->hdr->id);
|
||||
}
|
||||
|
||||
#define create_transaction_id(T) do { T = (unsigned short)rand(); } while ( T == COAP_INVALID_TID );
|
||||
|
||||
coap_tid_t
|
||||
coap_send( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pdu_t *pdu ) {
|
||||
if ( ntohs(pdu->hdr->id) == COAP_INVALID_TID )
|
||||
create_transaction_id( pdu->hdr->id );
|
||||
return coap_send_impl( context, dst, pdu, 1 );
|
||||
}
|
||||
|
||||
@@ -323,9 +319,6 @@ coap_tid_t
|
||||
coap_send_confirmed( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pdu_t *pdu ) {
|
||||
coap_queue_t *node;
|
||||
|
||||
if ( ntohs(pdu->hdr->id) == COAP_INVALID_TID )
|
||||
create_transaction_id( pdu->hdr->id );
|
||||
|
||||
/* send once, and enter into message queue for retransmission unless
|
||||
* retransmission counter is reached */
|
||||
|
||||
|
||||
@@ -95,8 +95,9 @@
|
||||
#define COAP_MEDIATYPE_ANY 0xff /* any media type */
|
||||
|
||||
/* CoAP transaction id */
|
||||
typedef unsigned short coap_tid_t;
|
||||
#define COAP_INVALID_TID 0
|
||||
/*typedef unsigned short coap_tid_t; */
|
||||
typedef int coap_tid_t;
|
||||
#define COAP_INVALID_TID -1
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
# if (BSD >= 199103)
|
||||
|
||||
Reference in new issue
Block a user