Removed OCGetInterfaceAddress
authorYuliya Kamatkova <yuliya.kamatkova@intel.com>
Mon, 9 Feb 2015 19:53:42 +0000 (14:53 -0500)
committerSashi Penta <sashi.kumar.penta@intel.com>
Mon, 9 Feb 2015 23:30:32 +0000 (23:30 +0000)
Removed obsolete OCGetInterfaceAddress and
cleaned up C Samples.

Note: OCSocket will eventually be completely removed
but not in this commit (due to dependencies)

Change-Id: Ie5af18518102be8595973fd1ff1d7dc4fdfd4007
Signed-off-by: Yuliya Kamatkova <yuliya.kamatkova@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/319
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
15 files changed:
resource/csdk/ocsocket/include/ocsocket.h
resource/csdk/ocsocket/src/ocsocket.c
resource/csdk/ocsocket/src/ocsocket_arduino.c
resource/csdk/ocsocket/src/ocsocket_arduino_wifi.c
resource/csdk/ocsocket/test/android/ocsocket_gtest.cpp
resource/csdk/ocsocket/test/arduino/ocsocket_test.cpp
resource/csdk/ocsocket/test/linux/ocsocket_gtest.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverbasicops.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverslow.cpp
resource/csdk/stack/test/arduino/ocserver.cpp
resource/csdk/stack/test/linux/occlient.c
resource/csdk/stack/test/linux/ocserver.c
resource/csdk/stack/test/stacktests.cpp

index 9bad9ed..f74c4f8 100644 (file)
@@ -214,34 +214,6 @@ int32_t OCBuildIPv4Address(uint8_t a, uint8_t b, uint8_t c, uint8_t d,
             uint16_t port, OCDevAddr *ipAddr);
 
 
