Update snapshot(2018-02-14) 87/170287/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Sun, 18 Feb 2018 23:46:20 +0000 (08:46 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Sun, 18 Feb 2018 23:46:55 +0000 (08:46 +0900)
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
Change-Id: Id1b73ca10ec8b211a18601956891e92717c6f0a2

16 files changed:
android/android_api/base/jni/JniUtils.h
android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java
packaging/snapshot_history.txt
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/common/src/caremotehandler.c
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/pkix_interface.c
resource/csdk/stack/include/octypes.h
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/include/StringConstants.h
resource/src/OCException.cpp

index ebcec3d..0fe8578 100644 (file)
@@ -241,6 +241,8 @@ public:
                 return "NOT_ACCEPTABLE";
             case OC_STACK_UNAUTHORIZED_REQ:
                 return "UNAUTHORIZED_REQ";
+            case OC_STACK_TOO_MANY_REQUESTS:
+                return "TOO_MANY_REQUESTS";
             /** Error code from PDM */
             case OC_STACK_PDM_IS_NOT_INITIALIZED:
                 return "PDM_IS_NOT_INITIALIZED";
index 7318a0c..964674e 100644 (file)
@@ -58,6 +58,7 @@ public enum ErrorCode {
     INVALID_DEVICE_INFO("INVALID_DEVICE_INFO", ""),
     INVALID_JSON("INVALID_JSON", ""),
     UNAUTHORIZED_REQ("UNAUTHORIZED_REQ", "Request is not authorized by Resource Server"),
+    TOO_MANY_REQUESTS("TOO_MANY_REQUESTS", "Request is not served by Server; Request again after retry timer (in seconds)"),
     /** Error code from PDM */
     PDM_IS_NOT_INITIALIZED("PDM_IS_NOT_INITIALIZED", ""),
     DUPLICATE_UUID("DUPLICATE_UUID", ""),
index ab662ae..ac4fce2 100755 (executable)
@@ -1,3 +1,9 @@
+http://suprem.sec.samsung.net/jira/browse/CONPRO-1230
+
+commit_info_2018-02-14.txt
+
+commit_id: 6e8d34cb1d4d68f4ea7873102b73c37145a5ae11
+----------------------------------------------------------------------------------------------------------------------------------
 http://suprem.sec.samsung.net/jira/browse/CONPRO-1224
 
 commit_info_2018-02-07.txt
index fe713ba..618f0eb 100755 (executable)
@@ -374,6 +374,7 @@ typedef enum
     CA_NOT_ACCEPTABLE = 406,                /**< Not Acceptable */
     CA_REQUEST_ENTITY_INCOMPLETE = 408,     /**< Request Entity Incomplete */
     CA_REQUEST_ENTITY_TOO_LARGE = 413,      /**< Request Entity Too Large */
+    CA_TOO_MANY_REQUESTS = 429,             /**< Too Many Requests */
     CA_INTERNAL_SERVER_ERROR = 500,         /**< Internal Server Error */
     CA_NOT_IMPLEMENTED = 501,               /**< Not Implenented */
     CA_BAD_GATEWAY = 502,                   /**< Bad Gateway */
index 3b99e12..1e5b7e9 100644 (file)
@@ -119,6 +119,7 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
         case CA_NOT_ACCEPTABLE:
         case CA_REQUEST_ENTITY_INCOMPLETE:
         case CA_REQUEST_ENTITY_TOO_LARGE:
+        case CA_TOO_MANY_REQUESTS:
         case CA_INTERNAL_SERVER_ERROR:
         case CA_NOT_IMPLEMENTED:
         case CA_BAD_GATEWAY:
index bb65ad5..59347df 100644 (file)
@@ -40,6 +40,7 @@
 #include "pkix_interface.h"
 #include "hw_emul/hw_interface.h"
 #include "mbedtls/x509_crt.h"
+#include "secureresourceprovider.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -257,7 +258,7 @@ static void removeDeviceCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool
     g_doneCB = true;
 }
 
-static void resetDeviceCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError)
+static void resetDeviceCB(void* ctx)
 {
     OC_UNUSED(ctx);
     OIC_LOG_V(INFO, TAG, "Reset Device SUCCEEDED");
@@ -1676,7 +1677,6 @@ static int resetDevice(void)
     printf("   Resetting Selected Owned Device..\n");
 
     OCStackResult rst = SRPResetDevice(dev, resetDeviceCB);
-
     if (OC_STACK_OK != rst)
     {
         OIC_LOG_V(ERROR, TAG, "OCResetDevice API error: %d", rst);
index 0efb109..4c72d5f 100644 (file)
@@ -695,6 +695,13 @@ static OCStackApplicationResult SecurePortDiscoveryHandler(void *ctx, OCDoHandle
             OIC_LOG_V(DEBUG, TAG, "%s: TCP port from discovery = %d", __func__, resPayload->tcpPort);
 #endif
             DiscoveryInfo* pDInfo = (DiscoveryInfo*)ctx;
+
+            if(pDInfo->isSingleDiscovery && pDInfo->isFound)
+            {
+                OIC_LOG(INFO, TAG, "Device is already founded at Single mode.");
+                return OC_STACK_DELETE_TRANSACTION;
+            }
+
             OCProvisionDev_t *ptr = GetDevice(&pDInfo->pCandidateList,
                                                          clientResponse->devAddr.addr,
                                                          clientResponse->devAddr.port);
@@ -1052,6 +1059,7 @@ OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisi
     {
         OIC_LOG(ERROR, TAG, "OCStack resource error");
         OICFree(pDInfo);
+        pDInfo = NULL;
         return res;
     }
 
@@ -1061,6 +1069,7 @@ OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisi
     {
         OIC_LOG(ERROR, TAG, "Failed to wait response for secure discovery.");
         OICFree(pDInfo);
+        pDInfo = NULL;
         OCStackResult resCancel = OCCancel(handle, OC_HIGH_QOS, NULL, 0);
         if(OC_STACK_OK !=  resCancel)
         {
@@ -1073,10 +1082,12 @@ OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisi
     {
         OIC_LOG(ERROR, TAG, "Failed to remove registered callback");
         OICFree(pDInfo);
+        pDInfo = NULL;
         return res;
     }
     OIC_LOG(DEBUG, TAG, "OUT PMDeviceDiscovery");
     OICFree(pDInfo);
+    pDInfo = NULL;
     return res;
 }
 
index 9fca96e..d77300b 100644 (file)
@@ -568,7 +568,7 @@ OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
     // because we use 3 Cert, 6K is enough size for saving Certs.
     if (6144 <= chainSize)
     {
-        OIC_LOG_V(ERROR, TAG, "chainSize(%d) is invalid", chainSize);
+        OIC_LOG_V(ERROR, TAG, "chainSize(%lu) is invalid", chainSize);
         return OC_STACK_INVALID_PARAM;
     }
 
index a93acb7..34fc6f4 100644 (file)
@@ -1169,7 +1169,7 @@ OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t cr
     OIC_LOG_BUFFER(DEBUG, TAG, cred->subject.id, sizeof(cred->subject.id));
     if (cred->privateData.data)
     {
-        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : privateData len: %d", cred->privateData.len);
+        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : privateData len: %lu", cred->privateData.len);
         OIC_LOG_BUFFER(DEBUG, TAG, cred->privateData.data, cred->privateData.len);
     }
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
@@ -1179,13 +1179,13 @@ OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t cr
     }
     if (cred->publicData.data)
     {
-        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : publicData len: %d", cred->publicData.len);
+        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : publicData len: %lu", cred->publicData.len);
         OIC_LOG_BUFFER(DEBUG, TAG, cred->publicData.data, cred->publicData.len);
 
     }
     if (cred->optionalData.data)
     {
-        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : optionalData len: %d", cred->optionalData.len);
+        OIC_LOG_V(DEBUG, TAG, "GenerateCredential : optionalData len: %lu", cred->optionalData.len);
         OIC_LOG_BUFFER(DEBUG, TAG, cred->optionalData.data, cred->optionalData.len);
         OIC_LOG_V(DEBUG, TAG, "GenerateCredential : optionalData revstat: %d", cred->optionalData.revstat);
     }
index 8de7e4c..0058be4 100644 (file)
@@ -320,7 +320,7 @@ void CheckInvalidDERSignature(uint8_t *crtBuf, size_t *crtBufLen)
                     *derCrtBufLen = (size_t)crt_len + remained_len;
 
                     mbedtls_x509_crt_free(&crt_cpy);
-                    OIC_LOG_V(INFO, TAG, "Dev cert : %lu -> %lu", org_len, crt_len);
+                    OIC_LOG_V(INFO, TAG, "Dev cert : %lu -> %i", org_len, crt_len);
                     OIC_LOG_V(INFO, TAG, "Remained chain : %lu", remained_len);
                     OIC_LOG_V(INFO, TAG, "Cert Length (After) : %lu", *crtBufLen);
                 }
@@ -341,7 +341,7 @@ void CheckInvalidDERSignature(uint8_t *crtBuf, size_t *crtBufLen)
 exit:
     mbedtls_x509_crt_free(&deviceCert);
     OICFree(derCrtBufTmp);
-    OIC_LOG_V(DEBUG, TAG, "Cert chain length = %d", *crtBufLen);
+    OIC_LOG_V(DEBUG, TAG, "Cert chain length = %lu", *crtBufLen);
     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
 }
 
@@ -378,7 +378,7 @@ static bool GetPkixInfoFromHw(PkiInfo_t * inf)
         // check and fix invalid cert signature
         CheckInvalidDERSignature(inf->crt.data, &inf->crt.len);
 
-        OIC_LOG_V(INFO, TAG, "Cert chain length = %d", inf->crt.len);
+        OIC_LOG_V(INFO, TAG, "Cert chain length = %lu", inf->crt.len);
         OIC_LOG_V(INFO, TAG, "Out %s", __func__);
         return true;
     }
