fixed CoAP/TCP header type check logic from the size.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Thu, 10 Dec 2015 00:51:10 +0000 (00:51 +0000)
committerJon A. Cruz <jonc@osg.samsung.com>
Mon, 11 Jan 2016 17:13:43 +0000 (17:13 +0000)
The first nibble of coap over tcp message format is used
to indicate the length of the options/payload.
if the first nibble is 13, An 8-bit unsigned integer follows
the initial byte and indicates the length of options/payload minus 13.
(14: 16-bit unsigned integer,
     indicates the length of options/payload minus 269.
 15: 32-bit unsigned interger,
     indicates the length of options/payload minus 65805)

Change-Id: I2a88eb161584fb0104d2b533e3456c19a4b99304
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4479
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c

index e4f40d6..3086b22 100644 (file)
@@ -245,15 +245,15 @@ void coap_delete_pdu(coap_pdu_t *pdu)
 #ifdef WITH_TCP
 coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size)
 {
-    if (COAP_TCP_LENGTH_LIMIT_8_BIT < size && COAP_TCP_LENGTH_LIMIT_16_BIT >= size)
+    if (COAP_TCP_LENGTH_FIELD_8_BIT < size && COAP_TCP_LENGTH_FIELD_16_BIT >= size)
     {
         return coap_tcp_8bit;
     }
-    else if (COAP_TCP_LENGTH_LIMIT_16_BIT < size && COAP_TCP_LENGTH_LIMIT_32_BIT >= size)
+    else if (COAP_TCP_LENGTH_FIELD_16_BIT < size && COAP_TCP_LENGTH_FIELD_32_BIT >= size)
     {
         return coap_tcp_16bit;
     }
-    else if (COAP_TCP_LENGTH_LIMIT_32_BIT < size)
+    else if (COAP_TCP_LENGTH_FIELD_32_BIT < size)
     {
         return coap_tcp_32bit;
     }