-//-- OCGetInterfaceAddress ------------------------------------------------------
-/** @ingroup ocsocket
- *
- * This method is used to retrieved the IPv4/IPv6 address of the local interface.
- * If no interface name is provided, this API retrieves the IP address of
- * the default interface.
- *
- * @note currently, only IPv4(AF_INET) is supported for addrType argument.
- *
- * @param[in]  ifName
- *              interface whose address needs to be retrieved.
- * @param[in]  ifNameLen
- *              length of the interface name
- * @param[in]  addrType
- *              IPv4 or IPv6
- * @param[out] addrv4
- *              IPv4 address in a.b.c.d format
- * @param[in]  addrLen
- *              size of the buffer at addrv4. Should be at least 16 bytes for an
- *              IPv4 address.
- *
- * @retval 0 for Success, otherwise some error value
- */
-//-------------------------------------------------------------------------------
-int32_t OCGetInterfaceAddress(uint8_t* ifName, uint32_t ifNameLen, uint16_t addrType,
-             uint8_t *addrv4,  uint32_t addrLen);
-
-
 //-- OCDevAddrToString ----------------------------------------------------
 /** @ingroup ocsocket
  *
index d79c70b..311bf36 100644 (file)
@@ -72,105 +72,6 @@ int32_t OCBuildIPv4Address(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint16_t
     return ERR_SUCCESS;
 }
 
-#ifdef __ANDROID__
-/// Retrieves the IP address assigned to specified wireless interface
-int32_t OCGetInterfaceAddress(uint8_t* ifName, uint32_t ifNameLen, uint16_t addrType,
-             uint8_t *addr,  uint32_t addrLen)
-{
-    int32_t ret = ERR_UNKNOWN;
-    int32_t sfd = 0xFFFFFFFF;
-    struct ifreq ifr;
-
-    VERIFY_NON_NULL(addr);
-    VERIFY_NON_NULL(ifName);
-    if (ifNameLen > (IFNAMSIZ - 1) ) {
-        return ERR_INVALID_INPUT;
-    }
-    if (addrType != AF_INET) {
-        return ERR_INVALID_INPUT;
-    }
-
-    sfd = socket(addrType, SOCK_DGRAM, 0);
-    if (sfd < 0) {
-        OC_LOG_V(FATAL, MOD_NAME, "socket API ret val %d", sfd);
-        goto exit;
-    }
-
-    ifr.ifr_addr.sa_family = addrType;
-
-    strncpy(ifr.ifr_name, (const char*)ifName, ifNameLen);
-
-    if (ioctl(sfd, SIOCGIFADDR, &ifr) != 0) {
-        OC_LOG(FATAL, MOD_NAME, "ioctl call failed");
-        goto exit;
-    }
-
-    strncpy((char *)addr,
-            inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr),
-            addrLen);
-    ret = ERR_SUCCESS;
-
-exit:
-    if (sfd >= 0) {
-        close(sfd);
-    }
-    return ret;
-}
-
-#else
-/// Retrieves the IP address assigned to specified wireless interface
-int32_t OCGetInterfaceAddress(uint8_t* ifName, uint32_t ifNameLen, uint16_t addrType,
-             uint8_t *addr,  uint32_t addrLen)
-{
-    struct ifaddrs *myaddrs = NULL, *ifa = NULL;
-    int32_t ret = ERR_UNKNOWN;
-
-    VERIFY_NON_NULL(addr);
-
-    if (addrType != AF_INET) {
-        return ERR_INVALID_INPUT;
-    }
-
-    if(getifaddrs(&myaddrs) != 0) {
-        goto exit;
-    }
-
-    for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) {
-        if (ifa->ifa_addr == NULL)
-            continue;
-        if (!(ifa->ifa_flags & IFF_UP))
-            continue;
-        if (!(ifa->ifa_flags & IFF_RUNNING))
-            continue;
-
-        if (ifName && ifa->ifa_name) {
-           if(strncmp((const char*)ifName, ifa->ifa_name, ifNameLen) != 0)
-            continue;
-        }
-
-        switch (ifa->ifa_addr->sa_family)
-        {
-            case AF_INET:
-                {
-                    struct sockaddr_in *s4 = (struct sockaddr_in *)ifa->ifa_addr;
-                    if(inet_ntop(AF_INET, &(s4->sin_addr), (char *)addr, addrLen))
-                        ret = ERR_SUCCESS;
-                    goto exit;
-                }
-
-            default:
-                continue;
-        }
-    }
-
-exit:
-    if (myaddrs) {
-        freeifaddrs(myaddrs);
-    }
-    return ret;
-}
-#endif //__ANDROID__
-
 /// Creates a BSD socket and binds it specified port for UDP
 int32_t OCInitUDP(OCDevAddr* ipAddr, int32_t *sockfd, OC_SOCKET_OPTION sockoption)
 {
index ed51f79..c46c62e 100644 (file)
@@ -70,30 +70,6 @@ int32_t OCBuildIPv4Address(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint16_t
     return ERR_SUCCESS;
 }
 
-
-/// Retrieves the IP address assigned to Arduino Ethernet shield
-int32_t OCGetInterfaceAddress(uint8_t* ifName, uint32_t ifNameLen, uint16_t addrType,
-             uint8_t *addr,  uint32_t addrLen)
-{
-    //TODO : Fix this for scenarios when this API is invoked when device is not connected
-    uint8_t rawIPAddr[4];
-    VERIFY_NON_NULL(addr);
-    if (addrLen < IPNAMESIZE) {
-        OC_LOG(FATAL, MOD_NAME, PCF("OCGetInterfaceAddress: addrLen MUST be atleast 16"));
-        return ERR_INVALID_INPUT;
-    }
-
-    if (addrType != AF_INET) {
-        return ERR_INVALID_INPUT;
-    }
-    W5100.getIPAddress(rawIPAddr);
-    snprintf((char *)addr, addrLen, "%d.%d.%d.%d", rawIPAddr[0], rawIPAddr[1], rawIPAddr[2], rawIPAddr[3]);
-
-    OC_LOG_BUFFER(INFO, MOD_NAME, addr, addrLen);
-
-    return ERR_SUCCESS;
-}
-
 /// Retrieves a empty socket and bind it for UDP with the input port
 int32_t OCInitUDP(OCDevAddr* ipAddr, int32_t* sockfd, OC_SOCKET_OPTION sockoption)
 {
index 37f5fe9..2cd8991 100644 (file)
@@ -78,31 +78,6 @@ int32_t OCBuildIPv4Address(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint16_t
     return ERR_SUCCESS;
 }
 
-
-/// Retrieves the IP address assigned to Arduino Ethernet shield
-int32_t OCGetInterfaceAddress(uint8_t* ifName, uint32_t ifNameLen, uint16_t addrType,
-             uint8_t *addr,  uint32_t addrLen)
-{
-    WiFiClass WiFi;
-
-    VERIFY_NON_NULL(addr);
-    if (addrLen < IPNAMESIZE) {
-        OC_LOG(FATAL, MOD_NAME, PCF("OCGetInterfaceAddress: addrLen MUST be at least 16"));
-        return ERR_INVALID_INPUT;
-    }
-
-    if (addrType != AF_INET) {
-        return ERR_INVALID_INPUT;
-    }
-
-    IPAddress ip = WiFi.localIP();
-    snprintf((char *)addr, addrLen, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
-
-    OC_LOG_BUFFER(INFO, MOD_NAME, addr, addrLen);
-
-    return ERR_SUCCESS;
-}
-
 /// Retrieves a empty socket and bind it for UDP with the input port
 int32_t OCInitUDP(OCDevAddr* ipAddr, int32_t* sockfd, OC_SOCKET_OPTION sockoption)
 {
index 1c90e0b..21257b4 100644 (file)
@@ -119,26 +119,6 @@ TEST(DevAddrToIPv4Addr, InvalidInput) {
     EXPECT_EQ(ERR_INVALID_INPUT, OCDevAddrToPort(NULL, NULL ));
 }
 
-
-TEST(GetInterfaceAddress, Positive) {
-    uint8_t addr[20];
-    uint8_t ifname[] = "wlan0";
-    EXPECT_EQ(ERR_SUCCESS, OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, sizeof(addr)));
-    OC_LOG_V(INFO, MOD_NAME, "IPv4 Address: %s\n", addr);
-    //On Android, it is MUST to provide interface name
-    //EXPECT_EQ(0, get_ipv4addr( NULL, 0, addr, sizeof(addr)));
-}
-
-TEST(GetInterfaceAddress, Negative) {
-    uint8_t addr[20];
-    uint8_t ifname[] = "ethxx";
-    EXPECT_EQ(ERR_INVALID_INPUT, OCGetInterfaceAddress( NULL, 0, AF_INET, addr, sizeof(addr)));
-    EXPECT_EQ(ERR_UNKNOWN, OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, sizeof(addr)));
-    EXPECT_EQ(ERR_INVALID_INPUT, OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, NULL, sizeof(addr)));
-    EXPECT_EQ(ERR_UNKNOWN, OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, 0));
-    EXPECT_EQ(ERR_INVALID_INPUT, OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET6, addr, sizeof(addr)));
-}
-
 TEST(InitUDP, Positive) {
     OCDevAddr ipaddr;
     int32_t  sockfd;
@@ -154,7 +134,6 @@ TEST(InitUDP, Positive) {
     EXPECT_EQ(ERR_SUCCESS, OCInitUDP(&ipaddr, &sockfd));
     OCClose(sockfd);
 
-    OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, sizeof(addr));
     sscanf((const char*)addr, "%d.%d.%d.%d", (int*)&a, (int*)&b, (int*)&c, (int*)&d);
     OCBuildIPv4Address(a,b,c,d, TEST_PORT_NUM, &ipaddr);
     EXPECT_EQ(ERR_SUCCESS, OCInitUDP(&ipaddr, &sockfd));
@@ -202,8 +181,6 @@ TEST(SendToRecvfromUnicast, Positive) {
     uint8_t a,b,c,d;
     //uint8_t tmp1[512];
 
-
-    OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, sizeof(addr));
     sscanf((const char*)addr, "%d.%d.%d.%d", (int*)&a, (int*)&b, (int*)&c, (int*)&d);
 
     //Create sending socket
index 1271143..ecd99d3 100644 (file)
@@ -87,19 +87,6 @@ unsigned int TEST_BUF_LEN = sizeof(TEST_BUF);
 #define VERIFY_SUCCESS(op, res) { if (op == res) {OC_LOG(DEBUG, MOD_NAME, PCF(#op " SUCCEEDED"));} \
      else {OC_LOG(FATAL, MOD_NAME, PCF(#op "!!!!  FAILED FAILED FAILED !!!!"));} }
 
-
-//OCGetInterfaceAddress tests
-void test10() {
-    char strAddr[16] = "";
-    VERIFY_SUCCESS(OCGetInterfaceAddress(NULL, 0, AF_INET, (uint8_t*)strAddr, 16), ERR_SUCCESS);
-    OC_LOG(DEBUG, MOD_NAME, PCF("My IP address :"));
-    OC_LOG_BUFFER(INFO, MOD_NAME, (uint8_t*)strAddr, sizeof(strAddr));
-    delay(15000);
-    VERIFY_SUCCESS(OCGetInterfaceAddress(NULL, 0, AF_INET, NULL, 16), ERR_INVALID_INPUT);
-    VERIFY_SUCCESS(OCGetInterfaceAddress(NULL, 0, AF_INET, (uint8_t*)strAddr, 10), ERR_INVALID_INPUT);
-    OC_LOG(DEBUG, MOD_NAME, PCF("test10 - Completed"));
-}
-
 //OCBuildIPv4Address tests
 void test20() {
     OCDevAddr ipAddr;
index b6c9872..12c285f 100644 (file)
@@ -117,27 +117,6 @@ TEST(DevAddrToIPv4Addr, InvalidInput) {
     EXPECT_EQ(ERR_INVALID_INPUT, OCDevAddrToPort(NULL, NULL ));
 }
 
-
-
-
-TEST(GetInterfaceAddress, Positive) {
-    uint8_t addr[20];
-    uint8_t ifname[] = "eth0";
-    EXPECT_EQ(ERR_SUCCESS, OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET,  addr, sizeof(addr)));
-    printf("IPv4 Address: %s\n", addr);
-    EXPECT_EQ(ERR_SUCCESS, OCGetInterfaceAddress( NULL, 0,  AF_INET, addr, sizeof(addr)));
-    printf("IPv4 Address: %s\n", addr);
-}
-
-TEST(GetInterfaceAddress, Negative) {
-    uint8_t addr[20];
-    uint8_t ifname[] = "ethxx";
-    EXPECT_EQ(ERR_UNKNOWN, OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET, addr, sizeof(addr)));
-    EXPECT_EQ(ERR_INVALID_INPUT, OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET, NULL, sizeof(addr)));
-    EXPECT_EQ(ERR_UNKNOWN, OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET, addr, 0));
-    EXPECT_EQ(ERR_INVALID_INPUT, OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET6, addr, sizeof(addr)));
-}
-
 TEST(InitUDP, Positive) {
     OCDevAddr ipaddr;
     int32_t  sockfd;
@@ -153,7 +132,6 @@ TEST(InitUDP, Positive) {
     EXPECT_EQ(ERR_SUCCESS, OCInitUDP(&ipaddr, &sockfd));
     OCClose(sockfd);
 
-    OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET, addr, sizeof(addr));
     sscanf((const char*)addr, "%d.%d.%d.%d", (int*)&a, (int*)&b, (int*)&c, (int*)&d);
     OCBuildIPv4Address(a,b,c,d, TEST_PORT_NUM, &ipaddr);
     EXPECT_EQ(ERR_SUCCESS, OCInitUDP(&ipaddr, &sockfd));
@@ -210,7 +188,6 @@ TEST(SendToRecvfromUnicast, Positive) {
     OCInitUDP(&ipaddr2, &rsfd);
 
     //Since this is a Unit test, we will attempt to send message to ourself at a specific port
-    OCGetInterfaceAddress( ifname, sizeof(ifname), AF_INET, addr, sizeof(addr));
     sscanf((const char*)addr, "%d.%d.%d.%d", (int*)&a, (int*)&b, (int*)&c, (int*)&d);
     OCBuildIPv4Address(a,b,c,d, TEST_PORT_NUM, &ipaddr2);
 
@@ -307,7 +284,6 @@ TEST(GetSocketInfo, Positive) {
     EXPECT_TRUE(port == 5678);
     OCClose(sockfd);
 
-    OCGetInterfaceAddress( ifname, sizeof(ifname),  AF_INET, addr, sizeof(addr));
     sscanf((const char*)addr, "%d.%d.%d.%d", (int*)&a, (int*)&b, (int*)&c, (int*)&d);
     OCBuildIPv4Address(a,b,c,d, TEST_PORT_NUM, &ipaddr);
     EXPECT_EQ(ERR_SUCCESS, OCInitUDP(&ipaddr, &sockfd));
index 6131cd0..9c4f60a 100644 (file)
@@ -756,10 +756,6 @@ static void PrintUsage()
 
 int main(int argc, char* argv[])
 {
-    uint8_t addr[20] = {0};
-    uint8_t* paddr = NULL;
-    uint16_t port = OC_WELL_KNOWN_PORT;
-    uint8_t ifname[] = "eth0";
     pthread_t threadId;
     pthread_t threadId_presence;
     int opt;
@@ -784,16 +780,8 @@ int main(int argc, char* argv[])
     }
 
     OC_LOG(DEBUG, TAG, "OCServer is starting...");
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    if ( OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr,
-                sizeof(addr)) == ERR_SUCCESS)
-    {
-        OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
-        paddr = addr;
-    }
 
-    if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK) {
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
index bcd741c..2de45bf 100644 (file)
@@ -291,22 +291,8 @@ void handleSigInt(int signum)
 
 int main(int argc, char* argv[])
 {
-    uint8_t addr[20] = {0};
-    uint8_t* paddr = NULL;
-    uint16_t port = OC_WELL_KNOWN_PORT;
-    uint8_t ifname[] = "eth0";
-
     OC_LOG(DEBUG, TAG, "OCServer is starting...");
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    if ( OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr,
-                sizeof(addr)) == ERR_SUCCESS)
-    {
-        OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
-        paddr = addr;
-    }
-
-    if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK)
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
index 75124bb..95bb9e1 100644 (file)
@@ -441,10 +441,6 @@ void *ChangeLightRepresentation (void *param)
 
 int main(int argc, char* argv[])
 {
-    uint8_t addr[20] = {0};
-    uint8_t* paddr = NULL;
-    uint16_t port = 0;
-    uint8_t ifname[] = "eth0";
     pthread_t threadId;
     int opt;
 
@@ -466,16 +462,7 @@ int main(int argc, char* argv[])
     }
 
     OC_LOG(DEBUG, TAG, "OCServer is starting...");
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    if (OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr,
-                               sizeof(addr)) == ERR_SUCCESS)
-    {
-        OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
-        paddr = addr;
-    }
-
-    if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK) {
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
index cd600bb..937ed45 100644 (file)
@@ -271,23 +271,9 @@ void AlarmHandler(int sig)
 
 int main(int argc, char* argv[])
 {
-    uint8_t addr[20] = {0};
-    uint8_t* paddr = NULL;
-    uint16_t port = OC_WELL_KNOWN_PORT;
-    uint8_t ifname[] = "eth0";
-
-
     OC_LOG(DEBUG, TAG, "OCServer is starting...");
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    if ( OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr,
-                sizeof(addr)) == ERR_SUCCESS)
-    {
-        OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
-        paddr = addr;
-    }
 
-    if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK)
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
index 3c47701..ce5b4fd 100644 (file)
@@ -9,12 +9,10 @@ static uint8_t ETHERNET_MAC[] = {0x90, 0xA2, 0xDA, 0x0F, 0x2B, 0x72 };
 #define TAG PCF("ocserver")
 
 void ocInitialize () {
-    char ipAddr[16] = "";
-    OCGetInterfaceAddress (NULL, 0, AF_INET, (uint8_t *)ipAddr, 16);
     OC_LOG(DEBUG, TAG, PCF("IP addr is:"));
     OC_LOG_BUFFER(INFO, TAG, (uint8_t*)ipAddr, sizeof(ipAddr));
     delay(2000);
-    OCInit (ipAddr, 8001, OC_SERVER);
+    OCInit (NULL, 0, OC_SERVER);
 }
 
 void setup() {
index ec48462..42c739d 100644 (file)
@@ -53,18 +53,12 @@ OCStackApplicationResult applicationDiscoverCB(
 }
 
 int main() {
-    uint8_t addr[20];
-    uint16_t port = USE_RANDOM_PORT;
-    uint8_t ifname[] = "eth0";
     OCDoHandle handle;
 
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr, sizeof(addr));
     OC_LOG_V(INFO, TAG, "Starting occlient on address %s",addr);
 
     /* Initialize OCStack*/
-    if (OCInit((char *) addr, port, OC_CLIENT) != OC_STACK_OK) {
+    if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
index 580ea0c..279815d 100644 (file)
@@ -48,16 +48,8 @@ void handleSigInt(int signum) {
 }
 
 int main() {
-    uint8_t addr[20];
-    uint16_t port = USE_RANDOM_PORT;
-    uint8_t ifname[] = "eth0";
-
-    /*Get Ip address on defined interface and initialize coap on it with random port number
-     * this port number will be used as a source port in all coap communications*/
-    OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr, sizeof(addr));
-
     OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
-    if (OCInit((char *) addr, port, OC_SERVER) != OC_STACK_OK) {
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
index d7996f2..6e91b6e 100644 (file)
@@ -83,13 +83,9 @@ OCEntityHandlerResult entityHandler(OCEntityHandlerFlag flag, OCEntityHandlerReq
 void InitStack(OCMode mode)
 {
     OC_LOG(INFO, TAG, "Entering InitStack");
-    uint8_t addr[20];
-    uint16_t port = USE_RANDOM_PORT;
-
-    OCGetInterfaceAddress(NULL, 0, AF_INET, addr, sizeof(addr));
     OC_LOG_V(INFO, TAG, "InitStack on address %s",addr);
 
-    EXPECT_EQ(OC_STACK_OK, OCInit((char *) addr, port, mode));
+    EXPECT_EQ(OC_STACK_OK, OCInit(NULL, 0, mode));
     OC_LOG(INFO, TAG, "Leaving InitStack");
 }