index 1f0c453..6afdb95 100644 (file)
@@ -1046,6 +1046,7 @@ typedef enum
 
     /** ERROR code from server */
     OC_STACK_FORBIDDEN_REQ,          /** 403*/
+    OC_STACK_TOO_MANY_REQUESTS,      /** 429*/
     OC_STACK_INTERNAL_SERVER_ERROR,  /** 500*/
     OC_STACK_NOT_IMPLEMENTED,        /** 501*/
     OC_STACK_BAD_GATEWAY,            /** 502*/
@@ -1170,6 +1171,7 @@ typedef enum
     OC_EH_NOT_ACCEPTABLE = 406,
     OC_EH_TOO_LARGE = 413,
     OC_EH_UNSUPPORTED_MEDIA_TYPE = 415,
+    OC_EH_TOO_MANY_REQUESTS = 429,
     OC_EH_INTERNAL_SERVER_ERROR = 500,
     OC_EH_NOT_IMPLEMENTED = 501,
     OC_EH_BAD_GATEWAY = 502,
index 050ecc6..b8f4b21 100755 (executable)
@@ -680,6 +680,9 @@ OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult)
         case OC_EH_RESOURCE_NOT_FOUND:
             result = OC_STACK_NO_RESOURCE;
             break;
+        case OC_EH_TOO_MANY_REQUESTS:
+            result = OC_STACK_TOO_MANY_REQUESTS;
+            break;
         case OC_EH_INTERNAL_SERVER_ERROR:
             result = OC_STACK_INTERNAL_SERVER_ERROR;
             break;
