Prevent fixes in Routing Manager and CA.
authorvimala.v <vimala.v@samsung.com>
Mon, 21 Sep 2015 13:40:41 +0000 (19:10 +0530)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Thu, 24 Sep 2015 15:01:21 +0000 (15:01 +0000)
Change-Id: I770c3bea4bbff8ddaf9d17f7fcb79274d2e85a34
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2867
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c
resource/csdk/routing/src/routingmanager.c
resource/csdk/routing/src/routingmessageparser.c
resource/csdk/routing/src/routingtablemanager.c
resource/csdk/stack/src/ocstack.c

index 4fbeeebbf0648eee062c50a309331aa7a3f44b0c..544f561d35b2c941471e0b6de355c36127bcf047 100755 (executable)
@@ -378,5 +378,11 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class)
     (void)class;
     OIC_LOG(DEBUG, TAG, "caIpStateDisabled");
 
-    CAIPGetInterfaceInformation(0);
+    u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
+    if (!iflist)
+    {
+        OIC_LOG_V(ERROR, TAG, "get interface info failed");
+        return;
+    }
+    u_arraylist_destroy(iflist);
 }
index 47e11b47a237e098a667c225d726ed86ce59714d..88427f3b8ebbb579dd9ecd1c0a5d182b044c4742 100644 (file)
@@ -368,6 +368,7 @@ void CAWIFIConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap,
             OIC_LOG_V(ERROR, TAG, "get interface info failed");
             return;
         }
+        u_arraylist_destroy(iflist);
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
index 7eadb234f0f0ad4bff146e2c0562948c844ea639..645330962e6c952f2cef80af9d44867c25413706 100644 (file)
@@ -316,11 +316,16 @@ OCStackResult RMHandleRequestPayload(OCDevAddr devAddr, const uint8_t *reqPayloa
     result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                            updatedTableList, false,
                                            &updatedPayload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+    if (OC_STACK_OK != result)
+    {
+        OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+        RMPFreePayload(updatedPayload);
+        goto exit;
+    }
 
     result = RMSendNotificationToAll(updatedPayload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     RMPFreePayload(updatedPayload);
+    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
 
 exit:
     u_linklist_free(&updatedTableList);
@@ -411,6 +416,7 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
                 result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                                        updatedTableList, false,
                                                        &updatedPayload);
+                RM_VERIFY_SUCCESS(result, OC_STACK_OK);
                 goto sendNotification;
             }
         }
@@ -470,15 +476,21 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
         result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                                alternativeRouteList, false,
                                                &removeTablePayload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+            RMPFreePayload(removeTablePayload);
+            goto exit;
+        }
         result = RMSendNotificationToAll(removeTablePayload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
         RMPFreePayload(removeTablePayload);
+        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     }
 
     if ( 0 >= u_linklist_length(updatedTableList))
     {
-        OC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d", u_linklist_length(updatedTableList));
+        OC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d",
+                 u_linklist_length(updatedTableList));
         goto exit;
     }
 
@@ -499,11 +511,11 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
 sendNotification:
     result = RMSendNotificationToAll(updatedPayload);
     RM_VERIFY_SUCCESS(result, OC_STACK_OK);
-    RMPFreePayload(updatedPayload);
 
 exit:
+    RMPFreePayload(updatedPayload);
+    RTMFreeGatewayRouteTable(&gatewayTableList);
     u_linklist_free(&updatedTableList);
-    u_linklist_free(&gatewayTableList);
     u_linklist_free(&alternativeRouteList);
     OC_LOG(DEBUG, TAG, "RMHandleResponsePayload OUT");
     return OC_STACK_OK;
@@ -532,7 +544,6 @@ OCStackResult RMHandleGETRequest(const OCServerRequest *request, const OCResourc
     }
 
     RMPFreePayload(payload);
-
     // Send a observe request
     result = RMSendObserveRequest(&(request->devAddr), NULL);
     if (OC_STACK_OK != result)
@@ -569,11 +580,16 @@ OCStackResult RMHandleOBSERVERequest(OCServerRequest *request, const OCResource
     result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                            g_routingGatewayTable, true,
                                            &payload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+    if (OC_STACK_OK != result)
+    {
+        OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+        RMPFreePayload(payload);
+        goto exit;
+    }
 
     result = RMSendResponse(request, resource, payload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     RMPFreePayload(payload);
+    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
 exit:
     OC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest OUT");
     return result;
@@ -603,14 +619,20 @@ OCStackResult RMHandleDELETERequest(const OCServerRequest *request, const OCReso
         g_sequenceNumber++;
         result = RMPConstructRemovalPayload(g_GatewayID, g_sequenceNumber, removedGatewayNodes,
                                             false, &resPayloads);
-        RTMFreeGatewayRouteTable(&removedGatewayNodes);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+            RMPFreePayload(resPayloads);
+            goto exit;
+        }
         result = RMSendNotificationToAll(resPayloads);
+        RMPFreePayload(resPayloads);
         RM_VERIFY_SUCCESS(result, OC_STACK_OK);
         RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
     }
 
 exit:
+    RTMFreeGatewayRouteTable(&removedGatewayNodes);
     OC_LOG(DEBUG, TAG, "RMHandleDELETERequest OUT");
     return result;
 }
@@ -692,11 +714,16 @@ void RMProcess()
         OCRepPayload *payload = NULL;
         result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber, NULL,
                                                false, &payload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
-
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+            RMPFreePayload(payload);
+            goto exit;
+        }
         OC_LOG(DEBUG, TAG, "Sending the alive notification to all");
         // Send notification for every 15s to all the neighbours.
         result = RMSendNotificationToAll(payload);
+        RMPFreePayload(payload);
         RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     }
 
@@ -713,13 +740,20 @@ void RMProcess()
             result = RMPConstructRemovalPayload(g_GatewayID, g_sequenceNumber, removedEntries,
                                                 false, &resPayloads);
             RTMFreeGatewayRouteTable(&removedEntries);
-            RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+            if (OC_STACK_OK != result)
+            {
+                OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+                RMPFreePayload(resPayloads);
+                goto exit;
+            }
             result = RMSendNotificationToAll(resPayloads);
+            RMPFreePayload(resPayloads);
             RM_VERIFY_SUCCESS(result, OC_STACK_OK);
             RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
         }
         g_refreshTableTime = currentTime;
         g_isValidated = false;
+        u_linklist_free(&removedEntries);
         goto exit;
     }
 
@@ -787,6 +821,7 @@ void RMSendDeleteToNeighbourNodes()
         if (OC_STACK_OK != result)
         {
             OC_LOG_V(DEBUG, TAG, "RMPConstructGatewayPayload failed[%d]", result);
+            RMPFreePayload(payload);
             u_linklist_free(&neighbourNodes);
             return;
         }
@@ -804,6 +839,7 @@ void RMSendDeleteToNeighbourNodes()
                 RMSendDeleteRequest(&devAddr, payload);
             }
         }
+        RMPFreePayload(payload);
         u_linklist_get_next(&iterTable);
     }
 
index 2e7572df9454c5019a5b10c2a20c5878bd00cb9e..323b3aafc4a5f75225cfc906bfe647b9ec511009 100644 (file)
@@ -274,7 +274,7 @@ OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gat
 
     if (NULL == gatewayTable)
     {
-        OC_LOG(DEBUG, TAG, "Parsed Request Payload");
+        OC_LOG(DEBUG, TAG, "gatewayTable is NULL");
         return OC_STACK_OK;
     }
 
@@ -317,8 +317,8 @@ OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gat
         if (NULL == entry->nextHop)
         {
             OC_LOG(DEBUG, TAG, "nextHop Calloc failed");
-            OICFree(entry);
             OICFree(entry->destination);
+            OICFree(entry);
             return OC_STACK_ERROR;
         }
 
index 5f5d9a41175b160f4e3c64807b388bee7fc4321d..3e12b5ebc69886d1891a848b856c4e3251b978b3 100644 (file)
@@ -931,9 +931,9 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
     while (NULL != iterTable)
     {
         RTMGatewayEntry_t *entry = u_linklist_get_data(iterTable);
-        for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
+        if (0 < u_arraylist_length(entry->destination->destIntfAddr))
         {
-            RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, i);
+            RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, 0);
             if (NULL == destCheck)
             {
                 OC_LOG(ERROR, TAG, "destCheck is null");
@@ -950,7 +950,6 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
                 *obsList = (OCObservationId *) OICRealloc((void *)*obsList,
                            (sizeof(OCObservationId) * (len + 1)));
             }
-            break;
         }
         u_linklist_get_next(&iterTable);
     }
index d2b13c978782d942a2be4be2207a354597b49361..e8f89e40314f2b082e4d241d935db5c49d8aecca 100644 (file)
@@ -1173,6 +1173,12 @@ void HandleCAResponses(const CAEndpoint_t* endPoint, const CAResponseInfo_t* res
                     {
                         type = PAYLOAD_TYPE_PLATFORM;
                     }
+#ifdef ROUTING_GATEWAY
+                    else if (strcmp(cbNode->requestUri, OC_RSRVD_GATEWAY_URI) == 0)
+                    {
+                        type = PAYLOAD_TYPE_REPRESENTATION;
+                    }
+#endif
                     else
                     {
                         OC_LOG_V(ERROR, TAG, "Unknown Payload type in Discovery: %d %s",