-void CALogPDUData(coap_pdu_t *pdu)
-{
- VERIFY_NON_NULL_VOID(pdu, CA_ADAPTER_UTILS_TAG, "pdu");
- OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "PDU Maker - payload : %s", pdu->data);
-
- OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "PDU Maker - type : %d", pdu->hdr->type);
-
- OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "PDU Maker - code : %d", pdu->hdr->code);
-
- OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "PDU Maker - id : %d", pdu->hdr->id);
-
- OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "PDU Maker - token : %s", pdu->hdr->token);
-}
-
-CALocalConnectivity_t *CAAdapterCreateLocalEndpoint(CATransportType_t type, const char *address)
-{
- CALocalConnectivity_t *info = (CALocalConnectivity_t *)
- OICCalloc(1, sizeof(CALocalConnectivity_t));
- if (NULL == info)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
- return NULL;
- }
-
- info->type = type;
- if (address && strlen(address))
- {
- if (CA_EDR == type)
- {
- OICStrcpy(info->addressInfo.BT.btMacAddress, sizeof(info->addressInfo.BT.btMacAddress),
- address);
- }
- else if (CA_LE == type)
- {
- OICStrcpy(info->addressInfo.LE.leMacAddress, sizeof(info->addressInfo.LE.leMacAddress),
- address);
- }
- else if (CA_IPV4 == type)
- {
- OICStrcpy(info->addressInfo.IP.ipAddress, sizeof(info->addressInfo.IP.ipAddress),
- address);
- }
- else if (CA_IPV6 == type)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Currently IPV6 is not supported");
- OICFree(info);
- return NULL;
- }
- else
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "type is not matched with any transport!");
- OICFree(info);
- return NULL;
- }
- }
-
- return info;
-}
-
-CALocalConnectivity_t *CAAdapterCopyLocalEndpoint(const CALocalConnectivity_t *connectivity)
-{
- VERIFY_NON_NULL_RET(connectivity, CA_ADAPTER_UTILS_TAG, "connectivity is NULL", NULL);
-
- CALocalConnectivity_t *info = (CALocalConnectivity_t *)
- OICCalloc(1, sizeof(CALocalConnectivity_t));
- if (NULL == info)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
- return NULL;
- }
-
- info->type = connectivity->type;
- if (CA_EDR == info->type && strlen(connectivity->addressInfo.BT.btMacAddress))
- {
- OICStrcpy(info->addressInfo.BT.btMacAddress, sizeof(info->addressInfo.BT.btMacAddress),
- connectivity->addressInfo.BT.btMacAddress);
- }
- else if (CA_LE == info->type && strlen(connectivity->addressInfo.LE.leMacAddress))
- {
- OICStrcpy(info->addressInfo.LE.leMacAddress, sizeof(info->addressInfo.LE.leMacAddress),
- connectivity->addressInfo.LE.leMacAddress);
- }
- else if ((CA_IPV4 == info->type)
-
- && strlen(connectivity->addressInfo.IP.ipAddress))
- {
- OICStrcpy(info->addressInfo.IP.ipAddress, sizeof(info->addressInfo.IP.ipAddress),
- connectivity->addressInfo.IP.ipAddress);
- info->addressInfo.IP.port = connectivity->addressInfo.IP.port;
- }
- else if (CA_IPV6 == info->type)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Currently IPV6 is not supported");
- OICFree(info);
- return NULL;
- }
- else
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "type is not matched with any transport!");
- OICFree(info);
- return NULL;
- }
-
- info->isSecured = connectivity->isSecured;
- return info;
-}
-
-void CAAdapterFreeLocalEndpoint(CALocalConnectivity_t *localEndpoint)
-{
- OICFree(localEndpoint);
-}
-
-CARemoteEndpoint_t *CAAdapterCreateRemoteEndpoint(CATransportType_t type, const char *address,
- const char *resourceUri)
-{
- CARemoteEndpoint_t *info = (CARemoteEndpoint_t *)
- OICCalloc(1, sizeof(CARemoteEndpoint_t));
- if (NULL == info)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
- return NULL;
- }
-
- info->transportType = type;
- if (address && strlen(address))
- {
- if (CA_EDR == type)
- {
- OICStrcpy(info->addressInfo.BT.btMacAddress, sizeof(info->addressInfo.BT.btMacAddress),
- address);
- }
- else if (CA_LE == type)
- {
- OICStrcpy(info->addressInfo.LE.leMacAddress, sizeof(info->addressInfo.LE.leMacAddress),
- address);
- }
- else if (CA_IPV4 == type)
- {
- OICStrcpy(info->addressInfo.IP.ipAddress, sizeof(info->addressInfo.IP.ipAddress),
- address);
- }
- else if (CA_IPV6 == type)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Currently IPV6 is not supported");
- OICFree(info);
- return NULL;
- }
- else
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "type is not matched with any transport!");
- OICFree(info);
- return NULL;
- }
- }
-
- if (resourceUri && strlen(resourceUri))
- {
- info->resourceUri = OICStrdup(resourceUri);
- }
-
- return info;
-}
-
-CARemoteEndpoint_t *CAAdapterCopyRemoteEndpoint(const CARemoteEndpoint_t *remoteEndpoint)
-{
- VERIFY_NON_NULL_RET(remoteEndpoint, CA_ADAPTER_UTILS_TAG, "Remote endpoint is NULL", NULL);
-
- CARemoteEndpoint_t *info = (CARemoteEndpoint_t *)
- OICCalloc(1, sizeof(CARemoteEndpoint_t));
- if (NULL == info)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
- return NULL;
- }
-
- info->transportType = remoteEndpoint->transportType;
- if (CA_EDR == info->transportType && ('\0' != remoteEndpoint->addressInfo.BT.btMacAddress[0]))
- {
- OICStrcpy(info->addressInfo.BT.btMacAddress, sizeof(info->addressInfo.BT.btMacAddress),
- remoteEndpoint->addressInfo.BT.btMacAddress);
- }
- else if (CA_LE == info->transportType
- && ('\0' != remoteEndpoint->addressInfo.LE.leMacAddress[0]))
- {
- OICStrcpy(info->addressInfo.LE.leMacAddress, sizeof(info->addressInfo.LE.leMacAddress),
- remoteEndpoint->addressInfo.LE.leMacAddress);
- }
- else if ((CA_IPV4 == info->transportType)
- && ('\0' != remoteEndpoint->addressInfo.IP.ipAddress[0]))
- {
- OICStrcpy(info->addressInfo.IP.ipAddress, sizeof(info->addressInfo.IP.ipAddress),
- remoteEndpoint->addressInfo.IP.ipAddress);
- info->addressInfo.IP.port = remoteEndpoint->addressInfo.IP.port;
- }
- else if (CA_IPV6 == info->transportType)
- {
- OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Currently IPV6 is not supported");
- }
- else
- {
- OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "Its not matching. May be multicast.");
- }
-
- //For Multicast, remote address will be null while resourceUri will have the service UUID
-
- if (remoteEndpoint->resourceUri && strlen(remoteEndpoint->resourceUri))
- {
- info->resourceUri = OICStrdup(remoteEndpoint->resourceUri);
- }
-
- info->isSecured = remoteEndpoint->isSecured;
- info->identity = remoteEndpoint->identity;
- return info;
-}
-
-void CAAdapterFreeRemoteEndpoint(CARemoteEndpoint_t *remoteEndpoint)
-{
- if (remoteEndpoint)
- {
- OICFree(remoteEndpoint->resourceUri);
- OICFree(remoteEndpoint);
- }
-}
-