connectivity: Fix discovery+blockwise regression
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Fri, 10 Mar 2017 15:14:16 +0000 (16:14 +0100)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Sat, 11 Mar 2017 03:13:03 +0000 (03:13 +0000)
A regression has been reported on discovery when large payloads are used.

After investigation in blockwise feature,
it appeared that regression occurred with this change:

https://gerrit.iotivity.org/gerrit/#/c/17419/

Author assumed that payload should fit into CoAP PDU (1400c),
which is against the blockwise feature's design.

Adjusting those tests, seems to fix the problem.

Bug: https://jira.iotivity.org/browse/IOT-1902
Change-Id: I0aa6d97de0987d13c54b426b537b5d83235517b7
Thanks-to: Pawel Winogrodzki <pawelwi@microsoft.com>
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17827
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/caprotocolmessage.c

index ba565df..c35f011 100644 (file)
@@ -1406,8 +1406,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
     VERIFY_NON_NULL(options, TAG, "options");
     VERIFY_TRUE(((*pdu)->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
                 "pdu->transport_hdr->udp.token_length");
-    VERIFY_TRUE((info->payloadSize <= COAP_MAX_PDU_SIZE), TAG,
-                    "info->payloadSize");
+    VERIFY_TRUE((info->payloadSize <= UINT_MAX), TAG, "info->payloadSize");
 
     CAResult_t res = CA_STATUS_OK;
     unsigned int dataLength = 0;
@@ -1526,7 +1525,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
     VERIFY_NON_NULL(options, TAG, "options");
-    VERIFY_TRUE((dataLength <= COAP_MAX_PDU_SIZE), TAG, "dataLength");
+    VERIFY_TRUE((dataLength <= UINT_MAX), TAG, "dataLength");
 
     // get set block data from CABlock list-set.
     coap_block_t *block1 = CAGetBlockOption(blockID, COAP_OPTION_BLOCK1);
@@ -1633,7 +1632,7 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
     VERIFY_NON_NULL(options, TAG, "options");
-    VERIFY_TRUE((dataLength <= COAP_MAX_PDU_SIZE), TAG, "dataLength");
+    VERIFY_TRUE((dataLength <= UINT_MAX), TAG, "dataLength");
 
     // get set block data from CABlock list-set.
     coap_block_t *block1 = CAGetBlockOption(blockID, COAP_OPTION_BLOCK1);
index 5060163..cdadc6f 100644 (file)
@@ -259,7 +259,7 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
     VERIFY_NON_NULL_RET(info, TAG, "info", NULL);
     VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint", NULL);
     VERIFY_NON_NULL_RET(transport, TAG, "transport", NULL);
-    VERIFY_TRUE_RET((info->payloadSize <= COAP_MAX_PDU_SIZE), TAG,
+    VERIFY_TRUE_RET((info->payloadSize <= UINT_MAX), TAG,
                     "info->payloadSize", NULL);
 
     size_t length = COAP_MAX_PDU_SIZE;