Transate OC_EH codes as documented. 27/22327/2
authorTodd Malsbary <todd.malsbary@intel.com>
Tue, 5 Sep 2017 19:03:17 +0000 (12:03 -0700)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 9 Oct 2017 14:00:53 +0000 (14:00 +0000)
The octypes.h header file defines what over-the-air codes should
result from the given OC_EH codes returned by an entity handler.  This
patch makes the code match the documentation.

Bug: https://jira.iotivity.org/browse/IOT-2685
Change-Id: I2a069310aff6557d1e1b11404099befe442bb159
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
resource/csdk/include/octypes.h
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocstack.c

index f78e612..440f244 100644 (file)
@@ -1067,7 +1067,7 @@ typedef enum
     OC_STACK_INVALID_IP,
     OC_STACK_INVALID_PORT,
     OC_STACK_INVALID_CALLBACK,
-    OC_STACK_INVALID_METHOD,
+    OC_STACK_INVALID_METHOD,        /** 405 */
 
     /** Invalid parameter.*/
     OC_STACK_INVALID_PARAM,
@@ -1128,7 +1128,7 @@ typedef enum
 
     /** Request is denied by the user*/
     OC_STACK_USER_DENIED_REQ,
-    OC_STACK_NOT_ACCEPTABLE,
+    OC_STACK_NOT_ACCEPTABLE,         /** 406 */
 
     /** ERROR code from server */
     OC_STACK_FORBIDDEN_REQ,          /** 403*/
index 99959e2..701d961 100644 (file)
@@ -1476,6 +1476,30 @@ OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult)
         case OC_EH_RESOURCE_NOT_FOUND:
             result = OC_STACK_NO_RESOURCE;
             break;
+        case OC_EH_BAD_REQ:
+            result = OC_STACK_INVALID_QUERY;
+            break;
+        case OC_EH_UNAUTHORIZED_REQ:
+            result = OC_STACK_UNAUTHORIZED_REQ;
+            break;
+        case OC_EH_BAD_OPT:
+            result = OC_STACK_INVALID_OPTION;
+            break;
+        case OC_EH_METHOD_NOT_ALLOWED:
+            result = OC_STACK_INVALID_METHOD;
+            break;
+        case OC_EH_NOT_ACCEPTABLE:
+            result = OC_STACK_NOT_ACCEPTABLE;
+            break;
+        case OC_EH_TOO_LARGE:
+            result = OC_STACK_TOO_LARGE_REQ;
+            break;
+        case OC_EH_SERVICE_UNAVAILABLE:
+            result = OC_STACK_SERVICE_UNAVAILABLE;
+            break;
+        case OC_EH_RETRANSMIT_TIMEOUT:
+            result = OC_STACK_COMM_ERROR;
+            break;
         default:
             result = OC_STACK_ERROR;
     }
index 9628203..56cfeb0 100644 (file)
@@ -942,6 +942,12 @@ CAResponseResult_t OCToCAStackResult(OCStackResult ocCode, OCMethod method)
         case OC_STACK_SERVICE_UNAVAILABLE:
             ret = CA_SERVICE_UNAVAILABLE;
             break;
+        case OC_STACK_INVALID_METHOD:
+            ret = CA_METHOD_NOT_ALLOWED;
+            break;
+        case OC_STACK_TOO_LARGE_REQ:
+            ret = CA_REQUEST_ENTITY_TOO_LARGE;
+            break;
         default:
             break;
     }