X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fip_adapter%2Farduino%2Fcaipclient_eth.cpp;h=3e234dfab84775a8dbf0f26147848e5797665e54;hb=a465d763b600cbc0b7420f01143c69a7bbccdfbe;hp=95b9334edee340537f151ff7c0890e4f914b25d0;hpb=935fdb9b67b6c10d007e652e9e2e028fd6ccfe09;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/ip_adapter/arduino/caipclient_eth.cpp b/resource/csdk/connectivity/src/ip_adapter/arduino/caipclient_eth.cpp index 95b9334..3e234df 100644 --- a/resource/csdk/connectivity/src/ip_adapter/arduino/caipclient_eth.cpp +++ b/resource/csdk/connectivity/src/ip_adapter/arduino/caipclient_eth.cpp @@ -17,7 +17,7 @@ * limitations under the License. * ******************************************************************/ -#include "caipinterface_singlethread.h" +#include "caipinterface.h" #include #include @@ -29,7 +29,7 @@ #include "logger.h" #include "cacommon.h" #include "caadapterinterface.h" -#include "caipadapter_singlethread.h" +#include "caipadapter.h" #include "caipadapterutils_eth.h" #include "caadapterutils.h" #include "oic_malloc.h" @@ -68,26 +68,26 @@ void CAIPSetUnicastPort(uint16_t port) return; } -uint32_t CAIPSendData(const char *remoteAddress, uint16_t port, - const char *buf, uint32_t bufLen, bool isMulticast) +void CAIPSendData(CAEndpoint_t *endpoint, const void *buf, + uint32_t bufLen, bool isMulticast) { if (!isMulticast && 0 == g_unicastPort) { OIC_LOG(ERROR, TAG, "port 0"); - return 0; + return; } - VERIFY_NON_NULL(buf, TAG, "buf"); - VERIFY_NON_NULL(remoteAddress, TAG, "address"); + VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint"); int socketID = 0; + uint16_t port = endpoint->port; if (isMulticast) { - if (CAArduinoInitMulticastUdpSocket(remoteAddress, port, g_unicastPort, &socketID) - != CA_STATUS_OK) + if (CAArduinoInitMulticastUdpSocket(endpoint->addr, port, + g_unicastPort, &socketID) != CA_STATUS_OK) { OIC_LOG(ERROR, TAG, "init mcast err"); - return 0; + return; } OIC_LOG_V(DEBUG, TAG, "MPORT:%d", port); OIC_LOG_V(DEBUG, TAG, "LPORT:%d", g_unicastPort); @@ -100,7 +100,7 @@ uint32_t CAIPSendData(const char *remoteAddress, uint16_t port, if (CAArduinoInitUdpSocket(&port, &socketID) != CA_STATUS_OK) { OIC_LOG(ERROR, TAG, "init ucast err"); - return 0; + return; } } else @@ -112,27 +112,30 @@ uint32_t CAIPSendData(const char *remoteAddress, uint16_t port, uint32_t ret; uint8_t ipAddr[4] = { 0 }; uint16_t parsedPort = 0; - if (CAParseIPv4AddressInternal(remoteAddress, ipAddr, sizeof(ipAddr), + if (CAParseIPv4AddressInternal(endpoint->addr, ipAddr, sizeof(ipAddr), &parsedPort) != CA_STATUS_OK) { OIC_LOG(ERROR, TAG, "parse fail"); - return 0; + return; } if (bufLen > 65535) // Max value for uint16_t { // This will never happen as max buffer size we are dealing with is COAP_MAX_PDU_SIZE OIC_LOG(ERROR, TAG, "Size exceeded"); - return 0; + return; } ret = sendto(socketID, (const uint8_t *)buf, (uint16_t)bufLen, ipAddr, port); + if (ret <= 0) + { + OIC_LOG_V(ERROR, TAG, "SendData failed: %d", ret); + } if (g_sockID != socketID) { close(socketID); } OIC_LOG(DEBUG, TAG, "OUT"); - return ret; }