'./src/routingutility.c',
'./src/routingmanager.c',
'./src/routingtablemanager.c',
+ './src/routingtablemanager_endpoint.c',
'./src/routingmanagerinterface.c',
'./src/routingmessageparser.c',
]
OCStackResult RTMFreeGatewayIdList(u_linklist_t **gatewayIdTable);
/**
- * Frees the endpoint table memory with nodes containing structute RTMEndpointEntry_t.
- * @param[in/out] endpointTable Endpoint Routing Table.
- * @return ::OC_STACK_OK or Appropriate error code.
- */
-OCStackResult RTMFreeEndpointRouteTable(u_linklist_t **endpointTable);
-
-/**
* Adds the entry to the routing table if the entry for Gateway id is
* not preset in Routing table, Updates the Old entry if Entry for
* Gateway Id is already present in Routing table i.e routeCost and NextHop
const RTMDestIntfInfo_t *destInterfaces, u_linklist_t **gatewayTable);
/**
- * Adds the endpoint entry to the routing table.
- * @param[in/out] endpointId Endpoint Id.
- * @param[in] destAddr Destination Address.
- * @param[in/out] endpointTable Endpoint Routing Table.
- * @return ::OC_STACK_OK or Appropriate error code.
- */
-OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *destAddr,
- u_linklist_t **endpointTable);
-
-/**
* Removes the gateway entry from the routing table and also removes
* corresponding entries having nexthop as removed gateway.
* @param[in] gatewayId Gateway id of node need to be removed.
u_linklist_t **gatewayTable);
/**
- * Removes the endpoint entry from the routing table.
- * @param[in] endpointId Endpoint id of node need to be removed.
- * @param[in/out] endpointTable Endpoint Routing Table.
- * @return ::OC_STACK_OK or Appropriate error code.
- */
-OCStackResult RTMRemoveEndpointEntry(uint16_t endpointId, u_linklist_t **endpointTable);
-
-/**
* Removes the gateway entry from the routing table which has gateway id and nexthop as given.
* @param[in] gatewayId Gateway Id.
* @param[in] nextHop Next Hop address.
OCStackResult RTMRemoveGateways(u_linklist_t **gatewayTable);
/**
- * Removes the endpoint nodes.
- * @param[in/out] endpointTable Endpoint Routing Table.
- * @return ::OC_STACK_OK or Appropriate error code.
- */
-OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable);
-
-/**
* 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
RTMGatewayId_t *RTMGetNextHop(uint32_t gatewayId, const u_linklist_t *gatewayTable);
/**
- * Gets endpoint entry
- * @param[in] endpointId Endpoint id of node need to be removed.
- * @param[in] endpointTable Endpoint Routing Table.
- * @return Endpoint Destination inteface address.
- */
-CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpointTable);
-
-/**
* Updates destination interface address of an entry with provided gateway id
* as destination.
* @param[in] gatewayId Gateway Id of Hop need to be updated.
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+/**
+ * @file
+ * This file contains the APIs for routing table manager endpoint.
+ */
+#ifndef ROUTING_TABLE_MANAGER_ENDPOINT_H_
+#define ROUTING_TABLE_MANAGER_ENDPOINT_H_
+
+#ifndef SINGLE_THREAD
+#include <unistd.h>
+#include <time.h>
+#include <sys/time.h>
+#endif
+
+#if defined(__ANDROID__)
+#include <linux/time.h>
+#endif
+#include "ulinklist.h"
+#include "uarraylist.h"
+#include "octypes.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Initialize the Routing Table Manager.
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMEndpointInitialize(u_linklist_t **endpointTable);
+
+/**
+ * Terminates the Routing Table Manager..
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMEndpointTerminate(u_linklist_t **endpointTable);
+
+/**
+ * Frees the endpoint table memory with nodes containing structute RTMEndpointEntry_t.
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMFreeEndpointRouteTable(u_linklist_t **endpointTable);
+
+/**
+ * Adds the endpoint entry to the routing table.
+ * @param[in/out] endpointId Endpoint Id.
+ * @param[in] destAddr Destination Address.
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *destAddr,
+ u_linklist_t **endpointTable);
+
+/**
+ * Removes the endpoint entry from the routing table.
+ * @param[in] endpointId Endpoint id of node need to be removed.
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMRemoveEndpointEntry(uint16_t endpointId, u_linklist_t **endpointTable);
+
+/**
+ * Removes the endpoint nodes.
+ * @param[in/out] endpointTable Endpoint Routing Table.
+ * @return ::OC_STACK_OK or Appropriate error code.
+ */
+OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable);
+
+/**
+ * Gets endpoint entry
+ * @param[in] endpointId Endpoint id of node need to be removed.
+ * @param[in] endpointTable Endpoint Routing Table.
+ * @return Endpoint Destination inteface address.
+ */
+CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpointTable);
+
+/**
+ * Prints the routing table
+ * @param[in] endpointTable Endpoint Routing Table.
+ */
+void RTMEndpointPrintTable(const u_linklist_t *endpointTable);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* ROUTING_TABLE_MANAGER_ENDPOINT_H_ */
#include <stdio.h>
#include <string.h>
#include "routingtablemanager.h"
+#include "routingtablemanager_endpoint.h"
#include "routingutility.h"
#include "oic_malloc.h"
#include "oic_string.h"
}
}
- if (NULL == *endpointTable)
+ if (OC_STACK_ERROR == RTMEndpointInitialize(endpointTable))
{
- *endpointTable = u_linklist_create();
- if (NULL == *endpointTable)
- {
- OIC_LOG(ERROR, TAG, "Creating Routing Table failed");
- RTMTerminate(gatewayTable, endpointTable);
- return OC_STACK_ERROR;
- }
+ OIC_LOG(ERROR, TAG, "Creating EndPoint Routing Table failed");
+ RTMTerminate(gatewayTable, endpointTable);
+ return OC_STACK_ERROR;
}
+
OIC_LOG(DEBUG, TAG, "RTMInitialize OUT");
return OC_STACK_OK;
}
return OC_STACK_OK;
}
-/*
- * Freeing every char pointer of endpoint entry here frees the table.
- */
-OCStackResult RTMFreeEndpointRouteTable(u_linklist_t **endpointTable)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- if (NULL == endpointTable || NULL == *endpointTable)
- {
- return OC_STACK_OK;
- }
-
- u_linklist_iterator_t *iterTable = NULL;
- u_linklist_init_iterator(*endpointTable, &iterTable);
- while (NULL != iterTable)
- {
- RTMEndpointEntry_t *hop = u_linklist_get_data(iterTable);
- if (NULL != hop)
- {
- OICFree(hop);
- }
-
- OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
- if (OC_STACK_OK != ret)
- {
- OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
- return OC_STACK_ERROR;
- }
- }
- u_linklist_free(endpointTable);
- OIC_LOG(DEBUG, TAG, "OUT");
- return OC_STACK_OK;
-}
-
OCStackResult RTMFreeGatewayIdList(u_linklist_t **gatewayIdTable)
{
OIC_LOG(DEBUG, TAG, "IN");
*gatewayTable = NULL;
}
- ret = RTMFreeEndpointRouteTable(endpointTable);
- if (OC_STACK_OK != ret)
- {
- OIC_LOG(ERROR, TAG, "Deleting Endpoint Routing Table failed");
- }
- if (NULL != *endpointTable)
- {
- *endpointTable = NULL;
- }
+ RTMEndpointTerminate(endpointTable);
OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
return OC_STACK_OK;
}
-OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *destAddr,
- u_linklist_t **endpointTable)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- RM_NULL_CHECK_WITH_RET(endpointId, TAG, "endpointId");
- RM_NULL_CHECK_WITH_RET(destAddr, TAG, "destAddr");
- RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
- if (NULL == *endpointTable)
- {
- *endpointTable = u_linklist_create();
- if (NULL == *endpointTable)
- {
- OIC_LOG(ERROR, TAG, "u_linklist_create failed");
- return OC_STACK_NO_MEMORY;
- }
- }
-
- u_linklist_iterator_t *iterTable = NULL;
- u_linklist_init_iterator(*endpointTable, &iterTable);
- // Iterate over gateway list to find if already entry with this gatewayid is present.
- while (NULL != iterTable)
- {
- RTMEndpointEntry_t *entry =
- (RTMEndpointEntry_t *) u_linklist_get_data(iterTable);
-
- if (NULL != entry && (0 == memcmp(destAddr->addr, entry->destIntfAddr.addr,
- strlen(entry->destIntfAddr.addr)))
- && destAddr->port == entry->destIntfAddr.port)
- {
- *endpointId = entry->endpointId;
- OIC_LOG(ERROR, TAG, "Adding failed as Enpoint Entry Already present in Table");
- return OC_STACK_DUPLICATE_REQUEST;
- }
- u_linklist_get_next(&iterTable);
- }
-
- // Filling Entry.
- RTMEndpointEntry_t *hopEntry = (RTMEndpointEntry_t *)OICCalloc(1, sizeof(RTMEndpointEntry_t));
-
- if (NULL == hopEntry)
- {
- OIC_LOG(ERROR, TAG, "Malloc failed for hop entry");
- return OC_STACK_ERROR;
- }
-
- hopEntry->endpointId = *endpointId;
- hopEntry->destIntfAddr = *destAddr;
-
- OCStackResult ret = u_linklist_add(*endpointTable, (void *)hopEntry);
- if (OC_STACK_OK != ret)
- {
- OIC_LOG(ERROR, TAG, "Adding Enpoint Entry to Routing Table failed");
- OICFree(hopEntry);
- return OC_STACK_ERROR;
- }
- OIC_LOG(DEBUG, TAG, "OUT");
- return OC_STACK_OK;
-}
-
OCStackResult RTMAddObserver(uint32_t obsID, CAEndpoint_t devAddr, u_linklist_t **gatewayTable)
{
OIC_LOG(DEBUG, TAG, "IN");
return OC_STACK_ERROR;
}
-OCStackResult RTMRemoveEndpointEntry(uint16_t endpointId, u_linklist_t **endpointTable)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
- RM_NULL_CHECK_WITH_RET(*endpointTable, TAG, "*endpointTable");
-
- u_linklist_iterator_t *iterTable = NULL;
- u_linklist_init_iterator(*endpointTable, &iterTable);
- while (NULL != iterTable)
- {
- RTMEndpointEntry_t *entry = u_linklist_get_data(iterTable);
- if (NULL != entry && endpointId == entry->endpointId)
- {
- OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
- if (OC_STACK_OK != ret)
- {
- OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
- return OC_STACK_ERROR;
- }
- OICFree(entry);
- }
- else
- {
- u_linklist_get_next(&iterTable);
- }
- }
- OIC_LOG(DEBUG, TAG, "OUT");
- return OC_STACK_OK;
-}
-
OCStackResult RTMRemoveGateways(u_linklist_t **gatewayTable)
{
OIC_LOG(DEBUG, TAG, "IN");
return OC_STACK_OK;
}
-OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- if (NULL == endpointTable || NULL == *endpointTable)
- {
- OIC_LOG(DEBUG, TAG, "OUT");
- return OC_STACK_OK;
- }
-
- OCStackResult ret = RTMFreeEndpointRouteTable(endpointTable);
- if (OC_STACK_OK != ret)
- {
- OIC_LOG(ERROR, TAG, "Freeing Endpoints failed");
- return OC_STACK_ERROR;
- }
- OIC_LOG(DEBUG, TAG, "OUT");
- return OC_STACK_OK;
-}
-
void RTMFreeGateway(RTMGatewayId_t *gateway, u_linklist_t **gatewayTable)
{
OIC_LOG(DEBUG, TAG, "IN");
return NULL;
}
-CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpointTable)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- if (NULL == endpointTable)
- {
- OIC_LOG(ERROR, TAG, "endpointTable is null");
- return NULL;
- }
-
- u_linklist_iterator_t *iterTable = NULL;
- u_linklist_init_iterator(endpointTable, &iterTable);
-
- while (NULL != iterTable)
- {
- RTMEndpointEntry_t *entry = u_linklist_get_data(iterTable);
- if (NULL != entry && (endpointId == entry->endpointId))
- {
- OIC_LOG(DEBUG, TAG, "OUT");
- return &(entry->destIntfAddr);
- }
- u_linklist_get_next(&iterTable);
- }
- OIC_LOG(DEBUG, TAG, "OUT");
- return NULL;
-}
-
void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
const u_linklist_t *gatewayTable)
{
u_linklist_get_next(&iterTable);
}
- OIC_LOG(DEBUG, RM_TAG, "=================Endpoint List table============================\n");
- u_linklist_iterator_t *iterEndpointTable = NULL;
- u_linklist_init_iterator(endpointTable, &iterEndpointTable);
-
- // Iterate over endpoint list to find if already entry for gatewayid is present.
- while (NULL != iterEndpointTable)
- {
- RTMEndpointEntry_t *hop =
- (RTMEndpointEntry_t *) u_linklist_get_data(iterEndpointTable);
- if (NULL == hop)
- {
- OIC_LOG(ERROR, RM_TAG, "Printing Table Failed");
- return;
- }
- OIC_LOG_V(DEBUG, RM_TAG, "EndpointId : %u\naddr : %s Port : %d",
- hop->endpointId, hop->destIntfAddr.addr, hop->destIntfAddr.port);
-
- OIC_LOG(DEBUG, RM_TAG, "********************************************\n");
- u_linklist_get_next(&iterEndpointTable);
- }
+ RTMEndpointPrintTable(endpointTable);
}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include "routingtablemanager_endpoint.h"
+#include "routingtablemanager.h"
+#include "routingutility.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+#include "include/logger.h"
+
+/**
+ * Logging tag for module name.
+ */
+#define TAG "OIC_RM_TM"
+
+/**
+ * Tag for printing the Routing table.
+ */
+#define RM_TAG "OIC_RM_RAP"
+
+OCStackResult RTMEndpointInitialize(u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "RTMEndpointInitialize IN");
+ if (NULL == *endpointTable)
+ {
+ *endpointTable = u_linklist_create();
+ if (NULL == *endpointTable)
+ {
+ OIC_LOG(ERROR, TAG, "Creating Routing Table failed");
+ return OC_STACK_ERROR;
+ }
+ }
+ OIC_LOG(DEBUG, TAG, "RTMEndpointInitialize OUT");
+ return OC_STACK_OK;
+}
+
+/*
+ * Freeing every char pointer of endpoint entry here frees the table.
+ */
+OCStackResult RTMFreeEndpointRouteTable(u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ if (NULL == endpointTable || NULL == *endpointTable)
+ {
+ return OC_STACK_OK;
+ }
+
+ u_linklist_iterator_t *iterTable = NULL;
+ u_linklist_init_iterator(*endpointTable, &iterTable);
+ while (NULL != iterTable)
+ {
+ RTMEndpointEntry_t *hop = u_linklist_get_data(iterTable);
+ if (NULL != hop)
+ {
+ OICFree(hop);
+ }
+
+ OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
+ if (OC_STACK_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ return OC_STACK_ERROR;
+ }
+ }
+ u_linklist_free(endpointTable);
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+}
+
+/*
+ * Freeing memory first and then Freeing linked list for gateway and endpoint.
+ */
+OCStackResult RTMEndpointTerminate(u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ OCStackResult ret = RTMFreeEndpointRouteTable(endpointTable);
+ if (OC_STACK_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "Deleting Endpoint Routing Table failed");
+ }
+ if (NULL != *endpointTable)
+ {
+ *endpointTable = NULL;
+ }
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+}
+
+OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *destAddr,
+ u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ RM_NULL_CHECK_WITH_RET(endpointId, TAG, "endpointId");
+ RM_NULL_CHECK_WITH_RET(destAddr, TAG, "destAddr");
+ RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
+ if (NULL == *endpointTable)
+ {
+ *endpointTable = u_linklist_create();
+ if (NULL == *endpointTable)
+ {
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
+ }
+
+ u_linklist_iterator_t *iterTable = NULL;
+ u_linklist_init_iterator(*endpointTable, &iterTable);
+ // Iterate over gateway list to find if already entry with this gatewayid is present.
+ while (NULL != iterTable)
+ {
+ RTMEndpointEntry_t *entry =
+ (RTMEndpointEntry_t *) u_linklist_get_data(iterTable);
+
+ if (NULL != entry && (0 == memcmp(destAddr->addr, entry->destIntfAddr.addr,
+ strlen(entry->destIntfAddr.addr)))
+ && destAddr->port == entry->destIntfAddr.port)
+ {
+ *endpointId = entry->endpointId;
+ OIC_LOG(ERROR, TAG, "Adding failed as Enpoint Entry Already present in Table");
+ return OC_STACK_DUPLICATE_REQUEST;
+ }
+ u_linklist_get_next(&iterTable);
+ }
+
+ // Filling Entry.
+ RTMEndpointEntry_t *hopEntry = (RTMEndpointEntry_t *)OICCalloc(1, sizeof(RTMEndpointEntry_t));
+
+ if (NULL == hopEntry)
+ {
+ OIC_LOG(ERROR, TAG, "Malloc failed for hop entry");
+ return OC_STACK_ERROR;
+ }
+
+ hopEntry->endpointId = *endpointId;
+ hopEntry->destIntfAddr = *destAddr;
+
+ OCStackResult ret = u_linklist_add(*endpointTable, (void *)hopEntry);
+ if (OC_STACK_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "Adding Enpoint Entry to Routing Table failed");
+ OICFree(hopEntry);
+ return OC_STACK_ERROR;
+ }
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+}
+
+OCStackResult RTMRemoveEndpointEntry(uint16_t endpointId, u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
+ RM_NULL_CHECK_WITH_RET(*endpointTable, TAG, "*endpointTable");
+
+ u_linklist_iterator_t *iterTable = NULL;
+ u_linklist_init_iterator(*endpointTable, &iterTable);
+ while (NULL != iterTable)
+ {
+ RTMEndpointEntry_t *entry = u_linklist_get_data(iterTable);
+ if (NULL != entry && endpointId == entry->endpointId)
+ {
+ OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
+ if (OC_STACK_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ return OC_STACK_ERROR;
+ }
+ OICFree(entry);
+ }
+ else
+ {
+ u_linklist_get_next(&iterTable);
+ }
+ }
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+}
+
+OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ if (NULL == endpointTable || NULL == *endpointTable)
+ {
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+ }
+
+ OCStackResult ret = RTMFreeEndpointRouteTable(endpointTable);
+ if (OC_STACK_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "Freeing Endpoints failed");
+ return OC_STACK_ERROR;
+ }
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return OC_STACK_OK;
+}
+
+CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpointTable)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ if (NULL == endpointTable)
+ {
+ OIC_LOG(ERROR, TAG, "endpointTable is null");
+ return NULL;
+ }
+
+ u_linklist_iterator_t *iterTable = NULL;
+ u_linklist_init_iterator(endpointTable, &iterTable);
+
+ while (NULL != iterTable)
+ {
+ RTMEndpointEntry_t *entry = u_linklist_get_data(iterTable);
+ if (NULL != entry && (endpointId == entry->endpointId))
+ {
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return &(entry->destIntfAddr);
+ }
+ u_linklist_get_next(&iterTable);
+ }
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return NULL;
+}
+
+void RTMEndpointPrintTable(const u_linklist_t *endpointTable)
+{
+ RM_NULL_CHECK_VOID(endpointTable, TAG, "endpointTable");
+
+ OIC_LOG(DEBUG, RM_TAG, "=================Endpoint List table============================\n");
+ u_linklist_iterator_t *iterEndpointTable = NULL;
+ u_linklist_init_iterator(endpointTable, &iterEndpointTable);
+
+ // Iterate over endpoint list to find if already entry for gatewayid is present.
+ while (NULL != iterEndpointTable)
+ {
+ RTMEndpointEntry_t *hop =
+ (RTMEndpointEntry_t *) u_linklist_get_data(iterEndpointTable);
+ if (NULL == hop)
+ {
+ OIC_LOG(ERROR, RM_TAG, "Printing Table Failed");
+ return;
+ }
+ OIC_LOG_V(DEBUG, RM_TAG, "EndpointId : %u\naddr : %s Port : %d Flags : %d",
+ hop->endpointId, hop->destIntfAddr.addr, hop->destIntfAddr.port, hop->destIntfAddr.flags);
+
+ OIC_LOG(DEBUG, RM_TAG, "********************************************\n");
+ u_linklist_get_next(&iterEndpointTable);
+ }
+}