index 91d7e1c..325abb7 100644 (file)
@@ -487,6 +487,9 @@ CAResponseResult_t ConvertEHResultToCAResult (OCEntityHandlerResult result, OCMe
         case OC_EH_NOT_ACCEPTABLE: // 4.06
             caResult = CA_NOT_ACCEPTABLE;
             break;
+        case OC_EH_TOO_MANY_REQUESTS: // 4.29
+            caResult = CA_TOO_MANY_REQUESTS;
+            break;
         case OC_EH_INTERNAL_SERVER_ERROR: // 5.00
             caResult = CA_INTERNAL_SERVER_ERROR;
             break;
index f5575b1..9ad65c2 100644 (file)
@@ -722,6 +722,9 @@ OCStackResult CAResponseToOCStackResult(CAResponseResult_t caCode)
         case CA_FORBIDDEN_REQ:
             ret = OC_STACK_FORBIDDEN_REQ;
             break;
+        case CA_TOO_MANY_REQUESTS:
+            ret = OC_STACK_TOO_MANY_REQUESTS;
+            break;
         case CA_INTERNAL_SERVER_ERROR:
             ret = OC_STACK_INTERNAL_SERVER_ERROR;
             break;
@@ -807,6 +810,9 @@ CAResponseResult_t OCToCAStackResult(OCStackResult ocCode, OCMethod method)
         case OC_STACK_FORBIDDEN_REQ:
             ret = CA_FORBIDDEN_REQ;
             break;
+        case OC_STACK_TOO_MANY_REQUESTS:
+            ret = CA_TOO_MANY_REQUESTS;
+            break;
         case OC_STACK_INTERNAL_SERVER_ERROR:
             ret = CA_INTERNAL_SERVER_ERROR;
             break;
index 3e366a3..0f224d4 100644 (file)
@@ -132,6 +132,7 @@ namespace OC
         static const char NOT_ACCEPTABLE[]             = "Request not acceptable";
         static const char PUBLISH_RESOURCE_FAILED[]    = "Publish Resource failure";
         static const char FORBIDDEN_REQ[]              = "Forbidden request";
+        static const char TOO_MANY_REQUESTS[]          = "Too Many Requests";
         static const char INTERNAL_SERVER_ERROR[]      = "Internal server error";
         static const char NOTIFY_ALL_OBSERVERS_FAILED[]  = "notifyAllObservers failed";
         static const char NOTIFY_LIST_OBSERVERS_FAILED[] = "notifyListOfObservers failed";
index 8e55515..530320b 100644 (file)
@@ -119,6 +119,8 @@ std::string OC::OCException::reason(const OCStackResult sr)
             return OC::Exception::NOT_ACCEPTABLE;
         case OC_STACK_FORBIDDEN_REQ:
             return OC::Exception::FORBIDDEN_REQ;
+        case OC_STACK_TOO_MANY_REQUESTS:
+            return OC::Exception::TOO_MANY_REQUESTS;
         case OC_STACK_INTERNAL_SERVER_ERROR:
             return OC::Exception::INTERNAL_SERVER_ERROR;
         case OC_STACK_METHOD_NOT_ALLOWED: