clean up RoutingManager codes in here and there.
authorjihwan.seo <jihwan.seo@samsung.com>
Fri, 18 Sep 2015 11:09:55 +0000 (20:09 +0900)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Sat, 19 Sep 2015 12:27:47 +0000 (12:27 +0000)
Change-Id: Ib4ac2c34033f594c8d2821898d4831e18869a3d3
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2693
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
resource/csdk/routing/include/routingmanagerinterface.h
resource/csdk/routing/include/routingmessageparser.h
resource/csdk/routing/include/routingtablemanager.h
resource/csdk/routing/src/routingmanagerinterface.c
resource/csdk/routing/src/routingtablemanager.c

index f0f3db0..8563b5b 100644 (file)
@@ -54,7 +54,7 @@ OCStackResult RMDiscoverGatewayResource();
 OCStackResult RMSendObserveRequest(const OCDevAddr *devAddr, OCRepPayload *payload);
 
 /**
- * Send delete request to all the neighbour nodes.
+ * Send delete request to all the neighbor nodes.
  * @param[in]   devAddr   Device address of the Gateway device hosting
  *                        the gateway resource.
  * @param[in]   payload   Payload to be sent with the request.
index 58307d5..5706b5a 100644 (file)
@@ -72,7 +72,7 @@ OCStackResult RMPConstructRemovalPayload(uint32_t gatewayId, uint32_t seqNum,
 
 /**
  * Parse payload for request and get gateway id.
- * @param[in]   payload              Payload.
+ * @param[in]       payload              Payload.
  * @param[in]       payloadSize          Payload Size.
  * @param[out]      gatewayId            Gateway Id.
  * @return  ::OC_STACK_OK or Appropriate error code.
@@ -86,7 +86,7 @@ OCStackResult RMPParseRequestPayload(const uint8_t* payload, size_t payloadSize,
  * @param[in/out]   seqNum               Sequence Number of Gateway.
  * @param[in/out]   gatewayId            Gateway Id.
  * @param[in/out]   gatewayTable         Parsed routing table from Payload.
- * @param[out]      isUpdateSeqNeeded   Response type of payload response/notification.
+ * @param[out]      isUpdateSeqNeeded    Response type of payload response/notification.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
 OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gatewayId,
@@ -96,7 +96,6 @@ OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gat
 /**
  * Frees payload.
  * @param[in/out]   payload              Encoded Payload for Gateway ID.
- * @return  NONE.
  */
 void RMPFreePayload(OCRepPayload *payload);
 
index abe7655..9497b48 100644 (file)
@@ -221,12 +221,11 @@ OCStackResult RTMRemoveGateways(u_linklist_t **gatewayTable);
 OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable);
 
 /**
- * Gets the neighbour nodes i.e nodes with routecost 1.
- * @param[in/out]   neighbourNodes        link list containing neighbouring nodes.
+ * Gets the neighbor nodes i.e nodes with routecost 1.
+ * @param[in/out]   neighbourNodes        link list containing neighbor nodes.
                                           this list will be pointer to GatewayIds
                                           and must be freed by caller.
  * @param[in]       gatewayTable           Gateway Routing Table.
- * @return  NONE.
  */
 void RTMGetNeighbours(u_linklist_t **neighbourNodes, const u_linklist_t *gatewayTable);
 
@@ -251,7 +250,7 @@ CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpo
  * as destination.
  * @param[in]        gatewayId               Gateway Id of Hop need to be updated.
  * @param[in]        destInterfaces          Destination Interface Information.
- * @param[in]        addAdr                  Add/Remove Dest intf addr.
+ * @param[in]        addAdr                  Add/Remove destination address.
  * @param[in/out]    gatewayTable            Gateway Routing Table.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
@@ -261,7 +260,7 @@ OCStackResult RTMUpdateDestinationIntfAdr(uint32_t gatewayId, RTMDestIntfInfo_t
 /**
  * Updates Multicast sequence number for gatewayID
  * @param[in]       gatewayId           Gateway Id of Hop need to be updated.
- * @param[in]       seqNum              sequence number for last cast packet from gateway.
+ * @param[in]       seqNum              Sequence number for last cast packet from gateway.
  * @param[in/out]   gatewayTable        Gateway Routing Table.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
@@ -272,7 +271,6 @@ OCStackResult RTMUpdateMcastSeqNumber(uint32_t gatewayId, uint16_t seqNum,
  * Prints the routing table
  * @param[in]    gatewayTable           Gateway Routing Table.
  * @param[in]    endpointTable          Endpoint Routing Table.
- * @return  NONE.
  */
 void RTMPrintTable(const u_linklist_t *gatewayTable, const u_linklist_t *endpointTable);
 
@@ -280,7 +278,6 @@ void RTMPrintTable(const u_linklist_t *gatewayTable, const u_linklist_t *endpoin
  * Frees the GatewayId
  * @param[in]        gateway                Gateway Structure pointer.
  * @param[in/out]    gatewayTable           Gateway Routing Table.
- * @return  NONE.
  */
 void RTMFreeGateway(RTMGatewayId_t *gateway, u_linklist_t **gatewayTable);
 
@@ -289,7 +286,6 @@ void RTMFreeGateway(RTMGatewayId_t *gateway, u_linklist_t **gatewayTable);
  * @param[in/out]    obsList                List of Observation IDs.
  * @param[in/out]    obsListLen             Length if Observation ID list.
  * @param[in]        gatewayTable           Gateway Routing Table.
- * @return  NONE.
  */
 void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
                         const u_linklist_t *gatewayTable);
@@ -299,7 +295,7 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
  * @param[in]        obsID                  Observation ID.
  * @param[in]        devAddr                Address of Gateway.
  * @param[in/out]    gatewayTable           Gateway Routing Table.
- * @return  NONE.
+ * @return  ::OC_STACK_OK or Appropriate error code.
  */
 OCStackResult RTMAddObserver(uint32_t obsID, CAEndpoint_t devAddr, u_linklist_t **gatewayTable);
 
@@ -309,7 +305,7 @@ OCStackResult RTMAddObserver(uint32_t obsID, CAEndpoint_t devAddr, u_linklist_t
  * @param[in]        devAddr                Address of Gateway.
  * @param[in/out]    obsID                  Observation ID.
  * @param[in]        gatewayTable           Gateway Routing Table.
- * @return  NONE
+ * @return  true or false.
  */
 bool RTMIsObserverPresent(CAEndpoint_t devAddr, OCObservationId *obsID,
                           const u_linklist_t *gatewayTable);
@@ -322,16 +318,16 @@ uint64_t RTMGetCurrentTime();
 
 /**
  * Update Gateway Address Validity.
- * @param[in/out] invalidTable      Removed entries Table.
- * @param[in/out] gatewayTable      Gateway Routing Table.
+ * @param[in/out]    invalidTable      Removed entries Table.
+ * @param[in/out]    gatewayTable      Gateway Routing Table.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
 OCStackResult RTMUpdateDestAddrValidity(u_linklist_t **invalidTable, u_linklist_t **gatewayTable);
 
 /**
  * Removes invalid gateways.
- * @param[in/out] invalidTable      Removed entries Table.
- * @param[in/out] gatewayTable      Gateway Routing Table.
+ * @param[in/out]    invalidTable      Removed entries Table.
+ * @param[in/out]    gatewayTable      Gateway Routing Table.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
 OCStackResult RTMRemoveInvalidGateways(u_linklist_t **invalidTable, u_linklist_t **gatewayTable);
@@ -341,7 +337,7 @@ OCStackResult RTMRemoveInvalidGateways(u_linklist_t **invalidTable, u_linklist_t
  * @param[in]       gatewayId           Gateway Id.
  * @param[in]       seqNum              Sequence Number of Entry.
  * @param[in]       destInterfaces      Destination Interface Information.
- * @param[out]   gatewayTable        Gateway Routing Table.
+ * @param[out]      gatewayTable        Gateway Routing Table.
  * @param[in]       forceUpdate         To Update parameters forcefully.
  * @return  ::OC_STACK_OK or Appropriate error code.
  */
index 59f31f0..86c53c9 100644 (file)
@@ -121,7 +121,7 @@ OCStackResult RMDiscoverGatewayResource()
                           OC_LOW_QOS, &discoverData, NULL, 0);
 
     // Temp fix for packet drops in WIFI.
-    for (int sendData = 0; sendData < MAX_SEND_DATA; sendData++)
+    for (uint8_t sendData = 0; sendData < MAX_SEND_DATA; sendData++)
     {
         result = OCDoResource(NULL, OC_REST_DISCOVER, GW_RESOURCE_URI, 0, 0,
                               CT_ADAPTER_IP, OC_LOW_QOS, &discoverData, NULL, 0);
@@ -272,4 +272,4 @@ OCStackResult RMAddObserverToStack(const OCServerRequest *request, OCObservation
                 &request->devAddr);
     OC_LOG(DEBUG, TAG, "RMAddObserverToStack OUT");
     return result;
-}
\ No newline at end of file
+}
index 59ce172..5f5d9a4 100644 (file)
@@ -919,6 +919,12 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
     RM_NULL_CHECK_VOID(obsList, TAG, "obsList");
 
     *obsList = (OCObservationId *) OICCalloc(MAX_OBSERVER_LIST_LENGTH, sizeof(OCObservationId));
+    if (!(*obsList))
+    {
+        OC_LOG(ERROR, TAG, "out of memory");
+        return;
+    }
+
     u_linklist_iterator_t *iterTable = NULL;
     u_linklist_init_iterator(gatewayTable, &iterTable);
     uint8_t len = 0;