Merge master to cloud-interface branch
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Wed, 19 Aug 2015 03:53:37 +0000 (12:53 +0900)
committerJon A. Cruz <jonc@osg.samsung.com>
Thu, 20 Aug 2015 03:27:23 +0000 (03:27 +0000)
merge master branch to use latest master code.

Change-Id: I57a2415e334c99755df87da5f97f28deb3ce5d76
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2238
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Tested-by: Jon A. Cruz <jonc@osg.samsung.com>
87 files changed:
android/BuildInstructionsForAndroidAPI.txt
android/android_api/SConscript
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java
auto_build.sh
build_common/android/compatibility/c_compat.c
resource/c_common/platform_features.h
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/api/cainterface.h
resource/csdk/connectivity/common/inc/uarraylist.h
resource/csdk/connectivity/common/src/caremotehandler.c
resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
resource/csdk/connectivity/common/src/uarraylist.c
resource/csdk/connectivity/inc/caadapterinterface.h
resource/csdk/connectivity/inc/caadapternetdtls.h
resource/csdk/connectivity/inc/caipinterface.h
resource/csdk/connectivity/inc/camessagehandler.h
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/ResourceModel.c
resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.h
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrendpoint.c
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrnwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.h
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/cableserver.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/canetworkconfigurator.c
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c [changed mode: 0644->0755]
resource/csdk/connectivity/src/ip_adapter/arduino/caipnwmonitor_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipnwmonitor_wifi.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_wifi.cpp
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c
resource/csdk/doc/CCF Lite GIT Repo Layout.docx [deleted file]
resource/csdk/security/src/secureresourcemanager.c
resource/csdk/stack/include/octypes.h
resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.h
resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp
resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp
resource/csdk/stack/src/ocpayloadconvert.c
resource/csdk/stack/src/ocpayloadparse.c
resource/csdk/stack/src/ocstack.c
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/src/OCRepresentation.cpp
resource/third_party_libs.scons
service/SConscript
service/notification-manager/NotificationManager/src/ResourceHosting.cpp
service/protocol-plugin/plugins/mqtt-light/lib/cpp/test.txt [deleted file]
service/resource-encapsulation/SConscript
service/resource-encapsulation/examples/linux/SampleResourceClient.cpp
service/resource-encapsulation/include/RCSDiscoveryManager.h
service/resource-encapsulation/include/RCSResourceAttributes.h
service/resource-encapsulation/include/RCSResourceObject.h
service/resource-encapsulation/src/common/SConscript
service/resource-encapsulation/src/common/primitiveResource/src/RCSResourceAttributes.cpp
service/resource-encapsulation/src/common/utils/include/AtomicHelper.h [new file with mode: 0644]
service/resource-encapsulation/src/resourceBroker/include/ResourcePresence.h
service/resource-encapsulation/src/resourceBroker/src/ResourcePresence.cpp
service/resource-encapsulation/src/resourceClient/RCSDiscoveryManager.cpp
service/resource-encapsulation/src/resourceContainer/SConscript
service/resource-encapsulation/src/resourceContainer/src/ResourceContainerImpl.cpp
service/resource-encapsulation/src/serverBuilder/SConscript
service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp
service/resource-encapsulation/unittests/ResourceClientTest.cpp
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/DataReader.java
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/ModelData.java
service/soft-sensor-manager/SDK/java/org/iotivity/service/ssm/QueryEngine.java
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.h
service/third_party_libs.scons

index 1b0f239..a30df42 100644 (file)
@@ -10,11 +10,10 @@ Build Instructions for Android-API:
         def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
 
 4.Build scons for android and your targeted architecture (This will also build Android API):
-    a.scons TARGET_OS=android TARGET_ARCH=<target arch> TARGET_TRANSPORT=IP RELEASE=1
-               where <target arch> can be armeabi, armeabi-v7a, x86.
+    a.scons TARGET_OS=android TARGET_ARCH=<target arch> TARGET_TRANSPORT=<target transport> RELEASE=1
+               where <target arch> can be armeabi, armeabi-v7a, x86, x86_64.
                Note: To build in debug mode, use RELEASE=0.
                Note: The minimum SDK version supported is 21.
-               Note: Only TARGET_TRANSPORT currently supported is IP
     b.If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal
     c.You should see the .aar files generated inside of '<iotivity>/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file
 
index 11983d7..5fba6e7 100644 (file)
@@ -43,6 +43,6 @@ if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exi
     os.system(android_home + '/tools/android')
 
 jdk_env = Environment(ENV=os.environ)
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE))
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE))
 jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")
 
index d042e9e..fc562be 100644 (file)
@@ -63,7 +63,7 @@ public final class OcPlatform {
      */
     public static final String GROUP_INTERFACE = "oic.mi.grp";
 
-    public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";
+    public static final String WELL_KNOWN_QUERY = "/oic/res";
     public static final String MULTICAST_PREFIX = "224.0.1.187:5683";
     public static final String MULTICAST_IP = "224.0.1.187";
     public static final int MULTICAST_PORT = 5683;
index 891cb40..ef20573 100644 (file)
@@ -72,8 +72,7 @@ public class CaLeClientInterface {
     private native static void caLeRegisterGattCallback(BluetoothGattCallback callback);
 
     // BluetoothAdapter.LeScanCallback
-    private native static void caLeScanCallback(BluetoothDevice device,
-                                                int rssi, byte[] scanRecord);
+    private native static void caLeScanCallback(BluetoothDevice device);
 
     // BluetoothGattCallback
     private native static void caLeGattConnectionStateChangeCallback(
@@ -81,24 +80,13 @@ public class CaLeClientInterface {
 
     private native static void caLeGattServicesDiscoveredCallback(BluetoothGatt gatt, int status);
 
-    private native static void caLeGattCharacteristicReadCallback(
-            BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
-            byte[] data, int status);
-
     private native static void caLeGattCharacteristicWriteCallback(
-            BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
-            byte[] data, int status);
+            BluetoothGatt gatt, byte[] data, int status);
 
     private native static void caLeGattCharacteristicChangedCallback(
-            BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] data);
-
-    private native static void caLeGattDescriptorReadCallback(BluetoothGatt gatt,
-                                                             BluetoothGattDescriptor descriptor,
-                                                             int status);
+            BluetoothGatt gatt, byte[] data);
 
-    private native static void caLeGattDescriptorWriteCallback(BluetoothGatt gatt,
-                                                              BluetoothGattDescriptor descriptor,
-                                                              int status);
+    private native static void caLeGattDescriptorWriteCallback(BluetoothGatt gatt, int status);
 
     private native static void caLeGattReliableWriteCompletedCallback(BluetoothGatt gatt,
                                                                      int status);
@@ -125,7 +113,7 @@ public class CaLeClientInterface {
                     Log.d(TAG, "UUID : " + uuid.toString());
                     if(uuid.toString().contains(SERVICE_UUID.toLowerCase())) {
                         Log.d(TAG, "we found that has the Device");
-                        caLeScanCallback(device, rssi, scanRecord);
+                        caLeScanCallback(device);
                     }
                 }
             } catch(UnsatisfiedLinkError e) {
@@ -202,9 +190,6 @@ public class CaLeClientInterface {
         public void onCharacteristicRead(BluetoothGatt gatt,
                 BluetoothGattCharacteristic characteristic, int status) {
             super.onCharacteristicRead(gatt, characteristic, status);
-
-            caLeGattCharacteristicReadCallback(gatt, characteristic,
-                                               characteristic.getValue(), status);
         }
 
         @Override
@@ -212,8 +197,7 @@ public class CaLeClientInterface {
                 BluetoothGattCharacteristic characteristic, int status) {
             super.onCharacteristicWrite(gatt, characteristic, status);
 
-            caLeGattCharacteristicWriteCallback(gatt, characteristic,
-                                                characteristic.getValue(), status);
+            caLeGattCharacteristicWriteCallback(gatt, characteristic.getValue(), status);
         }
 
         @Override
@@ -221,16 +205,13 @@ public class CaLeClientInterface {
                 BluetoothGattCharacteristic characteristic) {
             super.onCharacteristicChanged(gatt, characteristic);
 
-            caLeGattCharacteristicChangedCallback(gatt, characteristic,
-                                                  characteristic.getValue());
+            caLeGattCharacteristicChangedCallback(gatt, characteristic.getValue());
         }
 
         @Override
         public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
                 int status) {
             super.onDescriptorRead(gatt, descriptor, status);
-
-            caLeGattDescriptorReadCallback(gatt, descriptor, status);
         }
 
         @Override
@@ -238,21 +219,17 @@ public class CaLeClientInterface {
                 int status) {
             super.onDescriptorWrite(gatt, descriptor, status);
 
-            caLeGattDescriptorWriteCallback(gatt, descriptor, status);
+            caLeGattDescriptorWriteCallback(gatt, status);
         }
 
         @Override
         public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
             super.onReliableWriteCompleted(gatt, status);
-
-            caLeGattReliableWriteCompletedCallback(gatt, status);
         }
 
         @Override
         public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
             super.onReadRemoteRssi(gatt, rssi, status);
-
-            caLeGattReadRemoteRssiCallback(gatt, rssi, status);
         }
     };
 
@@ -293,3 +270,4 @@ public class CaLeClientInterface {
     };
 }
 
+
index 18ac49f..281beac 100644 (file)
@@ -56,23 +56,10 @@ public class CaLeServerInterface {
                                                                   BluetoothGattService service);
 
     private native static void caLeGattServerCharacteristicReadRequestCallback(
-            BluetoothDevice device,
-            int requestId, int offset, BluetoothGattCharacteristic characteristic, byte[] data);
+            BluetoothDevice device, byte[] data);
 
     private native static void caLeGattServerCharacteristicWriteRequestCallback(
-            BluetoothDevice device, int requestId,
-            BluetoothGattCharacteristic characteristic, byte[] data, boolean preparedWrite,
-            boolean responseNeeded, int offset, byte[] value);
-
-    private native static void caLeGattServerDescriptorReadRequestCallback(
-            BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor);
-
-    public native static void caLeGattServerDescriptorWriteRequestCallback(
-            BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor,
-            boolean preparedWrite, boolean responseNeeded, int offset, byte[] value);
-
-    private native static void caLeGattServerExecuteWriteCallback(BluetoothDevice device,
-                                                                 int requestId, boolean execute);
+            BluetoothDevice device, byte[] data);
 
     private native static void caLeGattServerNotificationSentCallback(BluetoothDevice device,
                                                                      int status);
@@ -107,9 +94,7 @@ public class CaLeServerInterface {
                 BluetoothGattCharacteristic characteristic) {
             super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
 
-            caLeGattServerCharacteristicReadRequestCallback(device, requestId, offset,
-                                                            characteristic,
-                                                            characteristic.getValue());
+            caLeGattServerCharacteristicReadRequestCallback(device, characteristic.getValue());
         }
 
         @Override
@@ -119,9 +104,7 @@ public class CaLeServerInterface {
             super.onCharacteristicWriteRequest(device, requestId, characteristic,
                     preparedWrite, responseNeeded, offset, value);
 
-            caLeGattServerCharacteristicWriteRequestCallback(device, requestId, characteristic,
-                                                             value, preparedWrite, responseNeeded,
-                                                             offset, value);
+            caLeGattServerCharacteristicWriteRequestCallback(device, value);
         }
 
         @Override
@@ -129,8 +112,6 @@ public class CaLeServerInterface {
                 BluetoothDevice device,
                 int requestId, int offset, BluetoothGattDescriptor descriptor) {
             super.onDescriptorReadRequest(device, requestId, offset, descriptor);
-
-            caLeGattServerDescriptorReadRequestCallback(device, requestId, offset, descriptor);
         }
 
         @Override
@@ -140,17 +121,11 @@ public class CaLeServerInterface {
                 byte[] value) {
             super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite,
                                            responseNeeded, offset, value);
-
-            caLeGattServerDescriptorWriteRequestCallback(device, requestId, descriptor,
-                                                         preparedWrite, responseNeeded, offset,
-                                                         value);
         }
 
         @Override
         public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
             super.onExecuteWrite(device, requestId, execute);
-
-            caLeGattServerExecuteWriteCallback(device, requestId, execute);
         }
 
         @Override
index 568920e..750f641 100755 (executable)
@@ -69,9 +69,18 @@ function build_android()
 
        echo "*********** Build for android x86 *************"
        scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=IP $2
+       scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BT $2
+       scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BLE $2
+
+       echo "*********** Build for android x86_64 *************"
+       scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=IP $2
+       scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=BT $2
+       scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=BLE $2
 
        echo "*********** Build for android armeabi *************"
        scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=IP $2
+       scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BT $2
+       scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BLE $2
 
        # enable parallel build
        export SCONSFLAGS="-Q -j 4"
@@ -82,10 +91,12 @@ function build_arduino()
        echo "*********** Build for arduino avr *************"
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$1 $2
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$1 $2
+       scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 RELEASE=$1 $2
 
        echo "*********** Build for arduino arm *************"
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$1 $2
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$1 $2
+       # BLE support for the Arduino Due is currently unavailable.
 }
 
 function build_tizen()
@@ -210,5 +221,3 @@ else
 fi
 
 echo "===================== done ====================="
-
-
index 000428a..b76c739 100644 (file)
@@ -45,16 +45,3 @@ void srandom(unsigned int __s)
 {
     srand48(__s);
 }
-
-/* from unistd.h */
-int getpagesize(void)
-{
-  extern unsigned int __page_size;
-  return __page_size;
-}
-
-int __getpageshift(void)
-{
-  extern unsigned int __page_shift;
-  return __page_shift;
-}
index 2fdaded..8f39e19 100644 (file)
     #define SUPPORTS_DEFAULT_CTOR
 #endif
 
+#if (__STDC_VERSION__ >= 201112L)
+    #include <stdassert.h>
+    #define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
+#else
+    #define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
+#endif
+
 #endif
index b5beea1..cc261ce 100644 (file)
@@ -236,13 +236,21 @@ typedef struct
 {
     CATransportAdapter_t    adapter;    // adapter type
     CATransportFlags_t      flags;      // transport modifiers
+    uint16_t                port;       // for IP
     char                    addr[MAX_ADDR_STR_SIZE_CA]; // address for all
     uint32_t                interface;  // usually zero for default interface
-    uint16_t                port;       // for IP
-    CARemoteId_t identity;              // endpoint identity
 } CAEndpoint_t;
 
 /**
+ * Endpoint information for secure messages
+ */
+typedef struct
+{
+    CAEndpoint_t endpoint;      /**< endpoint */
+    CARemoteId_t identity;      /**< endpoint identity */
+} CASecureEndpoint_t;
+
+/**
  * @enum CAResult_t
  * Enums for CA return values
  */
@@ -347,6 +355,7 @@ typedef struct
     CAPayload_t payload;        /**< payload of the request  */
     size_t payloadSize;         /**< size in bytes of the payload */
     CAURI_t resourceUri;        /**< Resource URI information **/
+    CARemoteId_t identity;      /**< endpoint identity */
 } CAInfo_t;
 
 /**
@@ -406,16 +415,38 @@ typedef struct
  */
 typedef struct
 {
-    int fd;
-    uint16_t port;
+    int fd;        /**< socket fd */
+    uint16_t port; /**< socket port */
 } CASocket_t;
 
+#define HISTORYSIZE (4)
+
+typedef struct
+{
+    CATransportFlags_t flags;
+    uint16_t messageId;
+} CAHistoryItem_t;
+
+typedef struct
+{
+    int nextIndex;
+    CAHistoryItem_t items[HISTORYSIZE];
+} CAHistory_t;
+
+/**
+ * Hold interface index for keeping track of comings and goings
+ */
+typedef struct
+{
+    int32_t ifIndex; /**< network interface index */
+} CAIfItem_t;
+
 typedef struct
 {
-    CATransportFlags_t clientFlags;
-    CATransportFlags_t serverFlags;
-    bool client;
-    bool server;
+    CATransportFlags_t clientFlags; /**< flag for client */
+    CATransportFlags_t serverFlags; /**< flag for server */
+    bool client; /**< client mode */
+    bool server; /**< server mode */
 
     struct sockets
     {
@@ -432,17 +463,26 @@ typedef struct
         int shutdownFds[2]; /**< shutdown pipe */
         int selectTimeout;  /**< in seconds */
         int maxfd;          /**< highest fd (for select) */
-        int numInterfaces;  /**< number of active interfaces */
         bool started;       /**< the IP adapter has started */
         bool terminate;     /**< the IP adapter needs to stop */
         bool ipv6enabled;   /**< IPv6 enabled by OCInit flags */
         bool ipv4enabled;   /**< IPv4 enabled by OCInit flags */
+        bool dualstack;     /**< IPv6 and IPv4 enabled */
+
+        struct networkmonitors
+        {
+            CAIfItem_t *ifItems; /**< current network interface index list */
+            size_t sizeIfItems;  /**< size of network interface index array */
+            size_t numIfItems;   /**< number of valid network interfaces */
+        } nm;
     } ip;
 
     struct calayer
     {
-        CATransportFlags_t previousRequestFlags; /**< address family filtering */
-        uint16_t previousRequestMessageId;       /**< address family filtering */
+        CAHistory_t requestHistory;  /**< filter IP family in requests */
+        CAHistory_t responseHistory; /**< filter IP family in responses */
+        CATransportFlags_t previousRequestFlags;/**< address family filtering */
+        uint16_t previousRequestMessageId;      /**< address family filtering */
     } ca;
 } CAGlobals_t;
 
index 27b4ff2..7449b28 100644 (file)
@@ -42,28 +42,25 @@ extern "C"
 #endif
 
 /**
- * @brief   Callback function type for request delivery.
- * @param   object      [OUT] Endpoint object from which the request is received. It contains
- *                            endpoint address based on the connectivity type.
- * @param   requestInfo [OUT] Info for resource model to understand about the request.
- * @return  NONE
+ * Callback function type for request delivery.
+ * @param[out]   object       Endpoint object from which the request is received.
+ *                            It contains endpoint address based on the connectivity type.
+ * @param[out]   requestInfo  Info for resource model to understand about the request.
  */
 typedef void (*CARequestCallback)(const CAEndpoint_t *object,
                                   const CARequestInfo_t *requestInfo);
 
 /**
- * @brief   Callback function type for response delivery.
- * @param   object          [OUT] Endpoint object from which the response is received.
- * @param   responseInfo    [OUT] Identifier which needs to be mapped with response.
- * @return  NONE
+ * Callback function type for response delivery.
+ * @param[out]   object           Endpoint object from which the response is received.
+ * @param[out]   responseInfo     Identifier which needs to be mapped with response.
  */
 typedef void (*CAResponseCallback)(const CAEndpoint_t *object,
                                    const CAResponseInfo_t *responseInfo);
 /**
- * @brief   Callback function type for error
- * @param   object          [OUT] remote device information
- * @param   errorInfo       [OUT] CA Error information
- * @return  NONE
+ * Callback function type for error.
+ * @param[out]   object           remote device information.
+ * @param[out]   errorInfo        CA Error information.
  */
 typedef void (*CAErrorCallback)(const CAEndpoint_t *object,
                                 const CAErrorInfo_t *errorInfo);
@@ -76,83 +73,80 @@ typedef void (*CAErrorCallback)(const CAEndpoint_t *object,
  */
 typedef struct
 {
-   unsigned char identity[DTLS_PSK_ID_LEN]; /** identity of self */
-   uint32_t num;                            /** number of credentials in this blob */
+   unsigned char identity[DTLS_PSK_ID_LEN]; /** identity of self. */
+   uint32_t num;                            /** number of credentials in this blob. */
    OCDtlsPskCreds *creds;                   /** list of credentials. Size of this
                                                 array is determined by 'num' variable. */
 } CADtlsPskCredsBlob_t;
 
 /**
- * @brief   Callback function type for getting DTLS credentials.
- * @param   credInfo          [OUT] DTLS credentials info. Handler has to allocate new memory for
- *                                  both credInfo and credInfo->creds which is then freed by CA
- * @return  NONE
+ * Callback function type for getting DTLS credentials.
+ * @param[out]   credInfo     DTLS credentials info. Handler has to allocate new memory for.
+ *                            both credInfo and credInfo->creds which is then freed by CA.
  */
 typedef void (*CAGetDTLSCredentialsHandler)(CADtlsPskCredsBlob_t **credInfo);
 #endif //__WITH_DTLS__
 
 /**
- * @brief   Initialize the connectivity abstraction module.
- *          It will initialize adapters, thread pool and other modules based on the platform
- *          compilation options.
+ * Initialize the connectivity abstraction module.
+ * It will initialize adapters, thread pool and other modules based on the platform
+ * compilation options.
  *
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED or #CA_MEMORY_ALLOC_FAILED
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
  */
 CAResult_t CAInitialize();
 
 /**
- * @brief   Terminate the connectivity abstraction module.
- *          All threads, data structures are destroyed for next initializations.
- * @return  NONE
+ * Terminate the connectivity abstraction module.
+ * All threads, data structures are destroyed for next initializations.
  */
 void CATerminate();
 
 /**
- * @brief   Starts listening servers.
- *          This API is used by resource hosting server for listening multicast requests.
- *          Based on the adapters configurations, different kinds of servers are started.
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED
+ * Starts listening servers.
+ * This API is used by resource hosting server for listening multicast requests.
+ * Based on the adapters configurations, different kinds of servers are started.
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED
  */
 CAResult_t CAStartListeningServer();
 
 /**
- * @brief   Starts discovery servers.
- *          This API is used by resource required clients for listening multicast requests.
- *          Based on the adapters configurations, different kinds of servers are started.
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED
+ * Starts discovery servers.
+ * This API is used by resource required clients for listening multicast requests.
+ * Based on the adapters configurations, different kinds of servers are started.
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED
  */
 CAResult_t CAStartDiscoveryServer();
 
 /**
- * @brief   Register request callbacks and response callbacks.
- *          Requests and responses are delivered these callbacks .
- * @param   ReqHandler   [IN] Request callback ( for GET,PUT ..etc)
- * @param   RespHandler  [IN] Response Handler Callback
+ * Register request callbacks and response callbacks.
+ *          Requests and responses are delivered these callbacks.
+ * @param[in]   ReqHandler    Request callback ( for GET,PUT ..etc).
+ * @param[in]   RespHandler   Response Handler Callback.
  * @see     CARequestCallback
  * @see     CAResponseCallback
  * @see     CAErrorCallback
- * @return  NONE
  */
 void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
                        CAErrorCallback ErrorHandler);
 
 #ifdef __WITH_DTLS__
 /**
- * @brief   Register callback to get DTLS PSK credentials.
- * @param   GetDTLSCredentials   [IN] GetDTLS Credetials callback
- * @return  #CA_STATUS_OK
+ * Register callback to get DTLS PSK credentials.
+ * @param[in]   GetDTLSCredentials    GetDTLS Credetials callback.
+ * @return  ::CA_STATUS_OK
  */
 CAResult_t CARegisterDTLSCredentialsHandler(CAGetDTLSCredentialsHandler GetDTLSCredentials);
 #endif //__WITH_DTLS__
 
 /**
- * @brief   Create an endpoint description
- * @param   flags               [IN]  how the adapter should be used
- * @param   adapter             [IN]  which adapter to use
- * @param   addr                [IN]  string representation of address
- * @param   port                [IN]  port (for IP_ADAPTER)
- * @param   endpoint            [OUT] Endpoint which contains the above
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED
+ * Create an endpoint description.
+ * @param[in]   flags                 how the adapter should be used.
+ * @param[in]   adapter               which adapter to use.
+ * @param[in]   addr                  string representation of address.
+ * @param[in]   port                  port (for IP_ADAPTER).
+ * @param[in]   endpoint              Endpoint which contains the above.
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED
  * @remark  The created Remote endpoint can be freed using CADestroyEndpoint().
  * @see     CADestroyEndpoint
  */
@@ -163,94 +157,93 @@ CAResult_t CACreateEndpoint(CATransportFlags_t flags,
                             CAEndpoint_t **object);
 
 /**
- * @brief   Destroy the remote endpoint created
- * @param   object  [IN] Remote Endpoint object created with CACreateEndpoint
- * @return  NONE
+ * Destroy the remote endpoint created.
+ * @param[in]   object   Remote Endpoint object created with CACreateEndpoint.
  */
 void CADestroyEndpoint(CAEndpoint_t *object);
 
 /**
- * @brief   Generating the token for matching the request and response.
- * @param   token          [OUT] Token for the request
- * @param   tokenLength    [IN]  length of the token
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED or #CA_MEMORY_ALLOC_FAILED
- *          or #CA_STATUS_NOT_INITIALIZED
+ * Generating the token for matching the request and response.
+ * @param[in]   token            Token for the request.
+ * @param[in]   tokenLength      length of the token.
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or
+ *          ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_NOT_INITIALIZED
  * @remark  Token memory is destroyed by the caller using CADestroyToken().
  * @see     CADestroyToken
  */
 CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
 
 /**
- * @brief   Destroy the token generated by CAGenerateToken
- * @param   token   [IN] token to be freed
- * @return  NONE
+ * Destroy the token generated by CAGenerateToken.
+ * @param[in]   token    token to be freed.
  */
 void CADestroyToken(CAToken_t token);
 
 /**
- * @brief   Send control Request on a resource
- * @param   object      [IN] Endpoint where the payload need to be sent.
+ * Send control Request on a resource.
+ * @param[in]   object       Endpoint where the payload need to be sent.
  *                           This endpoint is delivered with Request or response callback.
- * @param   requestInfo [IN] Information for the request.
- * @return  #CA_STATUS_OK #CA_STATUS_FAILED #CA_MEMORY_ALLOC_FAILED
+ * @param[in]   requestInfo  Information for the request.
+ * @return  ::CA_STATUS_OK ::CA_STATUS_FAILED ::CA_MEMORY_ALLOC_FAILED
  */
 CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
 
 /**
- * @brief   Send the response
- * @param   object          [IN] Endpoint where the payload need to be sent.
- *                               This endpoint is delivered with Request or response callback
- * @param   responseInfo    [IN] Information for the response
- * @return  #CA_STATUS_OK or  #CA_STATUS_FAILED or #CA_MEMORY_ALLOC_FAILED
+ * Send the response.
+ * @param[in]   object           Endpoint where the payload need to be sent.
+ *                               This endpoint is delivered with Request or response callback.
+ * @param[in]   responseInfo     Information for the response.
+ * @return  ::CA_STATUS_OK or  ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
  */
 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
 
 /**
- * @brief   Send notification to the remote object
- * @param   object          [IN] Endpoint where the payload need to be sent.
+ * Send notification to the remote object.
+ * @param[in]   object           Endpoint where the payload need to be sent.
  *                               This endpoint is delivered with Request or response callback.
- * @param   responseInfo    [IN] Information for the response.
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED or #CA_MEMORY_ALLOC_FAILED
+ * @param[in]   responseInfo     Information for the response.
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
  */
 CAResult_t CASendNotification(const CAEndpoint_t *object,
                       const  CAResponseInfo_t *responseInfo);
 
 /**
- * @brief   Select network to use
- * @param   interestedNetwork   [IN] Connectivity Type enum
- * @return  #CA_STATUS_OK or #CA_NOT_SUPPORTED or #CA_STATUS_FAILED or #CA_NOT_SUPPORTED
+ * Select network to use.
+ * @param[in]   interestedNetwork    Connectivity Type enum.
+ * @return  ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
+ *          ::CA_STATUS_FAILED or ::CA_NOT_SUPPORTED
  */
 CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
 
 /**
- * @brief   Select network to unuse
- * @param   nonInterestedNetwork    [IN] Connectivity Type enum
- * @return  #CA_STATUS_OK or #CA_NOT_SUPPORTED or #CA_STATUS_FAILED
+ * Select network to unuse.
+ * @param[in]   nonInterestedNetwork     Connectivity Type enum.
+ * @return  ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED
  */
 CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
 
 /**
- * @brief   Get network information
- *          It should be destroyed by the caller as it Get Information.
- * @param   info    [OUT] LocalConnectivity objects
- * @param   size    [OUT] No Of Array objects
- * @return  #CA_STATUS_OK or #CA_STATUS_FAILED or #CA_STATUS_INVALID_PARAM or
-*                #CA_MEMORY_ALLOC_FAILED
+ * Get network information.
+ * It should be destroyed by the caller as it Get Information.
+ * @param[out]   info     LocalConnectivity objects
+ * @param[out]   size     No Of Array objects
+ * @return  ::CA_STATUS_OK or ::CA_STATUS_FAILED or
+ *          ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
  */
 CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
 
 /**
- * @brief    To Handle the Request or Response
- * @return   #CA_STATUS_OK
+ * To Handle the Request or Response.
+ * @return   ::CA_STATUS_OK
  */
 CAResult_t CAHandleRequestResponse();
 
 #ifdef RA_ADAPTER
 /**
- * @brief   Set Remote Access information for XMPP Client.
- * @param   caraInfo          [IN] remote access info.
+ * Set Remote Access information for XMPP Client.
+ * @param[in]   caraInfo          remote access info.
  *
- * @return  #CA_STATUS_OK
+ * @return  ::CA_STATUS_OK
  */
 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
 #endif
@@ -259,26 +252,26 @@ CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
 #ifdef __WITH_DTLS__
 
 /**
- * Select the cipher suite for dtls handshake
+ * Select the cipher suite for dtls handshake.
  *
- * @param[IN] cipher  cipher suite (Note : Make sure endianness)
- *                               0xC018 : TLS_ECDH_anon_WITH_AES_128_CBC_SHA
- *                               0xC0A8 : TLS_PSK_WITH_AES_128_CCM_8
- *                               0xC0AE : TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
+ * @param[in] cipher  cipher suite (Note : Make sure endianness).
+ *                    0xC018 : TLS_ECDH_anon_WITH_AES_128_CBC_SHA
+ *                    0xC0A8 : TLS_PSK_WITH_AES_128_CCM_8
+ *                    0xC0AE : TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
  *
- * @retval  CA_STATUS_OK    Successful
- * @retval  CA_STATUS_INVALID_PARAM  Invalid input argumets
- * @retval  CA_STATUS_FAILED Operation failed
+ * @retval  ::CA_STATUS_OK    Successful.
+ * @retval  ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
  */
 CAResult_t CASelectCipherSuite(const uint16_t cipher);
 
 /**
- * Enable TLS_ECDH_anon_WITH_AES_128_CBC_SHA cipher suite in dtls
+ * Enable TLS_ECDH_anon_WITH_AES_128_CBC_SHA cipher suite in dtls.
  *
- * @param[IN] enable  TRUE/FALSE enables/disables anonymous cipher suite
+ * @param[in] enable  TRUE/FALSE enables/disables anonymous cipher suite.
  *
- * @retval  CA_STATUS_OK    Successful
- * @retval  CA_STATUS_FAILED Operation failed
+ * @retval  ::CA_STATUS_OK    Successful.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
  *
  * @note anonymous cipher suite should only be enabled for 'JustWorks' provisioning.
  */
@@ -286,23 +279,23 @@ CAResult_t CAEnableAnonECDHCipherSuite(const bool enable);
 
 
 /**
- * Generate ownerPSK using PRF
+ * Generate ownerPSK using PRF.
  * OwnerPSK = TLS-PRF('master key' , 'oic.sec.doxm.jw',
- *                                    'ID of new device(Resource Server)',
- *                                    'ID of owner smart-phone(Provisioning Server)')
+ *                    'ID of new device(Resource Server)',
+ *                    'ID of owner smart-phone(Provisioning Server)')
  *
- * @param[IN] endpoint  information of network address
- * @param[IN] label  Ownership transfer method e.g)"oic.sec.doxm.jw"
- * @param[IN] labelLen  Byte length of label
- * @param[IN] rsrcServerDeviceID  ID of new device(Resource Server)
- * @param[IN] rsrcServerDeviceIDLen  Byte length of rsrcServerDeviceID
- * @param[IN] provServerDeviceID  label of previous owner
- * @param[IN] provServerDeviceIDLen  byte length of provServerDeviceID
- * @param[IN,OUT] ownerPSK  Output buffer for owner PSK
- * @param[IN] ownerPSKSize  Byte length of the ownerPSK to be generated
+ * @param[in] endpoint  information of network address.
+ * @param[in] label  Ownership transfer method e.g)"oic.sec.doxm.jw".
+ * @param[in] labelLen  Byte length of label.
+ * @param[in] rsrcServerDeviceID  ID of new device(Resource Server).
+ * @param[in] rsrcServerDeviceIDLen  Byte length of rsrcServerDeviceID.
+ * @param[in] provServerDeviceID  label of previous owner.
+ * @param[in] provServerDeviceIDLen  byte length of provServerDeviceID.
+ * @param[in,out] ownerPSK  Output buffer for owner PSK.
+ * @param[in] ownerPSKSize  Byte length of the ownerPSK to be generated.
  *
- * @retval  CA_STATUS_OK    Successful
- * @retval  CA_STATUS_FAILED Operation failed
+ * @retval  ::CA_STATUS_OK    Successful.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
  */
 CAResult_t CAGenerateOwnerPSK(const CAEndpoint_t *endpoint,
                               const uint8_t* label, const size_t labelLen,
@@ -313,22 +306,22 @@ CAResult_t CAGenerateOwnerPSK(const CAEndpoint_t *endpoint,
                               uint8_t* ownerPSK, const size_t ownerPSKSize);
 
 /**
- * Initiate DTLS handshake with selected cipher suite
+ * Initiate DTLS handshake with selected cipher suite.
  *
- * @param[IN] endpoint  information of network address
+ * @param[in] endpoint  information of network address.
  *
- * @retval  CA_STATUS_OK    Successful
- * @retval  CA_STATUS_FAILED Operation failed
+ * @retval  ::CA_STATUS_OK    Successful.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
  */
 CAResult_t CAInitiateHandshake(const CAEndpoint_t *endpoint);
 
 /**
- * Close the DTLS session
+ * Close the DTLS session.
  *
- * @param[IN] endpoint  information of network address
+ * @param[in] endpoint  information of network address.
  *
- * @retval  CA_STATUS_OK    Successful
- * @retval  CA_STATUS_FAILED Operation failed
+ * @retval  ::CA_STATUS_OK    Successful.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
  */
 CAResult_t CACloseDtlsSession(const CAEndpoint_t *endpoint);
 
index a055a1b..7e8403a 100644 (file)
@@ -22,7 +22,7 @@
 #define U_ARRAYLIST_H_
 
 #include <stdint.h>
-#include "cacommon.h"
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -31,6 +31,10 @@ extern "C"
 
 /**
  * array list structure.
+ *
+ * @note
+ * Members should be treated as private and not accessed directly. Instead
+ * all access should be through the defined u_arraylist_*() functions.
  */
 typedef struct u_arraylist_t
 {
@@ -50,10 +54,8 @@ u_arraylist_t *u_arraylist_create();
  * Arraylist elements are deleted. Calling function must take care of free
  * dynamic memory allocated before freeing the arraylist.
  * @param[in] list       u_arraylist pointer
- * @return ::CAResult_t.
- * ::CA_STATUS_OK if Success, ::CA_STATUS_INVALID_PARAM if pointer to list is NULL.
  */
-CAResult_t u_arraylist_free(u_arraylist_t **list);
+void u_arraylist_free(u_arraylist_t **list);
 
 /**
  * Returns the data of the index from the array list.
@@ -67,10 +69,9 @@ void *u_arraylist_get(const u_arraylist_t *list, uint32_t index);
  * Add data in the array list.
  * @param[in] list        pointer of array list.
  * @param[in] data        pointer of data.
- * @return CAResult_t.
- * ::CA_STATUS_OK if Success, ::CA_MEMORY_ALLOC_FAILED if memory allocation fails.
+ * @return true if success, false otherwise.
  */
-CAResult_t u_arraylist_add(u_arraylist_t *list, void *data);
+bool u_arraylist_add(u_arraylist_t *list, void *data);
 
 /**
  * Remove the data of the index from the array list.
index 48e5f56..cca8bd8 100644 (file)
@@ -63,94 +63,16 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep)
         return NULL;
     }
 
-    *clone = *rep;
-
-    if (rep->info.token)
-    {
-        char *temp = NULL;
-
-        // allocate token field
-        uint8_t len = rep->info.tokenLength;
-
-        if (len)
-        {
-            temp = (char *) OICCalloc(len, sizeof(char));
-            if (!temp)
-            {
-                OIC_LOG(ERROR, TAG, "CACloneRequestInfo Out of memory");
-
-                CADestroyRequestInfoInternal(clone);
-
-                return NULL;
-            }
-            memcpy(temp, rep->info.token, len);
-        }
-
-        // save the token
-        clone->info.token = temp;
-        clone->info.tokenLength = len;
-    }
-
-    if (NULL != rep->info.options && 0 < rep->info.numOptions)
-    {
-        // save the options
-        clone->info.options =
-            (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t) * rep->info.numOptions);
-        if (NULL == clone->info.options)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneRequestInfo Out of memory");
-            OICFree(clone->info.token);
-            OICFree(clone);
-            return NULL;
-        }
-        memcpy(clone->info.options, rep->info.options,
-               sizeof(CAHeaderOption_t) * rep->info.numOptions);
-    }
-    else
-    {
-        clone->info.options = NULL;
-        clone->info.numOptions = 0;
-    }
-
-    if (NULL != rep->info.payload && 0 < rep->info.payloadSize)
+    CAResult_t result = CACloneInfo(&rep->info, &clone->info);
+    if(CA_STATUS_OK != result)
     {
-        // allocate payload field
-        uint8_t *temp = OICMalloc(rep->info.payloadSize);
-        if (NULL == temp)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneRequestInfo Out of memory");
-
-            CADestroyRequestInfoInternal(clone);
-
-            return NULL;
-        }
-        memcpy(temp, rep->info.payload, rep->info.payloadSize);
-
-        // save the payload
-        clone->info.payload = temp;
-    }
-    else
-    {
-        clone->info.payload = NULL;
-        clone->info.payloadSize = 0;
+        OIC_LOG(ERROR, TAG, "CACloneRequestInfo error in CACloneInfo");
+        CADestroyRequestInfoInternal(clone);
+        return NULL;
     }
 
-    if (NULL != rep->info.resourceUri)
-    {
-        // allocate payload field
-        char *temp = OICStrdup(rep->info.resourceUri);
-        if (NULL == temp)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneRequestInfo Out of memory");
-
-            CADestroyRequestInfoInternal(clone);
-
-            return NULL;
-        }
-
-        // save the resourceUri
-        clone->info.resourceUri = temp;
-    }
+    clone->method = rep->method;
+    clone->isMulticast = rep->isMulticast;
 
     return clone;
 }
@@ -198,96 +120,16 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
         OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
         return NULL;
     }
-    *clone = *rep;
 
-    if (rep->info.token)
+    CAResult_t result = CACloneInfo(&rep->info, &clone->info);
+    if(CA_STATUS_OK != result)
     {
-        char *temp = NULL;
-
-        // allocate token field
-        uint8_t len = rep->info.tokenLength;
-
-        if (len)
-        {
-            temp = (char *) OICCalloc(len, sizeof(char));
-            if (!temp)
-            {
-                OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
-
-                CADestroyResponseInfoInternal(clone);
-
-                return NULL;
-            }
-            memcpy(temp, rep->info.token, len);
-        }
-        // save the token
-        clone->info.token = temp;
-        clone->info.tokenLength = len;
-    }
-
-    if (NULL != rep->info.options && rep->info.numOptions)
-    {
-        // save the options
-        clone->info.options =
-                (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t) * rep->info.numOptions);
-
-        if (NULL == clone->info.options)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
-
-            OICFree(clone->info.token);
-            OICFree(clone);
-            return NULL;
-        }
-        memcpy(clone->info.options, rep->info.options,
-                sizeof(CAHeaderOption_t) * rep->info.numOptions);
-    }
-    else
-    {
-        clone->info.options = NULL;
-        clone->info.numOptions = 0;
-    }
-
-    if (NULL != rep->info.payload && 0 < rep->info.payloadSize)
-    {
-        // allocate payload field
-        uint8_t *temp = (uint8_t *) OICMalloc(rep->info.payloadSize);
-        if (NULL == temp)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
-
-            CADestroyResponseInfoInternal(clone);
-
-            return NULL;
-        }
-        memcpy(temp, rep->info.payload, rep->info.payloadSize);
-
-        // save the payload
-        clone->info.payload = temp;
-    }
-    else
-    {
-        clone->info.payload = NULL;
-        clone->info.payloadSize = 0;
-    }
-
-    if (NULL != rep->info.resourceUri)
-    {
-        // allocate payload field
-        char *temp = OICStrdup(rep->info.resourceUri);
-        if (NULL == temp)
-        {
-            OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
-
-            CADestroyResponseInfoInternal(clone);
-
-            return NULL;
-        }
-
-        // save the resourceUri
-        clone->info.resourceUri = temp;
+        OIC_LOG(ERROR, TAG, "CACloneResponseInfo error in CACloneInfo");
+        CADestroyResponseInfoInternal(clone);
+        return NULL;
     }
 
+    clone->result = rep->result;
     return clone;
 }
 
@@ -386,6 +228,8 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
         return CA_STATUS_INVALID_PARAM;
     }
 
+    memset(clone, 0 , sizeof(CAInfo_t));
+
     //Do not free clone. we cannot declare it const, as the content is modified
     if ((info->token) && (0 < info->tokenLength))
     {
@@ -397,7 +241,7 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
         temp = (char *) OICMalloc(len * sizeof(char));
         if (!temp)
         {
-            OIC_LOG(ERROR, TAG, "CAClonePayloadInfo Out of memory");
+            OIC_LOG(ERROR, TAG, "CACloneInfo Out of memory");
             return CA_MEMORY_ALLOC_FAILED;
         }
 
@@ -415,20 +259,21 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
 
         if (!clone->options)
         {
-            OIC_LOG(ERROR, TAG, "CAClonePayloadInfo Out of memory");
+            OIC_LOG(ERROR, TAG, "CACloneInfo Out of memory");
             CADestroyInfoInternal(clone);
             return CA_MEMORY_ALLOC_FAILED;
         }
         memcpy(clone->options, info->options, sizeof(CAHeaderOption_t) * info->numOptions);
+        clone->numOptions = info->numOptions;
     }
 
-    if (info->payload && 0 < info->payloadSize)
+    if ((info->payload) && (0 < info->payloadSize))
     {
         // allocate payload field
         uint8_t *temp = OICMalloc(info->payloadSize);
         if (!temp)
         {
-            OIC_LOG(ERROR, TAG, "CAClonePayloadInfo Out of memory");
+            OIC_LOG(ERROR, TAG, "CACloneInfo Out of memory");
             CADestroyInfoInternal(clone);
             return CA_MEMORY_ALLOC_FAILED;
         }
@@ -436,11 +281,7 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
 
         // save the payload
         clone->payload = temp;
-    }
-    else
-    {
-        clone->payload = NULL;
-        clone->payloadSize = 0;
+        clone->payloadSize = info->payloadSize;
     }
 
     if (info->resourceUri)
@@ -449,7 +290,7 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
         char *temp = OICStrdup(info->resourceUri);
         if (!temp)
         {
-            OIC_LOG(ERROR, TAG, "CAClonePayloadInfo Out of memory");
+            OIC_LOG(ERROR, TAG, "CACloneInfo Out of memory");
             CADestroyInfoInternal(clone);
             return CA_MEMORY_ALLOC_FAILED;
         }
@@ -458,6 +299,9 @@ CAResult_t CACloneInfo(const CAInfo_t *info, CAInfo_t *clone)
         clone->resourceUri = temp;
     }
 
+    clone->messageId = info->messageId;
+    clone->type = info->type;
+
     return CA_STATUS_OK;
 
 }
index 744b1a5..751bafc 100644 (file)
@@ -165,13 +165,13 @@ CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func
     }
 
     ca_mutex_lock(thread_pool->details->list_lock);
-    CAResult_t addResult = u_arraylist_add(thread_pool->details->threads_list, (void*)threadHandle);
+    bool addResult = u_arraylist_add(thread_pool->details->threads_list, (void*)threadHandle);
     ca_mutex_unlock(thread_pool->details->list_lock);
 
-    if(addResult != CA_STATUS_OK)
+    if(!addResult)
     {
         OIC_LOG_V(ERROR, TAG, "Arraylist Add failed, may not be properly joined: %d", addResult);
-        return addResult;
+        return CA_STATUS_FAILED;
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
@@ -200,11 +200,7 @@ void ca_thread_pool_free(ca_thread_pool_t thread_pool)
         }
     }
 
-    CAResult_t freeres = u_arraylist_free(&(thread_pool->details->threads_list));
-    if(CA_STATUS_OK != freeres)
-    {
-        OIC_LOG_V(ERROR, TAG, "Failed to free array list, error was: %d", freeres);
-    }
+    u_arraylist_free(&(thread_pool->details->threads_list));
 
     ca_mutex_unlock(thread_pool->details->list_lock);
     ca_mutex_free(thread_pool->details->list_lock);
index be897be..8cc88f4 100644 (file)
@@ -54,19 +54,17 @@ u_arraylist_t *u_arraylist_create()
     return list;
 }
 
-CAResult_t u_arraylist_free(u_arraylist_t **list)
+void u_arraylist_free(u_arraylist_t **list)
 {
     if (!list || !(*list))
     {
-        return CA_STATUS_INVALID_PARAM;
+        return;
     }
 
     OICFree((*list)->data);
     OICFree(*list);
 
     *list = NULL;
-
-    return CA_STATUS_OK;
 }
 
 void *u_arraylist_get(const u_arraylist_t *list, uint32_t index)
@@ -84,20 +82,20 @@ void *u_arraylist_get(const u_arraylist_t *list, uint32_t index)
     return NULL;
 }
 
-CAResult_t u_arraylist_add(u_arraylist_t *list, void *data)
+bool u_arraylist_add(u_arraylist_t *list, void *data)
 {
     if (!list)
     {
-        return CA_STATUS_INVALID_PARAM;
+        return false;
     }
 
     if (list->size <= list->length)
     {
-
-       uint32_t new_size = list->size + 1;
+        uint32_t new_size = list->size + 1;
         if (!(list->data = (void **) realloc(list->data, new_size * sizeof(void *))))
         {
-            return CA_MEMORY_ALLOC_FAILED;
+            OIC_LOG(ERROR, TAG, "Failed to re-allocation memory");
+            return false;
         }
 
         memset(list->data + list->size, 0, (new_size - list->size) * sizeof(void *));
@@ -107,7 +105,7 @@ CAResult_t u_arraylist_add(u_arraylist_t *list, void *data)
     list->data[list->length] = data;
     list->length++;
 
-    return CA_STATUS_OK;
+    return true;
 }
 
 void *u_arraylist_remove(u_arraylist_t *list, uint32_t index)
index f220870..a750291 100644 (file)
@@ -168,7 +168,7 @@ typedef void (*CARegisterConnectivityCallback)(CAConnectivityHandler_t handler,
  * This will be used during the receive of network requests and response.
  * @see SendUnicastData(), SendMulticastData()
  */
-typedef void (*CANetworkPacketReceivedCallback)(const CAEndpoint_t *endPoint,
+typedef void (*CANetworkPacketReceivedCallback)(const CASecureEndpoint_t *sep,
                                             const void *data, uint32_t dataLen);
 
 /**
index dc19b9f..e6940d8 100644 (file)
@@ -38,7 +38,7 @@
  */
 extern void OCGetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo);
 
-typedef void (*CAPacketReceivedCallback)(const CAEndpoint_t *endpoint,
+typedef void (*CAPacketReceivedCallback)(const CASecureEndpoint_t *sep,
                                          const void *data, uint32_t dataLength);
 
 typedef void (*CAPacketSendCallback)(CAEndpoint_t *endpoint,
@@ -249,7 +249,7 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
  * @retval  ::CA_STATUS_FAILED Operation failed.
  *
  */
-CAResult_t CAAdapterNetDtlsDecrypt(const CAEndpoint_t *endpoint,
+CAResult_t CAAdapterNetDtlsDecrypt(const CASecureEndpoint_t *sep,
                                    uint8_t *data,
                                    uint32_t dataLen);
 
index 6a71f28..677b1f9 100644 (file)
@@ -50,12 +50,12 @@ typedef enum
 /**
  * Callback to be notified on reception of any data from remote OIC devices.
  *
- * @param[in]  endpoint      network endpoint description.
+ * @param[in]  sep         network endpoint description.
  * @param[in]  data          Data received from remote OIC device.
  * @param[in]  dataLength    Length of data in bytes.
  * @pre  Callback must be registered using CAIPSetPacketReceiveCallback().
  */
-typedef void (*CAIPPacketReceivedCallback)(const CAEndpoint_t *endpoint,
+typedef void (*CAIPPacketReceivedCallback)(const CASecureEndpoint_t *sep,
                                            const void *data,
                                            uint32_t dataLength);
 
@@ -173,7 +173,41 @@ typedef struct
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
 
 /**
- * Set callback for error handling.
+ * @brief   Find a new network interface.
+ *
+ * @return  Description of interface (or NULL if no change)
+ */
+CAInterface_t *CAFindInterfaceChange();
+
+/**
+ * @brief   Let the network monitor update the polling interval.
+ * @param   [in] current polling interval
+ *
+ * @return  desired polling interval
+ */
+int CAGetPollingInterval(int interval);
+
+/**
+ * @brief   Tell the IP server an interface has been added.
+ */
+void CAWakeUpForChange();
+
+/**
+ * @brief   Initializes network monitor.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAIPInitializeNetworkMonitor();
+
+/**
+ * @brief   Terminates network monitor.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAIPTerminateNetworkMonitor();
+
+/**
+ * @brief  Set callback for error handling.
  *
  * @param[in]  ipErrorCallback  callback to notify error to the ipadapter.
  */
index 4ec1cad..45f9f64 100644 (file)
@@ -52,9 +52,7 @@ typedef struct
     CARequestInfo_t *requestInfo;
     CAResponseInfo_t *responseInfo;
     CAErrorInfo_t *errorInfo;
-    CAHeaderOption_t *options;
     CADataType_t dataType;
-    uint8_t numOptions;
 } CAData_t;
 
 #ifdef __cplusplus
index 705427b..ce5f039 100644 (file)
@@ -1372,6 +1372,13 @@ void callback(char *subject, char *receivedData)
 {
     bool isAttached = false;
     JNIEnv* env;
+
+    if (!g_responseListenerObject)
+    {
+        LOGE("g_responseListenerObject is NULL, cannot have callback");
+        return;
+    }
+
     jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);
     if (JNI_OK != res)
     {
@@ -1387,6 +1394,12 @@ void callback(char *subject, char *receivedData)
     }
 
     jclass cls = (*env)->GetObjectClass(env, g_responseListenerObject);
+    if (!cls)
+    {
+        LOGE("could not get class");
+        goto detach_thread;
+    }
+
     jmethodID mid = (*env)->GetMethodID(env, cls, "OnResponseReceived",
                                         "(Ljava/lang/String;Ljava/lang/String;)V");
     if (!mid)
@@ -1461,7 +1474,7 @@ void parsing_coap_uri(const char* uri, addressSet_t* address, CATransportFlags_t
     }
 
     // #2. copy uri for parse
-    int32_t len = strlen(uri) - startIndex;
+    size_t len = strlen(uri) - startIndex;
 
     if (len <= 0)
     {
@@ -1476,19 +1489,26 @@ void parsing_coap_uri(const char* uri, addressSet_t* address, CATransportFlags_t
         return;
     }
 
-    memcpy(cloneUri, &uri[startIndex], sizeof(char) * len);
-    cloneUri[len] = '\0';
+    OICStrcpy(cloneUri, len+1, &uri[startIndex]);
 
-    char *pAddress = cloneUri;
-    LOGI("pAddress : %s", pAddress);
+    char *pstr = NULL;
+    //filter out the resource uri
+    char *pUrl = strtok_r(cloneUri, "/", &pstr);
 
-    int res = get_address_set(pAddress, address);
-    if (res == -1)
+    if (pUrl)
     {
-        LOGE("address parse error");
+        LOGI("pAddress : %s", pUrl);
+        int res = get_address_set(pUrl, address);
+        if (res == -1)
+        {
+            LOGE("address parse error");
 
-        free(cloneUri);
-        return;
+            return;
+        }
+    }
+    else
+    {
+        LOGE("strtok_r error, could not get the address");
     }
 
     return;
index 97a72bf..af9ed9a 100644 (file)
@@ -50,7 +50,7 @@ static ca_mutex g_dtlsContextMutex = NULL;
  */
 static CAGetDTLSCredentialsHandler g_getCredentialsCallback = NULL;
 
-static CAEndpoint_t *GetPeerInfo(const CAEndpoint_t *peer)
+static CASecureEndpoint_t *GetPeerInfo(const CAEndpoint_t *peer)
 {
     uint32_t list_index = 0;
     uint32_t list_length = 0;
@@ -61,18 +61,18 @@ static CAEndpoint_t *GetPeerInfo(const CAEndpoint_t *peer)
         return NULL;
     }
 
-    CAEndpoint_t *peerInfo;
+    CASecureEndpoint_t *peerInfo = NULL;
     list_length = u_arraylist_length(g_caDtlsContext->peerInfoList);
     for (list_index = 0; list_index < list_length; list_index++)
     {
-        peerInfo = (CAEndpoint_t *)u_arraylist_get(g_caDtlsContext->peerInfoList, list_index);
+        peerInfo = (CASecureEndpoint_t *)u_arraylist_get(g_caDtlsContext->peerInfoList, list_index);
         if (NULL == peerInfo)
         {
             continue;
         }
 
-        if((0 == strncmp(peer->addr, peerInfo->addr, MAX_ADDR_STR_SIZE_CA)) &&
-                (peer->port == peerInfo->port))
+        if((0 == strncmp(peer->addr, peerInfo->endpoint.addr, MAX_ADDR_STR_SIZE_CA)) &&
+                (peer->port == peerInfo->endpoint.port))
         {
             return peerInfo;
         }
@@ -80,8 +80,8 @@ static CAEndpoint_t *GetPeerInfo(const CAEndpoint_t *peer)
     return NULL;
 }
 
-static CAResult_t CAAddIdToPeerInfoList(const char *peerAddr, uint16_t port,
-        const unsigned char *id, uint16_t id_length, CATransportFlags_t flag)
+static CAResult_t CAAddIdToPeerInfoList(const char *peerAddr, uint32_t port,
+        const unsigned char *id, uint16_t id_length)
 {
     if(NULL == peerAddr
        || NULL == id
@@ -93,31 +93,28 @@ static CAResult_t CAAddIdToPeerInfoList(const char *peerAddr, uint16_t port,
         return CA_STATUS_INVALID_PARAM;
     }
 
-    CAEndpoint_t *peer = (CAEndpoint_t *)OICCalloc(1, sizeof (CAEndpoint_t));
+    CASecureEndpoint_t *peer = (CASecureEndpoint_t *)OICCalloc(1, sizeof (CASecureEndpoint_t));
     if (NULL == peer)
     {
         OIC_LOG(ERROR, NET_DTLS_TAG, "peerInfo malloc failed!");
         return CA_MEMORY_ALLOC_FAILED;
     }
 
-    OICStrcpy(peer->addr, sizeof(peer->addr), peerAddr);
-    peer->port = port;
-    peer->flags = flag;
-    peer->flags |= CA_SECURE;
-    peer->adapter = CA_ADAPTER_IP;
+    OICStrcpy(peer->endpoint.addr, sizeof(peer->endpoint.addr), peerAddr);
+    peer->endpoint.port = port;
 
     memcpy(peer->identity.id, id, id_length);
     peer->identity.id_length = id_length;
 
-    if(NULL != GetPeerInfo(peer))
+    if (NULL != GetPeerInfo(&peer->endpoint))
     {
         OIC_LOG(ERROR, NET_DTLS_TAG, "CAAddIdToPeerInfoList peer already exist");
         OICFree(peer);
         return CA_STATUS_FAILED;
     }
 
-    CAResult_t result = u_arraylist_add(g_caDtlsContext->peerInfoList, (void *)peer);
-    if (CA_STATUS_OK != result)
+    bool result = u_arraylist_add(g_caDtlsContext->peerInfoList, (void *)peer);
+    if (!result)
     {
         OIC_LOG(ERROR, NET_DTLS_TAG, "u_arraylist_add failed!");
         OICFree(peer);
@@ -301,8 +298,8 @@ static CAResult_t CADtlsCacheMsg(stCACacheMessage_t *msg)
         return CA_STATUS_FAILED;
     }
 
-    CAResult_t result = u_arraylist_add(g_caDtlsContext->cacheList, (void *)msg);
-    if (CA_STATUS_OK != result)
+    bool result = u_arraylist_add(g_caDtlsContext->cacheList, (void *)msg);
+    if (!result)
     {
         OIC_LOG(ERROR, NET_DTLS_TAG, "u_arraylist_add failed!");
     }
@@ -385,12 +382,13 @@ static int32_t CAReadDecryptedPayload(dtls_context_t *context,
 
     stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session;
 
-    CAEndpoint_t endpoint = { 0 };
-    CAConvertAddrToName(&(addrInfo->addr.st), endpoint.addr, &endpoint.port);
-    endpoint.flags = addrInfo->addr.st.ss_family == AF_INET ? CA_IPV4 : CA_IPV6;
-    endpoint.flags |= CA_SECURE;
-    endpoint.adapter = CA_ADAPTER_IP;
-    int type = 0;
+    CASecureEndpoint_t sep =
+    { .endpoint =
+    { .adapter = CA_ADAPTER_IP, .flags =
+            ((addrInfo->addr.st.ss_family == AF_INET) ? CA_IPV4 : CA_IPV6) | CA_SECURE, .port = 0 },
+            .identity =
+            { 0 } };
+    CAConvertAddrToName(&(addrInfo->addr.st), sep.endpoint.addr, &sep.endpoint.port);
 
     if (NULL == g_caDtlsContext)
     {
@@ -398,17 +396,18 @@ static int32_t CAReadDecryptedPayload(dtls_context_t *context,
         return 0;
     }
 
+    int type = 0;
     if ((0 <= type) && (MAX_SUPPORTED_ADAPTERS > type) &&
         (NULL != g_caDtlsContext->adapterCallbacks[type].recvCallback))
     {
         // Get identity of the source of packet
-        CAEndpoint_t *peerInfo = GetPeerInfo(&endpoint);
+        CASecureEndpoint_t *peerInfo = GetPeerInfo(&sep.endpoint);
         if (peerInfo)
         {
-            endpoint.identity = peerInfo->identity;
+            sep.identity = peerInfo->identity;
         }
 
-        g_caDtlsContext->adapterCallbacks[type].recvCallback(&endpoint, buf, bufLen);
+        g_caDtlsContext->adapterCallbacks[type].recvCallback(&sep, buf, bufLen);
     }
     else
     {
@@ -483,7 +482,7 @@ static int32_t CAHandleSecureEvent(dtls_context_t *context,
         OIC_LOG(INFO, NET_DTLS_TAG, "Peer closing connection");
 
         stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session;
-        char peerAddr[MAX_ADDR_STR_SIZE_CA] = {0};
+        char peerAddr[MAX_ADDR_STR_SIZE_CA] = { 0 };
         uint16_t port = 0;
         CAConvertAddrToName(&(addrInfo->addr.st), peerAddr, &port);
         CARemovePeerFromPeerInfoList(peerAddr, port);
@@ -550,15 +549,11 @@ static int32_t CAGetPskCredentials(dtls_context_t *ctx,
                     // data structure when handshake completes. Therefore, currently this is a
                     // workaround to cache remote end-point identity when tinyDTLS asks for PSK.
                     stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session;
-                    char peerAddress[MAX_ADDR_STR_SIZE_CA] = {0};
+                    char peerAddr[MAX_ADDR_STR_SIZE_CA] = { 0 };
                     uint16_t port = 0;
-                    CAConvertAddrToName(&(addrInfo->addr.st), peerAddress, &port);
+                    CAConvertAddrToName(&(addrInfo->addr.st), peerAddr, &port);
 
-                    CATransportFlags_t flag =
-                            addrInfo->addr.st.ss_family == AF_INET ? CA_IPV4 : CA_IPV6;
-
-                    CAResult_t result = CAAddIdToPeerInfoList(peerAddress,
-                            port, desc, descLen, flag);
+                    CAResult_t result = CAAddIdToPeerInfoList(peerAddr, port, desc, descLen);
                     if(CA_STATUS_OK != result )
                     {
                         OIC_LOG(ERROR, NET_DTLS_TAG, "Fail to add peer id to gDtlsPeerInfoList");
@@ -954,15 +949,15 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
     return CA_STATUS_OK;
 }
 
-CAResult_t CAAdapterNetDtlsDecrypt(const CAEndpoint_t *endpoint,
+CAResult_t CAAdapterNetDtlsDecrypt(const CASecureEndpoint_t *sep,
                                    uint8_t *data, uint32_t dataLen)
 {
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
-    VERIFY_NON_NULL_RET(endpoint, NET_DTLS_TAG, "endpoint is NULL" , CA_STATUS_INVALID_PARAM);
+    VERIFY_NON_NULL_RET(sep, NET_DTLS_TAG, "endpoint is NULL" , CA_STATUS_INVALID_PARAM);
 
     stCADtlsAddrInfo_t addrInfo = { 0 };
 
-    CAConvertNameToAddr(endpoint->addr, endpoint->port, &(addrInfo.addr.st));
+    CAConvertNameToAddr(sep->endpoint.addr, sep->endpoint.port, &(addrInfo.addr.st));
     addrInfo.ifIndex = 0;
     addrInfo.size = CASizeOfAddrInfo(&addrInfo);
 
index cbd1fb8..5a8a231 100644 (file)
@@ -525,7 +525,7 @@ void CAEDRNativeRemoveDevice(const char *remoteAddress)
             OIC_LOG_V(DEBUG, TAG, "[EDR][Native] remove state : %s", remoteAddress);
             OICFree(state);
 
-            CAEDRReorderingDeviceList(index);
+            u_arraylist_remove(g_deviceStateList, index);
             break;
         }
     }
@@ -569,23 +569,6 @@ CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress)
     return STATE_DISCONNECTED;
 }
 
-void CAEDRReorderingDeviceList(uint32_t index)
-{
-    if (index >= g_deviceStateList->length)
-    {
-        return;
-    }
-
-    if (index < g_deviceStateList->length - 1)
-    {
-        memmove(&g_deviceStateList->data[index], &g_deviceStateList->data[index + 1],
-                (g_deviceStateList->length - index - 1) * sizeof(void *));
-    }
-
-    g_deviceStateList->size--;
-    g_deviceStateList->length--;
-}
-
 /**
  * Device Socket Object List
  */
@@ -808,7 +791,7 @@ void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket)
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
 
-            CAEDRReorderingDeviceSocketList(index);
+            u_arraylist_remove(g_deviceObjectList, index);
             break;
         }
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
@@ -856,7 +839,7 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address)
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
 
-            CAEDRReorderingDeviceSocketList(index);
+            u_arraylist_remove(g_deviceObjectList, index);
             break;
         }
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
@@ -939,20 +922,3 @@ uint32_t CAEDRGetSocketListLength()
 
     return length;
 }
-
-void CAEDRReorderingDeviceSocketList(uint32_t index)
-{
-    if (index >= g_deviceObjectList->length)
-    {
-        return;
-    }
-
-    if (index < g_deviceObjectList->length - 1)
-    {
-        memmove(&g_deviceObjectList->data[index], &g_deviceObjectList->data[index + 1],
-                (g_deviceObjectList->length - index - 1) * sizeof(void *));
-    }
-
-    g_deviceObjectList->size--;
-    g_deviceObjectList->length--;
-}
index 00ddffc..ec12615 100644 (file)
@@ -130,12 +130,6 @@ void CAEDRNativeRemoveDevice(const char *remoteAddress);
 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
 
 /**
- * Reordering for the list.
- * @param[in]   index           index of device list that want to reordering.
- */
-void CAEDRReorderingDeviceList(uint32_t index);
-
-/**
  * This function will create the device socket list.
  */
 void CAEDRNativeCreateDeviceSocketList();
@@ -196,11 +190,6 @@ jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddres
  */
 uint32_t CAEDRGetSocketListLength();
 
-/**
- * Reordering for the list.
- * @param[in]   index           index of device list that want to reordering.
- */
-void CAEDRReorderingDeviceSocketList(uint32_t index);
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index 18061e7..c7156e6 100644 (file)
@@ -34,7 +34,6 @@ CAResult_t CAEDRSendData(int serverFD, const void *data, uint32_t dataLength)
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
     VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
-    VERIFY_NON_NULL(sentDataLen, EDR_ADAPTER_TAG, "Sent data length holder is null");
 
     if (0 > serverFD)
     {
index 20b9962..d9af8e6 100644 (file)
@@ -51,10 +51,9 @@ static CAEDRNetworkStatusCallback g_edrNetworkChangeCallback = NULL;
 static void CAEDRAdapterStateChangeCallback(int result, bt_adapter_state_e adapterState,
                                             void *userData);
 
-void *GMainLoopThread (void *param)
+void GMainLoopThread (void *param)
 {
     g_main_loop_run(g_mainloop);
-    return NULL;
 }
 
 CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
index 38ae49a..075c9bd 100644 (file)
@@ -2221,7 +2221,12 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
 
-            CALEClientReorderingList(index, g_deviceList);
+            if (NULL == u_arraylist_remove(g_deviceList, index))
+            {
+                OIC_LOG(ERROR, TAG, "List removal failed.");
+                ca_mutex_unlock(g_deviceListMutex);
+                return CA_STATUS_FAILED;
+            }
             ca_mutex_unlock(g_deviceListMutex);
             return CA_STATUS_OK;
         }
@@ -2468,8 +2473,15 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
             (*env)->DeleteGlobalRef(env, jarrayObj);
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
+
+            if (NULL == u_arraylist_remove(g_gattObjectList, index))
+            {
+                OIC_LOG(ERROR, TAG, "List removal failed.");
+                ca_mutex_unlock(g_gattObjectMutex);
+                return CA_STATUS_FAILED;
+            }
             ca_mutex_unlock(g_gattObjectMutex);
-            return CALEClientReorderingList(index, g_gattObjectList);
+            return CA_STATUS_OK;
         }
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
         (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
@@ -2537,8 +2549,14 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
 
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->ReleaseStringUTFChars(env, addr, remoteAddress);
+            if (NULL == u_arraylist_remove(g_gattObjectList, index))
+            {
+                OIC_LOG(ERROR, TAG, "List removal failed.");
+                ca_mutex_unlock(g_gattObjectMutex);
+                return CA_STATUS_FAILED;
+            }
             ca_mutex_unlock(g_gattObjectMutex);
-            return CALEClientReorderingList(index, g_gattObjectList);
+            return CA_STATUS_OK;
         }
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
         (*env)->ReleaseStringUTFChars(env, addr, remoteAddress);
@@ -2716,12 +2734,12 @@ CAResult_t CALEClientRemoveDeviceState(const char* remoteAddress)
             OIC_LOG_V(DEBUG, TAG, "remove state : %s", remoteAddress);
             OICFree(state);
 
-            CAResult_t res = CALEClientReorderingList(index, g_deviceStateList);
-            if(CA_STATUS_OK != res)
+            if (NULL == u_arraylist_remove(g_deviceStateList, index))
             {
-                OIC_LOG(ERROR, TAG, "CALEClientReorderingList has failed");
-                return res;
+                OIC_LOG(ERROR, TAG, "List removal failed.");
+                return CA_STATUS_FAILED;
             }
+
             return CA_STATUS_OK;
         }
     }
@@ -2873,32 +2891,6 @@ void CALEClientCreateDeviceList()
     }
 }
 
-CAResult_t CALEClientReorderingList(uint32_t index, u_arraylist_t *list)
-{
-    if (!list)
-    {
-        OIC_LOG(ERROR, TAG, "list is null");
-        return CA_STATUS_FAILED;
-    }
-
-    if (index >= list->length)
-    {
-        OIC_LOG(ERROR, TAG, "index is not available");
-        return CA_STATUS_FAILED;
-    }
-
-    if (index < list->length - 1)
-    {
-        memmove(&list->data[index], &list->data[index + 1],
-                (list->length - index - 1) * sizeof(void *));
-    }
-
-    list->size--;
-    list->length--;
-
-    return CA_STATUS_OK;
-}
-
 /**
  * Check Sent Count for remove g_sendBuffer
  */
index 1b04609..708a1c5 100644 (file)
@@ -509,14 +509,6 @@ bool CALEClientIsSetCharacteristic(const char* remoteAddress);
 void CALEClientCreateDeviceList();
 
 /**
- * Reordering for device state list.
- * @param[in]   index                 index of device list that want to reordering.
- * @param[in]   list                  the list to reorder.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEClientReorderingList(uint32_t index, u_arraylist_t *list);
-
-/**
  * update the counter which data is sent to remote device.
  * @param[in]   env                   JNI interface pointer.
  */
index db04fac..8f8ec34 100644 (file)
@@ -2018,12 +2018,11 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
                 (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
                 (*env)->DeleteGlobalRef(env, jarrayObj);
 
-                CAResult_t res = CALEServerReorderinglist(index);
-                if (CA_STATUS_OK != res)
+                if (NULL == u_arraylist_remove(g_connectedDeviceList, index))
                 {
-                    OIC_LOG(ERROR, TAG, "CALEServerReorderinglist has failed");
+                    OIC_LOG(ERROR, TAG, "List removal failed.");
                     ca_mutex_unlock(g_connectedDeviceListMutex);
-                    return res;
+                    return CA_STATUS_FAILED;
                 }
                 ca_mutex_unlock(g_connectedDeviceListMutex);
                 return CA_STATUS_OK;
@@ -2041,32 +2040,6 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
     return CA_STATUS_FAILED;
 }
 
-CAResult_t CALEServerReorderinglist(uint32_t index)
-{
-    if (!g_connectedDeviceList)
-    {
-        OIC_LOG(ERROR, TAG, "g_connectedDeviceList is null");
-        return CA_STATUS_FAILED;
-    }
-
-    if (index >= g_connectedDeviceList->length)
-    {
-        OIC_LOG(ERROR, TAG, "index is not available");
-        return CA_STATUS_FAILED;
-    }
-
-    if (index < g_connectedDeviceList->length - 1)
-    {
-        memmove(&g_connectedDeviceList->data[index], &g_connectedDeviceList->data[index + 1],
-                (g_connectedDeviceList->length - index - 1) * sizeof(void *));
-    }
-
-    g_connectedDeviceList->size--;
-    g_connectedDeviceList->length--;
-
-    return CA_STATUS_OK;
-}
-
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeServerInterface_caLeRegisterGattServerCallback(JNIEnv *env, jobject obj,
                                                                         jobject callback)
index 1b7a862..48484b5 100644 (file)
@@ -292,13 +292,6 @@ CAResult_t CALEServerRemoveAllDevices(JNIEnv *env);
 CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address);
 
 /**
- * Reordering for the list (connected device list).
- * @param[in]   index                 index of device list that want to reordering.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEServerReorderinglist(uint32_t index);
-
-/**
  * initialize mutex.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
index 9a46051..2a198db 100644 (file)
@@ -257,193 +257,6 @@ static CAQueueingThread_t *g_bleReceiverQueue = NULL;
 static CAQueueingThread_t *g_bleServerSendQueueHandle = NULL;
 
 /**
- * Starting LE connectivity adapters.
- *
- * As its peer to peer it does not require to start any servers.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-static CAResult_t CAStartLE();
-
-/**
- * Start listening server for receiving multicast search requests.
- *
- * Transport Specific Behavior:
- *   LE  Starts GATT Server with prefixed UUID and Characteristics
- *   per OIC Specification.
- * @return  ::CA_STATUS_OK or Appropriate error code.
- */
-static CAResult_t CAStartLEListeningServer();
-
-/**
- * Sarting discovery of servers for receiving multicast
- * advertisements.
- *
- * Transport Specific Behavior:
- *   LE  Starts GATT Server with prefixed UUID and Characteristics
- *   per OIC Specification.
- *
- * @return ::CA_STATUS_OK or Appropriate error code
- */
-static CAResult_t CAStartLEDiscoveryServer();
-
-/**
- * Send data to the endpoint using the adapter connectivity.
- *
- * @param[in] endpoint Remote Endpoint information (like MAC address,
- *                     reference URI and connectivity type) to which
- *                     the unicast data has to be sent.
- * @param[in] data     Data which required to be sent.
- * @param[in] dataLen  Size of data to be sent.
- *
- * @note  dataLen must be > 0.
- *
- * @return The number of bytes sent on the network, or -1 on error.
- */
-static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
-                                   const void *data,
-                                   uint32_t dataLen);
-
-/**
- * Send multicast data to the endpoint using the LE connectivity.
- *
- * @param[in] endpoint Remote Endpoint information to which the
- *                     multicast data has to be sent.
- * @param[in] data     Data which required to be sent.
- * @param[in] dataLen  Size of data to be sent.
- *
- * @note  dataLen must be > 0.
- *
- * @return The number of bytes sent on the network, or -1 on error.
- */
-static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
-                                     const void *data,
-                                     uint32_t dataLen);
-
-/**
- * Get LE Connectivity network information.
- *
- * @param[out] info Local connectivity information structures.
- * @param[out] size Number of local connectivity structures.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info,
-                                              uint32_t *size);
-
-/**
- * Read Synchronous API callback.
- *
- * @return  ::CA_STATUS_OK or Appropriate error code.
- */
-static CAResult_t CAReadLEData();
-
-/**
- * Stopping the adapters and close socket connections.
- *
- * LE Stops all GATT servers and GATT Clients.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-static CAResult_t CAStopLE();
-
-/**
- * Terminate the LE connectivity adapter.
- *
- * Configuration information will be deleted from further use.
- */
-static void CATerminateLE();
-
-/**
- * Set the NetworkPacket received callback to CA layer from adapter
- * layer.
- *
- * @param[in] callback Callback handle sent from the upper layer.
- */
-static void CASetLEReqRespAdapterCallback(CANetworkPacketReceivedCallback callback);
-
-/**
- * Push the data from CA layer to the Sender processor queue.
- *
- * @param[in] remoteEndpoint Remote endpoint information of the
- *                           server.
- * @param[in] data           Data to be transmitted from LE.
- * @param[in] dataLen        Length of the Data being transmitted.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- * @retval ::CA_STATUS_OK  Successful.
- * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
- * @retval ::CA_STATUS_FAILED Operation failed.
- */
-static CAResult_t CALEAdapterServerSendData(const CAEndpoint_t *remoteEndpoint,
-                                            const uint8_t *data,
-                                            uint32_t dataLen);
-
-/**
- * Push the data from CA layer to the Sender processor queue.
- *
- * @param[in] remoteEndpoint Remote endpoint information of the
- *                           server.
- * @param[in] data           Data to be transmitted from LE.
- * @param[in] dataLen        Length of the Data being transmitted.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- * @retval ::CA_STATUS_OK  Successful.
- * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
- * @retval ::CA_STATUS_FAILED Operation failed.
- */
-static CAResult_t CALEAdapterClientSendData(const CAEndpoint_t *remoteEndpoint,
-                                            const uint8_t *data,
-                                            uint32_t dataLen);
-
-/**
- * This function will receive the data from the GattServer and add the
- * data to the Server receiver queue.
- *
- * @param[in] remoteAddress Remote address of the device from where
- *                          data is received.
- * @param[in] data          Actual data recevied from the remote
- *                          device.
- * @param[in] dataLength    Length of the data received from the
- *                          remote device.
- * @param[in] sentLength    Length of the data sent from the remote
- *                          device.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- * @retval ::CA_STATUS_OK  Successful.
- * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
- * @retval ::CA_STATUS_FAILED Operation failed.
- *
- */
-static CAResult_t CALEAdapterServerReceivedData(const char *remoteAddress,
-                                                const uint8_t *data,
-                                                uint32_t dataLength,
-                                                uint32_t *sentLength);
-
-/**
- * This function will receive the data from the GattClient and add the
- * data into the Client receiver queue.
- *
- * @param[in] remoteAddress Remote address of the device from where
- *                          data is received.
- * @param[in] data          Actual data recevied from the remote
- *                          device.
- * @param[in] dataLength    Length of the data received from the
- *                          remote device.
- * @param[in] sentLength    Length of the data sent from the remote
- *                          device.
- *
- * @return ::CA_STATUS_OK or Appropriate error code.
- * @retval ::CA_STATUS_OK  Successful.
- * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
- * @retval ::CA_STATUS_FAILED Operation failed.
- */
-static CAResult_t CALEAdapterClientReceivedData(const char *remoteAddress,
-                                                const uint8_t *data,
-                                                uint32_t dataLength,
-                                                uint32_t *sentLength);
-
-/**
  * This function will be associated with the sender queue for
  * GattServer.
  *
@@ -1606,6 +1419,193 @@ static void CATerminateLEAdapterMutex()
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
 }
 
+/**
+ * Starting LE connectivity adapters.
+ *
+ * As its peer to peer it does not require to start any servers.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+static CAResult_t CAStartLE();
+
+/**
+ * Start listening server for receiving multicast search requests.
+ *
+ * Transport Specific Behavior:
+ *   LE  Starts GATT Server with prefixed UUID and Characteristics
+ *   per OIC Specification.
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+static CAResult_t CAStartLEListeningServer();
+
+/**
+ * Sarting discovery of servers for receiving multicast
+ * advertisements.
+ *
+ * Transport Specific Behavior:
+ *   LE  Starts GATT Server with prefixed UUID and Characteristics
+ *   per OIC Specification.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code
+ */
+static CAResult_t CAStartLEDiscoveryServer();
+
+/**
+ * Send data to the endpoint using the adapter connectivity.
+ *
+ * @param[in] endpoint Remote Endpoint information (like MAC address,
+ *                     reference URI and connectivity type) to which
+ *                     the unicast data has to be sent.
+ * @param[in] data     Data which required to be sent.
+ * @param[in] dataLen  Size of data to be sent.
+ *
+ * @note  dataLen must be > 0.
+ *
+ * @return The number of bytes sent on the network, or -1 on error.
+ */
+static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
+                                   const void *data,
+                                   uint32_t dataLen);
+
+/**
+ * Send multicast data to the endpoint using the LE connectivity.
+ *
+ * @param[in] endpoint Remote Endpoint information to which the
+ *                     multicast data has to be sent.
+ * @param[in] data     Data which required to be sent.
+ * @param[in] dataLen  Size of data to be sent.
+ *
+ * @note  dataLen must be > 0.
+ *
+ * @return The number of bytes sent on the network, or -1 on error.
+ */
+static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
+                                     const void *data,
+                                     uint32_t dataLen);
+
+/**
+ * Get LE Connectivity network information.
+ *
+ * @param[out] info Local connectivity information structures.
+ * @param[out] size Number of local connectivity structures.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info,
+                                              uint32_t *size);
+
+/**
+ * Read Synchronous API callback.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+static CAResult_t CAReadLEData();
+
+/**
+ * Stopping the adapters and close socket connections.
+ *
+ * LE Stops all GATT servers and GATT Clients.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+static CAResult_t CAStopLE();
+
+/**
+ * Terminate the LE connectivity adapter.
+ *
+ * Configuration information will be deleted from further use.
+ */
+static void CATerminateLE();
+
+/**
+ * This function will receive the data from the GattServer and add the
+ * data to the Server receiver queue.
+ *
+ * @param[in] remoteAddress Remote address of the device from where
+ *                          data is received.
+ * @param[in] data          Actual data recevied from the remote
+ *                          device.
+ * @param[in] dataLength    Length of the data received from the
+ *                          remote device.
+ * @param[in] sentLength    Length of the data sent from the remote
+ *                          device.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK  Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ *
+ */
+static CAResult_t CALEAdapterServerReceivedData(const char *remoteAddress,
+                                                const uint8_t *data,
+                                                uint32_t dataLength,
+                                                uint32_t *sentLength);
+
+/**
+ * This function will receive the data from the GattClient and add the
+ * data into the Client receiver queue.
+ *
+ * @param[in] remoteAddress Remote address of the device from where
+ *                          data is received.
+ * @param[in] data          Actual data recevied from the remote
+ *                          device.
+ * @param[in] dataLength    Length of the data received from the
+ *                          remote device.
+ * @param[in] sentLength    Length of the data sent from the remote
+ *                          device.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK  Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ */
+static CAResult_t CALEAdapterClientReceivedData(const char *remoteAddress,
+                                                const uint8_t *data,
+                                                uint32_t dataLength,
+                                                uint32_t *sentLength);
+
+/**
+ * Set the NetworkPacket received callback to CA layer from adapter
+ * layer.
+ *
+ * @param[in] callback Callback handle sent from the upper layer.
+ */
+static void CASetLEReqRespAdapterCallback(CANetworkPacketReceivedCallback callback);
+
+/**
+ * Push the data from CA layer to the Sender processor queue.
+ *
+ * @param[in] remoteEndpoint Remote endpoint information of the
+ *                           server.
+ * @param[in] data           Data to be transmitted from LE.
+ * @param[in] dataLen        Length of the Data being transmitted.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK  Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ */
+static CAResult_t CALEAdapterServerSendData(const CAEndpoint_t *remoteEndpoint,
+                                            const uint8_t *data,
+                                            uint32_t dataLen);
+
+/**
+ * Push the data from CA layer to the Sender processor queue.
+ *
+ * @param[in] remoteEndpoint Remote endpoint information of the
+ *                           server.
+ * @param[in] data           Data to be transmitted from LE.
+ * @param[in] dataLen        Length of the Data being transmitted.
+ *
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK  Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ */
+static CAResult_t CALEAdapterClientSendData(const CAEndpoint_t *remoteEndpoint,
+                                            const uint8_t *data,
+                                            uint32_t dataLen);
+
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback reqRespCallback,
                           CANetworkChangeCallback netCallback,
@@ -1670,7 +1670,7 @@ CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
 
 static CAResult_t CAStartLE()
 {
-    OIC_LOG(DEBUG, CALEADAPTER_TAG, __func__);
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CAStartLE");
 
     return CAStartLEAdapter();
 }
index a971465..807f1d9 100644 (file)
@@ -219,8 +219,8 @@ void CAStartBleGattServerThread(void *data)
         return;
     }
 
-    char *charReadUUID = CA_GATT_RESPONSE_CHRC_UUID;
-    char charReadValue[] = {33, 44, 55, 66}; // These are initial random values
+    static const char charReadUUID[] = CA_GATT_RESPONSE_CHRC_UUID;
+    uint8_t charReadValue[] = {33, 44, 55, 66}; // These are initial random values
 
     ret = CAAddNewCharacteristicsToGattServer(g_gattSvcPath, charReadUUID, charReadValue,
             CA_BLE_INITIAL_BUF_SIZE, true); // For Read Characteristics.
@@ -232,8 +232,8 @@ void CAStartBleGattServerThread(void *data)
         return;
     }
 
-    char *charWriteUUID = CA_GATT_REQUEST_CHRC_UUID;
-    char charWriteValue[] = {33, 44, 55, 66}; // These are initial random values
+    static const char charWriteUUID[] = CA_GATT_REQUEST_CHRC_UUID;
+    uint8_t charWriteValue[] = {33, 44, 55, 66}; // These are initial random values
 
 
     ret = CAAddNewCharacteristicsToGattServer(g_gattSvcPath, charWriteUUID, charWriteValue,
@@ -592,7 +592,7 @@ void CABleGattRemoteCharacteristicWriteCb(char *charPath,
 
     OIC_LOG_V(DEBUG,
               TZ_BLE_SERVER_TAG,
-              "charPath = [%s] charValue = [%x] len [%d]",
+              "charPath = [%s] charValue = [%p] len [%d]",
               charPath,
               charValue,
               charValueLen);
@@ -647,12 +647,12 @@ CAResult_t CARegisterBleServicewithGattServer(const char *svcPath)
 }
 
 CAResult_t CAAddNewCharacteristicsToGattServer(const char *svcPath, const char *charUUID,
-        const char *charValue, int charValueLen, bool read)
+        const uint8_t *charValue, int charValueLen, bool read)
 {
 
     OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
 
-    char *charFlags[1];
+    const char *charFlags[1];
     if(read)
     {
         charFlags[0] = "notify";
@@ -665,8 +665,14 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const char *svcPath, const char *
     size_t flagLen = sizeof(charFlags) / sizeof(charFlags[0]);
 
     char *charPath = NULL;
-    int ret = bt_gatt_add_characteristic(charUUID, charValue, charValueLen, charFlags, flagLen,
-                  svcPath, &charPath);
+    int ret =
+        bt_gatt_add_characteristic(charUUID,
+                                   (const char *) charValue,
+                                   charValueLen,
+                                   charFlags,
+                                   flagLen,
+                                   svcPath,
+                                   &charPath);
 
     if (0 != ret || NULL == charPath)
     {
@@ -713,7 +719,7 @@ CAResult_t CARemoveCharacteristicsFromGattServer(const char *charPath)
 }
 
 CAResult_t CAUpdateCharacteristicsToGattClient(const char *address,
-                                               const char *charValue,
+                                               const uint8_t *charValue,
                                                uint32_t charValueLen)
 {
     OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
@@ -733,7 +739,7 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address,
         return CA_STATUS_FAILED;
     }
 
-    char *data = (char *) OICCalloc(sizeof(char), (charValueLen + 1));
+    char *data = OICCalloc(charValueLen, 1);
     if (NULL == data)
     {
         OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "malloc failed!");
@@ -741,12 +747,16 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address,
         return CA_STATUS_FAILED;
     }
 
-    OICStrcpy(data, charValueLen + 1, charValue);
+    memcpy(data, charValue, charValueLen);   // Binary data
 
-    OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "updating characteristics char [%s] data [%s] dataLen [%d]",
+    OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "updating characteristics char [%s] data [%p] dataLen [%u]",
               (const char *)g_gattReadCharPath, data, charValueLen);
 
-    int ret =  bt_gatt_update_characteristic(g_gattReadCharPath, data, charValueLen, address);
+    int ret =
+        bt_gatt_update_characteristic(g_gattReadCharPath,
+                                      data,
+                                      charValueLen,
+                                      address);
     if (0 != ret)
     {
         OIC_LOG_V(ERROR, TZ_BLE_SERVER_TAG,
@@ -763,7 +773,7 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address,
     return CA_STATUS_OK;
 }
 
-CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue, uint32_t charValueLen)
+CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *charValue, uint32_t charValueLen)
 {
     OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
 
@@ -778,7 +788,7 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue, uint32
         return CA_STATUS_FAILED;
     }
 
-    char *data = (char *) OICMalloc(sizeof(char) * (charValueLen + 1));
+    char *data = OICMalloc(charValueLen);
     if (NULL == data)
     {
         OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "malloc failed!");
@@ -786,12 +796,16 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue, uint32
         return CA_STATUS_FAILED;
     }
 
-    OICStrcpy(data, charValueLen + 1, charValue);
+    memcpy(data, charValue, charValueLen);   // Binary data
 
-    OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "updating characteristics char [%s] data [%s] dataLen [%d]",
+    OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "updating characteristics char [%s] data [%p] dataLen [%u]",
               (const char *)g_gattReadCharPath, data, charValueLen);
 
-    int ret =  bt_gatt_update_characteristic(g_gattReadCharPath, data, charValueLen, NULL);
+    int ret =
+        bt_gatt_update_characteristic(g_gattReadCharPath,
+                                      data,
+                                      charValueLen,
+                                      NULL);
     if (0 != ret)
     {
         OIC_LOG_V(ERROR, TZ_BLE_SERVER_TAG,
index c016654..80cd517 100644 (file)
@@ -2004,22 +2004,6 @@ CAData_t *CACloneCAData(const CAData_t *data)
         clone->remoteEndpoint = CACloneEndpoint(data->remoteEndpoint);
     }
 
-    if (NULL != data->options && 0 < data->numOptions)
-    {
-        // copy data
-        CAHeaderOption_t *headerOption = (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t)
-                                                                        * data->numOptions);
-        if (NULL == headerOption)
-        {
-            OIC_LOG(ERROR, TAG, "Out of memory");
-            CADestroyDataSet(clone);
-            return NULL;
-        }
-        memcpy(headerOption, data->options, sizeof(CAHeaderOption_t) * data->numOptions);
-
-        clone->options = headerOption;
-    }
-
     return clone;
 }
 
@@ -2475,8 +2459,8 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData)
 
     ca_mutex_lock(g_context.blockDataListMutex);
 
-    CAResult_t res = u_arraylist_add(g_context.dataList, (void *) data);
-    if (CA_STATUS_OK != res)
+    bool res = u_arraylist_add(g_context.dataList, (void *) data);
+    if (!res)
     {
         OIC_LOG(ERROR, TAG, "add has failed");
         CADestroyBlockID(data->blockDataId);
@@ -2558,7 +2542,6 @@ void CADestroyDataSet(CAData_t* data)
     CAFreeEndpoint(data->remoteEndpoint);
     CADestroyRequestInfoInternal(data->requestInfo);
     CADestroyResponseInfoInternal(data->responseInfo);
-    OICFree(data->options);
     OICFree(data);
 }
 
index 9df1da3..9b1f8d4 100644 (file)
@@ -123,14 +123,14 @@ CAResult_t CASetAdapterRAInfo(const CARAInfo_t *caraInfo)
 }
 #endif
 
-static void CAReceivedPacketCallback(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
+static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
+                                     const void *data, uint32_t dataLen)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
-    // Call the callback.
     if (g_networkPacketReceivedCallback != NULL)
     {
-        g_networkPacketReceivedCallback(endpoint, data, dataLen);
+        g_networkPacketReceivedCallback(sep, data, dataLen);
     }
     else
     {
index 38b185d..0742377 100644 (file)
@@ -71,8 +71,9 @@ static void CAErrorHandler(const CAEndpoint_t *endpoint,
                            const void *data, uint32_t dataLen,
                            CAResult_t result);
 
-static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void *data,
-                                       CADataType_t dataType);
+static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint,
+                                       const CARemoteId_t *identity,
+                                       const void *data, CADataType_t dataType);
 
 static void CASendErrorInfo(const CAEndpoint_t *endpoint, const CAInfo_t *info,
                             CAResult_t result);
@@ -82,7 +83,7 @@ static void CAProcessReceivedData(CAData_t *data);
 #endif
 static void CADestroyData(void *data, uint32_t size);
 static void CALogPayloadInfo(CAInfo_t *info);
-static bool CADropSecondRequest(const CAEndpoint_t *endpoint, uint16_t messageId);
+static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *endpoint, uint16_t id);
 
 #ifdef WITH_BWT
 void CAAddDataToSendThread(CAData_t *data)
@@ -111,7 +112,7 @@ void CAAddDataToReceiveThread(CAData_t *data)
 static bool CAIsSelectedNetworkAvailable()
 {
     u_arraylist_t *list = CAGetSelectedNetworkList();
-    if (!list || list->length == 0)
+    if (!list || u_arraylist_length(list) == 0)
     {
         OIC_LOG(ERROR, TAG, "No selected network");
         return false;
@@ -120,7 +121,9 @@ static bool CAIsSelectedNetworkAvailable()
     return true;
 }
 
-static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void *data, CADataType_t dataType)
+static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint,
+                                       const CARemoteId_t *identity,
+                                       const void *data, CADataType_t dataType)
 {
     OIC_LOG(DEBUG, TAG, "CAGenerateHandlerData IN");
     CAInfo_t *info = NULL;
@@ -164,6 +167,10 @@ static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void
         }
         cadata->responseInfo = resInfo;
         info = &resInfo->info;
+        if (identity)
+        {
+            info->identity = *identity;
+        }
         OIC_LOG(DEBUG, TAG, "Response Info :");
         CALogPayloadInfo(info);
     }
@@ -188,7 +195,7 @@ static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void
             return NULL;
         }
 
-        if (CADropSecondRequest(endpoint, reqInfo->info.messageId))
+        if (CADropSecondMessage(&caglobals.ca.requestHistory, endpoint, reqInfo->info.messageId))
         {
             OIC_LOG(ERROR, TAG, "Second Request with same Token, Drop it");
             CAFreeEndpoint(ep);
@@ -199,6 +206,10 @@ static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void
 
         cadata->requestInfo = reqInfo;
         info = &reqInfo->info;
+        if (identity)
+        {
+            info->identity = *identity;
+        }
         OIC_LOG(DEBUG, TAG, "Request Info :");
         CALogPayloadInfo(info);
    }
@@ -225,6 +236,10 @@ static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint, const void
 
         cadata->errorInfo = errorInfo;
         info = &errorInfo->info;
+        if (identity)
+        {
+            info->identity = *identity;
+        }
         OIC_LOG(DEBUG, TAG, "error Info :");
         CALogPayloadInfo(info);
     }
@@ -330,7 +345,6 @@ static void CADestroyData(void *data, uint32_t size)
         CADestroyErrorInfoInternal(cadata->errorInfo);
     }
 
-    OICFree(cadata->options);
     OICFree(cadata);
     OIC_LOG(DEBUG, TAG, "CADestroyData OUT");
 }
@@ -548,47 +562,55 @@ static void CASendThreadProcess(void *threadData)
 /*
  * If a second message arrives with the same token and the other address
  * family, drop it.  Typically, IPv6 beats IPv4, so the IPv4 message is dropped.
- * This can be made more robust (for instance, another message could arrive
- * in between), but it is good enough for now.
  */
-static bool CADropSecondRequest(const CAEndpoint_t *endpoint, uint16_t messageId)
+static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *ep, uint16_t id)
 {
-    if (!endpoint)
+    if (!ep)
     {
         return true;
     }
-    if (endpoint->adapter != CA_ADAPTER_IP)
+    if (ep->adapter != CA_ADAPTER_IP)
+    {
+        return false;
+    }
+    if (!caglobals.ip.dualstack)
     {
         return false;
     }
 
     bool ret = false;
-    CATransportFlags_t familyFlags = endpoint->flags & CA_IPFAMILY_MASK;
+    CATransportFlags_t familyFlags = ep->flags & CA_IPFAMILY_MASK;
 
-    if (messageId == caglobals.ca.previousRequestMessageId)
+    for (size_t i = 0; i < sizeof(history->items) / sizeof(history->items[0]); i++)
     {
-        if ((familyFlags ^ caglobals.ca.previousRequestFlags) == CA_IPFAMILY_MASK)
+        CAHistoryItem_t *item = &(history->items[i]);
+        if (id == item->messageId)
         {
-            if (familyFlags & CA_IPV6)
-            {
-                OIC_LOG(INFO, TAG, "IPv6 duplicate response ignored");
-            }
-            else
+            if ((familyFlags ^ item->flags) == CA_IPFAMILY_MASK)
             {
-                OIC_LOG(INFO, TAG, "IPv4 duplicate response ignored");
+                OIC_LOG_V(INFO, TAG, "IPv%c duplicate message ignored",
+                                            familyFlags & CA_IPV6 ? '6' : '4');
+                ret = true;
+                break;
             }
-            ret = true;
         }
     }
-    caglobals.ca.previousRequestFlags = familyFlags;
-    caglobals.ca.previousRequestMessageId = messageId;
+
+    history->items[history->nextIndex].flags = familyFlags;
+    history->items[history->nextIndex].messageId = id;
+    if (++history->nextIndex >= HISTORYSIZE)
+    {
+        history->nextIndex = 0;
+    }
+
     return ret;
 }
 
-static void CAReceivedPacketCallback(const CAEndpoint_t *remoteEndpoint, const void *data, uint32_t dataLen)
+static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
+                                     const void *data, uint32_t dataLen)
 {
     OIC_LOG(DEBUG, TAG, "IN");
-    VERIFY_NON_NULL_VOID(remoteEndpoint, TAG, "remoteEndpoint");
+    VERIFY_NON_NULL_VOID(sep, TAG, "remoteEndpoint");
     VERIFY_NON_NULL_VOID(data, TAG, "data");
 
     uint32_t code = CA_NOT_FOUND;
@@ -604,7 +626,7 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *remoteEndpoint, const v
     OIC_LOG_V(DEBUG, TAG, "code = %d", code);
     if (CA_GET == code || CA_POST == code || CA_PUT == code || CA_DELETE == code)
     {
-        cadata = CAGenerateHandlerData(remoteEndpoint, pdu, CA_REQUEST_DATA);
+        cadata = CAGenerateHandlerData(&(sep->endpoint), &(sep->identity), pdu, CA_REQUEST_DATA);
         if (!cadata)
         {
             OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, CAGenerateHandlerData failed!");
@@ -614,7 +636,7 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *remoteEndpoint, const v
     }
     else
     {
-        cadata = CAGenerateHandlerData(remoteEndpoint, pdu, CA_RESPONSE_DATA);
+        cadata = CAGenerateHandlerData(&(sep->endpoint), &(sep->identity), pdu, CA_RESPONSE_DATA);
         if (!cadata)
         {
             OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, CAGenerateHandlerData failed!");
@@ -652,24 +674,24 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *remoteEndpoint, const v
     CAProcessReceivedData(cadata);
 #else
 #ifdef WITH_BWT
-        if (CA_ADAPTER_GATT_BTLE != remoteEndpoint->adapter)
+    if (CA_ADAPTER_GATT_BTLE != sep->endpoint.adapter)
+    {
+        CAResult_t res = CAReceiveBlockWiseData(pdu, &(sep->endpoint), cadata, dataLen);
+        if (CA_NOT_SUPPORTED == res)
         {
-            CAResult_t res = CAReceiveBlockWiseData(pdu, remoteEndpoint, cadata, dataLen);
-            if (CA_NOT_SUPPORTED == res)
-            {
-                OIC_LOG(ERROR, TAG, "this message does not have block option");
-                CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
-            }
-            else
-            {
-                CADestroyData(cadata, sizeof(CAData_t));
-            }
+            OIC_LOG(ERROR, TAG, "this message does not have block option");
+            CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
         }
         else
-#endif
         {
-            CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
+            CADestroyData(cadata, sizeof(CAData_t));
         }
+    }
+    else
+#endif
+    {
+        CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
+    }
 #endif
 
     coap_delete_pdu(pdu);
@@ -746,7 +768,6 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
                                    CADataType_t dataType)
 {
     OIC_LOG(DEBUG, TAG, "CAPrepareSendData IN");
-    CAInfo_t *info = NULL;
 
     CAData_t *cadata = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
     if (!cadata)
@@ -768,7 +789,6 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
         }
 
         cadata->type = request->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
-        info = &request->info;
         cadata->requestInfo =  request;
     }
     else if(CA_RESPONSE_DATA == dataType)
@@ -784,7 +804,6 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
         }
 
         cadata->type = SEND_TYPE_UNICAST;
-        info = &response->info;
         cadata->responseInfo = response;
     }
     else
@@ -794,25 +813,6 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
         return NULL;
     }
 
-    if (NULL != info->options && 0 < info->numOptions)
-    {
-        uint8_t numOptions = info->numOptions;
-        // copy data
-        CAHeaderOption_t *headerOption = (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t)
-                                                                        * numOptions);
-        if(!headerOption)
-        {
-            OIC_LOG(ERROR, TAG, "memory allocation failed");
-            CADestroyData(cadata, sizeof(CAData_t));
-            return NULL;
-        }
-
-        memcpy(headerOption, info->options, sizeof(CAHeaderOption_t) * numOptions);
-
-        cadata->options = headerOption;
-        cadata->numOptions = numOptions;
-    }
-
     CAEndpoint_t* ep = CACloneEndpoint(endpoint);
     if (!ep)
     {
@@ -1149,7 +1149,7 @@ static void CALogPayloadInfo(CAInfo_t *info)
 {
     if(info)
     {
-        if (!info->options)
+        if (info->options)
         {
             for (uint32_t i = 0; i < info->numOptions; i++)
             {
@@ -1159,13 +1159,13 @@ static void CALogPayloadInfo(CAInfo_t *info)
             }
         }
 
-        if (!info->payload)
+        if (info->payload)
         {
             OIC_LOG_V(DEBUG, TAG, "payload: %p(%u)", info->payload,
                       info->payloadSize);
         }
 
-        if (!info->token)
+        if (info->token)
         {
             OIC_LOG(DEBUG, TAG, "token:");
             OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *) info->token,
@@ -1200,7 +1200,7 @@ void CAErrorHandler(const CAEndpoint_t *endpoint,
         return;
     }
 
-    CAData_t *cadata = CAGenerateHandlerData(endpoint, pdu, CA_ERROR_DATA);
+    CAData_t *cadata = CAGenerateHandlerData(endpoint, NULL, pdu, CA_ERROR_DATA);
     if(!cadata)
     {
         OIC_LOG(ERROR, TAG, "CAErrorHandler, CAGenerateHandlerData failed!");
index 01e9d4d..d36d378 100644 (file)
@@ -50,7 +50,7 @@ CAResult_t CAAddNetworkType(CATransportAdapter_t transportType)
             return CA_MEMORY_ALLOC_FAILED;
         }
     }
-    CAResult_t res = CA_STATUS_OK;
+    bool res = true;
     switch (transportType)
     {
         case CA_ADAPTER_IP:
@@ -111,15 +111,15 @@ CAResult_t CAAddNetworkType(CATransportAdapter_t transportType)
             break;
     }
 
-    if (CA_STATUS_OK != res)
+    if (!res)
     {
         OIC_LOG_V(ERROR, TAG, "Add arraylist failed[Err code: %d]", res);
-        return res;
+        return CA_STATUS_FAILED;
     }
     // start selected interface adapter
-    res = CAStartAdapter(transportType);
+    CAResult_t result = CAStartAdapter(transportType);
     OIC_LOG(DEBUG, TAG, "OUT");
-    return res;
+    return result;
 
 exit:
     OIC_LOG(DEBUG, TAG, "This adapter is already enabled");
index a418a03..b140264 100644 (file)
@@ -229,6 +229,14 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode)
         return NULL;
     }
 
+    if (outpdu->hdr->version != COAP_DEFAULT_VERSION)
+    {
+        OIC_LOG_V(ERROR, TAG, "coap version is not available : %d",
+                  outpdu->hdr->version);
+        coap_delete_pdu(outpdu);
+        return NULL;
+    }
+
     if (outCode)
     {
         (*outCode) = (uint32_t) CA_RESPONSE_CODE(outpdu->hdr->code);
old mode 100644 (file)
new mode 100755 (executable)
index b15502c..7896334
 #include "logger.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
+#include "org_iotivity_ca_CaIpInterface.h"
 
 #define TAG "IP_MONITOR"
 
-char *getHostIPAddress(const char *ifa_name) {
-    static char address[INET_ADDRSTRLEN] = {};
-    memset(&address, 0, INET_ADDRSTRLEN);
-    struct ifreq ifr;
-    int sck, status, len = sizeof(ifr.ifr_name) - 1;
-    char *ip;
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+                                         uint32_t addr, int flags);
 
-    if ((sck = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+static CAResult_t CAAddInterfaceItem(u_arraylist_t *iflist, int index,
+                            const char *name, int family, uint32_t addr, int flags);
+
+CAResult_t CAIPJniInit();
+
+#define MAX_INTERFACE_INFO_LENGTH 1024 // allows 32 interfaces from SIOCGIFCONF
+
+CAResult_t CAIPInitializeNetworkMonitor()
+{
+    return CAIPJniInit();
+}
+
+CAResult_t CAIPTerminateNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+int CAGetPollingInterval(int interval)
+{
+    return interval;
+}
+
+CAInterface_t *CAFindInterfaceChange()
+{
+    char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
+    struct ifconf ifc  = { .ifc_len = MAX_INTERFACE_INFO_LENGTH, .ifc_buf = buf };
+
+    int s = caglobals.ip.u6.fd != -1 ? caglobals.ip.u6.fd : caglobals.ip.u4.fd;
+    if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
+    {
+        OIC_LOG_V(ERROR, TAG, "SIOCGIFCONF failed: %s", strerror(errno));
         return NULL;
     }
 
-    strncpy(ifr.ifr_name, ifa_name, len);
-    ifr.ifr_name[len] = '\0';
-    if ((status = ioctl(sck, SIOCGIFADDR, &ifr)) < 0) {
-        close(sck);
+    CAInterface_t *foundNewInterface = NULL;
+
+    struct ifreq* ifr = ifc.ifc_req;
+    size_t interfaces = ifc.ifc_len / sizeof (ifc.ifc_req[0]);
+    size_t ifreqsize = ifc.ifc_len;
+
+    CAIfItem_t *previous = (CAIfItem_t *)OICMalloc(ifreqsize);
+    if (!previous)
+    {
+        OIC_LOG(ERROR, TAG, "OICMalloc failed");
         return NULL;
     }
-    close(sck);
-    ip = inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr);
-    len = sizeof(address) - 1;
-    strncpy(address, ip, len);
-    address[len] = '\0';
-    return address;
-}
 
-u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
-{
-    if (desiredIndex < 0)
+    memcpy(previous, caglobals.ip.nm.ifItems, ifreqsize);
+    size_t numprevious = caglobals.ip.nm.numIfItems;
+
+    if (ifreqsize > caglobals.ip.nm.sizeIfItems)
     {
-        OIC_LOG_V(ERROR, TAG, "invalid index : %d", desiredIndex);
-        return NULL;
+
+        CAIfItem_t *items = (CAIfItem_t *)OICRealloc(caglobals.ip.nm.ifItems, ifreqsize);
+        if (!items)
+        {
+            OIC_LOG(ERROR, TAG, "OICRealloc failed");
+            OICFree(previous);
+            return NULL;
+        }
+        caglobals.ip.nm.ifItems = items;
+        caglobals.ip.nm.sizeIfItems = ifreqsize;
     }
 
+    caglobals.ip.nm.numIfItems = 0;
+    for (size_t i = 0; i < interfaces; i++)
+    {
+        struct ifreq* item = &ifr[i];
+        char *name = item->ifr_name;
+        struct sockaddr_in *sa4 = (struct sockaddr_in *)&item->ifr_addr;
+        uint32_t ipv4addr = sa4->sin_addr.s_addr;
+
+        if (ioctl(s, SIOCGIFFLAGS, item) < 0)
+        {
+            OIC_LOG_V(ERROR, TAG, "SIOCGIFFLAGS failed: %s", strerror(errno));
+            continue;
+        }
+        int16_t flags = item->ifr_flags;
+        if ((flags & IFF_LOOPBACK) || !(flags & IFF_RUNNING))
+        {
+            continue;
+        }
+        if (ioctl(s, SIOCGIFINDEX, item) < 0)
+        {
+            OIC_LOG_V(ERROR, TAG, "SIOCGIFINDEX failed: %s", strerror(errno));
+            continue;
+        }
+
+        int ifIndex = item->ifr_ifindex;
+        caglobals.ip.nm.ifItems[i].ifIndex = ifIndex;  // refill interface list
+        caglobals.ip.nm.numIfItems++;
+
+        if (foundNewInterface)
+        {
+            continue;   // continue updating interface list
+        }
+
+        // see if this interface didn't previously exist
+        bool found = false;
+        for (size_t j = 0; j < numprevious; j++)
+        {
+            if (ifIndex == previous[j].ifIndex)
+            {
+                found = true;
+                break;
+            }
+        }
+        if (found)
+        {
+            OIC_LOG_V(INFO, TAG, "Interface found: %s", name);
+            continue;
+        }
+
+        foundNewInterface = CANewInterfaceItem(ifIndex, name, AF_INET, ipv4addr, flags);
+    }
+
+    OICFree(previous);
+    return foundNewInterface;
+}
+
+u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
+{
     u_arraylist_t *iflist = u_arraylist_create();
     if (!iflist)
     {
@@ -78,34 +171,81 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
         return NULL;
     }
 
-    char* ipAddr = getHostIPAddress("wlan0");
-    if (NULL == ipAddr)
+    char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
+    struct ifconf ifc = { .ifc_len = MAX_INTERFACE_INFO_LENGTH, .ifc_buf = buf };
+
+    int s = caglobals.ip.u6.fd != -1 ? caglobals.ip.u6.fd : caglobals.ip.u4.fd;
+    if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
     {
-        OIC_LOG_V(ERROR, TAG, "Failed to get ifaddrs: %s", strerror(errno));
+        OIC_LOG_V(ERROR, TAG, "SIOCGIFCONF failed: %s", strerror(errno));
         u_arraylist_destroy(iflist);
         return NULL;
     }
-    OIC_LOG_V(DEBUG, TAG, "Got ifaddrs:: %s", ipAddr);
 
-    struct in_addr inaddr;
-    inet_pton(AF_INET, ipAddr, &(inaddr));
+    struct ifreq* ifr = ifc.ifc_req;
+    size_t interfaces = ifc.ifc_len / sizeof (ifc.ifc_req[0]);
+    size_t ifreqsize = ifc.ifc_len;
 
-    CAInterface_t *ifitem = (CAInterface_t *)OICCalloc(1, sizeof(CAInterface_t));;
-    OICStrcpy(ifitem->name, INTERFACE_NAME_MAX, "wlan0");
-    ifitem->index = 0; //if_nametoindex("wlan0");
-    ifitem->family = AF_INET; //we support ipv4 only
-    ifitem->ipv4addr = inaddr.s_addr;
-    ifitem->flags = IFF_UP|IFF_RUNNING;
-
-    CAResult_t result = u_arraylist_add(iflist, ifitem);
-    if (CA_STATUS_OK != result)
+    if (ifreqsize > caglobals.ip.nm.sizeIfItems)
     {
-        OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
-        goto exit;
+        CAIfItem_t *items = (CAIfItem_t *)OICRealloc(caglobals.ip.nm.ifItems, ifreqsize);
+        if (!items)
+        {
+            OIC_LOG(ERROR, TAG, "OICRealloc failed");
+            goto exit;
+        }
+        caglobals.ip.nm.ifItems = items;
+        caglobals.ip.nm.sizeIfItems = ifreqsize;
     }
 
-    OIC_LOG_V(ERROR, TAG, "Added interface: %s (%d)", ifitem->name, ifitem->family);
+    caglobals.ip.nm.numIfItems = 0;
+    for (size_t i = 0; i < interfaces; i++)
+    {
+        CAResult_t result = CA_STATUS_OK;
+        struct ifreq* item = &ifr[i];
+        char *name = item->ifr_name;
+        struct sockaddr_in *sa4 = (struct sockaddr_in *)&item->ifr_addr;
+        uint32_t ipv4addr = sa4->sin_addr.s_addr;
+
+        if (ioctl(s, SIOCGIFFLAGS, item) < 0)
+        {
+            OIC_LOG_V(ERROR, TAG, "SIOCGIFFLAGS failed: %s", strerror(errno));
+            continue;
+        }
+        int16_t flags = item->ifr_flags;
+        if ((flags & IFF_LOOPBACK) || !(flags & IFF_RUNNING))
+        {
+            continue;
+        }
+        if (ioctl(s, SIOCGIFINDEX, item) < 0)
+        {
+            OIC_LOG_V(ERROR, TAG, "SIOCGIFINDEX failed: %s", strerror(errno));
+            continue;
+        }
+
+        int ifindex = item->ifr_ifindex;
+        caglobals.ip.nm.ifItems[i].ifIndex = ifindex;
+        caglobals.ip.nm.numIfItems++;
+
+        if (desiredIndex && (ifindex != desiredIndex))
+        {
+            continue;
+        }
 
+        // Add IPv4 interface
+        result = CAAddInterfaceItem(iflist, ifindex, name, AF_INET, ipv4addr, flags);
+        if (CA_STATUS_OK != result)
+        {
+            goto exit;
+        }
+
+        // Add IPv6 interface
+        result = CAAddInterfaceItem(iflist, ifindex, name, AF_INET6, ipv4addr, flags);
+        if (CA_STATUS_OK != result)
+        {
+            goto exit;
+        }
+    }
     return iflist;
 
 exit:
@@ -113,3 +253,131 @@ exit:
     return NULL;
 }
 
+static CAResult_t CAAddInterfaceItem(u_arraylist_t *iflist, int index,
+                            const char *name, int family, uint32_t addr, int flags)
+{
+    CAInterface_t *ifitem = CANewInterfaceItem(index, name, family, addr, flags);
+    if (!ifitem)
+    {
+        return CA_STATUS_FAILED;
+    }
+    bool result = u_arraylist_add(iflist, ifitem);
+    if (!result)
+    {
+        OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+        OICFree(ifitem);
+        return CA_STATUS_FAILED;
+    }
+
+    return CA_STATUS_OK;
+}
+
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+                                         uint32_t addr, int flags)
+{
+    CAInterface_t *ifitem = (CAInterface_t *)OICCalloc(1, sizeof (CAInterface_t));
+    if (!ifitem)
+    {
+        OIC_LOG(ERROR, TAG, "Malloc failed");
+        return NULL;
+    }
+
+    OICStrcpy(ifitem->name, sizeof (ifitem->name), name);
+    ifitem->index = index;
+    ifitem->family = family;
+    ifitem->ipv4addr = addr;
+    ifitem->flags = flags;
+
+    return ifitem;
+}
+
+CAResult_t CAIPJniInit()
+{
+    OIC_LOG(DEBUG, TAG, "CAIPJniInit_IN");
+
+    JavaVM *jvm = CANativeJNIGetJavaVM();
+    if (!jvm)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get JavaVM pointer");
+        return CA_STATUS_FAILED;
+    }
+
+    jobject context = CANativeJNIGetContext();
+    if (!context)
+    {
+        OIC_LOG(ERROR, TAG, "unable to get application context");
+        return CA_STATUS_FAILED;
+    }
+
+    JNIEnv* env;
+    if ((*jvm)->GetEnv(jvm, (void**) &env, JNI_VERSION_1_6) != JNI_OK)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get JNIEnv pointer");
+        return CA_STATUS_FAILED;
+    }
+
+    jclass cls_Context = (*env)->FindClass(env, "android/content/Context");
+    if (!cls_Context)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get context object class");
+        return CA_STATUS_FAILED;
+    }
+
+    jmethodID mid_getApplicationContext = (*env)->GetMethodID(env, cls_Context,
+                                                                "getApplicationContext",
+                                                                "()Landroid/content/Context;");
+    if (!mid_getApplicationContext)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
+        return CA_STATUS_FAILED;
+    }
+
+    jobject jApplicationContext = (*env)->CallObjectMethod(env, context,
+                                                           mid_getApplicationContext);
+    if (!jApplicationContext)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get application context");
+        return CA_STATUS_FAILED;
+    }
+
+    jclass cls_CaIpInterface = (*env)->FindClass(env, "org/iotivity/ca/CaIpInterface");
+    if (!cls_CaIpInterface)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get CaIpInterface class");
+        return CA_STATUS_FAILED;
+    }
+
+    jmethodID mid_CaIpInterface_ctor = (*env)->GetMethodID(env, cls_CaIpInterface, "<init>",
+                                                                   "(Landroid/content/Context;)V");
+    if (!mid_CaIpInterface_ctor)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get CaIpInterface constructor method");
+        return CA_STATUS_FAILED;
+    }
+
+    (*env)->NewObject(env, cls_CaIpInterface, mid_CaIpInterface_ctor, jApplicationContext);
+    OIC_LOG(DEBUG, TAG, "Create CaIpInterface instance, success");
+
+    OIC_LOG(DEBUG, TAG, "CAIPJniInit_OUT");
+    return CA_STATUS_OK;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *env, jclass class)
+{
+    (void)env;
+    (void)class;
+    OIC_LOG(DEBUG, TAG, "caIpStateEnabled");
+
+    CAWakeUpForChange();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class)
+{
+    (void)env;
+    (void)class;
+    OIC_LOG(DEBUG, TAG, "caIpStateDisabled");
+
+    CAIPGetInterfaceInformation(0);
+}
index 243f328..06fca45 100644 (file)
 // defined & used (as-is defined in the linux socket headers).
 #define AF_INET (2)
 
+CAResult_t CAIPInitializeNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+CAResult_t CAIPTerminateNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
 /// Retrieves the IP address assigned to Arduino Ethernet shield
 void CAArduinoGetInterfaceAddress(uint32_t *address)
 {
@@ -64,7 +74,7 @@ void CAArduinoGetInterfaceAddress(uint32_t *address)
 
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
 {
-    CAResult_t result;
+    bool result = true;
 
     u_arraylist_t *iflist = u_arraylist_create();
     if (!iflist)
@@ -88,7 +98,7 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
     CAArduinoGetInterfaceAddress(&ifitem->ipv4addr);
 
     result = u_arraylist_add(iflist, ifitem);
-    if (CA_STATUS_OK != result)
+    if (!result)
     {
         OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
         goto exit;
index 92acb32..f35de3c 100644 (file)
 // defined & used (as-is defined in the linux socket headers).
 #define AF_INET (2)
 
+CAResult_t CAIPInitializeNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+CAResult_t CAIPTerminateNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
 /// Retrieves the IP address assigned to Arduino WiFi shield
 void CAArduinoGetInterfaceAddress(uint32_t *address)
 {
@@ -68,7 +78,7 @@ void CAArduinoGetInterfaceAddress(uint32_t *address)
 
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
 {
-    CAResult_t result = CA_STATUS_OK;
+    bool result = true;
 
     u_arraylist_t *iflist = u_arraylist_create();
     if (!iflist)
@@ -92,7 +102,7 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
     CAArduinoGetInterfaceAddress(&ifitem->ipv4addr);
 
     result = u_arraylist_add(iflist, ifitem);
-    if (CA_STATUS_OK != result)
+    if (!result)
     {
         OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
         goto exit;
index 099e6d3..74a51f6 100644 (file)
@@ -194,12 +194,10 @@ void CAPacketReceivedCallback(const char *ipAddress, const uint16_t port,
     OIC_LOG(DEBUG, TAG, "IN");
     if (g_packetReceivedCallback)
     {
-        CAEndpoint_t ep;
-        strncpy(ep.addr, ipAddress, MAX_ADDR_STR_SIZE_CA);
-        ep.port = port;
-        ep.flags = CA_IPV4;
-        ep.adapter = CA_ADAPTER_IP;
-        g_packetReceivedCallback(&ep, data, dataLength);
+        CASecureEndpoint_t sep =
+        {.endpoint = {.adapter = CA_ADAPTER_IP, .flags = CA_IPV4, .port = port}};
+        OICStrcpy(sep.endpoint.addr, sizeof(sep.endpoint.addr), ipAddress);
+        g_packetReceivedCallback(&sep, data, dataLength);
     }
     OIC_LOG(DEBUG, TAG, "OUT");
 }
index 0086b22..d537adc 100644 (file)
@@ -181,12 +181,11 @@ void CAPacketReceivedCallback(const char *ipAddress, const uint16_t port,
     OIC_LOG(DEBUG, TAG, "IN");
     if (gPacketReceivedCallback)
     {
-        CAEndpoint_t ep;
-        strncpy(ep.addr, ipAddress, MAX_ADDR_STR_SIZE_CA);
-        ep.port = port;
-        ep.flags = CA_IPV4;
-        ep.adapter = CA_ADAPTER_IP;
-        gPacketReceivedCallback(&ep, data, dataLength);
+        CASecureEndpoint_t sep =
+        {.endpoint = {.adapter = CA_ADAPTER_IP, .flags = CA_IPV4, .port = port}};
+
+        OICStrcpy(sep.endpoint.addr, sizeof(sep.endpoint.addr), ipAddress);
+        gPacketReceivedCallback(&sep, data, dataLength);
         OIC_LOG(DEBUG, TAG, "Notified network packet");
     }
     OIC_LOG(DEBUG, TAG, "OUT");
index 1579c03..f2ba419 100644 (file)
@@ -75,7 +75,7 @@ static CANetworkChangeCallback g_networkChangeCallback = NULL;
  */
 static CAErrorHandleCallback g_errorCallback = NULL;
 
-static void CAIPPacketReceivedCB(const CAEndpoint_t *endpoint,
+static void CAIPPacketReceivedCB(const CASecureEndpoint_t *endpoint,
                                  const void *data, uint32_t dataLength);
 #ifdef __WITH_DTLS__
 static void CAIPPacketSendCB(CAEndpoint_t *endpoint,
@@ -164,19 +164,20 @@ static void CAIPPacketSendCB(CAEndpoint_t *endpoint, const void *data, uint32_t
 }
 #endif
 
-void CAIPPacketReceivedCB(const CAEndpoint_t *endpoint, const void *data,
+
+void CAIPPacketReceivedCB(const CASecureEndpoint_t *sep, const void *data,
                           uint32_t dataLength)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
-    VERIFY_NON_NULL_VOID(endpoint, TAG, "ipAddress is NULL");
+    VERIFY_NON_NULL_VOID(sep, TAG, "sep is NULL");
     VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");
 
-    OIC_LOG_V(DEBUG, TAG, "Address: %s, port:%d", endpoint->addr, endpoint->port);
+    OIC_LOG_V(DEBUG, TAG, "Address: %s, port:%d", sep->endpoint.addr, sep->endpoint.port);
 
     if (g_networkPacketCallback)
     {
-        g_networkPacketCallback(endpoint, data, dataLength);
+        g_networkPacketCallback(sep, data, dataLength);
     }
     OIC_LOG(DEBUG, TAG, "OUT");
 }
@@ -239,6 +240,7 @@ static void CAInitializeIPGlobals()
     }
     caglobals.ip.ipv6enabled = flags & CA_IPV6;
     caglobals.ip.ipv4enabled = flags & CA_IPV4;
+    caglobals.ip.dualstack = caglobals.ip.ipv6enabled && caglobals.ip.ipv4enabled;
 }
 
 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
@@ -262,6 +264,7 @@ CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
     caglobals.ip.threadpool = handle;
 
     CAIPSetPacketReceiveCallback(CAIPPacketReceivedCB);
+    CAIPInitializeNetworkMonitor();
 #ifdef __WITH_DTLS__
     CAAdapterNetDtlsInit();
 
@@ -425,6 +428,8 @@ void CATerminateIP()
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
+    CAIPTerminateNetworkMonitor();
+
 #ifdef __WITH_DTLS__
     CADTLSSetAdapterCallbacks(NULL, NULL, 0);
 #endif
index 3568b65..6ead6a4 100644 (file)
 
 #include "caipinterface.h"
 
-#ifndef __APPLE__
-#include <asm/types.h>
-#else
-    #ifndef IPV6_ADD_MEMBERSHIP
-        #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
-    #endif
-#endif
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <stdio.h>
@@ -106,6 +99,7 @@ static void CAHandleNetlink();
 static void CAApplyInterfaces();
 static void CAFindReadyMessage();
 static void CASelectReturned(fd_set *readFds, int ret);
+static void CAProcessNewInterface(CAInterface_t *ifchanged);
 static CAResult_t CAReceiveMessage(int fd, CATransportFlags_t flags);
 
 #define SET(TYPE, FDS) \
@@ -203,6 +197,11 @@ static void CASelectReturned(fd_set *readFds, int ret)
         }
         else
         {
+            CAInterface_t *ifchanged = CAFindInterfaceChange();
+            if (ifchanged)
+            {
+                CAProcessNewInterface(ifchanged);
+            }
             break;
         }
 
@@ -230,20 +229,20 @@ static CAResult_t CAReceiveMessage(int fd, CATransportFlags_t flags)
         return CA_STATUS_FAILED;
     }
 
-    CAEndpoint_t ep = { .adapter = CA_ADAPTER_IP,
-                        .flags = flags };
+    CASecureEndpoint_t sep =
+    {.endpoint = {.adapter = CA_ADAPTER_IP, .flags = flags}};
 
     if (flags & CA_IPV6)
     {
-        ep.interface = ((struct sockaddr_in6 *)&srcAddr)->sin6_scope_id;
+        sep.endpoint.interface = ((struct sockaddr_in6 *)&srcAddr)->sin6_scope_id;
         ((struct sockaddr_in6 *)&srcAddr)->sin6_scope_id = 0;
     }
-    CAConvertAddrToName(&srcAddr, ep.addr, &ep.port);
+    CAConvertAddrToName(&srcAddr, sep.endpoint.addr, &sep.endpoint.port);
 
     if (flags & CA_SECURE)
     {
 #ifdef __WITH_DTLS__
-        int ret = CAAdapterNetDtlsDecrypt(&ep, (uint8_t *)recvBuffer, recvLen);
+        int ret = CAAdapterNetDtlsDecrypt(&sep, (uint8_t *)recvBuffer, recvLen);
         OIC_LOG_V(DEBUG, TAG, "CAAdapterNetDtlsDecrypt returns [%d]", ret);
 #else
         OIC_LOG(ERROR, TAG, "Encrypted message but no DTLS");
@@ -253,7 +252,7 @@ static CAResult_t CAReceiveMessage(int fd, CATransportFlags_t flags)
     {
         if (g_packetReceivedCallback)
         {
-            g_packetReceivedCallback(&ep, recvBuffer, recvLen);
+            g_packetReceivedCallback(&sep, recvBuffer, recvLen);
         }
     }
 
@@ -473,6 +472,8 @@ CAResult_t CAIPStartServer(const ca_thread_pool_t threadPool)
     // create source of network interface change notifications
     CAInitializeNetlink();
 
+    caglobals.ip.selectTimeout = CAGetPollingInterval(caglobals.ip.selectTimeout);
+
     CAApplyInterfaces();
 
     caglobals.ip.terminate = false;
@@ -507,6 +508,14 @@ void CAIPStopServer()
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
+void CAWakeUpForChange()
+{
+    if (caglobals.ip.shutdownFds[1] != -1)
+    {
+        write(caglobals.ip.shutdownFds[1], "w", 1);
+    }
+}
+
 static void applyMulticastToInterface4(struct in_addr inaddr)
 {
     if (!caglobals.ip.ipv4enabled)
@@ -537,7 +546,7 @@ static void applyMulticast6(int fd, struct in6_addr *addr, uint32_t interface)
     struct ipv6_mreq mreq;
     mreq.ipv6mr_multiaddr = *addr;
     mreq.ipv6mr_interface = interface;
-    if (setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq, sizeof (mreq)))
+    if (setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof (mreq)))
     {
         if (EADDRINUSE != errno)
         {
@@ -609,74 +618,81 @@ static void CAApplyInterfaces()
     u_arraylist_destroy(iflist);
 }
 
+static void CAProcessNewInterface(CAInterface_t *ifitem)
+{
+    applyMulticastToInterface6(ifitem->index);
+    struct in_addr inaddr;
+    inaddr.s_addr = ifitem->ipv4addr;
+    applyMulticastToInterface4(inaddr);
+}
+
 static void CAHandleNetlink()
 {
 #ifdef __linux__
     char buf[4096];
     struct nlmsghdr *nh;
     struct sockaddr_nl sa;
-    struct iovec iov = { buf, sizeof(buf) };
-    struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
+    struct iovec iov = { buf, sizeof (buf) };
+    struct msghdr msg = { (void *)&sa, sizeof (sa), &iov, 1, NULL, 0, 0 };
 
     size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
 
     for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
     {
-        if (nh->nlmsg_type == RTM_NEWLINK)
+        if (nh->nlmsg_type != RTM_NEWLINK)
         {
-            struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
-            if ((ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING))
-            {
-                continue;
-            }
+            continue;
+        }
+
+        struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
+        if (!ifi || (ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING))
+        {
+            continue;
+        }
 
-            int newIndex = ifi->ifi_index;
+        int newIndex = ifi->ifi_index;
 
-            u_arraylist_t *iflist = CAIPGetInterfaceInformation(newIndex);
-            if (!iflist)
+        u_arraylist_t *iflist = CAIPGetInterfaceInformation(newIndex);
+        if (!iflist)
+        {
+            OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
+            return;
+        }
+
+        uint32_t listLength = u_arraylist_length(iflist);
+        for (uint32_t i = 0; i < listLength; i++)
+        {
+            CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
+            if (!ifitem)
             {
-                OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
-                return;
+                continue;
             }
 
-            uint32_t listLength = u_arraylist_length(iflist);
-            for (uint32_t i = 0; i < listLength; i++)
+            if ((int)ifitem->index != newIndex)
             {
-                CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
-                if (!ifitem)
-                {
-                    continue;
-                }
-
-                if ((int)ifitem->index != newIndex)
-                {
-                    continue;
-                }
-
-                applyMulticastToInterface6(newIndex);
-                struct in_addr inaddr;
-                inaddr.s_addr = ifitem->ipv4addr;
-                applyMulticastToInterface4(inaddr);
-                break; // we found the one we were looking for
+                continue;
             }
-            u_arraylist_destroy(iflist);
+
+            CAProcessNewInterface(ifitem);
+            break; // we found the one we were looking for
         }
+        u_arraylist_destroy(iflist);
     }
 #endif // __linux__
 }
 
 void CAIPSetPacketReceiveCallback(CAIPPacketReceivedCallback callback)
 {
-OIC_LOG(DEBUG, TAG, "IN");
+    OIC_LOG(DEBUG, TAG, "IN");
 
-g_packetReceivedCallback = callback;
+    g_packetReceivedCallback = callback;
 
-OIC_LOG(DEBUG, TAG, "OUT");
+    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 void CAIPSetExceptionCallback(CAIPExceptionCallback callback)
 {
-OIC_LOG(DEBUG, TAG, "IN");
+    OIC_LOG(DEBUG, TAG, "IN");
 
     g_exceptionCallback = callback;
 
index a5fb789..fd889ee 100644 (file)
 
 #define TAG "IP_MONITOR"
 
+CAResult_t CAIPInitializeNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+CAResult_t CAIPTerminateNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+int CAGetPollingInterval(int interval)
+{
+    return interval;
+}
+
+CAInterface_t *CAFindInterfaceChange()
+{
+    return NULL;
+}
+
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
 {
     if (desiredIndex < 0)
@@ -111,8 +131,8 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
         ifitem->ipv4addr = ((struct sockaddr_in *)(ifa->ifa_addr))->sin_addr.s_addr;
         ifitem->flags = ifa->ifa_flags;
 
-        CAResult_t result = u_arraylist_add(iflist, ifitem);
-        if (CA_STATUS_OK != result)
+        bool result = u_arraylist_add(iflist, ifitem);
+        if (!result)
         {
             OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
             goto exit;
index 90e200f..b81b357 100644 (file)
 
 #define TAG "IP_MONITOR"
 
+CAResult_t CAIPInitializeNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+CAResult_t CAIPTerminateNetworkMonitor()
+{
+    return CA_STATUS_OK;
+}
+
+int CAGetPollingInterval(int interval)
+{
+    return interval;
+}
+
+CAInterface_t *CAFindInterfaceChange()
+{
+    return NULL;
+}
+
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
 {
     u_arraylist_t *iflist = u_arraylist_create();
@@ -92,8 +112,8 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
         ifitem->ipv4addr = ((struct sockaddr_in *)(ifa->ifa_addr))->sin_addr.s_addr;
         ifitem->flags = ifa->ifa_flags;
 
-        CAResult_t result = u_arraylist_add(iflist, ifitem);
-        if (CA_STATUS_OK != result)
+        bool result = u_arraylist_add(iflist, ifitem);
+        if (!result)
         {
             OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
             goto exit;
diff --git a/resource/csdk/doc/CCF Lite GIT Repo Layout.docx b/resource/csdk/doc/CCF Lite GIT Repo Layout.docx
deleted file mode 100644 (file)
index 0020cc5..0000000
Binary files a/resource/csdk/doc/CCF Lite GIT Repo Layout.docx and /dev/null differ
index ddccc55..48e7bfc 100644 (file)
@@ -73,7 +73,7 @@ void SRMRequestHandler(const CAEndpoint_t *endPoint, const CARequestInfo_t *requ
 
     // Copy the subjectID
     OicUuid_t subjectId = {.id = {0}};
-    memcpy(subjectId.id, endPoint->identity.id, sizeof(subjectId.id));
+    memcpy(subjectId.id, requestInfo->info.identity.id, sizeof(subjectId.id));
 
     //Check the URI has the query and skip it before checking the permission
     char *uri = strstr(requestInfo->info.resourceUri, "?");
index 5f602ff..839fd73 100644 (file)
@@ -377,17 +377,15 @@ typedef struct
     /** transport modifiers.*/
     OCTransportFlags        flags;
 
+    /** for IP.*/
+    uint16_t                port;
+
     /** address for all adapters.*/
     char                    addr[MAX_ADDR_STR_SIZE];
 
     /** usually zero for default interface.*/
     uint32_t                interface;
 
-    /** for IP.*/
-    uint16_t                port;
-
-    /** secure node identity.*/
-    OCIdentity              identity;
 } OCDevAddr;
 
 /**
@@ -1029,6 +1027,9 @@ typedef struct
     /** backward compatibility.*/
     OCConnectivityType connType;
 
+    /** the security identity of the remote server.*/
+    OCIdentity identity;
+
     /** the is the result of our stack, OCStackResult should contain coap/other error codes.*/
     OCStackResult result;
 
index bc37c05..5b551bb 100644 (file)
 
 Import('env')
 
+transport = env.get('TARGET_TRANSPORT')
+if 'BLE' in transport:
+        # Only supported for ethernet and WiFi.
+        Return()
+
 arduino_simplecs_env = env.Clone()
 ######################################################################
 # Build flags
index 533436a..5faaccd 100644 (file)
 #include "payload_logging.h"
 
 // Tracking user input
-static int UNICAST_DISCOVERY = 0;
-static int TEST_CASE = 0;
-static int CONNECTIVITY = 0;
+static int UnicastDiscovery = 0;
+static int TestCase = 0;
+static int Connectivity = 0;
 
-static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s/oic/d";
-static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oic/d";
-static const char * UNICAST_PLATFORM_DISCOVERY_QUERY = "coap://%s/oic/p";
-static const char * MULTICAST_PLATFORM_DISCOVERY_QUERY = "/oic/p";
+static const char *DEVICE_DISCOVERY_QUERY = "%s/oic/d";
+static const char *PLATFORM_DISCOVERY_QUERY = "%s/oic/p";
+static const char *RESOURCE_DISCOVERY_QUERY = "%s/oic/res";
 
-static const char * UNICAST_RESOURCE_DISCOVERY_QUERY = "coap://%s/oic/res";
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
 //The following variable determines the interface protocol (IPv4, IPv6, etc)
-//to be used for sending unicast messages. Default set to IPv4.
-static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
-static std::string coapServerIP = "255.255.255.255";
-static std::string coapServerPort = "5683";
+//to be used for sending unicast messages. Default set to IP dual stack.
+static OCConnectivityType ConnType = CT_ADAPTER_IP;
+static OCDevAddr serverAddr;
+static char discoveryAddr[100];
 static std::string coapServerResource = "/a/light";
-// Size to hold IPV4_ADDRESS:PORT
-static const int IPV4_ADDR_SIZE = 24;
-//Use ipv4addr for both InitDiscovery and InitPlatformOrDeviceDiscovery
-char ipv4addr[IPV4_ADDR_SIZE];
+
 void StripNewLineChar(char* str);
 
 // The handle for the observe registration
@@ -82,7 +76,7 @@ OCPayload* putPayload()
 {
     OCRepPayload* payload = OCRepPayloadCreate();
 
-    if(!payload)
+    if (!payload)
     {
         std::cout << "Failed to create put payload object"<<std::endl;
         std::exit(1);
@@ -134,6 +128,7 @@ static void PrintUsage()
 }
 
 OCStackResult InvokeOCDoResource(std::ostringstream &query,
+                                 OCDevAddr *remoteAddr,
                                  OCMethod method,
                                  OCQualityOfService qos,
                                  OCClientResponseHandler cb,
@@ -148,9 +143,9 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    ret = OCDoResource(&handle, method, query.str().c_str(), 0,
+    ret = OCDoResource(&handle, method, query.str().c_str(), remoteAddr,
                        (method == OC_REST_PUT) ? putPayload() : NULL,
-                       (OC_CONNTYPE), qos, &cbData, options, numOptions);
+                       (ConnType), qos, &cbData, options, numOptions);
 
     if (ret != OC_STACK_OK)
     {
@@ -173,12 +168,12 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
 OCStackApplicationResult putReqCB(void* ctx, OCDoHandle /*handle*/,
                                   OCClientResponse * clientResponse)
 {
-    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -194,12 +189,12 @@ OCStackApplicationResult putReqCB(void* ctx, OCDoHandle /*handle*/,
 OCStackApplicationResult postReqCB(void *ctx, OCDoHandle /*handle*/,
                                    OCClientResponse *clientResponse)
 {
-    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -216,12 +211,12 @@ OCStackApplicationResult deleteReqCB(void *ctx,
                                      OCDoHandle /*handle*/,
                                      OCClientResponse *clientResponse)
 {
-    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for DELETE recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -237,13 +232,13 @@ OCStackApplicationResult deleteReqCB(void *ctx,
 OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
                                   OCClientResponse * clientResponse)
 {
-    if(clientResponse == NULL)
+    if (clientResponse == NULL)
     {
         OC_LOG(INFO, TAG, "getReqCB received NULL clientResponse");
         return   OC_STACK_DELETE_TRANSACTION;
     }
 
-    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
     }
@@ -253,14 +248,14 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
     OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
     OC_LOG(INFO, TAG, PCF("=============> Get Response"));
 
-    if(clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
+    if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
     {
         OC_LOG (INFO, TAG, "Received vendor specific options");
         uint8_t i = 0;
         OCHeaderOption * rcvdOptions = clientResponse->rcvdVendorSpecificHeaderOptions;
         for( i = 0; i < clientResponse->numRcvdVendorSpecificHeaderOptions; i++)
         {
-            if(((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID)
+            if (((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID)
             {
                 OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
                         ((OCHeaderOption)rcvdOptions[i]).optionID );
@@ -276,12 +271,12 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
 OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle /*handle*/,
                                   OCClientResponse * clientResponse)
 {
-    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for OBS query recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
         OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
@@ -292,7 +287,7 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle /*handle*/,
         gNumObserveNotifies++;
         if (gNumObserveNotifies == 15) //large number to test observing in DELETE case.
         {
-            if(TEST_CASE == TEST_OBS_REQ_NON || TEST_CASE == TEST_OBS_REQ_CON)
+            if (TestCase == TEST_OBS_REQ_NON || TestCase == TEST_OBS_REQ_CON)
             {
                 if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
                 {
@@ -300,7 +295,7 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle /*handle*/,
                 }
                 return OC_STACK_DELETE_TRANSACTION;
             }
-            else if(TEST_CASE == TEST_OBS_REQ_NON_CANCEL_IMM)
+            else if (TestCase == TEST_OBS_REQ_NON_CANCEL_IMM)
             {
                 if (OCCancel (gObserveDoHandle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK)
                 {
@@ -308,16 +303,16 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle /*handle*/,
                 }
             }
         }
-        if(clientResponse->sequenceNumber == OC_OBSERVE_REGISTER)
+        if (clientResponse->sequenceNumber == OC_OBSERVE_REGISTER)
         {
             OC_LOG(INFO, TAG, "This also serves as a registration confirmation");
         }
-        else if(clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER)
+        else if (clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER)
         {
             OC_LOG(INFO, TAG, "This also serves as a deregistration confirmation");
             return OC_STACK_DELETE_TRANSACTION;
         }
-        else if(clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION)
+        else if (clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION)
         {
             OC_LOG(INFO, TAG, "This also tells you that registration/deregistration failed");
             return OC_STACK_DELETE_TRANSACTION;
@@ -341,7 +336,6 @@ OCStackApplicationResult presenceCB(void* ctx, OCDoHandle /*handle*/,
     if (clientResponse)
     {
         OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
-        OC_LOG_V(INFO, TAG, "NONCE NUMBER: %u", clientResponse->sequenceNumber);
         OC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d",
                 gNumPresenceNotifies);
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -366,7 +360,7 @@ OCStackApplicationResult presenceCB(void* ctx, OCDoHandle /*handle*/,
 
 // This is a function called back when a device is discovered
 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
-        OCClientResponse * clientResponse)
+                                        OCClientResponse * clientResponse)
 {
     if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
     {
@@ -385,10 +379,11 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
                 clientResponse->devAddr.port);
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
 
-        OC_CONNTYPE = clientResponse->connType;
+        ConnType = clientResponse->connType;
+        serverAddr = clientResponse->devAddr;
         parseClientResponse(clientResponse);
 
-        switch(TEST_CASE)
+        switch(TestCase)
         {
             case TEST_GET_REQ_NON:
                 InitGetRequest(OC_LOW_QOS, 0, 0);
@@ -453,16 +448,16 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
     return OC_STACK_KEEP_TRANSACTION;
 }
 
-OCStackApplicationResult PlatformDiscoveryReqCB (void* ctx,
-                                                 OCDoHandle /*handle*/,
-        OCClientResponse * clientResponse)
+OCStackApplicationResult PlatformDiscoveryReqCB(void* ctx,
+                                                OCDoHandle /*handle*/,
+                                                OCClientResponse * clientResponse)
 {
     if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG(INFO, TAG, PCF("Discovery Response:"));
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -472,18 +467,18 @@ OCStackApplicationResult PlatformDiscoveryReqCB (void* ctx,
         OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
     }
 
-    return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
+    return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
 }
 
-OCStackApplicationResult DeviceDiscoveryReqCB (void* ctx, OCDoHandle /*handle*/,
-        OCClientResponse * clientResponse)
+OCStackApplicationResult DeviceDiscoveryReqCB(void* ctx, OCDoHandle /*handle*/,
+                                              OCClientResponse * clientResponse)
 {
     if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully");
     }
 
-    if(clientResponse)
+    if (clientResponse)
     {
         OC_LOG(INFO, TAG, PCF("Discovery Response:"));
         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
@@ -493,7 +488,7 @@ OCStackApplicationResult DeviceDiscoveryReqCB (void* ctx, OCDoHandle /*handle*/,
         OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
     }
 
-    return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
+    return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
 }
 
 #ifdef WITH_PRESENCE
@@ -503,37 +498,37 @@ int InitPresence()
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
     std::ostringstream querySuffix;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << OC_RSRVD_PRESENCE_URI;
-    if(TEST_CASE == TEST_OBS_PRESENCE)
+    query << OC_RSRVD_PRESENCE_URI;
+    if (TestCase == TEST_OBS_PRESENCE)
     {
-        result = InvokeOCDoResource(query, OC_REST_PRESENCE, OC_LOW_QOS,
-                presenceCB, NULL, 0);
+        result = InvokeOCDoResource(query, &serverAddr, OC_REST_PRESENCE,
+                OC_LOW_QOS, presenceCB, NULL, 0);
     }
-    if(TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTER || TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTERS)
+    if (TestCase == TEST_OBS_PRESENCE_WITH_FILTER || TestCase == TEST_OBS_PRESENCE_WITH_FILTERS)
     {
         querySuffix.str("");
         querySuffix << query.str() << "?rt=core.led";
-        result = InvokeOCDoResource(querySuffix, OC_REST_PRESENCE, OC_LOW_QOS,
-                presenceCB, NULL, 0);
+        result = InvokeOCDoResource(querySuffix, &serverAddr, OC_REST_PRESENCE,
+                OC_LOW_QOS, presenceCB, NULL, 0);
     }
-    if(TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTERS)
+    if (TestCase == TEST_OBS_PRESENCE_WITH_FILTERS)
     {
-        if(result == OC_STACK_OK)
+        if (result == OC_STACK_OK)
         {
             querySuffix.str("");
             querySuffix << query.str() << "?rt=core.fan";
-            result = InvokeOCDoResource(querySuffix, OC_REST_PRESENCE, OC_LOW_QOS,
+            result = InvokeOCDoResource(querySuffix, &serverAddr, OC_REST_PRESENCE, OC_LOW_QOS,
                     presenceCB, NULL, 0);
         }
     }
-    if(TEST_CASE == TEST_OBS_MULTICAST_PRESENCE)
+    if (TestCase == TEST_OBS_MULTICAST_PRESENCE)
     {
-        if(result == OC_STACK_OK)
+        if (result == OC_STACK_OK)
         {
             std::ostringstream multicastPresenceQuery;
             multicastPresenceQuery.str("");
             multicastPresenceQuery << "coap://" << OC_MULTICAST_PREFIX << OC_RSRVD_PRESENCE_URI;
-            result = InvokeOCDoResource(multicastPresenceQuery, OC_REST_PRESENCE, OC_LOW_QOS,
+            result = InvokeOCDoResource(multicastPresenceQuery, &serverAddr, OC_REST_PRESENCE, OC_LOW_QOS,
                     presenceCB, NULL, 0);
         }
     }
@@ -545,8 +540,8 @@ int InitGetRequestToUnavailableResource(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << "/SomeUnknownResource";
-    return (InvokeOCDoResource(query, OC_REST_GET, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
+    query << "/SomeUnknownResource";
+    return (InvokeOCDoResource(query, &serverAddr, OC_REST_GET, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
             getReqCB, NULL, 0));
 }
 
@@ -554,17 +549,17 @@ int InitObserveRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
-    return (InvokeOCDoResource(query,
-            OC_REST_OBSERVE, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, obsReqCB, NULL, 0));
+    query << coapServerResource;
+    return (InvokeOCDoResource(query, &serverAddr, OC_REST_OBSERVE,
+              (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, obsReqCB, NULL, 0));
 }
 
 int InitPutRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
-    return (InvokeOCDoResource(query, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
+    query << coapServerResource;
+    return (InvokeOCDoResource(query, &serverAddr, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
             putReqCB, NULL, 0));
 }
 
@@ -573,10 +568,10 @@ int InitPostRequest(OCQualityOfService qos)
     OCStackResult result;
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
 
     // First POST operation (to create an Light instance)
-    result = InvokeOCDoResource(query, OC_REST_POST,
+    result = InvokeOCDoResource(query, &serverAddr, OC_REST_POST,
                                ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
                                postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -586,7 +581,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // Second POST operation (to create an Light instance)
-    result = InvokeOCDoResource(query, OC_REST_POST,
+    result = InvokeOCDoResource(query, &serverAddr, OC_REST_POST,
                                ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
                                postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -595,7 +590,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // This POST operation will update the original resourced /a/light
-    return (InvokeOCDoResource(query, OC_REST_POST,
+    return (InvokeOCDoResource(query, &serverAddr, OC_REST_POST,
                                ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
                                postReqCB, NULL, 0));
 }
@@ -604,7 +599,7 @@ void* RequestDeleteDeathResourceTask(void* myqos)
 {
     sleep (30);//long enough to give the server time to finish deleting the resource.
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
 
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
 
@@ -619,7 +614,7 @@ void* RequestDeleteDeathResourceTask(void* myqos)
         qos = OC_HIGH_QOS;
     }
 
-    OCStackResult result = InvokeOCDoResource(query, OC_REST_DELETE,
+    OCStackResult result = InvokeOCDoResource(query, &serverAddr, OC_REST_DELETE,
                                qos,
                                deleteReqCB, NULL, 0);
 
@@ -635,12 +630,12 @@ int InitDeleteRequest(OCQualityOfService qos)
 {
     OCStackResult result;
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
 
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
 
     // First DELETE operation
-    result = InvokeOCDoResource(query, OC_REST_DELETE,
+    result = InvokeOCDoResource(query, &serverAddr, OC_REST_DELETE,
                                qos,
                                deleteReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -666,7 +661,7 @@ int InitGetRequest(OCQualityOfService qos, uint8_t withVendorSpecificHeaderOptio
 
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
 
     // ocserver is written to only process "power<X" query.
     if (getWithQuery)
@@ -691,12 +686,12 @@ int InitGetRequest(OCQualityOfService qos, uint8_t withVendorSpecificHeaderOptio
     }
     if (withVendorSpecificHeaderOptions)
     {
-        return (InvokeOCDoResource(query, OC_REST_GET,
+        return (InvokeOCDoResource(query, &serverAddr, OC_REST_GET,
                 (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, getReqCB, options, 2));
     }
     else
     {
-        return (InvokeOCDoResource(query, OC_REST_GET,
+        return (InvokeOCDoResource(query, &serverAddr, OC_REST_GET,
                 (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, getReqCB, NULL, 0));
     }
 }
@@ -709,32 +704,15 @@ int InitPlatformDiscovery(OCQualityOfService qos)
     OCCallbackData cbData;
     char szQueryUri[64] = { 0 };
 
+    snprintf(szQueryUri, sizeof (szQueryUri) - 1, PLATFORM_DISCOVERY_QUERY, discoveryAddr);
+
     cbData.cb = PlatformDiscoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    if(UNICAST_DISCOVERY)
-    {
-        snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_PLATFORM_DISCOVERY_QUERY, ipv4addr);
-    }
-    else
-    {
-        strncpy(szQueryUri, MULTICAST_PLATFORM_DISCOVERY_QUERY, sizeof(szQueryUri) -1 );
-    }
-    szQueryUri[sizeof(szQueryUri) -1] = '\0';
-
-    if(UNICAST_DISCOVERY)
-    {
-        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
-                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
-    else
-    {
-
-        ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
-                        (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
-
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, NULL, 0, CT_DEFAULT,
+                       (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
+                       &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack device error");
@@ -749,33 +727,17 @@ int InitDeviceDiscovery(OCQualityOfService qos)
 
     OCStackResult ret;
     OCCallbackData cbData;
-    char szQueryUri[64] = { 0 };
+    char szQueryUri[100] = { 0 };
+
+    snprintf(szQueryUri, sizeof (szQueryUri) - 1, DEVICE_DISCOVERY_QUERY, discoveryAddr);
 
     cbData.cb = DeviceDiscoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    if(UNICAST_DISCOVERY)
-    {
-        snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DEVICE_DISCOVERY_QUERY, ipv4addr);
-    }
-    else
-    {
-        strncpy(szQueryUri, MULTICAST_DEVICE_DISCOVERY_QUERY, sizeof(szQueryUri) -1 );
-    }
-    szQueryUri[sizeof(szQueryUri) -1] = '\0';
-
-    if(UNICAST_DISCOVERY)
-    {
-        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
-                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
-    else
-    {
-        ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
-                        (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
-
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, NULL, 0, CT_DEFAULT,
+                       (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
+                       &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack device error");
@@ -788,31 +750,17 @@ int InitDiscovery(OCQualityOfService qos)
 {
     OCStackResult ret;
     OCCallbackData cbData;
-    /* Start a discovery query*/
-    char szQueryUri[64] = { 0 };
+    char szQueryUri[100] = { 0 };
 
-    if (UNICAST_DISCOVERY)
-    {
-        snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_RESOURCE_DISCOVERY_QUERY, ipv4addr);
-    }
-    else
-    {
-        strcpy(szQueryUri, MULTICAST_RESOURCE_DISCOVERY_QUERY);
-    }
+    snprintf(szQueryUri, sizeof (szQueryUri) - 1, RESOURCE_DISCOVERY_QUERY, discoveryAddr);
 
     cbData.cb = discoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
-    if(UNICAST_DISCOVERY)
-    {
-        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
-                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
-    else
-    {
-        ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
-                        (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
-    }
+
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, NULL, 0, CT_DEFAULT,
+                       (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
+                       &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -829,13 +777,13 @@ int main(int argc, char* argv[])
         switch(opt)
         {
             case 'u':
-                UNICAST_DISCOVERY = atoi(optarg);
+                UnicastDiscovery = atoi(optarg);
                 break;
             case 't':
-                TEST_CASE = atoi(optarg);
+                TestCase = atoi(optarg);
                 break;
             case 'c':
-                CONNECTIVITY = atoi(optarg);
+                Connectivity = atoi(optarg);
                 break;
             default:
                 PrintUsage();
@@ -843,24 +791,23 @@ int main(int argc, char* argv[])
         }
     }
 
-    if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
-            (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
-            (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
+    if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) ||
+            (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS) ||
+            (Connectivity < CT_ADAPTER_DEFAULT || Connectivity >= MAX_CT))
     {
         PrintUsage();
         return -1;
     }
 
-    /* Initialize OCStack*/
-    if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
+    if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
 
-    if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IP)
+    if (Connectivity == CT_ADAPTER_DEFAULT || Connectivity == CT_IP)
     {
-        OC_CONNTYPE = CT_ADAPTER_IP;
+        ConnType = CT_ADAPTER_IP;
     }
     else
     {
@@ -868,28 +815,31 @@ int main(int argc, char* argv[])
         PrintUsage();
     }
 
-    if (UNICAST_DISCOVERY)
+    discoveryAddr[0] = '\0';
+
+    if (UnicastDiscovery)
     {
-        OC_LOG(INFO, TAG, "Enter IP address with port number of the Server hosting resource");
-        OC_LOG(INFO, TAG, "as follows - eg: 192.168.0.15:45454 (IP:Port) \n");
+        OC_LOG(INFO, TAG, "Enter IP address of server with optional port number");
+        OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+        OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
 
-        if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
+        if (fgets(discoveryAddr, sizeof (discoveryAddr), stdin))
         {
             //Strip newline char from ipv4addr
-            StripNewLineChar(ipv4addr);
+            StripNewLineChar(discoveryAddr);
         }
         else
         {
-            OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
+            OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
             return OC_STACK_INVALID_PARAM;
         }
     }
 
-    if(UNICAST_DISCOVERY  == 0  && TEST_CASE == TEST_DISCOVER_DEV_REQ)
+    if (UnicastDiscovery == 0 && TestCase == TEST_DISCOVER_DEV_REQ)
     {
         InitDeviceDiscovery(OC_LOW_QOS);
     }
-    else if(UNICAST_DISCOVERY  == 0  && TEST_CASE == TEST_DISCOVER_PLATFORM_REQ)
+    else if (UnicastDiscovery == 0 && TestCase == TEST_DISCOVER_PLATFORM_REQ)
     {
         InitPlatformDiscovery(OC_LOW_QOS);
     }
@@ -922,35 +872,6 @@ int main(int argc, char* argv[])
     return 0;
 }
 
-std::string getIPAddrTBServer(OCClientResponse * clientResponse)
-{
-    if (!clientResponse)
-    {
-        return "";
-    }
-    if (!clientResponse->addr)
-    {
-        return "";
-    }
-
-    return std::string(clientResponse->devAddr.addr);
-}
-
-std::string getPortTBServer(OCClientResponse * clientResponse)
-{
-    if (!clientResponse)
-    {
-        return "";
-    }
-    if (!clientResponse->addr)
-    {
-        return "";
-    }
-    std::ostringstream ss;
-    ss << clientResponse->devAddr.port;
-    return ss.str();
-}
-
 std::string getConnectivityType (OCConnectivityType connType)
 {
     switch (connType & CT_MASK_ADAPTER)
@@ -977,13 +898,10 @@ std::string getConnectivityType (OCConnectivityType connType)
 
 std::string getQueryStrForGetPut(OCClientResponse * /*clientResponse*/)
 {
-
     return "/a/light";
 }
 
 void parseClientResponse(OCClientResponse * clientResponse)
 {
-    coapServerIP = getIPAddrTBServer(clientResponse);
-    coapServerPort = getPortTBServer(clientResponse);
     coapServerResource = getQueryStrForGetPut(clientResponse);
 }
index ce00796..e2a4a69 100644 (file)
 #define MAX_IP_ADDR_ST_SZ  16 //string size of "155.255.255.255" (15 + 1)
 #define MAX_PORT_ST_SZ  6     //string size of "65535" (5 + 1)
 
-static int IPV4_ADDR_SIZE = 24;
-static int UNICAST_DISCOVERY = 0;
-static int TEST_CASE = 0;
-static int CONNECTIVITY = 0;
-
-static const char UNICAST_DISCOVERY_QUERY[] = "coap://%s/oic/res";
+static int UnicastDiscovery = 0;
+static int TestCase = 0;
+static int Connectivity = 0;
 
 //The following variable determines the interface protocol (IP, etc)
 //to be used for sending unicast messages. Default set to IP.
-static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
+static OCConnectivityType ConnType = CT_ADAPTER_IP;
+static const char *RESOURCE_DISCOVERY_QUERY = "%s/oic/res";
 
 int gQuitFlag = 0;
 
@@ -100,9 +97,12 @@ const ResourceNode * getResource()
     return resourceList;
 }
 
-OCStackResult InvokeOCDoResource(std::ostringstream &query, OCMethod method,
-                                 OCConnectivityType connType, OCQualityOfService qos,
-        OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions)
+OCStackResult InvokeOCDoResource(std::ostringstream &query,
+                                 OCMethod method,
+                                 const OCDevAddr *dest,
+                                 OCQualityOfService qos,
+                                 OCClientResponseHandler cb,
+                                 OCHeaderOption * options, uint8_t numOptions)
 {
     OCStackResult ret;
     OCCallbackData cbData;
@@ -111,9 +111,9 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query, OCMethod method,
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    ret = OCDoResource(NULL, method, query.str().c_str(), 0,
+    ret = OCDoResource(NULL, method, query.str().c_str(), dest,
         (method == OC_REST_PUT || method == OC_REST_POST) ? putPayload() : NULL,
-         connType, qos, &cbData, options, numOptions);
+         CT_DEFAULT, qos, &cbData, options, numOptions);
 
     if (ret != OC_STACK_OK)
     {
@@ -125,7 +125,7 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query, OCMethod method,
 }
 
 OCStackApplicationResult putReqCB(void* ctx, OCDoHandle /*handle*/,
-                                OCClientResponse * clientResponse)
+                                  OCClientResponse * clientResponse)
 {
     if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
@@ -149,7 +149,7 @@ OCStackApplicationResult putReqCB(void* ctx, OCDoHandle /*handle*/,
 }
 
 OCStackApplicationResult postReqCB(void *ctx, OCDoHandle /*handle*/,
-                          OCClientResponse *clientResponse)
+                                   OCClientResponse *clientResponse)
 {
     if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
@@ -174,7 +174,7 @@ OCStackApplicationResult postReqCB(void *ctx, OCDoHandle /*handle*/,
 }
 
 OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
-                           OCClientResponse * clientResponse)
+                                  OCClientResponse * clientResponse)
 {
     if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
     {
@@ -221,7 +221,7 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
  * This is a function called back when a device is discovered
  */
 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
-        OCClientResponse * clientResponse)
+                                        OCClientResponse * clientResponse)
 {
     if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
@@ -247,7 +247,7 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
     {
         OC_LOG(ERROR, TAG, "<====DISCOVERY Callback fail to receive clientResponse====>\n");
     }
-    return (UNICAST_DISCOVERY) ?
+    return (UnicastDiscovery) ?
            OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
 }
 
@@ -262,10 +262,10 @@ int InitPutRequest(OCQualityOfService qos)
         OC_LOG_V(ERROR, TAG, "Resource null, can't do PUT request\n");
         return -1;
     }
-    query << "coap://" << resource->ip << ":" << resource->port << resource->uri ;
+    query << resource->uri;
     OC_LOG_V(INFO, TAG,"Executing InitPutRequest, Query: %s", query.str().c_str());
 
-    return (InvokeOCDoResource(query, OC_REST_PUT, resource->connType,
+    return (InvokeOCDoResource(query, OC_REST_PUT, &resource->endpoint,
            ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
             putReqCB, NULL, 0));
 }
@@ -275,7 +275,7 @@ int InitPostRequest(OCQualityOfService qos)
     OCStackResult result;
     std::ostringstream query;
     //Get most recently inserted resource
-    const ResourceNode * resource  = getResource();
+    const ResourceNode *resource  = getResource();
 
     if(!resource)
     {
@@ -283,11 +283,11 @@ int InitPostRequest(OCQualityOfService qos)
         return -1;
     }
 
-    query << "coap://" << resource->ip << ":" << resource->port << resource->uri ;
+    query << resource->uri;
     OC_LOG_V(INFO, TAG,"Executing InitPostRequest, Query: %s", query.str().c_str());
 
     // First POST operation (to create an LED instance)
-    result = InvokeOCDoResource(query, OC_REST_POST, resource->connType,
+    result = InvokeOCDoResource(query, OC_REST_POST, &resource->endpoint,
             ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
             postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -297,7 +297,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // Second POST operation (to create an LED instance)
-    result = InvokeOCDoResource(query, OC_REST_POST, resource->connType,
+    result = InvokeOCDoResource(query, OC_REST_POST, &resource->endpoint,
             ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
             postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -306,7 +306,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // This POST operation will update the original resourced /a/led
-    return (InvokeOCDoResource(query, OC_REST_POST,resource->connType,
+    return (InvokeOCDoResource(query, OC_REST_POST, &resource->endpoint,
                 ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
                 postReqCB, NULL, 0));
 }
@@ -322,10 +322,10 @@ int InitGetRequest(OCQualityOfService qos)
         OC_LOG_V(ERROR, TAG, "Resource null, can't do GET request\n");
         return -1;
     }
-    query << "coap://" << resource->ip << ":" << resource->port << resource->uri ;
+    query << resource->uri;
     OC_LOG_V(INFO, TAG,"Executing InitGetRequest, Query: %s", query.str().c_str());
 
-    return (InvokeOCDoResource(query, OC_REST_GET, resource->connType,
+    return (InvokeOCDoResource(query, OC_REST_GET, &resource->endpoint,
             (qos == OC_HIGH_QOS)?OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0));
 }
 
@@ -333,44 +333,34 @@ int InitDiscovery()
 {
     OCStackResult ret;
     OCCallbackData cbData;
-    /* Start a discovery query*/
-    char szQueryUri[64] = {};
-    if (UNICAST_DISCOVERY)
+    char queryUri[200];
+    char ipaddr[100] = { '\0' };
+
+    if (UnicastDiscovery)
     {
-        char ipv4addr[IPV4_ADDR_SIZE];
-        OC_LOG(INFO, TAG, "Enter IP address with port of the Server hosting resource"\
-                    "(Ex: 192.168.0.15:1234) ");
+        OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+        OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+        OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
 
-        if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
+        if (fgets(ipaddr, sizeof (ipaddr), stdin))
         {
-            //Strip newline char from ipv4addr
-            StripNewLineChar(ipv4addr);
-            snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DISCOVERY_QUERY, ipv4addr);
+            StripNewLineChar(ipaddr); //Strip newline char from ipaddr
         }
         else
         {
-            OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
+            OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
             return OC_STACK_INVALID_PARAM;
         }
     }
-    else
-    {
-        OICStrcpy(szQueryUri, sizeof(szQueryUri), MULTICAST_RESOURCE_DISCOVERY_QUERY);
-    }
+
+    snprintf(queryUri, sizeof (queryUri), RESOURCE_DISCOVERY_QUERY, ipaddr);
+
     cbData.cb = discoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
-    if (UNICAST_DISCOVERY)
-    {
-        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
-                OC_LOW_QOS, &cbData, NULL, 0);
-    }
-    else
-    {
-        ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
-                OC_LOW_QOS, &cbData, NULL, 0);
-    }
 
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,
+                       OC_LOW_QOS, &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -378,48 +368,9 @@ int InitDiscovery()
     return ret;
 }
 
-const char *getIPAddr(const OCClientResponse *clientResponse)
-{
-    if (!clientResponse)
-    {
-        return "";
-    }
-
-    const OCDevAddr *devAddr = &clientResponse->devAddr;
-    char *ipaddr = (char *) OICCalloc(1, strlen(devAddr->addr) +1);
-    if (ipaddr)
-    {
-        snprintf(ipaddr, MAX_IP_ADDR_ST_SZ, "%s", devAddr->addr);
-    }
-    else
-    {
-        OC_LOG(ERROR, TAG, "Memory not allocated to ipaddr");
-    }
-    return ipaddr;
-}
-
-const char *getPort(const OCClientResponse *clientResponse)
-{
-    if(!clientResponse)
-    {
-        return "";
-    }
-
-    char *port = NULL;
-    if((port = (char *)OICCalloc(1, MAX_PORT_ST_SZ)))
-    {
-        snprintf(port, MAX_PORT_ST_SZ, "%d", clientResponse->devAddr.port);
-    }
-    else
-    {
-        OC_LOG(ERROR, TAG, "Memory not allocated to port");
-    }
-    return port;
-}
-
 void queryResource()
 {
-    switch(TEST_CASE)
+    switch(TestCase)
     {
         case TEST_DISCOVER_REQ:
             break;
@@ -507,9 +458,7 @@ int insertResource(const char * sid, char const * uri,
     {
         iter->sid = sid_cpy;
         iter->uri = uri_cpy;
-        iter->ip = getIPAddr(clientResponse);
-        iter->port = getPort(clientResponse);
-        iter->connType = clientResponse->connType;
+        iter->endpoint = clientResponse->devAddr;
         iter->next = NULL;
     }
     else
@@ -543,9 +492,9 @@ void printResourceList()
         OC_LOG(INFO, TAG, "*****************************************************");
         OC_LOG_V(INFO, TAG, "sid = %s",iter->sid);
         OC_LOG_V(INFO, TAG, "uri = %s", iter->uri);
-        OC_LOG_V(INFO, TAG, "ip = %s", iter->ip);
-        OC_LOG_V(INFO, TAG, "port = %s", iter->port);
-        switch (iter->connType & CT_MASK_ADAPTER)
+        OC_LOG_V(INFO, TAG, "ip = %s", iter->endpoint.addr);
+        OC_LOG_V(INFO, TAG, "port = %d", iter->endpoint.port);
+        switch (iter->endpoint.adapter)
         {
             case OC_ADAPTER_IP:
                 OC_LOG(INFO, TAG, "connType = Default (IPv4)");
@@ -576,8 +525,6 @@ void freeResourceList()
         resourceList = resourceList->next;
         OICFree((void *)temp->sid);
         OICFree((void *)temp->uri);
-        OICFree((void *)temp->ip);
-        OICFree((void *)temp->port);
         OICFree(temp);
     }
     resourceList = NULL;
@@ -592,14 +539,13 @@ int main(int argc, char* argv[])
         switch(opt)
         {
             case 'u':
-                UNICAST_DISCOVERY = atoi(optarg);
+                UnicastDiscovery = atoi(optarg);
                 break;
             case 't':
-                TEST_CASE = atoi(optarg);
+                TestCase = atoi(optarg);
                 break;
             case 'c':
-
-                CONNECTIVITY = atoi(optarg);
+                Connectivity = atoi(optarg);
                 break;
             default:
                 PrintUsage();
@@ -607,24 +553,24 @@ int main(int argc, char* argv[])
         }
     }
 
-    if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
-        (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
-        (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
+    if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) ||
+        (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS) ||
+        (Connectivity < CT_ADAPTER_DEFAULT || Connectivity >= MAX_CT))
     {
         PrintUsage();
         return -1;
     }
 
     /* Initialize OCStack*/
-    if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
+    if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack init error");
         return 0;
     }
 
-    if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY ==  CT_IP)
+    if(Connectivity == CT_ADAPTER_DEFAULT || Connectivity ==  CT_IP)
     {
-        OC_CONNTYPE =  CT_ADAPTER_IP;//CT_DEFAULT;
+        ConnType =  CT_ADAPTER_IP;//CT_DEFAULT;
     }
     else
     {
index 012a11a..15c0dfd 100644 (file)
@@ -28,9 +28,6 @@
 //-----------------------------------------------------------------------------
 #define TAG "occlientbasicops"
 #define DEFAULT_CONTEXT_VALUE 0x99
-#ifndef MAX_LENGTH_IPv4_ADDR
-#define MAX_LENGTH_IPv4_ADDR 16
-#endif
 
 //-----------------------------------------------------------------------------
 // Typedefs
@@ -63,9 +60,7 @@ struct ResourceNode
 {
     const char * sid;
     const char * uri;
-    const char * ip;
-    const char * port;
-    OCConnectivityType connType;
+    OCDevAddr endpoint;
     ResourceNode * next;
 };
 
@@ -76,12 +71,6 @@ struct ResourceNode
 /* call getResult in common.cpp to get the result in string format. */
 const char *getResult(OCStackResult result);
 
-/* Get the IP address of the server */
-const char * getIPAddr(const OCClientResponse * clientResponse);
-
-/* Get the port number the server is listening on */
-const char * getPort(const OCClientResponse * clientResponse);
-
 /* Performs GET/PUT/POST query on most recently discovered resource*/
 void queryResource();
 
@@ -132,7 +121,7 @@ void parseClientResponse(OCClientResponse * clientResponse);
  * to the lower layers
  */
 OCStackResult InvokeOCDoResource(std::ostringstream &query,
-        OCMethod method, OCQualityOfService qos,
+        OCMethod method, OCDevAddr *dest, OCQualityOfService qos,
         OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions);
 
 /*
index 23392f9..c023c26 100644 (file)
@@ -30,8 +30,6 @@
 #include "payload_logging.h"
 #include "logger.h"
 const char *getResult(OCStackResult result);
-std::string getIPAddrTBServer(OCClientResponse * clientResponse);
-std::string getPortTBServer(OCClientResponse * clientResponse);
 std::string getQueryStrForGetPut();
 
 #define TAG PCF("occlient")
@@ -63,10 +61,10 @@ typedef enum {
     CT_ADAPTER_DEFAULT = 0,
     CT_IP,
     MAX_CT
-} CLIENT_CONNECTIVITY_TYPE;
+} CLIENT_ConnectivityType_TYPE;
 
-unsigned static int TEST = TEST_INVALID;
-unsigned static int CONNECTIVITY = 0;
+unsigned static int TestType = TEST_INVALID;
+unsigned static int ConnectivityType = 0;
 
 typedef struct
 {
@@ -90,8 +88,8 @@ testToTextMap queryInterface[] = {
 
 //The following variable determines the interface protocol (IP, etc)
 //to be used for sending unicast messages. Default set to IP.
-static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
+static OCConnectivityType ConnType = CT_ADAPTER_IP;
+static const char * RESOURCE_DISCOVERY_QUERY = "/oic/res";
 
 // The handle for the observe registration
 OCDoHandle gObserveDoHandle;
@@ -202,17 +200,16 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
             }
         }
     }
-    if(TEST == TEST_PUT_DEFAULT || TEST == TEST_PUT_BATCH || TEST == TEST_PUT_LINK_LIST)
+    if(TestType == TEST_PUT_DEFAULT || TestType == TEST_PUT_BATCH || TestType == TEST_PUT_LINK_LIST)
     {
         InitPutRequest(clientResponse);
     }
     return OC_STACK_KEEP_TRANSACTION;
 }
 
-
 // This is a function called back when a device is discovered
 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
-        OCClientResponse * clientResponse)
+                                        OCClientResponse * clientResponse)
 {
     OC_LOG(INFO, TAG,
             "Entering discoveryReqCB (Application Layer CB)");
@@ -230,10 +227,10 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
             clientResponse->devAddr.port);
     OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
 
-    OC_CONNTYPE = clientResponse->connType;
+    ConnType = clientResponse->connType;
 
-    if(TEST == TEST_UNKNOWN_RESOURCE_GET_DEFAULT || TEST == TEST_UNKNOWN_RESOURCE_GET_BATCH ||\
-            TEST == TEST_UNKNOWN_RESOURCE_GET_LINK_LIST)
+    if(TestType == TEST_UNKNOWN_RESOURCE_GET_DEFAULT || TestType == TEST_UNKNOWN_RESOURCE_GET_BATCH ||\
+            TestType == TEST_UNKNOWN_RESOURCE_GET_LINK_LIST)
     {
         InitGetRequestToUnavailableResource(clientResponse);
     }
@@ -250,14 +247,14 @@ int InitGetRequestToUnavailableResource(OCClientResponse * clientResponse)
     OCStackResult ret;
     OCCallbackData cbData;
     std::ostringstream getQuery;
-    getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
-            clientResponse->devAddr.port << "/SomeUnknownResource";
+    getQuery << "/SomeUnknownResource";
     cbData.cb = getReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    ret = OCDoResource(NULL, OC_REST_GET, getQuery.str().c_str(), 0, 0, OC_CONNTYPE, OC_LOW_QOS,
-            &cbData, NULL, 0);
+    ret = OCDoResource(NULL, OC_REST_GET, getQuery.str().c_str(),
+                       &clientResponse->devAddr, 0, ConnType, OC_LOW_QOS,
+                       &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -272,9 +269,7 @@ int InitObserveRequest(OCClientResponse * clientResponse)
     OCCallbackData cbData;
     OCDoHandle handle;
     std::ostringstream obsReg;
-    obsReg << "coap://" << clientResponse->devAddr.addr << ":" <<
-            clientResponse->devAddr.addr <<
-            getQueryStrForGetPut();
+    obsReg << getQueryStrForGetPut();
     cbData.cb = getReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
@@ -283,8 +278,9 @@ int InitObserveRequest(OCClientResponse * clientResponse)
     OC_LOG_PAYLOAD(INFO, TAG, payload);
     OCPayloadDestroy(payload);
 
-    ret = OCDoResource(&handle, OC_REST_OBSERVE, obsReg.str().c_str(), 0, 0, OC_CONNTYPE,
-            OC_LOW_QOS, &cbData, NULL, 0);
+    ret = OCDoResource(&handle, OC_REST_OBSERVE, obsReg.str().c_str(),
+                       &clientResponse->devAddr, 0, ConnType,
+                       OC_LOW_QOS, &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -305,7 +301,7 @@ int InitPutRequest(OCClientResponse * clientResponse)
     std::ostringstream getQuery;
     getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
             clientResponse->devAddr.port <<
-            "/a/room" << queryInterface[TEST].text;
+            "/a/room" << queryInterface[TestType].text;
     cbData.cb = putReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
@@ -314,8 +310,9 @@ int InitPutRequest(OCClientResponse * clientResponse)
     OC_LOG_PAYLOAD(INFO, TAG, payload);
     OCPayloadDestroy(payload);
 
-    ret = OCDoResource(NULL, OC_REST_PUT, getQuery.str().c_str(), 0, putPayload(),
-                        OC_CONNTYPE, OC_LOW_QOS, &cbData, NULL, 0);
+    ret = OCDoResource(NULL, OC_REST_PUT, getQuery.str().c_str(),
+                       &clientResponse->devAddr, putPayload(), ConnType,
+                       OC_LOW_QOS, &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -331,18 +328,16 @@ int InitGetRequest(OCClientResponse * clientResponse)
 
     //* Make a GET query*/
     std::ostringstream getQuery;
-    getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
-            clientResponse->devAddr.port <<
-            "/a/room" << queryInterface[TEST].text;
+    getQuery << "/a/room" << queryInterface[TestType].text;
 
     std::cout << "Get Query: " << getQuery.str() << std::endl;
 
     cbData.cb = getReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
-    ret = OCDoResource(NULL, OC_REST_GET,
-            getQuery.str().c_str(), 0, 0, OC_CONNTYPE, OC_LOW_QOS,
-            &cbData, NULL, 0);
+    ret = OCDoResource(NULL, OC_REST_GET, getQuery.str().c_str(),
+                       &clientResponse->devAddr, 0, ConnType, OC_LOW_QOS,
+                       &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -357,12 +352,12 @@ int InitDiscovery()
     /* Start a discovery query*/
     char szQueryUri[64] = { 0 };
 
-    strcpy(szQueryUri, MULTICAST_RESOURCE_DISCOVERY_QUERY);
+    strcpy(szQueryUri, RESOURCE_DISCOVERY_QUERY);
 
     cbData.cb = discoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
-    ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, NULL, 0, ConnType,
                         OC_LOW_QOS,
             &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
@@ -381,18 +376,18 @@ int main(int argc, char* argv[])
         switch (opt)
         {
             case 't':
-                TEST = atoi(optarg);
+                TestType = atoi(optarg);
                 break;
             case 'c':
-                CONNECTIVITY = atoi(optarg);
+                ConnectivityType = atoi(optarg);
                 break;
             default:
                 PrintUsage();
                 return -1;
         }
     }
-    if ((TEST <= TEST_INVALID || TEST >= MAX_TESTS) ||
-        CONNECTIVITY >= MAX_CT)
+    if ((TestType <= TEST_INVALID || TestType >= MAX_TESTS) ||
+        ConnectivityType >= MAX_CT)
     {
         PrintUsage();
         return -1;
@@ -405,14 +400,14 @@ int main(int argc, char* argv[])
         return 0;
     }
 
-    if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IP)
+    if(ConnectivityType == CT_ADAPTER_DEFAULT || ConnectivityType == CT_IP)
     {
-        OC_CONNTYPE = CT_ADAPTER_IP;
+        ConnType = CT_ADAPTER_IP;
     }
     else
     {
         OC_LOG(INFO, TAG, "Default Connectivity type selected...");
-        OC_CONNTYPE = CT_ADAPTER_IP;
+        ConnType = CT_ADAPTER_IP;
     }
 
     InitDiscovery();
index abf0e52..8b98b52 100644 (file)
 #include "payload_logging.h"
 
 // Tracking user input
-static int UNICAST_DISCOVERY = 0;
-static int TEST_CASE = 0;
-static int CONNECTIVITY = 0;
+static int UnicastDiscovery = 0;
+static int TestCase = 0;
+static int ConnectivityType = 0;
 
-static const char * UNICAST_DISCOVERY_QUERY = "coap://%s/oic/res";
-static std::string coapServerIP = "255.255.255.255";
-static uint16_t coapServerPort = 5683;
 static std::string coapServerResource = "/a/led";
 
 //The following variable determines the interface protocol (IP, etc)
 //to be used for sending unicast messages. Default set to IP.
-static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
-static int IPV4_ADDR_SIZE = 24;
+static OCConnectivityType AdapterType = CT_ADAPTER_IP;
+static OCDevAddr endpoint;
+static const char *RESOURCE_DISCOVERY_QUERY = "%s/oic/res";
 void StripNewLineChar(char* str);
 
 int gQuitFlag = 0;
@@ -62,7 +59,7 @@ void handleSigInt(int signum)
 
 static void PrintUsage()
 {
-    OC_LOG(INFO, TAG, "Usage : occlient -c <0|1|2> -u <0|1> -t <1|2|3>");
+    OC_LOG(INFO, TAG, "Usage : occlient -c <0|1> -u <0|1> -t <1|2|3>");
     OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
     OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
     OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
@@ -90,7 +87,7 @@ OCPayload* putPayload()
 }
 
 OCStackResult InvokeOCDoResource(std::ostringstream &query,
-        OCMethod method, OCQualityOfService qos,
+        OCMethod method, OCDevAddr *dest, OCQualityOfService qos,
         OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions)
 {
     OCStackResult ret;
@@ -100,9 +97,9 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
 
-    ret = OCDoResource(NULL, method, query.str().c_str(), 0,
+    ret = OCDoResource(NULL, method, query.str().c_str(), dest,
             (method == OC_REST_PUT) ? putPayload() : NULL,
-            OC_CONNTYPE, qos, &cbData, options, numOptions);
+            AdapterType, qos, &cbData, options, numOptions);
 
     if (ret != OC_STACK_OK)
     {
@@ -167,9 +164,9 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
             clientResponse->devAddr.addr, clientResponse->devAddr.port);
         OC_LOG_PAYLOAD (INFO, TAG, clientResponse->payload);
 
-        parseClientResponse(clientResponse);
+        endpoint = clientResponse->devAddr;
 
-        switch(TEST_CASE)
+        switch(TestCase)
         {
             case TEST_NON_CON_OP:
                 InitGetRequest(OC_LOW_QOS);
@@ -189,7 +186,7 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
         }
     }
 
-    return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
+    return UnicastDiscovery ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
 
 }
 
@@ -197,62 +194,56 @@ int InitGetRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
     OC_LOG_V (INFO, TAG, "Performing GET with query : %s", query.str().c_str());
-    return (InvokeOCDoResource(query, OC_REST_GET, (qos == OC_HIGH_QOS)?
-            OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0));
+    return (InvokeOCDoResource(query, OC_REST_GET, &endpoint,
+                               (qos == OC_HIGH_QOS)? OC_HIGH_QOS : OC_LOW_QOS,
+                               getReqCB, NULL, 0));
 }
 
 int InitPutRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
     OC_LOG_V (INFO, TAG, "Performing PUT with query : %s", query.str().c_str());
-    return (InvokeOCDoResource(query, OC_REST_PUT, (qos == OC_HIGH_QOS)?
-            OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0));
+    return (InvokeOCDoResource(query, OC_REST_PUT, &endpoint,
+                               (qos == OC_HIGH_QOS)?  OC_HIGH_QOS:OC_LOW_QOS,
+                               getReqCB, NULL, 0));
 }
 
 int InitDiscovery()
 {
     OCStackResult ret;
     OCCallbackData cbData;
-    /* Start a discovery query*/
-    char szQueryUri[64] = { 0 };
-    if (UNICAST_DISCOVERY)
+    char queryUri[200];
+    char ipaddr[100] = { '\0' };
+
+    if (UnicastDiscovery)
     {
-        char ipv4addr[IPV4_ADDR_SIZE];
-        OC_LOG(INFO, TAG, "Enter IPv4:port of the Server hosting resource"\
-                "(Ex: 192.168.0.15:1234)");
-        if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
+        OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+        OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+        OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+
+        if (fgets(ipaddr, sizeof (ipaddr), stdin))
         {
-            //Strip newline char from ipv4addr
-            StripNewLineChar(ipv4addr);
-            snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DISCOVERY_QUERY, ipv4addr);
+            StripNewLineChar(ipaddr); //Strip newline char from ipaddr
         }
         else
         {
-            OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
+            OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
             return OC_STACK_INVALID_PARAM;
         }
     }
-    else
-    {
-        OICStrcpy(szQueryUri, sizeof(szQueryUri), MULTICAST_RESOURCE_DISCOVERY_QUERY);
-    }
+
+    snprintf(queryUri, sizeof (queryUri), RESOURCE_DISCOVERY_QUERY, ipaddr);
+
     cbData.cb = discoveryReqCB;
     cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
     cbData.cd = NULL;
-    if(UNICAST_DISCOVERY)
-    {
-        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
-                OC_LOW_QOS, &cbData, NULL, 0);
-    }
-    else
-    {
-        ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
-                OC_LOW_QOS, &cbData, NULL, 0);
-    }
+
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,
+                       OC_LOW_QOS, &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -269,13 +260,13 @@ int main(int argc, char* argv[])
         switch(opt)
         {
             case 'u':
-                UNICAST_DISCOVERY = atoi(optarg);
+                UnicastDiscovery = atoi(optarg);
                 break;
             case 't':
-                TEST_CASE = atoi(optarg);
+                TestCase = atoi(optarg);
                 break;
             case 'c':
-                CONNECTIVITY = atoi(optarg);
+                ConnectivityType = atoi(optarg);
                 break;
             default:
                 PrintUsage();
@@ -283,9 +274,9 @@ int main(int argc, char* argv[])
         }
     }
 
-    if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
-            (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
-            (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
+    if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) ||
+            (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS) ||
+            (ConnectivityType < CT_ADAPTER_DEFAULT || ConnectivityType >= MAX_CT))
     {
         PrintUsage();
         return -1;
@@ -298,14 +289,14 @@ int main(int argc, char* argv[])
         return 0;
     }
 
-    if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IP)
+    if(ConnectivityType == CT_ADAPTER_DEFAULT || ConnectivityType == CT_IP)
     {
-        OC_CONNTYPE = CT_ADAPTER_IP;
+        AdapterType = CT_ADAPTER_IP;
     }
     else
     {
         OC_LOG(INFO, TAG, "Default Connectivity type selected...");
-        OC_CONNTYPE = CT_ADAPTER_IP;
+        AdapterType = CT_ADAPTER_IP;
     }
 
     InitDiscovery();
@@ -338,10 +329,3 @@ std::string getQueryStrForGetPut(OCClientResponse * clientResponse)
     return "/a/led";
 }
 
-void parseClientResponse(OCClientResponse * clientResponse)
-{
-    coapServerIP = clientResponse->devAddr.addr;
-    coapServerPort = clientResponse->devAddr.port;
-    coapServerResource = getQueryStrForGetPut(clientResponse);
-}
-
index b375da1..41a9b66 100644 (file)
 #include "common.h"
 
 #define TAG "occlientbasicops"
-static int UNICAST_DISCOVERY = 0;
-static int TEST_CASE = 0;
-static int CONN_TYPE = 0;
+static int UnicastDiscovery = 0;
+static int TestCase = 0;
+static int ConnType = 0;
 
-static int IPV4_ADDR_SIZE = 24;
-static char UNICAST_DISCOVERY_QUERY[] = "coap://%s/oic/res";
-static char MULTICAST_DISCOVERY_QUERY[] = "/oic/res";
+static char DISCOVERY_QUERY[] = "%s/oic/res";
 OCConnectivityType discoveryReqConnType = CT_ADAPTER_IP;
+static OCDevAddr endpoint;
 
-static std::string coapServerIP;
-static std::string coapServerPort;
 static std::string coapServerResource;
 static int coapSecureResource;
 static OCConnectivityType ocConnType;
 
-
 //Secure Virtual Resource database for Iotivity Client application
 //It contains Client's Identity and the PSK credentials
 //of other devices which the client trusts
@@ -92,12 +88,15 @@ static void PrintUsage()
             " Initiate Nonconfirmable Get/Put/Post Requests");
     OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
     OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
-    OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+    OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
 }
 
 OCStackResult InvokeOCDoResource(std::ostringstream &query,
-        OCMethod method, OCQualityOfService qos,
-        OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions)
+                                 OCMethod method,
+                                 const OCDevAddr *dest,
+                                 OCQualityOfService qos,
+                                 OCClientResponseHandler cb,
+                                 OCHeaderOption * options, uint8_t numOptions)
 {
     OCStackResult ret;
     OCCallbackData cbData;
@@ -106,7 +105,7 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
     cbData.context = NULL;
     cbData.cd = NULL;
 
-    ret = OCDoResource(NULL, method, query.str().c_str(), 0,
+    ret = OCDoResource(NULL, method, query.str().c_str(), dest,
             (method == OC_REST_PUT || method == OC_REST_POST) ? putPayload() : NULL,
             ocConnType, qos, &cbData, options, numOptions);
 
@@ -118,7 +117,7 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
     return ret;
 }
 
-OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
+OCStackApplicationResult putReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
 {
     OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
 
@@ -131,7 +130,7 @@ OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse
     return OC_STACK_DELETE_TRANSACTION;
 }
 
-OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientResponse *clientResponse)
+OCStackApplicationResult postReqCB(void *, OCDoHandle, OCClientResponse *clientResponse)
 {
     OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
 
@@ -144,7 +143,7 @@ OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientRespons
     return OC_STACK_DELETE_TRANSACTION;
 }
 
-OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
+OCStackApplicationResult getReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
 {
     OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
 
@@ -159,7 +158,7 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse
 }
 
 // This is a function called back when a device is discovered
-OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
+OCStackApplicationResult discoveryReqCB(void*, OCDoHandle,
         OCClientResponse * clientResponse)
 {
     OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
@@ -177,10 +176,11 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
             OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
 
             ocConnType = clientResponse->connType;
+            endpoint = clientResponse->devAddr;
 
             if (parseClientResponse(clientResponse) != -1)
             {
-                switch(TEST_CASE)
+                switch(TestCase)
                 {
                     case TEST_NON_CON_OP:
                         InitGetRequest(OC_LOW_QOS);
@@ -197,7 +197,7 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
         }
     }
 
-    return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
+    return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
 
 }
 
@@ -205,9 +205,9 @@ int InitPutRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << (coapSecureResource ? "coaps://" : "coap://") << coapServerIP
-        << ":" << coapServerPort  << coapServerResource;
-    return (InvokeOCDoResource(query, OC_REST_PUT,
+    query << coapServerResource;
+    endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
+    return (InvokeOCDoResource(query, OC_REST_PUT, &endpoint,
             ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS), putReqCB, NULL, 0));
 }
 
@@ -216,11 +216,11 @@ int InitPostRequest(OCQualityOfService qos)
     OCStackResult result;
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << (coapSecureResource ? "coaps://" : "coap://") << coapServerIP
-        << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
+    endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
 
     // First POST operation (to create an LED instance)
-    result = InvokeOCDoResource(query, OC_REST_POST,
+    result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
             ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
             postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -230,7 +230,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // Second POST operation (to create an LED instance)
-    result = InvokeOCDoResource(query, OC_REST_POST,
+    result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
             ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
             postReqCB, NULL, 0);
     if (OC_STACK_OK != result)
@@ -239,7 +239,7 @@ int InitPostRequest(OCQualityOfService qos)
     }
 
     // This POST operation will update the original resourced /a/led
-    return (InvokeOCDoResource(query, OC_REST_POST,
+    return (InvokeOCDoResource(query, OC_REST_POST, &endpoint,
                 ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
                 postReqCB, NULL, 0));
 }
@@ -248,45 +248,38 @@ int InitGetRequest(OCQualityOfService qos)
 {
     OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
     std::ostringstream query;
-    query << (coapSecureResource ? "coaps://" : "coap://") << coapServerIP
-        << ":" << coapServerPort << coapServerResource;
+    query << coapServerResource;
+    endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
 
-    return (InvokeOCDoResource(query, OC_REST_GET, (qos == OC_HIGH_QOS)?
-            OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0));
+    return (InvokeOCDoResource(query, OC_REST_GET, &endpoint,
+                ((qos == OC_HIGH_QOS)?  OC_HIGH_QOS:OC_LOW_QOS),
+                getReqCB, NULL, 0));
 }
 
 int InitDiscovery()
 {
     OCStackResult ret;
-    OCMethod method;
     OCCallbackData cbData;
-    char szQueryUri[MAX_URI_LENGTH] = { 0 };
+    char queryUri[200];
+    char ipaddr[100] = { '\0' };
 
-    if (UNICAST_DISCOVERY)
+    if (UnicastDiscovery)
     {
-        char ipv4addr[IPV4_ADDR_SIZE];
-        OC_LOG(INFO, TAG, "Enter IPv4 address:port of the Server hosting secure resource"\
-                "(Ex: 11.12.13.14:1234)\n");
-        if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
+        OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+        OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+        OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+
+        if (fgets(ipaddr, sizeof (ipaddr), stdin))
         {
-            //Strip newline char from ipv4addr
-            StripNewLineChar(ipv4addr);
-            snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DISCOVERY_QUERY, ipv4addr);
+            StripNewLineChar(ipaddr); //Strip newline char from ipaddr
         }
         else
         {
-            OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
+            OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
             return OC_STACK_INVALID_PARAM;
         }
-        method = OC_REST_GET;
-    }
-    else
-    {
-        //Send discovery request on Wifi and Ethernet interface
-        discoveryReqConnType = CT_DEFAULT;
-        OICStrcpy(szQueryUri, sizeof(szQueryUri), MULTICAST_DISCOVERY_QUERY);
-        method = OC_REST_DISCOVER;
     }
+    snprintf(queryUri, sizeof (queryUri), DISCOVERY_QUERY, ipaddr);
 
     cbData.cb = discoveryReqCB;
     cbData.context = NULL;
@@ -294,12 +287,11 @@ int InitDiscovery()
 
     /* Start a discovery query*/
     OC_LOG_V(INFO, TAG, "Initiating %s Resource Discovery : %s\n",
-        (UNICAST_DISCOVERY) ? "Unicast" : "Multicast",
-        szQueryUri);
+        (UnicastDiscovery) ? "Unicast" : "Multicast",
+        queryUri);
 
-    ret = OCDoResource(NULL, method, szQueryUri, 0, 0,
-            discoveryReqConnType, OC_LOW_QOS,
-            &cbData, NULL, 0);
+    ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,
+                       OC_LOW_QOS, &cbData, NULL, 0);
     if (ret != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "OCStack resource error");
@@ -323,13 +315,13 @@ int main(int argc, char* argv[])
         switch(opt)
         {
             case 'u':
-                UNICAST_DISCOVERY = atoi(optarg);
+                UnicastDiscovery = atoi(optarg);
                 break;
             case 't':
-                TEST_CASE = atoi(optarg);
+                TestCase = atoi(optarg);
                 break;
             case 'c':
-                CONN_TYPE = atoi(optarg);
+                ConnType = atoi(optarg);
                 break;
             default:
                 PrintUsage();
@@ -337,16 +329,16 @@ int main(int argc, char* argv[])
         }
     }
 
-    if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
-            (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS)||
-            (CONN_TYPE < CT_ADAPTER_DEFAULT || CONN_TYPE >= MAX_CT))
+    if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) ||
+            (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS)||
+            (ConnType < CT_ADAPTER_DEFAULT || ConnType >= MAX_CT))
     {
         PrintUsage();
         return -1;
     }
 
 
-    if(CONN_TYPE == CT_ADAPTER_DEFAULT || CONN_TYPE ==  CT_IP)
+    if(ConnType == CT_ADAPTER_DEFAULT || ConnType ==  CT_IP)
     {
         discoveryReqConnType = CT_DEFAULT;
     }
@@ -358,12 +350,7 @@ int main(int argc, char* argv[])
 
 
     // Initialize Persistent Storage for SVR database
-    OCPersistentStorage ps = {};
-    ps.open = client_fopen;
-    ps.read = fread;
-    ps.write = fwrite;
-    ps.close = fclose;
-    ps.unlink = unlink;
+    OCPersistentStorage ps = { client_fopen, fread, fwrite, fclose, unlink };
     OCRegisterPersistentStorageHandler(&ps);
 
     /* Initialize OCStack*/
@@ -401,41 +388,27 @@ int main(int argc, char* argv[])
     return 0;
 }
 
-std::string getPortTBServer(OCClientResponse * clientResponse)
-{
-    if(!clientResponse) return "";
-    std::ostringstream ss;
-    ss << clientResponse->devAddr.port;
-    return ss.str();
-}
-
 int parseClientResponse(OCClientResponse * clientResponse)
 {
     OCResourcePayload* res = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
 
     // Initialize all global variables
     coapServerResource.clear();
-    coapServerPort.clear();
-    coapServerIP.clear();
     coapSecureResource = 0;
 
-    while(res)
+    while (res)
     {
         coapServerResource.assign(res->uri);
         OC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
 
-        if(res->secure)
+        if (res->secure)
         {
+            endpoint.port = res->port;
             coapSecureResource = 1;
         }
 
         OC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
 
-        std::ostringstream ss;
-        ss << res->port;
-        coapServerPort = ss.str();
-        std::cout<<"PORT: "<<coapServerPort;
-
         // If we discovered a secure resource, exit from here
         if (coapSecureResource)
         {
@@ -445,14 +418,6 @@ int parseClientResponse(OCClientResponse * clientResponse)
         res = res->next;
     }
 
-    coapServerIP = clientResponse->devAddr.addr;
-
-    if(coapServerPort.length() == 0 || coapServerPort == "0")
-    {
-        coapServerPort = getPortTBServer(clientResponse);
-        OC_LOG_V(INFO, TAG, "Hosting Server Port -- %s", coapServerPort.c_str());
-    }
-
     return 0;
 }
 
index d72c136..a95c618 100644 (file)
@@ -19,6 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "ocpayloadcbor.h"
+#include "platform_features.h"
 #include <stdlib.h>
 #include "oic_malloc.h"
 #include "logger.h"
 #include "cbor.h"
 
 #define TAG PCF("OCPayloadConvert")
+// Arbitrarily chosen size that seems to contain the majority of packages
+#define INIT_SIZE (255)
 
-static OCStackResult OCConvertDiscoveryPayload(OCDiscoveryPayload* payload, uint8_t** outPayload,
+// Functions all return either a CborError, or a negative version of the OC_STACK return values
+static int64_t OCConvertPayloadHelper(OCPayload* payload, uint8_t* outPayload, size_t* size);
+static int64_t OCConvertDiscoveryPayload(OCDiscoveryPayload* payload, uint8_t* outPayload,
         size_t* size);
-static OCStackResult OCConvertDevicePayload(OCDevicePayload* payload, uint8_t** outPayload,
+static int64_t OCConvertDevicePayload(OCDevicePayload* payload, uint8_t* outPayload,
         size_t* size);
-static OCStackResult OCConvertPlatformPayload(OCPlatformPayload* payload, uint8_t** outPayload,
+static int64_t OCConvertPlatformPayload(OCPlatformPayload* payload, uint8_t* outPayload,
         size_t* size);
-static OCStackResult OCConvertRepPayload(OCRepPayload* payload, uint8_t** outPayload, size_t* size);
-static OCStackResult OCConvertPresencePayload(OCPresencePayload* payload, uint8_t** outPayload,
+static int64_t OCConvertRepPayload(OCRepPayload* payload, uint8_t* outPayload, size_t* size);
+static int64_t OCConvertPresencePayload(OCPresencePayload* payload, uint8_t* outPayload,
         size_t* size);
-static OCStackResult OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t** outPayload,
+static int64_t OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t* outPayload,
         size_t* size);
+static int64_t OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* payload);
+static int64_t OCConvertArray(CborEncoder* parent, const OCRepPayloadValueArray* valArray);
 
-bool AddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
+static int64_t AddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
         const char* value);
 
-bool ConditionalAddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
+static int64_t ConditionalAddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
         const char* value);
 
+#define STRINGIFY(s) XSTRINGIFY(s)
+#define XSTRINGIFY(s) #s
 
 OCStackResult OCConvertPayload(OCPayload* payload, uint8_t** outPayload, size_t* size)
 {
+    // TinyCbor Version 47a78569c0 or better on master is required for the re-allocation
+    // strategy to work.  If you receive the following assertion error, please do a git-pull
+    // from the extlibs/tinycbor/tinycbor directory
+    #define CborNeedsUpdating  (CborErrorOutOfMemory < CborErrorDataTooLarge)
+    OC_STATIC_ASSERT(!CborNeedsUpdating, "tinycbor needs to be updated to at least 47a78569c0");
+    #undef CborNeedsUpdating
+    if (!payload)
+    {
+        OC_LOG(ERROR, TAG, PCF("Payload parameter NULL"));
+        return OC_STACK_INVALID_PARAM;
+    }
+
+    if (!outPayload || !size)
+    {
+        OC_LOG(ERROR, TAG, PCF("Out parameter/s parameter NULL"));
+        return OC_STACK_INVALID_PARAM;
+    }
+
     OC_LOG_V(INFO, TAG, "Converting payload of type %d", payload->type);
+
+    size_t curSize = INIT_SIZE;
+    uint8_t* out = (uint8_t*)OICCalloc(1, curSize);
+    int64_t err = OCConvertPayloadHelper(payload, out, &curSize);
+
+    if (err == CborErrorOutOfMemory)
+    {
+        // reallocate "out" and try again!
+        uint8_t* out2 = (uint8_t*)OICRealloc(out, curSize);
+
+        if (!out2)
+        {
+            OICFree(out);
+            return OC_STACK_NO_MEMORY;
+        }
+
+        out = out2;
+        err = OCConvertPayloadHelper(payload, out, &curSize);
+    }
+
+    if (err == 0)
+    {
+        if (curSize < INIT_SIZE)
+        {
+            uint8_t* out2 = (uint8_t*)OICRealloc(out, curSize);
+
+            if (!out2)
+            {
+                OICFree(out);
+                return OC_STACK_NO_MEMORY;
+            }
+        }
+
+        *size = curSize;
+        *outPayload = out;
+        return OC_STACK_OK;
+    }
+    else if (err < 0)
+    {
+        return (OCStackResult)-err;
+    }
+    else
+    {
+        return OC_STACK_ERROR;
+    }
+}
+
+static int64_t OCConvertPayloadHelper(OCPayload* payload, uint8_t* outPayload, size_t* size)
+{
     switch(payload->type)
     {
         case PAYLOAD_TYPE_DISCOVERY:
@@ -71,82 +147,66 @@ OCStackResult OCConvertPayload(OCPayload* payload, uint8_t** outPayload, size_t*
     }
 }
 
-static OCStackResult OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t** outPayload,
-        size_t* size)
+static int64_t checkError(int64_t err, CborEncoder* encoder, uint8_t* outPayload, size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
+    if (err == CborErrorOutOfMemory)
     {
-        return OC_STACK_NO_MEMORY;
+        *size += encoder->ptr - encoder->end;
+        return err;
     }
-
+    else if (err != 0)
+    {
+        OC_LOG_V(ERROR, TAG, "Convert Payload failed", err);
+        return err;
+    }
+    else
+    {
+        *size = encoder->ptr - outPayload;
+        return 0;
+    }
+}
+static int64_t OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t* outPayload,
+        size_t* size)
+{
     CborEncoder encoder;
-    bool err = false;
+    int64_t err = 0;
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
 
     CborEncoder rootArray;
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, 2);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_SECURITY);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, 2);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_SECURITY);
 
     CborEncoder map;
 
-    err = err || cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
+    err = err | cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
 
     if(payload->securityData)
     {
-        err = err || AddTextStringToMap(&map, OC_RSRVD_REPRESENTATION,
+        err = err | AddTextStringToMap(&map, OC_RSRVD_REPRESENTATION,
                 sizeof(OC_RSRVD_REPRESENTATION) - 1,
                 payload->securityData);
     }
 
-    err = err || cbor_encoder_close_container(&rootArray, &map);
-
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
-
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Security Payload failed", err);
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
+    err = err | cbor_encoder_close_container(&rootArray, &map);
 
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
+    return checkError(err, &encoder, outPayload, size);
 
-    *outPayload = tempPayload;
-    return OC_STACK_OK;
 }
 
-static OCStackResult OCConvertDiscoveryPayload(OCDiscoveryPayload* payload, uint8_t** outPayload,
+static int64_t OCConvertDiscoveryPayload(OCDiscoveryPayload* payload, uint8_t* outPayload,
         size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-
     CborEncoder encoder = {0};
-    bool err = false;
+    int64_t err = 0;
     size_t resourceCount =  OCDiscoveryPayloadGetResourceCount(payload);
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
 
     CborEncoder rootArray;
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, 1 + resourceCount);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_DISCOVERY);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, 1 + resourceCount);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_DISCOVERY);
 
     for(size_t i = 0; i < resourceCount; ++i)
     {
@@ -155,333 +215,262 @@ static OCStackResult OCConvertDiscoveryPayload(OCDiscoveryPayload* payload, uint
 
         if(!resource)
         {
-            OICFree(*outPayload);
             return OC_STACK_INVALID_PARAM;
         }
 
-        err = err || cbor_encoder_create_map(&rootArray, &map, 3);
+        err = err | cbor_encoder_create_map(&rootArray, &map, 3);
         // Uri
-        err = err || AddTextStringToMap(&map, OC_RSRVD_HREF,
+        err = err | AddTextStringToMap(&map, OC_RSRVD_HREF,
                 sizeof(OC_RSRVD_HREF) - 1,
                 resource->uri);
 
         // Server ID
-        err = err || cbor_encode_text_string(&map, OC_RSRVD_SERVER_INSTANCE_ID,
+        err = err | cbor_encode_text_string(&map, OC_RSRVD_SERVER_INSTANCE_ID,
                 sizeof(OC_RSRVD_SERVER_INSTANCE_ID) - 1);
-        err = err || cbor_encode_byte_string(&map, resource->sid, UUID_SIZE);
+        err = err | cbor_encode_byte_string(&map, resource->sid, UUID_SIZE);
         // Prop Tag
         {
             CborEncoder propMap;
-            err = err || cbor_encode_text_string(&map, OC_RSRVD_PROPERTY,
+            err = err | cbor_encode_text_string(&map, OC_RSRVD_PROPERTY,
                     sizeof(OC_RSRVD_PROPERTY) -1 );
-            err = err || cbor_encoder_create_map(&map, &propMap, 3);
+            err = err | cbor_encoder_create_map(&map, &propMap, 3);
 
             // Resource Type
             {
                 CborEncoder rtArray;
-                err = err || cbor_encode_text_string(&propMap, OC_RSRVD_RESOURCE_TYPE,
+                err = err | cbor_encode_text_string(&propMap, OC_RSRVD_RESOURCE_TYPE,
                     sizeof(OC_RSRVD_RESOURCE_TYPE) - 1);
-                err = err || cbor_encoder_create_array(&propMap, &rtArray, CborIndefiniteLength);
+                err = err | cbor_encoder_create_array(&propMap, &rtArray, CborIndefiniteLength);
 
                 OCStringLL* rtPtr = resource->types;
                 while(rtPtr)
                 {
-                    err = err || cbor_encode_text_string(&rtArray, rtPtr->value,
+                    err = err | cbor_encode_text_string(&rtArray, rtPtr->value,
                             strlen(rtPtr->value));
                     rtPtr = rtPtr->next;
                 }
 
-                err = err || cbor_encoder_close_container(&propMap, &rtArray);
+                err = err | cbor_encoder_close_container(&propMap, &rtArray);
             }
 
             // Interface Types
             {
                 CborEncoder ifArray;
-                err = err || cbor_encode_text_string(&propMap, OC_RSRVD_INTERFACE,
+                err = err | cbor_encode_text_string(&propMap, OC_RSRVD_INTERFACE,
                         sizeof(OC_RSRVD_INTERFACE) - 1);
-                err = err || cbor_encoder_create_array(&propMap, &ifArray, CborIndefiniteLength);
+                err = err | cbor_encoder_create_array(&propMap, &ifArray, CborIndefiniteLength);
                 OCStringLL* ifPtr = resource->interfaces;
 
                 while(ifPtr)
                 {
-                    err = err || cbor_encode_text_string(&ifArray, ifPtr->value,
+                    err = err | cbor_encode_text_string(&ifArray, ifPtr->value,
                         strlen(ifPtr->value));
                     ifPtr= ifPtr->next;
                 }
 
-                err = err || cbor_encoder_close_container(&propMap, &ifArray);
+                err = err | cbor_encoder_close_container(&propMap, &ifArray);
             }
             // Policy
             {
                 CborEncoder policyMap;
-                err = err || cbor_encode_text_string(&propMap, OC_RSRVD_POLICY,
+                err = err | cbor_encode_text_string(&propMap, OC_RSRVD_POLICY,
                         sizeof(OC_RSRVD_POLICY) - 1);
-                err = err || cbor_encoder_create_map(&propMap, &policyMap, CborIndefiniteLength);
+                err = err | cbor_encoder_create_map(&propMap, &policyMap, CborIndefiniteLength);
 
                 // Bitmap
-                err = err || cbor_encode_text_string(&policyMap, OC_RSRVD_BITMAP,
+                err = err | cbor_encode_text_string(&policyMap, OC_RSRVD_BITMAP,
                         sizeof(OC_RSRVD_BITMAP) - 1);
-                err = err || cbor_encode_uint(&policyMap, resource->bitmap);
+                err = err | cbor_encode_uint(&policyMap, resource->bitmap);
 
                 if(resource->secure)
                 {
-                    err = err || cbor_encode_text_string(&policyMap, OC_RSRVD_SECURE,
+                    err = err | cbor_encode_text_string(&policyMap, OC_RSRVD_SECURE,
                             sizeof(OC_RSRVD_SECURE) - 1);
-                    err = err || cbor_encode_boolean(&policyMap, OC_RESOURCE_SECURE);
+                    err = err | cbor_encode_boolean(&policyMap, OC_RESOURCE_SECURE);
 
                     if(resource->port != 0)
                     {
-                        err = err || cbor_encode_text_string(&policyMap, OC_RSRVD_HOSTING_PORT,
+                        err = err | cbor_encode_text_string(&policyMap, OC_RSRVD_HOSTING_PORT,
                                 sizeof(OC_RSRVD_HOSTING_PORT) - 1);
-                        err = err || cbor_encode_uint(&policyMap, resource->port);
+                        err = err | cbor_encode_uint(&policyMap, resource->port);
                     }
                 }
 
-                err = err || cbor_encoder_close_container(&propMap, &policyMap);
+                err = err | cbor_encoder_close_container(&propMap, &policyMap);
             }
             // Close
-            err = err || cbor_encoder_close_container(&map, &propMap);
+            err = err | cbor_encoder_close_container(&map, &propMap);
         }
         // Close Item
-        err = err || cbor_encoder_close_container(&rootArray, &map);
+        err = err | cbor_encoder_close_container(&rootArray, &map);
     }
     // Close main array
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
 
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Discovery Payload failed with : %d", err);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
-
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
-
-    *outPayload = tempPayload;
-    return OC_STACK_OK;
+    return checkError(err, &encoder, outPayload, size);
 }
 
-static OCStackResult OCConvertDevicePayload(OCDevicePayload* payload, uint8_t** outPayload,
+static int64_t OCConvertDevicePayload(OCDevicePayload* payload, uint8_t* outPayload,
         size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-
     CborEncoder encoder = {0};
-    bool err = false;
+    int64_t err = 0;
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
     CborEncoder rootArray;
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, 2);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_DEVICE);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, 2);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_DEVICE);
 
     {
         CborEncoder map;
-        err = err || cbor_encoder_create_map(&rootArray, &map, 2);
+        err = err | cbor_encoder_create_map(&rootArray, &map, 2);
 
         // uri
-        err = err || AddTextStringToMap(&map, OC_RSRVD_HREF, sizeof(OC_RSRVD_HREF) - 1,
+        err = err | AddTextStringToMap(&map, OC_RSRVD_HREF, sizeof(OC_RSRVD_HREF) - 1,
                 payload->uri);
 
         // Rep Map
         {
             CborEncoder repMap;
-            err = err || cbor_encode_text_string(&map, OC_RSRVD_REPRESENTATION,
+            err = err | cbor_encode_text_string(&map, OC_RSRVD_REPRESENTATION,
                     sizeof(OC_RSRVD_REPRESENTATION) - 1);
-            err = err || cbor_encoder_create_map(&map, &repMap, 4);
+            err = err | cbor_encoder_create_map(&map, &repMap, 4);
 
             // Device ID
-            err = err || cbor_encode_text_string(&repMap, OC_RSRVD_DEVICE_ID,
+            err = err | cbor_encode_text_string(&repMap, OC_RSRVD_DEVICE_ID,
                     sizeof(OC_RSRVD_DEVICE_ID) - 1);
-            err = err || cbor_encode_byte_string(&repMap, payload->sid, UUID_SIZE);
+            err = err | cbor_encode_byte_string(&repMap, payload->sid, UUID_SIZE);
 
             // Device Name
-            err = err || AddTextStringToMap(&repMap, OC_RSRVD_DEVICE_NAME,
+            err = err | AddTextStringToMap(&repMap, OC_RSRVD_DEVICE_NAME,
                     sizeof(OC_RSRVD_DEVICE_NAME) - 1,
                     payload->deviceName);
 
             // Device Spec Version
-            err = err || AddTextStringToMap(&repMap, OC_RSRVD_SPEC_VERSION,
+            err = err | AddTextStringToMap(&repMap, OC_RSRVD_SPEC_VERSION,
                     sizeof(OC_RSRVD_SPEC_VERSION) - 1,
                     payload->specVersion);
 
             // Device data Model Version
-            err = err || AddTextStringToMap(&repMap, OC_RSRVD_DATA_MODEL_VERSION,
+            err = err | AddTextStringToMap(&repMap, OC_RSRVD_DATA_MODEL_VERSION,
                     sizeof(OC_RSRVD_DATA_MODEL_VERSION) - 1,
                     payload->dataModelVersion);
 
-            err = err || cbor_encoder_close_container(&map, &repMap);
+            err = err | cbor_encoder_close_container(&map, &repMap);
         }
 
         // Close Map
-        err = err || cbor_encoder_close_container(&rootArray, &map);
+        err = err | cbor_encoder_close_container(&rootArray, &map);
     }
 
     // Close main array
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
-
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Device Payload failed with : %d", err);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
-
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
 
-    *outPayload = tempPayload;
-    return OC_STACK_OK;
+    return checkError(err, &encoder, outPayload, size);
 }
 
-static OCStackResult OCConvertPlatformPayload(OCPlatformPayload* payload, uint8_t** outPayload,
+static int64_t OCConvertPlatformPayload(OCPlatformPayload* payload, uint8_t* outPayload,
         size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-
     CborEncoder encoder = {0};
-    bool err = false;
+    int64_t err = 0;
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
     CborEncoder rootArray;
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, 2);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_PLATFORM);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, 2);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_PLATFORM);
     {
         CborEncoder map;
-        err = err || cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
+        err = err | cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
 
         // uri
-        err = err || AddTextStringToMap(&map, OC_RSRVD_HREF, sizeof(OC_RSRVD_HREF) - 1,
+        err = err | AddTextStringToMap(&map, OC_RSRVD_HREF, sizeof(OC_RSRVD_HREF) - 1,
                 payload->uri);
 
         // Rep Map
         {
             CborEncoder repMap;
-            err = err || cbor_encode_text_string(&map, OC_RSRVD_REPRESENTATION,
+            err = err | cbor_encode_text_string(&map, OC_RSRVD_REPRESENTATION,
                     sizeof(OC_RSRVD_REPRESENTATION) - 1);
-            err = err || cbor_encoder_create_map(&map, &repMap, CborIndefiniteLength);
+            err = err | cbor_encoder_create_map(&map, &repMap, CborIndefiniteLength);
 
             // Platform ID
-            err = err || AddTextStringToMap(&repMap, OC_RSRVD_PLATFORM_ID,
+            err = err | AddTextStringToMap(&repMap, OC_RSRVD_PLATFORM_ID,
                     sizeof(OC_RSRVD_PLATFORM_ID) - 1,
                     payload->info.platformID);
 
             // MFG Name
-            err = err || AddTextStringToMap(&repMap, OC_RSRVD_MFG_NAME,
+            err = err | AddTextStringToMap(&repMap, OC_RSRVD_MFG_NAME,
                     sizeof(OC_RSRVD_MFG_NAME) - 1,
                     payload->info.manufacturerName);
 
             // MFG Url
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MFG_URL,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MFG_URL,
                     sizeof(OC_RSRVD_MFG_URL) - 1,
                     payload->info.manufacturerUrl);
 
             // Model Num
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MODEL_NUM,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MODEL_NUM,
                     sizeof(OC_RSRVD_MODEL_NUM) - 1,
                     payload->info.modelNumber);
 
             // Date of Mfg
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MFG_DATE,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_MFG_DATE,
                     sizeof(OC_RSRVD_MFG_DATE) - 1,
                     payload->info.dateOfManufacture);
 
             // Platform Version
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_PLATFORM_VERSION,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_PLATFORM_VERSION,
                     sizeof(OC_RSRVD_PLATFORM_VERSION) - 1,
                     payload->info.platformVersion);
 
             // OS Version
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_OS_VERSION,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_OS_VERSION,
                     sizeof(OC_RSRVD_OS_VERSION) - 1,
                     payload->info.operatingSystemVersion);
 
             // Hardware Version
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_HARDWARE_VERSION,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_HARDWARE_VERSION,
                     sizeof(OC_RSRVD_HARDWARE_VERSION) - 1,
                     payload->info.hardwareVersion);
 
             // Firmware Version
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_FIRMWARE_VERSION,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_FIRMWARE_VERSION,
                     sizeof(OC_RSRVD_FIRMWARE_VERSION) - 1,
                     payload->info.firmwareVersion);
 
             // Support URL
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_SUPPORT_URL,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_SUPPORT_URL,
                     sizeof(OC_RSRVD_SUPPORT_URL) - 1,
                     payload->info.supportUrl);
 
             // System Time
-            err = err || ConditionalAddTextStringToMap(&repMap, OC_RSRVD_SYSTEM_TIME,
+            err = err | ConditionalAddTextStringToMap(&repMap, OC_RSRVD_SYSTEM_TIME,
                     sizeof(OC_RSRVD_SYSTEM_TIME) - 1,
                     payload->info.systemTime);
-            err = err || cbor_encoder_close_container(&map, &repMap);
+            err = err | cbor_encoder_close_container(&map, &repMap);
         }
 
         // Close Map
-        err = err || cbor_encoder_close_container(&rootArray, &map);
+        err = err | cbor_encoder_close_container(&rootArray, &map);
     }
 
     // Close main array
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
-
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Platform Payload failed with : %d", err);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
-
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
-
-    *outPayload = tempPayload;
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
 
-    return OC_STACK_OK;
+    return checkError(err, &encoder, outPayload, size);
 }
 
-static bool OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* payload);
-
-static bool OCConvertArray(CborEncoder* parent, const OCRepPayloadValueArray* valArray)
+static int64_t OCConvertArray(CborEncoder* parent, const OCRepPayloadValueArray* valArray)
 {
     CborEncoder array;
-    bool err = false;
+    int64_t err = 0;
 
-    err = err || cbor_encoder_create_array(parent, &array, CborIndefiniteLength);
-    err = err || cbor_encode_uint(&array, valArray->type);
+    err = err | cbor_encoder_create_array(parent, &array, CborIndefiniteLength);
+    err = err | cbor_encode_uint(&array, valArray->type);
     for(int i = 0; i < MAX_REP_ARRAY_DEPTH; ++i)
     {
-        err = err || cbor_encode_uint(&array, valArray->dimensions[i]);
+        err = err | cbor_encode_uint(&array, valArray->dimensions[i]);
     }
 
     size_t dimTotal = calcDimTotal(valArray->dimensions);
@@ -495,16 +484,16 @@ static bool OCConvertArray(CborEncoder* parent, const OCRepPayloadValueArray* va
                 err = CborUnknownError;
                 break;
             case OCREP_PROP_INT:
-                err = err || cbor_encode_int(&array, valArray->iArray[i]);
+                err = err | cbor_encode_int(&array, valArray->iArray[i]);
                 break;
             case OCREP_PROP_DOUBLE:
-                err = err || cbor_encode_double(&array, valArray->dArray[i]);
+                err = err | cbor_encode_double(&array, valArray->dArray[i]);
                 break;
             case OCREP_PROP_BOOL:
-                err = err || cbor_encode_boolean(&array, valArray->bArray[i]);
+                err = err | cbor_encode_boolean(&array, valArray->bArray[i]);
                 break;
             case OCREP_PROP_STRING:
-                err = err || cbor_encode_text_string(&array, valArray->strArray[i],
+                err = err | cbor_encode_text_string(&array, valArray->strArray[i],
                         strlen(valArray->strArray[i]));
                 break;
             case OCREP_PROP_OBJECT:
@@ -517,18 +506,18 @@ static bool OCConvertArray(CborEncoder* parent, const OCRepPayloadValueArray* va
         }
     }
 
-    err = err || cbor_encoder_close_container(parent, &array);
+    err = err | cbor_encoder_close_container(parent, &array);
     return err;
 }
 
-static bool OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* payload)
+static int64_t OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* payload)
 {
-    bool err = false;
+    int64_t err = 0;
     CborEncoder map;
-    err = err || cbor_encoder_create_map(parent, &map, CborIndefiniteLength);
+    err = err | cbor_encoder_create_map(parent, &map, CborIndefiniteLength);
 
     // Uri
-    err = err || ConditionalAddTextStringToMap(&map, OC_RSRVD_HREF,
+    err = err | ConditionalAddTextStringToMap(&map, OC_RSRVD_HREF,
             sizeof(OC_RSRVD_HREF) - 1,
             payload->uri);
 
@@ -537,83 +526,83 @@ static bool OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* p
     if(payload->types || payload->interfaces)
     {
         OC_LOG_V(INFO, TAG, "Payload has types or interfaces");
-        err = err || cbor_encode_text_string(&map,
+        err = err | cbor_encode_text_string(&map,
                 OC_RSRVD_PROPERTY,
                 sizeof(OC_RSRVD_PROPERTY) - 1);
         CborEncoder propMap;
-        err = err || cbor_encoder_create_map(&map, &propMap, 2);
+        err = err | cbor_encoder_create_map(&map, &propMap, 2);
 
         CborEncoder curArray;
         if(payload->types)
         {
-            err = err || cbor_encode_text_string(&propMap,
+            err = err | cbor_encode_text_string(&propMap,
                     OC_RSRVD_RESOURCE_TYPE,
                     sizeof(OC_RSRVD_RESOURCE_TYPE) - 1);
-            err = err || cbor_encoder_create_array(&propMap, &curArray, CborIndefiniteLength);
+            err = err | cbor_encoder_create_array(&propMap, &curArray, CborIndefiniteLength);
             OCStringLL* val = payload->types;
             while(val)
             {
-                err = err || cbor_encode_text_string(&curArray, val->value, strlen(val->value));
+                err = err | cbor_encode_text_string(&curArray, val->value, strlen(val->value));
                 val = val->next;
             }
-            err = err || cbor_encoder_close_container(&propMap, &curArray);
+            err = err | cbor_encoder_close_container(&propMap, &curArray);
         }
         if(payload->interfaces)
         {
-            err = err || cbor_encode_text_string(&propMap,
+            err = err | cbor_encode_text_string(&propMap,
                     OC_RSRVD_INTERFACE,
                     sizeof(OC_RSRVD_INTERFACE) - 1);
-            err = err || cbor_encoder_create_array(&propMap, &curArray, CborIndefiniteLength);
+            err = err | cbor_encoder_create_array(&propMap, &curArray, CborIndefiniteLength);
             OCStringLL* val = payload->interfaces;
             while(val)
             {
-                err = err || cbor_encode_text_string(&curArray, val->value, strlen(val->value));
+                err = err | cbor_encode_text_string(&curArray, val->value, strlen(val->value));
                 val = val->next;
             }
-            err = err || cbor_encoder_close_container(&propMap, &curArray);
+            err = err | cbor_encoder_close_container(&propMap, &curArray);
         }
-        err = err || cbor_encoder_close_container(&map, &propMap);
+        err = err | cbor_encoder_close_container(&map, &propMap);
     }
 
     // Rep Map
     {
         CborEncoder repMap;
-        err = err || cbor_encode_text_string(&map,
+        err = err | cbor_encode_text_string(&map,
                 OC_RSRVD_REPRESENTATION,
                 sizeof(OC_RSRVD_REPRESENTATION) - 1);
-        err = err || cbor_encoder_create_map(&map, &repMap, CborIndefiniteLength);
+        err = err | cbor_encoder_create_map(&map, &repMap, CborIndefiniteLength);
         OCRepPayloadValue* value = payload->values;
         while(value)
         {
-            err = err || cbor_encode_text_string(&repMap,
+            err = err | cbor_encode_text_string(&repMap,
                     value->name,
                     strlen(value->name));
             switch(value->type)
             {
                 case OCREP_PROP_NULL:
-                    err = err || cbor_encode_null(&repMap);
+                    err = err | cbor_encode_null(&repMap);
                     break;
                 case OCREP_PROP_INT:
-                    err = err || cbor_encode_int(&repMap,
+                    err = err | cbor_encode_int(&repMap,
                             value->i);
                     break;
                 case OCREP_PROP_DOUBLE:
-                    err = err || cbor_encode_double(&repMap,
+                    err = err | cbor_encode_double(&repMap,
                             value->d);
                     break;
                 case OCREP_PROP_BOOL:
-                    err = err || cbor_encode_boolean(&repMap,
+                    err = err | cbor_encode_boolean(&repMap,
                             value->b);
                     break;
                 case OCREP_PROP_STRING:
-                    err = err || cbor_encode_text_string(&repMap,
+                    err = err | cbor_encode_text_string(&repMap,
                             value->str, strlen(value->str));
                     break;
                 case OCREP_PROP_OBJECT:
-                    err = err || OCConvertSingleRepPayload(&repMap, value->obj);
+                    err = err | OCConvertSingleRepPayload(&repMap, value->obj);
                     break;
                 case OCREP_PROP_ARRAY:
-                    err = err || OCConvertArray(&repMap, &value->arr);
+                    err = err | OCConvertArray(&repMap, &value->arr);
                     break;
                 default:
                     OC_LOG_V(ERROR, TAG, "Invalid Prop type: %d",
@@ -623,145 +612,93 @@ static bool OCConvertSingleRepPayload(CborEncoder* parent, const OCRepPayload* p
             value = value->next;
         }
 
-        err = err || cbor_encoder_close_container(&map, &repMap);
+        err = err | cbor_encoder_close_container(&map, &repMap);
     }
 
     // Close Map
-    err = err || cbor_encoder_close_container(parent, &map);
+    err = err | cbor_encoder_close_container(parent, &map);
 
     return err;
 }
 
-static OCStackResult OCConvertRepPayload(OCRepPayload* payload, uint8_t** outPayload, size_t* size)
+static int64_t OCConvertRepPayload(OCRepPayload* payload, uint8_t* outPayload, size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-
     CborEncoder encoder = {0};
-    bool err = false;
+    int64_t err = 0;
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
     CborEncoder rootArray;
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, CborIndefiniteLength);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_REPRESENTATION);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, CborIndefiniteLength);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_REPRESENTATION);
 
-    while(payload != NULL && !err)
+    while(payload != NULL && (err == 0 || err == CborErrorOutOfMemory))
     {
-        err = err || OCConvertSingleRepPayload(&rootArray, payload);
+        err = err | OCConvertSingleRepPayload(&rootArray, payload);
         payload = payload->next;
     }
 
     // Close main array
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
-
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Rep Payload failed with : %d", err);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
-
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
-
-    *outPayload = tempPayload;
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
 
-    return OC_STACK_OK;
+    return checkError(err, &encoder, outPayload, size);
 }
 
-static OCStackResult OCConvertPresencePayload(OCPresencePayload* payload,
-        uint8_t** outPayload, size_t* size)
+static int64_t OCConvertPresencePayload(OCPresencePayload* payload,
+        uint8_t* outPayload, size_t* size)
 {
-    *outPayload = (uint8_t*)OICCalloc(1, MAX_REQUEST_LENGTH);
-    *size = MAX_REQUEST_LENGTH;
-
-    if(!*outPayload)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-
     CborEncoder encoder = {0};
-    bool err = false;
+    int64_t err = 0;
 
-    cbor_encoder_init(&encoder, *outPayload, *size, 0);
+    cbor_encoder_init(&encoder, outPayload, *size, 0);
     CborEncoder rootArray;
 
-    err = err || cbor_encoder_create_array(&encoder, &rootArray, 2);
-    err = err || cbor_encode_uint(&rootArray, PAYLOAD_TYPE_PRESENCE);
+    err = err | cbor_encoder_create_array(&encoder, &rootArray, 2);
+    err = err | cbor_encode_uint(&rootArray, PAYLOAD_TYPE_PRESENCE);
 
 
     CborEncoder map;
-    err = err || cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
+    err = err | cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
 
     // Sequence Number
-    err = err || cbor_encode_text_string(&map,
+    err = err | cbor_encode_text_string(&map,
             OC_RSRVD_NONCE,
             sizeof(OC_RSRVD_NONCE) - 1);
-    err = err || cbor_encode_uint(&map, payload->sequenceNumber);
+    err = err | cbor_encode_uint(&map, payload->sequenceNumber);
 
     // Max Age
-    err = err || cbor_encode_text_string(&map,
+    err = err | cbor_encode_text_string(&map,
             OC_RSRVD_TTL,
             sizeof(OC_RSRVD_TTL) - 1);
-    err = err || cbor_encode_uint(&map, payload->maxAge);
+    err = err | cbor_encode_uint(&map, payload->maxAge);
 
     // Trigger
     const char* triggerStr = convertTriggerEnumToString(payload->trigger);
-    err = err || AddTextStringToMap(&map, OC_RSRVD_TRIGGER, sizeof(OC_RSRVD_TRIGGER) - 1,
+    err = err | AddTextStringToMap(&map, OC_RSRVD_TRIGGER, sizeof(OC_RSRVD_TRIGGER) - 1,
             triggerStr);
 
     // Resource type name
     if(payload->trigger != OC_PRESENCE_TRIGGER_DELETE)
     {
-        err = err || ConditionalAddTextStringToMap(&map, OC_RSRVD_RESOURCE_TYPE,
+        err = err | ConditionalAddTextStringToMap(&map, OC_RSRVD_RESOURCE_TYPE,
                 sizeof(OC_RSRVD_RESOURCE_TYPE) - 1, payload->resourceType);
     }
 
     // Close Map
-    err = err || cbor_encoder_close_container(&rootArray, &map);
-    err = err || cbor_encoder_close_container(&encoder, &rootArray);
-
-    if(err)
-    {
-        OC_LOG_V(ERROR, TAG, "Convert Presence Payload failed with : %d", err);
-        return OC_STACK_ERROR;
-    }
-
-    *size = encoder.ptr - *outPayload;
-    uint8_t* tempPayload = (uint8_t*)OICRealloc(*outPayload, *size);
-
-    if(!tempPayload)
-    {
-        OC_LOG_V(ERROR, TAG, PCF("Payload realloc failed!"));
-        OICFree(*outPayload);
-        return OC_STACK_ERROR;
-    }
-
-    *outPayload = tempPayload;
+    err = err | cbor_encoder_close_container(&rootArray, &map);
+    err = err | cbor_encoder_close_container(&encoder, &rootArray);
 
-    return OC_STACK_OK;
+    return checkError(err, &encoder, outPayload, size);
 }
 
-bool AddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
+static int64_t AddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
         const char* value)
 {
-    return cbor_encode_text_string(map, key, keylen) ||
+    return cbor_encode_text_string(map, key, keylen) |
            cbor_encode_text_string(map, value, strlen(value));
 }
 
-bool ConditionalAddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
+static int64_t ConditionalAddTextStringToMap(CborEncoder* map, const char* key, size_t keylen,
         const char* value)
 {
-    return value ? AddTextStringToMap(map, key, keylen, value) : false;
+    return value ? AddTextStringToMap(map, key, keylen, value) : 0;
 }
index 05c6b59..aa63c53 100644 (file)
@@ -635,7 +635,7 @@ static bool OCParseArray(OCRepPayload* out, const char* name, CborValue* contain
                      err = err || cbor_value_get_boolean(&insideArray, &(((bool*)arr)[i]));
                      err = err || cbor_value_advance_fixed(&insideArray);
                 }
-                if(err && !OCRepPayloadSetBoolArrayAsOwner(out, name, (bool*)arr, dimensions))
+                if(err || !OCRepPayloadSetBoolArrayAsOwner(out, name, (bool*)arr, dimensions))
                 {
                     OICFree(arr);
                     err = true;
index da12be7..e438bc6 100644 (file)
@@ -669,7 +669,7 @@ static OCStackResult ResetPresenceTTL(ClientCB *cbNode, uint32_t maxAgeSeconds)
 
     cbNode->presence->TTL = maxAgeSeconds;
 
-    for(int index = 0; index < PresenceTimeOutSize; index++)
+    for (int index = 0; index < PresenceTimeOutSize; index++)
     {
         // Guard against overflow
         if (cbNode->presence->TTL < (UINT32_MAX/(MILLISECONDS_PER_SECOND*PresenceTimeOut[index]))
@@ -817,7 +817,7 @@ OCStackResult HandlePresenceResponse(const CAEndpoint_t *endpoint,
 
     // check for unicast presence
     uriLen = FormCanonicalPresenceUri(endpoint, OC_RSRVD_PRESENCE_URI, presenceUri);
-    if (uriLen < 0 || uriLen >= sizeof (presenceUri))
+    if (uriLen < 0 || (size_t)uriLen >= sizeof (presenceUri))
     {
         return OC_STACK_INVALID_URI;
     }
@@ -1046,6 +1046,9 @@ void HandleCAResponses(const CAEndpoint_t* endPoint, const CAResponseInfo_t* res
             CopyEndpointToDevAddr(endPoint, &response.devAddr);
             FixUpClientResponse(&response);
             response.resourceUri = responseInfo->info.resourceUri;
+            memcpy(response.identity.id, responseInfo->info.identity.id,
+                                                sizeof (response.identity.id));
+            response.identity.id_length = responseInfo->info.identity.id_length;
 
             response.result = CAToOCStackResult(responseInfo->result);
             cbNode->callBack(cbNode->context,
@@ -1063,6 +1066,9 @@ void HandleCAResponses(const CAEndpoint_t* endPoint, const CAResponseInfo_t* res
             CopyEndpointToDevAddr(endPoint, &response.devAddr);
             FixUpClientResponse(&response);
             response.resourceUri = responseInfo->info.resourceUri;
+            memcpy(response.identity.id, responseInfo->info.identity.id,
+                                                sizeof (response.identity.id));
+            response.identity.id_length = responseInfo->info.identity.id_length;
 
             response.result = CAToOCStackResult(responseInfo->result);
             if(responseInfo->info.payload &&
@@ -1569,13 +1575,6 @@ OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
 {
     (void) ipAddr;
     (void) port;
-#ifdef RA_ADAPTER
-    if(!gRASetInfo)
-    {
-        OC_LOG(ERROR, TAG, PCF("Need to call OCSetRAInfo before calling OCInit"));
-        return OC_STACK_ERROR;
-    }
-#endif
     return OCInit1(mode, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS);
 }
 
@@ -1588,6 +1587,14 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
         return OC_STACK_OK;
     }
 
+#ifdef RA_ADAPTER
+    if(!gRASetInfo)
+    {
+        OC_LOG(ERROR, TAG, PCF("Need to call OCSetRAInfo before calling OCInit"));
+        return OC_STACK_ERROR;
+    }
+#endif
+
     OCStackResult result = OC_STACK_ERROR;
     OC_LOG(INFO, TAG, PCF("Entering OCInit"));
 
@@ -1611,12 +1618,12 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     caglobals.serverFlags = (CATransportFlags_t)serverFlags;
     if (!(caglobals.serverFlags & CA_IPFAMILY_MASK))
     {
-        caglobals.serverFlags = (CATransportFlags_t)(caglobals.serverFlags|CA_IPV4);
+        caglobals.serverFlags = (CATransportFlags_t)(caglobals.serverFlags|CA_IPV4|CA_IPV6);
     }
     caglobals.clientFlags = (CATransportFlags_t)clientFlags;
     if (!(caglobals.clientFlags & CA_IPFAMILY_MASK))
     {
-        caglobals.clientFlags = (CATransportFlags_t)(caglobals.clientFlags|CA_IPV4);
+        caglobals.clientFlags = (CATransportFlags_t)(caglobals.clientFlags|CA_IPV4|CA_IPV6);
     }
 
     defaultDeviceHandler = NULL;
@@ -1653,7 +1660,7 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     VERIFY_SUCCESS(result, OC_STACK_OK);
 
 #ifdef WITH_PRESENCE
-    PresenceTimeOutSize = sizeof(PresenceTimeOut)/sizeof(PresenceTimeOut[0]) - 1;
+    PresenceTimeOutSize = sizeof (PresenceTimeOut) / sizeof (PresenceTimeOut[0]) - 1;
 #endif // WITH_PRESENCE
 
     //Update Stack state to initialized
@@ -2057,6 +2064,8 @@ OCStackResult OCDoResource(OCDoHandle *handle,
         }
         else
         {
+            tmpDevAddr.adapter = adapter;
+            tmpDevAddr.flags = flags;
             destination = &tmpDevAddr;
             requestInfo.isMulticast = true;
         }
@@ -2394,7 +2403,7 @@ OCStackResult OCProcessPresence()
                                                 cbNode->presence->TTLlevel);
         OC_LOG_V(DEBUG, TAG, "current ticks %d", now);
 
-        if(cbNode->presence->TTLlevel >= (PresenceTimeOutSize + 1))
+        if (cbNode->presence->TTLlevel > PresenceTimeOutSize)
         {
             goto exit;
         }
@@ -2404,7 +2413,6 @@ OCStackResult OCProcessPresence()
             OC_LOG_V(DEBUG, TAG, "timeout ticks %d",
                     cbNode->presence->timeOut[cbNode->presence->TTLlevel]);
         }
-
         if (cbNode->presence->TTLlevel >= PresenceTimeOutSize)
         {
             OC_LOG(DEBUG, TAG, PCF("No more timeout ticks"));
@@ -3771,7 +3779,7 @@ OCStackResult getQueryFromUri(const char * uri, char** query, char ** uriWithout
 
     char *pointerToDelimiter = strstr(uri, "?");
 
-    uriWithoutQueryLen = pointerToDelimiter == NULL ? uriLen : pointerToDelimiter - uri;
+    uriWithoutQueryLen = pointerToDelimiter == NULL ? uriLen : (size_t)(pointerToDelimiter - uri);
     queryLen = pointerToDelimiter == NULL ? 0 : uriLen - uriWithoutQueryLen - 1;
 
     if (uriWithoutQueryLen)
index 7106d9e..b19f521 100644 (file)
@@ -85,7 +85,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
             std::cout << "\tpower: " << mylight.m_power << std::endl;
             std::cout << "\tname: " << mylight.m_name << std::endl;
 
-            if(observe_count() > 10)
+            if(observe_count() == 11)
             {
                 std::cout<<"Cancelling Observe..."<<std::endl;
                 OCStackResult result = curResource->cancelObserve();
index 5e69f01..61f8a92 100644 (file)
@@ -97,7 +97,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
         std::cout << "\tpower: " << mylight.m_power << std::endl;
         std::cout << "\tname: " << mylight.m_name << std::endl;
 
-        if(observe_count() > 10)
+        if(observe_count() == 11)
         {
             std::cout<<"Cancelling Observe..."<<std::endl;
             OCStackResult result = curResource->cancelObserve(OC::QualityOfService::HighQos);
index 01969fc..f61edb3 100644 (file)
@@ -398,13 +398,6 @@ namespace OC
             }
         }
 
-        OCRepPayload* cur = root;
-        for(auto& child : this->getChildren())
-        {
-            cur->next = child.getPayload();
-            cur = cur->next;
-        }
-
         return root;
     }
 
index 46b80bd..bac4cfb 100644 (file)
@@ -57,11 +57,11 @@ if target_os == 'android':
        if target_arch == 'armeabi-v7a-hard':
                target_arch = 'armeabi-v7a'
 
-       if target_arch not in ['x86', 'armeabi', 'armeabi-v7a']:
+       if target_arch not in ['x86', 'x86_64','armeabi', 'armeabi-v7a']:
                if not env.GetOption('help') and not env.GetOption('clean'):
                        print '''
 *********************************** Warning ***********************************
-* current only x86, armeabi, armeabi-v7a libraries are provided!              *
+* current only x86, x86_64, armeabi, armeabi-v7a libraries are provided!              *
 *******************************************************************************
 '''
        else:
index 5389725..a406ae1 100644 (file)
@@ -43,7 +43,7 @@ if target_os not in ['arduino','darwin','ios']:
                SConscript('notification-manager/SConscript')
 
        # Build resource-encapsulation project
-       if target_os not in ['android', 'tizen']:
+       if target_os not in ['tizen']:
                SConscript('resource-encapsulation/SConscript')
 #else:
 #      SConscript('notification-manager/SampleApp/arduino/SConscript')
index b41bfe9..a85a853 100644 (file)
@@ -184,9 +184,9 @@ void ResourceHosting::requestMulticastDiscovery()
 void ResourceHosting::requestDiscovery(std::string address)
 {
     std::string host = address;
-    std::string uri = OC_RSRVD_WELL_KNOWN_URI + std::string("?rt=") + HOSTING_RESOURSE_TYPE;
     RCSAddress rcsAddress = RCSAddress::unicast(host);
-    discoveryManager->discoverResource(rcsAddress, uri, pDiscoveryCB);
+    discoveryManager->discoverResourceByType(rcsAddress, OC_RSRVD_WELL_KNOWN_URI,
+            HOSTING_RESOURSE_TYPE, pDiscoveryCB);
 }
 
 void ResourceHosting::discoverHandler(RemoteObjectPtr remoteResource)
diff --git a/service/protocol-plugin/plugins/mqtt-light/lib/cpp/test.txt b/service/protocol-plugin/plugins/mqtt-light/lib/cpp/test.txt
deleted file mode 100644 (file)
index c6ba667..0000000
+++ /dev/null
@@ -1,883 +0,0 @@
-/usr/lib/i386-linux-gnu/mesa-egl:
-       libOpenVG.so.1 -> libOpenVG.so.1.0.0
-       libwayland-egl.so.1 -> libwayland-egl.so.1.0.0
-       libEGL.so.1 -> libEGL.so.1.0.0
-/usr/lib/i386-linux-gnu/mesa:
-       libGL.so.1 -> libGL.so.1.2.0
-/lib/i386-linux-gnu:
-       libblkid.so.1 -> libblkid.so.1.1.0
-       libnss_dns.so.2 -> libnss_dns-2.15.so
-       libnss_compat.so.2 -> libnss_compat-2.15.so
-       libwrap.so.0 -> libwrap.so.0.7.6
-       libpcsclite.so.1 -> libpcsclite.so.1.0.0
-       libkeyutils.so.1 -> libkeyutils.so.1.4
-       libntfs-3g.so.831 -> libntfs-3g.so.831.0.0
-       libpcprofile.so -> libpcprofile.so
-       libext2fs.so.2 -> libext2fs.so.2.4
-       libslang.so.2 -> libslang.so.2.2.4
-       libpci.so.3 -> libpci.so.3.1.8
-       libparted.so.0 -> libparted.so.0.0.1
-       libdl.so.2 -> libdl-2.15.so
-       libutil.so.1 -> libutil-2.15.so
-       libgcc_s.so.1 -> libgcc_s.so.1
-       libnss_nisplus.so.2 -> libnss_nisplus-2.15.so
-       libbsd.so.0 -> libbsd.so.0.3.0
-       libpng12.so.0 -> libpng12.so.0.46.0
-       librt.so.1 -> librt-2.15.so
-       ld-linux.so.2 -> ld-2.15.so
-       libncurses.so.5 -> libncurses.so.5.9
-       libcrypto.so.1.0.0 -> libcrypto.so.1.0.0
-       libacl.so.1 -> libacl.so.1.1.0
-       libgcrypt.so.11 -> libgcrypt.so.11.7.0
-       libnsl.so.1 -> libnsl-2.15.so
-       libpam.so.0 -> libpam.so.0.83.0
-       libmount.so.1 -> libmount.so.1.1.0
-       libselinux.so.1 -> libselinux.so.1
-       libpcre.so.3 -> libpcre.so.3.12.1
-       libdbus-1.so.3 -> libdbus-1.so.3.5.8
-       libuuid.so.1 -> libuuid.so.1.3.0
-       libexpat.so.1 -> libexpat.so.1.5.2
-       libnss_files.so.2 -> libnss_files-2.15.so
-       libcom_err.so.2 -> libcom_err.so.2.1
-       libnss_nis.so.2 -> libnss_nis-2.15.so
-       libatasmart.so.4 -> libatasmart.so.4.0.4
-       libssl.so.1.0.0 -> libssl.so.1.0.0
-       libthread_db.so.1 -> libthread_db-1.0.so
-       libncursesw.so.5 -> libncursesw.so.5.9
-       libgpg-error.so.0 -> libgpg-error.so.0.8.0
-       libe2p.so.2 -> libe2p.so.2.3
-       libss.so.2 -> libss.so.2.0
-       libBrokenLocale.so.1 -> libBrokenLocale-2.15.so
-       libcidn.so.1 -> libcidn-2.15.so
-       libpamc.so.0 -> libpamc.so.0.82.1
-       libmemusage.so -> libmemusage.so
-       libglib-2.0.so.0 -> libglib-2.0.so.0.3200.4
-       libnss_hesiod.so.2 -> libnss_hesiod-2.15.so
-       libanl.so.1 -> libanl-2.15.so
-       libcap.so.2 -> libcap.so.2.22
-       libresolv.so.2 -> libresolv-2.15.so
-       libattr.so.1 -> libattr.so.1.1.0
-       libpthread.so.0 -> libpthread-2.15.so
-       libm.so.6 -> libm-2.15.so
-       libz.so.1 -> libz.so.1.2.3.4
-       libhistory.so.6 -> libhistory.so.6.2
-       libnih-dbus.so.1 -> libnih-dbus.so.1.0.0
-       libSegFault.so -> libSegFault.so
-       libudev.so.0 -> libudev.so.0.13.0
-       libreadline.so.6 -> libreadline.so.6.2
-       libusb-1.0.so.0 -> libusb-1.0.so.0.1.0
-       libcrypt.so.1 -> libcrypt-2.15.so
-       libpam_misc.so.0 -> libpam_misc.so.0.82.0
-       libnih.so.1 -> libnih.so.1.0.0
-       libtinfo.so.5 -> libtinfo.so.5.9
-       libpopt.so.0 -> libpopt.so.0.0.0
-       libbz2.so.1.0 -> libbz2.so.1.0.4
-       libc.so.6 -> libc-2.15.so
-       libusb-0.1.so.4 -> libusb-0.1.so.4.4.4
-/usr/lib/i386-linux-gnu:
-       libnss3.so -> libnss3.so
-       libsmbclient.so.0 -> libsmbclient.so.0
-       libgobject-2.0.so.0 -> libgobject-2.0.so.0.3200.4
-       libpoppler-glib.so.8 -> libpoppler-glib.so.8.2.0
-       libavcodec.so.53 -> libavcodec.so.53.35.0
-       libwbclient.so.0 -> libwbclient.so.0
-       libbonoboui-2.so.0 -> libbonoboui-2.so.0.0.0
-       libjasper.so.1 -> libjasper.so.1.0.0
-       libsqlite3.so.0 -> libsqlite3.so.0.8.6
-       libgstbasevideo-1.0.so.0 -> libgstbasevideo-1.0.so.0.5.0
-       librtmp.so.0 -> librtmp.so.0
-       libframe.so.6 -> libframe.so.6.0.0
-       libnspr4.so -> libnspr4.so
-       libportaudio.so.2 -> libportaudio.so.2.0.0
-       libXdmcp.so.6 -> libXdmcp.so.6.0.0
-       libcanberra-gtk3.so.0 -> libcanberra-gtk3.so.0.1.8
-       libnettle.so.4 -> libnettle.so.4.3
-       libcups.so.2 -> libcups.so.2
-       libxcb-shape.so.0 -> libxcb-shape.so.0.0.0
-       libunistring.so.0 -> libunistring.so.0.1.2
-       libQtDeclarative.so.4 -> libQtDeclarative.so.4.8.1
-       libdbusmenu-gtk3.so.4 -> libdbusmenu-gtk3.so.4.0.13
-       libgsttag-0.10.so.0 -> libgsttag-0.10.so.0.25.0
-       libwmflite-0.2.so.7 -> libwmflite-0.2.so.7.0.1
-       libapt-pkg.so.4.12 -> libapt-pkg.so.4.12.0
-       libQtNetwork.so.4 -> libQtNetwork.so.4.8.1
-       libgnomecanvas-2.so.0 -> libgnomecanvas-2.so.0.3000.3
-       libtheoradec.so.1 -> libtheoradec.so.1.1.4
-       libcanberra.so.0 -> libcanberra.so.0.2.5
-       libgnutls-extra.so.26 -> libgnutls-extra.so.26.21.8
-       libxcb-render.so.0 -> libxcb-render.so.0.0.0
-       libgpm.so.2 -> libgpm.so.2
-       libxcb-util.so.0 -> libxcb-util.so.0.0.0
-       libraw1394.so.11 -> libraw1394.so.11.0.1
-       libpangocairo-1.0.so.0 -> libpangocairo-1.0.so.0.3000.0
-       libssl3.so -> libssl3.so
-       libgstcontroller-0.10.so.0 -> libgstcontroller-0.10.so.0.30.0
-       libcupsimage.so.2 -> libcupsimage.so.2
-       liblcms2.so.2 -> liblcms2.so.2.0.2
-       libgio-2.0.so.0 -> libgio-2.0.so.0.3200.4
-       libtxc_dxtn_s2tc.so.0 -> libtxc_dxtn_s2tc.so.0.0.0
-       libdbus-glib-1.so.2 -> libdbus-glib-1.so.2.2.2
-       libgstallocators-1.0.so.0 -> libgstallocators-1.0.so.0.201.0
-       libXi.so.6 -> libXi.so.6.1.0
-       libsvn_ra_svn-1.so.1 -> libsvn_ra_svn-1.so.1.0.0
-       liblber-2.4.so.2 -> liblber.so
-       libgstsignalprocessor-1.0.so.0 -> libgstsignalprocessor-1.0.so.0.5.0
-       libhcrypto.so.4 -> libhcrypto.so.4.1.0
-       libcanberra-gtk.so.0 -> libcanberra-gtk.so.0.1.8
-       libavahi-glib.so.1 -> libavahi-glib.so.1.0.2
-       libedit.so.2 -> libedit.so.2.11
-       libavahi-ui-gtk3.so.0 -> libavahi-ui-gtk3.so.0.1.4
-       libx264.so.120 -> libx264.so.120
-       libgstsdp-1.0.so.0 -> libgstsdp-1.0.so.0.201.0
-       libgstnet-0.10.so.0 -> libgstnet-0.10.so.0.30.0
-       libfarstream-0.1.so.0 -> libfarstream-0.1.so.0.0.1
-       libgstfft-0.10.so.0 -> libgstfft-0.10.so.0.25.0
-       libgstcdda-0.10.so.0 -> libgstcdda-0.10.so.0.25.0
-       libbamf3.so.0 -> libbamf3.so.0.0.0
-       libgstbasecamerabinsrc-1.0.so.0 -> libgstbasecamerabinsrc-1.0.so.0.7.0
-       libexempi.so.3 -> libexempi.so.3.2.2
-       libXss.so.1 -> libXss.so.1.0.0
-       libffi.so.6 -> libffi.so.6.0.0
-       libavformat.so.53 -> libavformat.so.53.21.1
-       libgstpbutils-0.10.so.0 -> libgstpbutils-0.10.so.0.25.0
-       libcdda_paranoia.so.0 -> libcdda_paranoia.so.0.10.2
-       libavahi-gobject.so.0 -> libavahi-gobject.so.0.0.4
-       libpolkit-gobject-1.so.0 -> libpolkit-gobject-1.so.0.0.0
-       libXfixes.so.3 -> libXfixes.so.3.1.0
-       libp11-kit.so.0 -> libp11-kit.so.0.0.0
-       libpng12.so.0 -> libpng.so
-       libswscale.so.2 -> libswscale.so.2.1.0
-       libxkbfile.so.1 -> libxkbfile.so.1.0.2
-       libcupscgi.so.1 -> libcupscgi.so.1
-       libtic.so.5 -> libtic.so.5.9
-       libSDL-1.2.so.0 -> libSDL-1.2.so.0.11.3
-       libgettextpo.so.0 -> libgettextpo.so.0.5.1
-       libgoa-1.0.so.0 -> libgoa-1.0.so.0.0.0
-       libvisual-0.4.so.0 -> libvisual-0.4.so.0.0.0
-       libQtXml.so.4 -> libQtXml.so.4.8.1
-       libdrm_intel.so.1 -> libdrm_intel.so.1.0.0
-       libltdl.so.7 -> libltdl.so.7.3.0
-       libgomp.so.1 -> libgomp.so.1.0.0
-       libXtst.so.6 -> libXtst.so.6.1.0
-       libgtk-3.so.0 -> libgtk-3.so.0.400.2
-       libogg.so.0 -> libogg.so.0.7.1
-       libXaw.so.7 -> libXaw7.so.7.0.0
-       libssh.so.4 -> libssh.so.4.2.2
-       libtdb.so.1 -> libtdb.so.1.2.9
-       libsvn_ra-1.so.1 -> libsvn_ra-1.so.1.0.0
-       libiec61883.so.0 -> libiec61883.so.0.1.1
-       libk5crypto.so.3 -> libk5crypto.so.3.1
-       libXinerama.so.1 -> libXinerama.so.1.0.0
-       libcupsfilters.so.1 -> libcupsfilters.so.1
-       libfontconfig.so.1 -> libfontconfig.so.1.4.4
-       libXrandr_ltss.so.2 -> libXrandr_ltss.so.2.2.0
-       libcupsdriver.so.1 -> libcupsdriver.so.1
-       libgstcontroller-1.0.so.0 -> libgstcontroller-1.0.so.0.201.0
-       libgnutlsxx.so.27 -> libgnutlsxx.so.27.0.0
-       libICE.so.6 -> libICE.so.6.3.0
-       libQtGui.so.4 -> libQtGui.so.4.8.1
-       libgssrpc.so.4 -> libgssrpc.so.4.1
-       librsvg-2.so.2 -> librsvg-2.so.2.36.1
-       libgdk-x11-2.0.so.0 -> libgdk-x11-2.0.so.0.2400.10
-       libsvn_subr-1.so.1 -> libsvn_subr-1.so.1.0.0
-       libgphoto2.so.2 -> libgphoto2.so.2.4.0
-       libtiff.so.4 -> libtiff.so.4.3.4
-       libv4l1.so.0 -> libv4l1.so.0
-       libgstsdp-0.10.so.0 -> libgstsdp-0.10.so.0.25.0
-       libORBitCosNaming-2.so.0 -> libORBitCosNaming-2.so.0.1.0
-       libdatrie.so.1 -> libdatrie.so.1.1.0
-       libplc4.so -> libplc4.so
-       libwacom.so.2 -> libwacom.so.2.0.0
-       libsoup-gnome-2.4.so.1 -> libsoup-gnome-2.4.so.1.5.0
-       libwayland_ltss-server.so.0 -> libwayland_ltss-server.so.0.0.0
-       libgstpbutils-1.0.so.0 -> libgstpbutils-1.0.so.0.201.0
-       libpangoxft-1.0.so.0 -> libpangoxft-1.0.so.0.3000.0
-       libglibmm-2.4.so.1 -> libglibmm-2.4.so.1.3.0
-       libpulse.so.0 -> libpulse.so.0.13.5
-       libbonobo-activation.so.4 -> libbonobo-activation.so.4.0.0
-       libpolkit-agent-1.so.0 -> libpolkit-agent-1.so.0.0.0
-       libtag.so.1 -> libtag.so.1.7.0
-       libGLEWmx.so.1.6 -> libGLEWmx.so.1.6.0
-       libatspi.so.0 -> libatspi.so.0.0.1
-       libgphoto2_port.so.0 -> libgphoto2_port.so.0.8.0
-       libcurl-gnutls.so.4 -> libcurl.so
-       libgbm.so.1 -> libgbm.so.1.0.0
-       libgstapp-0.10.so.0 -> libgstapp-0.10.so.0.25.0
-       libsndfile.so.1 -> libsndfile.so.1.0.25
-       libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.3200.4
-       libXmu.so.6 -> libXmu.so.6.2.0
-       libaudiofile.so.1 -> libaudiofile.so.1.0.0
-       libexif.so.12 -> libexif.so.12.3.2
-       libXau.so.6 -> libXau.so.6.0.0
-       libglapi.so.0 -> libglapi.so.0.0.0
-       libgtksourceview-3.0.so.0 -> libgtksourceview-3.0.so.0.0.0
-       liborc-0.4.so.0 -> liborc-0.4.so.0.18.0
-       libnotify.so.4 -> libnotify.so.4.0.0
-       libwind.so.0 -> libwind.so.0.0.0
-       libldap_r-2.4.so.2 -> libldap_r.so
-       libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
-       libgstinterfaces-0.10.so.0 -> libgstinterfaces-0.10.so.0.25.0
-       libelf.so.1 -> libelf-0.152.so
-       libdrm_nouveau.so.1 -> libdrm_nouveau1.so
-       libthai.so.0 -> libthai.so.0.1.6
-       libgstnet-1.0.so.0 -> libgstnet-1.0.so.0.201.0
-       libcares.so.2 -> libcares.so.2.0.0
-       liborc-test-0.4.so.0 -> liborc-test-0.4.so.0.18.0
-       libaa.so.1 -> libaa.so.1.0.4
-       libsvn_ra_local-1.so.1 -> libsvn_ra_local-1.so.1.0.0
-       libdrm.so.2 -> libdrm.so.2.4.0
-       libLLVM-3.3.so.1 -> libLLVM-3.3.so.1
-       libpcap.so.0.8 -> libpcap.so.1.1.1
-       libcupsmime.so.1 -> libcupsmime.so.1
-       libxcb.so.1 -> libxcb.so.1.1.0
-       libSM.so.6 -> libSM.so.6.0.1
-       libkms.so.1 -> libkms.so.1.0.0
-       libdbusmenu-gtk.so.4 -> libdbusmenu-gtk.so.4.0.13
-       libFLAC.so.8 -> libFLAC.so.8.2.0
-       libxcb-xfixes.so.0 -> libxcb-xfixes.so.0.0.0
-       libgstriff-1.0.so.0 -> libgstriff-1.0.so.0.201.0
-       libidn.so.11 -> libidn.so.11.6.6
-       libIDL-2.so.0 -> libIDL-2.so.0.0.0
-       libdbusmenu-qt.so.2 -> libdbusmenu-qt.so.2.6.0
-       libQtScript.so.4 -> libQtScript.so.4.8.1
-       libcairo-gobject.so.2 -> libcairo-gobject.so.2.11000.2
-       libluajit-5.1.so.2 -> libluajit-5.1.so.2.0.0
-       libpangomm-1.4.so.1 -> libpangomm-1.4.so.1.0.30
-       libXpm.so.4 -> libXpm.so.4.11.0
-       libsvn_diff-1.so.1 -> libsvn_diff-1.so.1.0.0
-       libdbusmenu-glib.so.4 -> libdbusmenu-glib.so.4.0.13
-       liblua5.1.so.0 -> liblua5.1.so.0.0.0
-       libbonobo-2.so.0 -> libbonobo-2.so.0.0.0
-       libpulse-mainloop-glib.so.0 -> libpulse-mainloop-glib.so.0.0.4
-       libexslt.so.0 -> libexslt.so.0.8.15
-       libmp3lame.so.0 -> libmp3lame.so.0.0.0
-       libpcreposix.so.3 -> libpcreposix.so.3.12.1
-       libquvi.so.7 -> libquvi.so.7.0.0
-       libaudio.so.2 -> libaudio.so.2.4
-       libpulse-simple.so.0 -> libpulse-simple.so.0.0.3
-       liboauth.so.0 -> liboauth.so.0.8.1
-       libQtCore.so.4 -> libQtCore.so.4.8.1
-       libwayland_ltss-client.so.0 -> libwayland_ltss-client.so.0.1.0
-       libQtDBus.so.4 -> libQtDBus.so.4.8.1
-       libtheoraenc.so.1 -> libtheoraenc.so.1.1.2
-       libatkmm-1.6.so.1 -> libatkmm-1.6.so.1.1.0
-       libgailutil-3.so.0 -> libgailutil-3.so.0.0.0
-       libgsttag-1.0.so.0 -> libgsttag-1.0.so.0.201.0
-       libgdk_pixbuf_xlib-2.0.so.0 -> libgdk_pixbuf_xlib-2.0.so.0.2600.1
-       libkrb5.so.3 -> libkrb5.so.3.3
-       libgnome-2.so.0 -> libgnome-2.so.0.3200.1
-       libgallium.so.0 -> libgallium.so.0.0.0
-       libXcomposite.so.1 -> libXcomposite.so.1.0.0
-       libsvn_fs-1.so.1 -> libsvn_fs-1.so.1.0.0
-       libgstreamer-0.10.so.0 -> libgstreamer-0.10.so.0.30.0
-       libXrender.so.1 -> libXrender.so.1.3.0
-       libmng.so.1 -> libmng.so.1.1.0.10
-       libgdu.so.0 -> libgdu.so.0.0.0
-       libxatracker.so.1 -> libxatracker.so.1.0.0
-       librom1394.so.0 -> librom1394.so.0.3.0
-       liblua5.1-c++.so.0 -> liblua5.1-c++.so.0.0.0
-       libplds4.so -> libplds4.so
-       libbamf.so.0 -> libbamf.so.0.0.0
-       libheimntlm.so.0 -> libheimntlm.so.0.1.0
-       libarchive.so.12 -> libarchive.so.12.0.3
-       libmad.so.0 -> libmad.so.0.2.1
-       libgthread-2.0.so.0 -> libgthread-2.0.so.0.3200.4
-       libgstaudio-1.0.so.0 -> libgstaudio-1.0.so.0.201.0
-       libgudev-1.0.so.0 -> libgudev-1.0.so.0.1.1
-       libvpx.so.1 -> libvpx.so.1.2.0
-       libgailutil.so.18 -> libgailutil.so.18.0.1
-       libsvn_client-1.so.1 -> libsvn_client-1.so.1.0.0
-       libdricore9.2.1.so.1 -> libdricore9.2.1.so.1.0.0
-       libQtOpenGL.so.4 -> libQtOpenGL.so.4.8.1
-       libhunspell-1.3.so.0 -> libhunspell-1.3.so.0.0.0
-       libcupsppdc.so.1 -> libcupsppdc.so.1
-       libkdb5.so.6 -> libkdb5.so.6.0
-       libpixman-1.so.0 -> libpixman-1.so.0.30.2
-       libpolkit-backend-1.so.0 -> libpolkit-backend-1.so.0.0.0
-       libibus-1.0.so.0 -> libibus-1.0.so.0.401.0
-       libxcb-dri2.so.0 -> libxcb-dri2.so.0.0.0
-       libgstcheck-0.10.so.0 -> libgstcheck-0.10.so.0.30.0
-       libXp.so.6 -> libXp.so.6.2.0
-       libart_lgpl_2.so.2 -> libart_lgpl_2.so.2.3.21
-       libhx509.so.5 -> libhx509.so.5.0.0
-       libform.so.5 -> libform.so.5.9
-       libgstbase-1.0.so.0 -> libgstbase-1.0.so.0.201.0
-       libX11-xcb.so.1 -> libX11-xcb.so.1.0.0
-       libgstaudio-0.10.so.0 -> libgstaudio-0.10.so.0.25.0
-       libjson-glib-1.0.so.0 -> libjson-glib-1.0.so.0.1400.2
-       libspeex.so.1 -> libspeex.so.1.5.0
-       libsvn_fs_util-1.so.1 -> libsvn_fs_util-1.so.1.0.0
-       libpoppler.so.19 -> libpoppler.so.19.0.0
-       libdconf.so.0 -> libdconf.so.0.0.0
-       libavahi-common.so.3 -> libavahi-common.so.3.5.3
-       libyajl.so.1 -> libyajl.so.1.0.12
-       libvorbis.so.0 -> libvorbis.so.0.4.5
-       libavc1394.so.0 -> libavc1394.so.0.3.0
-       libv4l2.so.0 -> libv4l2.so.0
-       libcolord.so.1 -> libcolord.so.1.0.8
-       libcairo.so.2 -> libcairo.so.2.11000.2
-       libGLEW.so.1.6 -> libGLEW.so.1.6.0
-       libgdbm_compat.so.3 -> libgdbm_compat.so.3.0.0
-       libdb-5.1.so -> libdb-5.1.so
-       libXt.so.6 -> libXt.so.6.0.0
-       libwavpack.so.1 -> libwavpack.so.1.1.4
-       libmpfr.so.4 -> libmpfr.so.4.1.0
-       libpangoft2-1.0.so.0 -> libpangoft2-1.0.so.0.3000.0
-       libieee1284.so.3 -> libieee1284.so.3.2.2
-       libfreetype.so.6 -> libfreetype.so.6.8.0
-       libdrm_nouveau.so.2 -> libdrm_nouveau.so.2.0.0
-       libgssapi.so.3 -> libgssapi.so.3.0.0
-       libspeexdsp.so.1 -> libspeexdsp.so.1.5.0
-       libdconf-dbus-1.so.0 -> libdconf-dbus-1.so.0.0.0
-       libgmp.so.10 -> libgmp.so.10.0.2
-       libcaca.so.0 -> libcucul.so.0.99.17
-       libcairomm-1.0.so.1 -> libcairomm-1.0.so.1.4.0
-       libsvn_repos-1.so.1 -> libsvn_repos-1.so.1.0.0
-       libgupnp-igd-1.0.so.4 -> libgupnp-igd-1.0.so.4.1.0
-       libgstvideo-1.0.so.0 -> libgstvideo-1.0.so.0.201.0
-       libXdamage.so.1 -> libXdamage.so.1.1.0
-       libasn1.so.8 -> libasn1.so.8.0.0
-       libsvn_fs_base-1.so.1 -> libsvn_fs_base-1.so.1.0.0
-       libvorbisenc.so.2 -> libvorbisenc.so.2.0.8
-       libgstapp-1.0.so.0 -> libgstapp-1.0.so.0.201.0
-       libvo-amrwbenc.so.0 -> libvo-amrwbenc.so.0.0.2
-       libtalloc.so.2 -> libtalloc.so.2.0.7
-       libshout.so.3 -> libshout.so.3.2.0
-       libnice.so.10 -> libnice.so.10.0.1
-       libbluetooth.so.3 -> libbluetooth.so.3.11.5
-       libgrail.so.5 -> libgrail.so.5.0.0
-       libgutenprint.so.3 -> libgutenprint.so.3.0.0
-       libmenuw.so.5 -> libmenuw.so.5.9
-       libpanelw.so.5 -> libpanelw.so.5.9
-       libkrb5.so.26 -> libkrb5.so.26.0.0
-       libgdu-gtk.so.0 -> libgdu-gtk.so.0.0.0
-       libgdbm.so.3 -> libgdbm.so.3.0.0
-       libgnutls-openssl.so.27 -> libgnutls-openssl.so.27.0.0
-       libmenu.so.5 -> libmenu.so.5.9
-       libpangox-1.0.so.0 -> libpangox-1.0.so.0.3000.0
-       libXft.so.2 -> libXft.so.2.2.0
-       libsensors.so.4 -> libsensors.so.4.3.1
-       libgstphotography-0.10.so.0 -> libgstphotography-0.10.so.0.0.0
-       libstartup-notification-1.so.0 -> libstartup-notification-1.so.0.0.0
-       libatk-1.0.so.0 -> libatk-1.0.so.0.20409.1
-       libsvn_auth_gnome_keyring-1.so.1 -> libsvn_auth_gnome_keyring-1.so.1.0.0
-       libquadmath.so.0 -> libquadmath.so.0.0.0
-       libgif.so.4 -> libungif.so.4.1.6
-       libstdc++.so.6 -> libstdc++.so.6.0.16
-       liblzma.so.5 -> liblzma.so.5.0.0
-       libass.so.4 -> libass.so.4.1.0
-       libproxy.so.1 -> libproxy.so.1.0.0
-       libcaca++.so.0 -> libcucul++.so.0.99.17
-       libglade-2.0.so.0 -> libglade-2.0.so.0.0.7
-       libavutil.so.51 -> libavutil.so.51.22.2
-       libxslt.so.1 -> libxslt.so.1.1.26
-       libva.so.1 -> libva.so.1.3200.0
-       libsmime3.so -> libsmime3.so
-       libdv.so.4 -> libdv.so.4.0.3
-       libavahi-client.so.3 -> libavahi-client.so.3.2.9
-       libsvn_fs_fs-1.so.1 -> libsvn_fs_fs-1.so.1.0.0
-       libgiomm-2.4.so.1 -> libgiomm-2.4.so.1.3.0
-       libgstrtp-1.0.so.0 -> libgstrtp-1.0.so.0.201.0
-       libgnutls.so.26 -> libgnutls.so.26.21.8
-       libQtXmlPatterns.so.4 -> libQtXmlPatterns.so.4.8.1
-       libao.so.4 -> libao.so.4.0.0
-       libpulsecommon-1.1.so -> libpulsecommon-1.1.so
-       libQtCLucene.so.4 -> libQtCLucene.so.4.8.1
-       libgstbase-0.10.so.0 -> libgstbase-0.10.so.0.30.0
-       libsvn_auth_kwallet-1.so.1 -> libsvn_auth_kwallet-1.so.1.0.0
-       libjpeg.so.8 -> libjpeg.so.8.0.2
-       libsamplerate.so.0 -> libsamplerate.so.0.1.8
-       libcurl.so.4 -> libcurl.so.4.2.0
-       libpipeline.so.1 -> libpipeline.so.1.2.1
-       libglamor_ltss.so.0 -> libglamor_ltss.so.0.0.0
-       libpciaccess.so.0 -> libpciaccess.so.0.11.0
-       libnssutil3.so -> libnssutil3.so
-       libgstriff-0.10.so.0 -> libgstriff-0.10.so.0.25.0
-       libXcursor.so.1 -> libXcursor.so.1.0.2
-       libformw.so.5 -> libformw.so.5.9
-       libjson.so.0 -> libjson.so.0.0.1
-       libgconf-2.so.4 -> libgconf-2.so.4.1.5
-       libkrb5support.so.0 -> libkrb5support.so.0.1
-       libwmf-0.2.so.7 -> libwmf-0.2.so.7.1.0
-       libdiscid.so.0 -> libdiscid.so.0.2.1
-       libjacknet.so.0 -> libjacknet.so.0.1.0
-       libgstbasecamerabinsrc-0.10.so.0 -> libgstbasecamerabinsrc-0.10.so.0.0.0
-       libgee.so.2 -> libgee.so.2.0.0
-       libavahi-core.so.7 -> libavahi-core.so.7.0.2
-       liblcms.so.1 -> liblcms.so.1.0.19
-       liblockfile.so.1 -> liblockfile.so.1.0
-       libdb-4.8.so -> libdb-4.8.so
-       libxcb-glx.so.0 -> libxcb-glx.so.0.0.0
-       libtiffxx.so.0 -> libtiffxx.so.0.0.8
-       libasyncns.so.0 -> libasyncns.so.0.3.1
-       libcdda_interface.so.0 -> libcdda_interface.so.0.10.2
-       libgstrtsp-0.10.so.0 -> libgstrtsp-0.10.so.0.25.0
-       libtheora.so.0 -> libtheora.so.0.3.10
-       libvo-aacenc.so.0 -> libvo-aacenc.so.0.0.2
-       libORBit-2.so.0 -> libORBit-2.so.0.1.0
-       libv4lconvert.so.0 -> libv4lconvert.so.0
-       libXv.so.1 -> libXv.so.1.0.0
-       libgnomeui-2.so.0 -> libgnomeui-2.so.0.2400.5
-       libsvn_wc-1.so.1 -> libsvn_wc-1.so.1.0.0
-       libgstphotography-1.0.so.0 -> libgstphotography-1.0.so.0.7.0
-       libasound.so.2 -> libasound.so.2.0.0
-       libsvn_ra_neon-1.so.1 -> libsvn_ra_neon-1.so.1.0.0
-       libcroco-0.6.so.3 -> libcroco-0.6.so.3.0.1
-       libopus.so.0 -> libopus.so.0.5.0
-       libXext.so.6 -> libXext.so.6.4.0
-       libXrandr.so.2 -> libXrandr.so.2.2.0
-       libQtSql.so.4 -> libQtSql.so.4.8.1
-       libsonic.so.0 -> libsonic.so.0.1.17
-       libapt-inst.so.1.4 -> libapt-inst.so.1.4.0
-       libgstvideo-0.10.so.0 -> libgstvideo-0.10.so.0.25.0
-       libpanel.so.5 -> libpanel.so.5.9
-       libSoundTouch.so.0 -> libSoundTouch.so.0.0.0
-       libgd.so.2 -> libgd.so.2.0.0
-       libXxf86vm.so.1 -> libXxf86vm.so.1.0.0
-       libpulsedsp.so -> libpulsedsp.so
-       libGLU.so.1 -> libGLU.so.1.3.08004
-       libmpc.so.2 -> libmpc.so.2.0.0
-       libgdk_pixbuf-2.0.so.0 -> libgdk_pixbuf-2.0.so.0.2600.1
-       libroken.so.18 -> libroken.so.18.1.0
-       libtasn1.so.3 -> libtasn1.so.3.1.12
-       libsvn_delta-1.so.1 -> libsvn_delta-1.so.1.0.0
-       libgstrtp-0.10.so.0 -> libgstrtp-0.10.so.0.25.0
-       libgstnetbuffer-0.10.so.0 -> libgstnetbuffer-0.10.so.0.25.0
-       libgstfft-1.0.so.0 -> libgstfft-1.0.so.0.201.0
-       libORBit-imodule-2.so.0 -> libORBit-imodule-2.so.0.0.0
-       libkadm5srv_mit.so.8 -> libkadm5srv_mit.so.8.0
-       libgssapi_krb5.so.2 -> libgssapi_krb5.so.2.2
-       libdrm_radeon.so.1 -> libdrm_radeon.so.1.0.1
-       libgoa-backend-1.0.so.0 -> libgoa-backend-1.0.so.0.0.0
-       libXmuu.so.1 -> libXmuu.so.1.0.0
-       libpango-1.0.so.0 -> libpango-1.0.so.0.3000.0
-       libsigc-2.0.so.0 -> libsigc-2.0.so.0.0.0
-       libsoup-2.4.so.1 -> libsoup-2.4.so.1.5.0
-       libssh_threads.so.4 -> libssh_threads.so.4.2.2
-       libkadm5clnt_mit.so.8 -> libkadm5clnt_mit.so.8.0
-       libgstcodecparsers-1.0.so.0 -> libgstcodecparsers-1.0.so.0.5.0
-       libgstrtsp-1.0.so.0 -> libgstrtsp-1.0.so.0.201.0
-       libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.10
-       libespeak.so.1 -> libespeak.so.1.1.46
-       libjack.so.0 -> libjack.so.0.1.0
-       libxcb-shm.so.0 -> libxcb-shm.so.0.0.0
-       libQtSvg.so.4 -> libQtSvg.so.4.8.1
-       libglibmm_generate_extra_defs-2.4.so.1 -> libglibmm_generate_extra_defs-2.4.so.1.3.0
-       libcurl-nss.so.4 -> libcurl-nss.so.4.2.0
-       libtelepathy-logger.so.2 -> libtelepathy-logger.so.2.2.1
-       libX11.so.6 -> libX11.so.6.3.0
-       libexpatw.so.1 -> libexpatw.so.1.5.2
-       libxml2.so.2 -> libxml2.so.2.7.8
-       libsane.so.1 -> libsane.so.1.0.22
-       libgeis.so.1 -> libgeis.so.1.3.0
-       libgnome-keyring.so.0 -> libgnome-keyring.so.0.2.0
-       libgdk-3.so.0 -> libgdk-3.so.0.400.2
-       libgstreamer-1.0.so.0 -> libgstreamer-1.0.so.0.201.0
-       libgstcheck-1.0.so.0 -> libgstcheck-1.0.so.0.201.0
-       libheimbase.so.1 -> libheimbase.so.1.0.0
-       libsasl2.so.2 -> libsasl2.so.2.0.25
-       liblouis.so.2 -> liblouis.so.2.2.3
-       libgnomevfs-2.so.0 -> libgnomevfs-2.so.0.2400.4
-       libgstdataprotocol-0.10.so.0 -> libgstdataprotocol-0.10.so.0.30.0
-       libvorbisfile.so.3 -> libvorbisfile.so.3.3.4
-/usr/local/lib:
-       libefreet.so.1 -> libefreet.so.1.9.3
-       libecore_ipc.so.1 -> libecore_ipc.so.1.9.3
-       libefreet_trash.so.1 -> libefreet_trash.so.1.9.3
-       libecore_evas.so.1 -> libecore_evas.so.1.9.3
-       libecore.so.1 -> libecore.so.1.9.3
-       libmosquittopp.so.1 -> libmosquittopp.so.1
-       libeina.so.1 -> libeina.so.1.9.3
-       libeet.so.1 -> libeet.so.1.9.3
-       libecore_imf_evas.so.1 -> libecore_imf_evas.so.1.9.3
-       libembryo.so.1 -> libembryo.so.1.9.3
-       libecore_avahi.so.1 -> libecore_avahi.so.1.9.3
-       libeldbus.so.1 -> libeldbus.so.1.9.3
-       libethumb.so.1 -> libethumb.so.1.9.3
-       libemotion.so.1 -> libemotion.so.1.9.3
-       libecore_con.so.1 -> libecore_con.so.1.9.3
-       libecore_imf.so.1 -> libecore_imf.so.1.9.3
-       libeeze.so.1 -> libeeze.so.1.9.3
-       libecore_input.so.1 -> libecore_input.so.1.9.3
-       libedje.so.1 -> libedje.so.1.9.3
-       libeo.so.1 -> libeo.so.1.9.3
-       libethumb_client.so.1 -> libethumb_client.so.1.9.3
-       libecore_file.so.1 -> libecore_file.so.1.9.3
-       libeio.so.1 -> libeio.so.1.9.3
-       libmosquitto.so.1 -> libmosquitto.so.1
-       libelementary.so.1 -> libelementary.so.1.9.3
-       libecore_audio.so.1 -> libecore_audio.so.1.9.3
-       libevas.so.1 -> libevas.so.1.9.3
-       libecore_input_evas.so.1 -> libecore_input_evas.so.1.9.3
-       libefreet_mime.so.1 -> libefreet_mime.so.1.9.3
-       libecore_x.so.1 -> libecore_x.so.1.9.3
-/lib:
-       libnl-genl-3.so.200 -> libnl-genl-3.so.200.3.0
-       libnss_mdns6_minimal.so.2 -> libnss_mdns6_minimal.so.2
-       libip6tc.so.0 -> libip6tc.so.0.0.0
-       libply.so.2 -> libply.so.2.0.0
-       libnss_mdns6.so.2 -> libnss_mdns6.so.2
-       libipq_pic.so.0 -> libipq_pic.so.0.0.0
-       liblvm2app.so.2.2 -> liblvm2app.so.2.2
-       libdevmapper.so.1.02.1 -> libdevmapper.so.1.02.1
-       libcryptsetup.so.4 -> libcryptsetup.so.4.0.0
-       libnss_mdns.so.2 -> libnss_mdns.so.2
-       libnss_mdns_minimal.so.2 -> libnss_mdns_minimal.so.2
-       libfuse.so.2 -> libfuse.so.2.8.6
-       libiw.so.30 -> libiw.so.30
-       libdevmapper-event.so.1.02.1 -> libdevmapper-event.so.1.02.1
-       libply-splash-graphics.so.2 -> libply-splash-graphics.so.2.0.0
-       libply-splash-core.so.2 -> libply-splash-core.so.2.0.0
-       libsysfs.so.2 -> libsysfs.so.2.0.1
-       libply-boot-client.so.2 -> libply-boot-client.so.2.0.0
-       libnss_mdns4.so.2 -> libnss_mdns4.so.2
-       libnss_mdns4_minimal.so.2 -> libnss_mdns4_minimal.so.2
-       libproc-3.2.8.so -> libproc-3.2.8.so
-       libbrlapi.so.0.5 -> libbrlapi.so.0.5.6
-       libnewt.so.0.52 -> libnewt.so.0.52.11
-       libipq.so.0 -> libipq.so.0.0.0
-       libiptc.so.0 -> libiptc.so.0.0.0
-       libulockmgr.so.1 -> libulockmgr.so.1.0.1
-       libnl-3.so.200 -> libnl-3.so.200.3.0
-       libxtables.so.7 -> libxtables.so.7.0.0
-       libip4tc.so.0 -> libip4tc.so.0.0.0
-       libx86.so.1 -> libx86.so.1
-/usr/lib:
-       liba52-0.7.4.so -> liba52-0.7.4.so
-       libvncserver.so.0 -> libvncserver.so.0.0.0
-       libspandsp.so.2 -> libspandsp.so.2.0.0
-       libflite_usenglish.so.1 -> libflite_usenglish.so.1.4
-       libido3-0.1.so.0 -> libido3-0.1.so.0.0.0
-       libicui18n.so.48 -> libicui18n.so.48.1.1
-       libXvMC.so.1 -> libXvMC.so.1.0.0
-       libdmapsharing-3.0.so.2 -> libdmapsharing-3.0.so.2.9.14
-       libgmime-2.6.so.0 -> libgmime-2.6.so.0.600.7
-       libefreet_trash.so.1 -> libefreet_trash.so.1.0.0
-       libQtGConf.so.1 -> libQtGConf.so.1.0.0
-       libbfd-2.22-system.so -> libbfd-2.22-system.so
-       libgs.so.9 -> libgs.so.9.05
-       libedbus.so.1 -> libedbus.so.1.0.0
-       libperl.so.5.14 -> libperl.so.5.14.2
-       libgdkmm-3.0.so.1 -> libgdkmm-3.0.so.1.1.0
-       libeconnman.so.1 -> libeconnman.so.1.0.0
-       libxklavier.so.16 -> libxklavier.so.16.2.0
-       libnux-2.0.so.0 -> libnux-2.0.so.0.1401.0
-       libvlccore.so.5 -> libvlccore.so.5.1.1
-       libopcodes-2.22-system.so -> libopcodes-2.22-system.so
-       libaccountsservice.so.0 -> libaccountsservice.so.0.0.0
-       libnm-util.so.2 -> libnm-util.so.2.3.0
-       libjavascriptcoregtk-1.0.so.0 -> libjavascriptcoregtk-1.0.so.0.13.4
-       libpulsecore-1.1.so -> libpulsecore-1.1.so
-       libflite_cmu_us_slt.so.1 -> libflite_cmu_us_slt.so.1.4
-       libkeybinder.so.0 -> libkeybinder.so.0.0.1
-       libguile-srfi-srfi-1-v-3.so.3 -> libguile-srfi-srfi-1-v-3.so.3.0.2
-       libindicator-messages-status-provider.so.1 -> libindicator-messages-status-provider.so.1.0.0
-       libopencore-amrwb.so.0 -> libopencore-amrwb.so.0.0.2
-       libfolks.so.25 -> libfolks.so.25.7.0
-       libisccc.so.80 -> libisccc.so.80.0.0
-       libutempter.so.0 -> libutempter.so.1.1.5
-       libijs-0.35.so -> libijs-0.35.so
-       libefreet.so.1 -> libefreet.so.1.0.0
-       libflite_cmu_us_awb.so.1 -> libflite_cmu_us_awb.so.1.4
-       libwpg-0.2.so.2 -> libwpg-0.2.so.2.0.1
-       libvte2_90.so.9 -> libvte2_90.so.9.3200.1
-       libvncclient.so.0 -> libvncclient.so.0.0.0
-       libtcl8.5.so.0 -> libtcl8.5.so.0
-       libgnome-control-center.so.1 -> libgnome-control-center.so.1.0.0
-       libpyglib-gi-2.0-python2.7.so.0 -> libpyglib-gi-2.0-python2.7.so.0.0.0
-       libisc.so.83 -> libisc.so.83.0.1
-       libenotify.so.1 -> libenotify.so.1.0.0
-       libwps-0.2.so.2 -> libwps-0.2.so.2.0.4
-       libschroedinger-1.0.so.0 -> libschroedinger-1.0.so.0.11.0
-       libgtkmm-3.0.so.1 -> libgtkmm-3.0.so.1.1.0
-       librest-0.7.so.0 -> librest-0.7.so.0.0.0
-       libicalss.so.0 -> libicalss.so.0.48.0
-       libgrip.so.0 -> libgrip.so.0.305.0
-       libtimezonemap.so.1 -> libtimezonemap.so.1.0.0
-       libecore_evas.so.1 -> libecore_evas.so.1.0.0
-       libvte.so.9 -> libvte.so.9.2800.2
-       libmetacity-private.so.0 -> libmetacity-private.so.0.0.0
-       libXxf86dga.so.1 -> libXxf86dga.so.1.0.0
-       libgck-1.so.0 -> libgck-1.so.0.0.0
-       libicutu.so.48 -> libicutu.so.48.1.1
-       libedje.so.1 -> libedje.so.1.0.0
-       libgwibber-gtk.so.2 -> libgwibber-gtk.so.2.0.0
-       libpurple-client.so.0 -> libpurple-client.so.0.10.3
-       libhpip.so.0 -> libhpip.so.0.0.1
-       libwnck-1.so.22 -> libwnck-1.so.22.3.31
-       libfreerdp-core.so.1.0 -> libfreerdp-core.so.1.0.1
-       libmhash.so.2 -> libmhash.so.2.0.1
-       libindicator3.so.7 -> libindicator3.so.7.0.0
-       libfreerdp-codec.so.1.0 -> libfreerdp-codec.so.1.0.1
-       libflite.so.1 -> libflite.so.1.4
-       libgweather-3.so.0 -> libgweather-3.so.0.0.6
-       libpeas-1.0.so.0 -> libpeas-1.0.so.0.200.0
-       libbind9.so.80 -> libbind9.so.80.0.3
-       libgnomekbd.so.7 -> libgnomekbd.so.7.0.0
-       libcrypto.so.1.0.0 -> libcrypto.so.1.0.0
-       libwnck-3.so.0 -> libwnck-3.so.0.2.0
-       libeina.so.1 -> libeina.so.1.0.0
-       libebook-1.2.so.12 -> libebook-1.2.so.12.3.1
-       libFS.so.6 -> libFS.so.6.0.0
-       libnetsnmpagent.so.15 -> libnetsnmpagent.so.15.1.2
-       libdaemon.so.0 -> libdaemon.so.0.5.0
-       libfribidi.so.0 -> libfribidi.so.0.3.1
-       libeet.so.1 -> libeet.so.1.4.0
-       libunity-misc.so.4 -> libunity-misc.so.4.1.0
-       libbulletml.so.0d2 -> libbulletml.so.0d2.0
-       libebluez.so.1 -> libebluez.so.1.0.0
-       libindicate.so.5 -> libindicate.so.5.0.7
-       libicule.so.48 -> libicule.so.48.1.1
-       libmtdev.so.1 -> libmtdev.so.1.0.0
-       libgnome-media-profiles-3.0.so.0 -> libgnome-media-profiles-3.0.so.0.0.0
-       libnetsnmpmibs.so.15 -> libnetsnmpmibs.so.15.1.2
-       liboverlay-scrollbar-0.2.so.0 -> liboverlay-scrollbar-0.2.so.0.0.16
-       libecore_imf_evas.so.1 -> libecore_imf_evas.so.1.0.0
-       libpaper.so.1 -> libpaper.so.1.1.2
-       libjte.so.1 -> libjte.so.1.0.0
-       libdotconf-1.0.so.0 -> libdotconf-1.0.so.0.10.4
-       libicutest.so.48 -> libicutest.so.48.1.1
-       libmimic.so.0 -> libmimic.so.0.0.1
-       libeukit.so.1 -> libeukit.so.1.0.0
-       libtotem-plparser.so.17 -> libtotem-plparser.so.17.0.3
-       libfolks-telepathy.so.25 -> libfolks-telepathy.so.25.7.0
-       libgtop-2.0.so.7 -> libgtop-2.0.so.7.2.0
-       libtwolame.so.0 -> libtwolame.so.0.0.0
-       libgwibber.so.2 -> libgwibber.so.2.0.0
-       libfreerdp-utils.so.1.0 -> libfreerdp-utils.so.1.0.1
-       libgnome-menu.so.2 -> libgnome-menu.so.2.4.13
-       libecore_file.so.1 -> libecore_file.so.1.0.0
-       libedataserver-1.2.so.15 -> libedataserver-1.2.so.15.0.0
-       librasqal.so.3 -> librasqal.so.3.0.0
-       libgexiv2.so.1 -> libgexiv2.so.1.0.0
-       libgettextlib-0.18.1.so -> libgettextlib.so
-       libmythes-1.2.so.0 -> libmythes-1.2.so.0.0.0
-       libprotoc.so.7 -> libprotoc.so.7.0.0
-       libfreerdp-rail.so.1.0 -> libfreerdp-rail.so.1.0.1
-       libsgutils2.so.2 -> libsgutils2.so.2.0.0
-       libaprutil-1.so.0 -> libaprutil-1.so.0.3.12
-       libraptor2.so.0 -> libraptor2.so.0.0.0
-       libgirepository-1.0.so.1 -> libgirepository-1.0.so.1.0.0
-       libunity-core-5.0.so.5 -> libunity-core-5.0.so.5.0.0
-       libflite_cmu_us_kal16.so.1 -> libflite_cmu_us_kal16.so.1.4
-       libecore_con.so.1 -> libecore_con.so.1.0.0
-       libecore_input_evas.so.1 -> libecore_input_evas.so.1.0.0
-       libjbig2dec.so.0 -> libjbig2dec.so.0.0.0
-       libnetsnmp.so.15 -> libnetsnmp.so.15.1.2
-       libzbar.so.0 -> libzbar.so.0.2.0
-       libXRes.so.1 -> libXRes.so.1.0.0
-       libcdio_paranoia.so.1 -> libcdio_paranoia.so.1.0.0
-       libedata-book-1.2.so.11 -> libedata-book-1.2.so.11.0.0
-       libnetsnmphelpers.so.15 -> libnetsnmphelpers.so.15.1.2
-       libgksu2.so.0 -> libgksu2.so.0.0.2
-       libQtBamf.so.1 -> libQtBamf.so.1.0.0
-       libnautilus-extension.so.1 -> libnautilus-extension.so.1.4.0
-       libebackend-1.2.so.1 -> libebackend-1.2.so.1.0.0
-       libI810XvMC.so.1 -> libI810XvMC.so.1.0.0
-       libembryo.so.1 -> libembryo.so.1.0.0
-       libmission-control-plugins.so.0 -> libmission-control-plugins.so.0.3.1
-       libguilereadline-v-17.so.17 -> libguilereadline-v-17.so.17.0.3
-       libsox.so.1 -> libsox.so.1.0.0
-       libcdio.so.13 -> libcdio.so.13.0.0
-       libsqlite.so.0 -> libsqlite.so.0.8.6
-       libecore_imf.so.1 -> libecore_imf.so.1.0.0
-       libevdocument3.so.4 -> libevdocument3.so.4.0.0
-       libehal.so.1 -> libehal.so.1.0.0
-       libt1.so.5 -> libt1.so.5.1.2
-       libdconf-qt.so.0 -> libdconf-qt.so.0.0.0
-       libboost_wserialization.so.1.46.1 -> libboost_wserialization.so.1.46.1
-       libaspell.so.15 -> libaspell.so.15.2.0
-       libusbmuxd.so.1 -> libusbmuxd.so.1.0.7
-       libevent-2.0.so.5 -> libevent-2.0.so.5.1.4
-       libdee-1.0.so.4 -> libdee-1.0.so.4.1.1
-       libimobiledevice.so.2 -> libimobiledevice.so.2.0.1
-       libtotem.so.0 -> libtotem.so.0.0.0
-       libopencore-amrnb.so.0 -> libopencore-amrnb.so.0.0.2
-       libgtkspell-3.so.0 -> libgtkspell-3.so.0.0.0
-       libsyncdaemon-1.0.so.1 -> libsyncdaemon-1.0.so.1.0.0
-       libid3tag.so.0 -> libid3tag.so.0.3.0
-       libxcb-keysyms.so.1 -> libxcb-keysyms.so.1.0.0
-       liblwres.so.80 -> liblwres.so.80.0.1
-       libgnome-menu-3.so.0 -> libgnome-menu-3.so.0.0.1
-       libgpgme-pthread.so.11 -> libgpgme-pthread.so.11.7.0
-       libXvMCW.so.1 -> libXvMCW.so.1.0.0
-       libenchant.so.1 -> libenchant.so.1.6.0
-       libgupnp-1.0.so.4 -> libgupnp-1.0.so.4.0.0
-       liblightdm-gobject-1.so.0 -> liblightdm-gobject-1.so.0.0.0
-       libasprintf.so.0 -> libasprintf.so.0.0.0
-       libprotobuf.so.7 -> libprotobuf.so.7.0.0
-       libwebkitgtk-1.0.so.0 -> libwebkitgtk-1.0.so.0.13.4
-       libmpeg2.so.0 -> libmpeg2.so.0.0.0
-       libssl.so.1.0.0 -> libssl.so.1.0.0
-       libfreerdp-gdi.so.1.0 -> libfreerdp-gdi.so.1.0.1
-       libgpgme.so.11 -> libgpgme.so.11.7.0
-       libplist.so.1 -> libplist.so.1.1.8
-       libmtp.so.9 -> libmtp.so.9.0.3
-       libecore_x.so.1 -> libecore_x.so.1.0.0
-       libcap-ng.so.0 -> libcap-ng.so.0.0.0
-       libnux-core-2.0.so.0 -> libnux-core-2.0.so.0.1401.0
-       libpyglib-2.0-python2.7.so.0 -> libpyglib-2.0-python2.7.so.0.0.0
-       libsidplay.so.1 -> libsidplay.so.1.0.3
-       libXfont.so.1 -> libXfont.so.1.4.1
-       libical.so.0 -> libical.so.0.48.0
-       libdvdnav.so.4 -> libdvdnav.so.4.2.0
-       libfreerdp-cache.so.1.0 -> libfreerdp-cache.so.1.0.1
-       libexttextcat.so.0 -> libexttextcat.so.0.0.0
-       libboost_serialization.so.1.46.1 -> libboost_serialization.so.1.46.1
-       libmagic.so.1 -> libmagic.so.1.0.0
-       libcamel-provider-1.2.so.29 -> libcamel-provider-1.2.so.29.0.0
-       libedata-cal-1.2.so.13 -> libedata-cal-1.2.so.13.0.0
-       libxcb-image.so.0 -> libxcb-image.so.0.0.0
-       librpmbuild.so.2 -> librpmbuild.so.2.0.1
-       libzeitgeist-1.0.so.1 -> libzeitgeist-1.0.so.1.1.4
-       libmpeg2convert.so.0 -> libmpeg2convert.so.0.0.0
-       libecore.so.1 -> libecore.so.1.0.0
-       libwpd-0.9.so.9 -> libwpd-0.9.so.9.0.4
-       libmms.so.0 -> libmms.so.0.0.2
-       libstlport_gcc.so.4.6 -> libstlport_gcc.so.4.6
-       libopencc.so.1 -> libopencc.so.1.0.0
-       libck-connector.so.0 -> libck-connector.so.0.0.0
-       libcdio_cdda.so.1 -> libcdio_cdda.so.1.0.0
-       librdf.so.0 -> librdf.so.0.0.0
-       libtelepathy-glib.so.0 -> libtelepathy-glib.so.0.70.2
-       libGeoIPUpdate.so.0 -> libGeoIPUpdate.so.0.0.0
-       libraw_r.so.5 -> libraw_r.so.5.0.0
-       libwebkitgtk-3.0.so.0 -> libwebkitgtk-3.0.so.0.13.4
-       libbrasero-utils3.so.1 -> libbrasero-utils3.so.1.2.3
-       libgcr-3.so.1 -> libgcr-3.so.1.0.0
-       libdca.so.0 -> libdca.so.0.0.0
-       libcompizconfig.so.0 -> libcompizconfig.so.0.0.0
-       librpmsign.so.0 -> librpmsign.so.0.0.1
-       libburn.so.4 -> libburn.so.4.71.0
-       libzephyr.so.4 -> libzephyr.so.4.0.0
-       libcamel-1.2.so.29 -> libcamel-1.2.so.29.0.0
-       libmodplug.so.1 -> libmodplug.so.1.0.0
-       liblrdf.so.0 -> liblrdf.so.0.0.0
-       libflite_cmu_us_kal.so.1 -> libflite_cmu_us_kal.so.1.4
-       libjavascriptcoregtk-3.0.so.0 -> libjavascriptcoregtk-3.0.so.0.13.4
-       libiculx.so.48 -> libiculx.so.48.1.1
-       libgdata.so.13 -> libgdata.so.13.2.0
-       libedataserverui-3.0.so.1 -> libedataserverui-3.0.so.1.0.0
-       libecore_ipc.so.1 -> libecore_ipc.so.1.0.0
-       libindicate-gtk.so.3 -> libindicate-gtk.so.3.0.3
-       libexiv2.so.11 -> libexiv2.so.11.0.0
-       libyelp.so.0 -> libyelp.so.0.0.0
-       libxapian.so.22 -> libxapian.so.22.4.2
-       libnm-glib.so.4 -> libnm-glib.so.4.3.0
-       libflite_cmu_time_awb.so.1 -> libflite_cmu_time_awb.so.1.4
-       libhpmud.so.0 -> libhpmud.so.0.0.6
-       librarian.so.0 -> librarian.so.0.0.0
-       libnetsnmptrapd.so.15 -> libnetsnmptrapd.so.15.1.2
-       libGeoIP.so.1 -> libGeoIP.so.1.4.8
-       libgettextsrc-0.18.1.so -> libgettextsrc.so
-       libpackagekit-glib2.so.14 -> libpackagekit-glib2.so.14.0.11
-       libecore_fb.so.1 -> libecore_fb.so.1.0.0
-       libgnome-bluetooth.so.8 -> libgnome-bluetooth.so.8.0.0
-       libminiupnpc.so.8 -> libminiupnpc.so.8
-       libguile-srfi-srfi-13-14-v-3.so.3 -> libguile-srfi-srfi-13-14-v-3.so.3.0.1
-       libraw.so.5 -> libraw.so.5.0.0
-       librhythmbox-core.so.5 -> librhythmbox-core.so.5.0.0
-       libxdelta.so.2 -> libxdelta.so.2.0.0
-       libgeoclue.so.0 -> libgeoclue.so.0.0.0
-       libfreerdp-channels.so.1.0 -> libfreerdp-channels.so.1.0.1
-       libgsm.so.1 -> libgsm.so.1.0.12
-       libgme.so.0 -> libgme.so.0.5.3
-       librpmio.so.2 -> librpmio.so.2.0.1
-       libnetfilter_conntrack.so.3 -> libnetfilter_conntrack.so.3.1.3
-       libappindicator3.so.1 -> libappindicator3.so.1.0.0
-       libicudata.so.48 -> libicudata.so.48.1.1
-       libnl-route-3.so.200 -> libnl-route-3.so.200.3.0
-       libicuuc.so.48 -> libicuuc.so.48.1.1
-       libIntelXvMC.so.1 -> libIntelXvMC.so.1.0.0
-       libraptor.so.1 -> libraptor.so.1.2.0
-       libgedit-private.so.0 -> libgedit-private.so.0.0.0
-       libindicator.so.7 -> libindicator.so.7.0.0
-       libsnmp.so.15 -> libsnmp.so.15.1.2
-       libguile.so.17 -> libguile.so.17.4.0
-       libcompiz_core.so.ABI-20120305 -> libcompiz_core.so.0.9.7.12
-       libunique-3.0.so.0 -> libunique-3.0.so.0.0.2
-       libfaad.so.2 -> libfaad.so.2.0.0
-       libneon-gnutls.so.27 -> libneon-gnutls.so.27.2.6
-       libpython2.7.so.1.0 -> libpython2.7.so.1.0
-       libspeechd.so.2 -> libspeechd.so.2.3.0
-       libecal-1.2.so.10 -> libecal-1.2.so.10.2.2
-       libwpd-stream-0.9.so.9 -> libwpd-stream-0.9.so.9.0.4
-       liboverlay-scrollbar3-0.2.so.0 -> liboverlay-scrollbar3-0.2.so.0.0.16
-       libunity.so.9 -> libunity.so.9.0.2
-       libhyphen.so.0 -> libhyphen.so.0.2.1
-       libbrasero-media3.so.1 -> libbrasero-media3.so.1.2.3
-       libelementary-ver-pre-svn-09.so.0 -> libelementary.so
-       libkpathsea.so.5 -> libkpathsea.so.5.0.0
-       libvlc.so.5 -> libvlc.so.5.3.2
-       libflite_cmulex.so.1 -> libflite_cmulex.so.1.4
-       libopenobex.so.1 -> libopenobex.so.1.5.0
-       libdns.so.81 -> libdns.so.81.3.1
-       libfreerdp-kbd.so.1.0 -> libfreerdp-kbd.so.1.0.1
-       libpspell.so.15 -> libpspell.so.15.2.0
-       libfolks-eds.so.25 -> libfolks-eds.so.25.7.0
-       libisofs.so.6 -> libisofs.so.6.54.0
-       libecore_input.so.1 -> libecore_input.so.1.0.0
-       libpurple.so.0 -> libpurple.so.0.10.3
-       librsync.so.1 -> librsync.so.1.0.2
-       librpm.so.2 -> librpm.so.2.0.1
-       libmeanwhile.so.1 -> libmeanwhile.so.1.0.2
-       libevas.so.1 -> libevas.so.1.0.0
-       libapr-1.so.0 -> libapr-1.so.0.4.6
-       liblirc_client.so.0 -> liblirc_client.so.0.2.1
-       libexpect.so.5.45 -> libexpect.so.5.45
-       libgucharmap_2_90.so.7 -> libgucharmap_2_90.so.7.0.0
-       libicuio.so.48 -> libicuio.so.48.1.1
-       libgpod.so.4 -> libgpod.so.4.3.2
-       libfontenc.so.1 -> libfontenc.so.1.0.0
-       libchromeXvMC.so.1 -> libchromeXvMC.so.1.0.0
-       libgssdp-1.0.so.3 -> libgssdp-1.0.so.3.0.0
-       libguile-srfi-srfi-4-v-3.so.3 -> libguile-srfi-srfi-4-v-3.so.3.0.1
-       libflite_cmu_us_rms.so.1 -> libflite_cmu_us_rms.so.1.4
-       liblaunchpad-integration-3.0.so.1 -> liblaunchpad-integration-3.0.so.1.0.0
-       libdjvulibre.so.21 -> libdjvulibre.so.21.3.0
-       libdecoration.so.0 -> libdecoration.so.0.0.0
-       libnm-gtk.so.0 -> libnm-gtk.so.0.0.0
-       libcmis-0.2.so.0 -> libcmis-0.2.so.0.0.0
-       libgpgme-pth.so.11 -> libgpgme-pth.so.11.7.0
-       libguile-srfi-srfi-60-v-2.so.2 -> libguile-srfi-srfi-60-v-2.so.2.0.2
-       libgnome-desktop-3.so.2 -> libgnome-desktop-3.so.2.1.4
-       libnfnetlink.so.0 -> libnfnetlink.so.0.2.0
-       libpeas-gtk-1.0.so.0 -> libpeas-gtk-1.0.so.0.200.0
-       libevview3.so.3 -> libevview3.so.3.0.0
-       libappindicator.so.1 -> libappindicator.so.1.0.0
-       libisccfg.so.82 -> libisccfg.so.82.0.0
-       libt1x.so.5 -> libt1x.so.5.1.2
-       libtotem-plparser-mini.so.17 -> libtotem-plparser-mini.so.17.0.3
-       libgnomekbdui.so.7 -> libgnomekbdui.so.7.0.0
-       libspectre.so.1 -> libspectre.so.1.1.6
-       libnm-glib-vpn.so.1 -> libnm-glib-vpn.so.1.1.0
-       libdvdread.so.4 -> libdvdread.so.4.2.0
-       libQtDee.so.2 -> libQtDee.so.2.0.0
-       libnux-graphics-2.0.so.0 -> libnux-graphics-2.0.so.0.1401.0
-       libslp.so.1 -> libslp.so.1.0.1
-       libdvdnavmini.so.4 -> libdvdnavmini.so.4.2.0
-       libnux-image-2.0.so.0 -> libnux-image-2.0.so.0.1401.0
-       libunity-2d-private.so.0 -> libunity-2d-private.so.0.0.0
-       libtelepathy-farstream.so.2 -> libtelepathy-farstream.so.2.0.1
-       libedsio.so.0 -> libedsio.so.0.0.0
-       libmusicbrainz3.so.6 -> libmusicbrainz3.so.6.2.0
-       libefreet_mime.so.1 -> libefreet_mime.so.1.0.0
-       libenca.so.0 -> libenca.so.0.5.1
-       libpth.so.20 -> libpth.so.20.0.27
-       libchromeXvMCPro.so.1 -> libchromeXvMCPro.so.1.0.0
-       libicalvcal.so.0 -> libicalvcal.so.0.48.0
-       libbrasero-burn3.so.1 -> libbrasero-burn3.so.1.2.3
-       libupower-glib.so.1 -> libupower-glib.so.1.0.1
-/usr/lib/i386-linux-gnu/sse2: (hwcap: 0x0000000004000000)
-       libspeex.so.1 -> libspeex.so.1.5.0
-       libspeexdsp.so.1 -> libspeexdsp.so.1.5.0
-/usr/lib/i386-linux-gnu/i686: (hwcap: 0x0008000000000000)
-/usr/lib/sse2: (hwcap: 0x0000000004000000)
-       libxapian.so.22 -> libxapian.so.22.4.2
-/usr/lib/i386-linux-gnu/i686/sse2: (hwcap: 0x0008000004000000)
-       libx264.so.120 -> libx264.so.120
-/usr/lib/i386-linux-gnu/i686/cmov: (hwcap: 0x0008000000008000)
-       libavcodec.so.53 -> libavcodec.so.53.35.0
-       libavformat.so.53 -> libavformat.so.53.21.1
-       libswscale.so.2 -> libswscale.so.2.1.0
-       libavutil.so.51 -> libavutil.so.51.22.2
index bf0ad09..022feff 100644 (file)
@@ -60,7 +60,7 @@ resourceClient_env.AppendUnique(CPPPATH = [
     'src/resourceCache/include'
 ])
 
-resourceClient_env.PrependUnique(LIBS = ['oc', 'rcs_common', 'octbstack', 'gnustl_shared','oc_logger', 'compatibility', 'log'])
+resourceClient_env.PrependUnique(LIBS = ['oc', 'rcs_common', 'octbstack','oc_logger'])
 
 if target_os not in ['windows', 'winrt']:
     resourceClient_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
@@ -69,7 +69,7 @@ if target_os == 'linux':
 
 if target_os == 'android':
     resourceClient_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-    resourceClient_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
+    resourceClient_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
 
 resourceClient_env.AppendUnique(LIBS = ['dl'])
 
@@ -90,8 +90,11 @@ client_src = [
         RESOURCECLIENT_DIR + 'RCSDiscoveryManager.cpp',
         RESOURCECLIENT_DIR + 'RCSRemoteResourceObject.cpp'
                ]
-ResourceClientsdk = resourceClient_env.StaticLibrary('rcs_client', client_src)
-resourceClient_env.InstallTarget(ResourceClientsdk , 'librcs_client')
+ResourceClientsdk_static = resourceClient_env.StaticLibrary('rcs_client', client_src)
+ResourceClientsdk_shared = resourceClient_env.SharedLibrary('rcs_client', client_src)
+
+resourceClient_env.InstallTarget([ResourceClientsdk_static,ResourceClientsdk_shared], 'librcs_client')
+resourceClient_env.UserInstallTargetLib([ResourceClientsdk_static,ResourceClientsdk_shared], 'librcs_client')
 
 ######################################################################
 # Build Sample App: SampleResourceClient & SampleResourceServer
@@ -101,7 +104,8 @@ SConscript('examples/SConscript')
 ######################################################################
 # Build UnitTests Resource Client , resourceCache and resourceBroker
 ################################################ ######################
-SConscript('unittests/SConscript')
-SConscript('src/resourceCache/unittests/SConscript')
-SConscript('src/resourceBroker/unittest/SConscript')
+if target_os == 'linux':
+    SConscript('unittests/SConscript')
+    SConscript('src/resourceCache/unittests/SConscript')
+    SConscript('src/resourceBroker/unittest/SConscript')
 
index 316042e..b905977 100644 (file)
@@ -39,8 +39,8 @@ constexpr int QUIT_INPUT = 3;
 std::shared_ptr<RCSRemoteResourceObject>  resource;
 
 const std::string defaultKey = "Temperature";
-const std::string resourceType = "?rt=core.TemperatureSensor";
-const std::string targetUri = OC_RSRVD_WELL_KNOWN_URI + resourceType;
+const std::string resourceType = "core.TemperatureSensor";
+const std::string relativetUri = OC_RSRVD_WELL_KNOWN_URI;
 
 std::mutex mtx;
 std::condition_variable cond;
@@ -397,8 +397,8 @@ bool discoverResource()
 {
     std::cout << "Wait 2 seconds until discovered." << std::endl;
 
-    RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(), targetUri,
-                                                         &onResourceDiscovered);
+    RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::multicast(),
+            relativetUri, resourceType, &onResourceDiscovered);
 
     std::unique_lock<std::mutex> lck(mtx);
     cond.wait_for(lck,std::chrono::seconds(2));
index 53ad2b1..2105647 100644 (file)
@@ -21,7 +21,7 @@
 /**
  * @file
  *
- * This file contains the RCSDiscoveryManager class which provide API to discover the Resource in the network
+ * This file contains the RCSDiscoveryManager class which provide APIs to discover the Resource in the network
  *
  */
 
@@ -35,54 +35,104 @@ namespace OIC
 {
     namespace Service
     {
-
         class RCSRemoteResourceObject;
         class RCSAddress;
 
         /**
-         * This class contains the resource discovery method.
+         * This class contains the resource discovery methods.
          *
          * @see RCSRemoteResourceObject
          */
         class RCSDiscoveryManager
         {
-        public:
+            public:
+
+                /**
+                 * Typedef for callback of discoverResource APIs
+                 *
+                 * @see discoverResource
+                 */
+                typedef std::function< void(std::shared_ptr< RCSRemoteResourceObject >) >
+                                       ResourceDiscoveredCallback;
+
+                /**
+                 * Returns RCSDiscoveryManager instance.
+                 *
+                 */
+                static RCSDiscoveryManager* getInstance();
+
+                /**
+                 * API for discovering the resource of Interest, regardless of URI and resource type
+                 *
+                 * @param address A RCSAddress object
+                 * @param cb A callback to obtain discovered resource
+                 *
+                 * @throws InvalidParameterException If cb is empty.
+                 *
+                 * @note The callback will be invoked in an internal thread.
+                 *
+                 * @see RCSAddress
+                 *
+                 */
+                void discoverResource(const RCSAddress& address, ResourceDiscoveredCallback cb);
 
-            /**
-             * Typedef for callback of discoverResource API
-             *
-             * @see discoverResource
-             */
-            typedef std::function< void(std::shared_ptr< RCSRemoteResourceObject >) >
-                ResourceDiscoveredCallback;
+                /**
+                 * API for discovering the resource of Interest, regardless of resource type
+                 *
+                 * @param address A RCSAddress object
+                 * @param relativeURI The relative uri of resource to be searched
+                 * @param cb A callback to obtain discovered resource
+                 *
+                 * @throws InvalidParameterException If cb is empty.
+                 *
+                 * @note The callback will be invoked in an internal thread.
+                 *
+                 * @see RCSAddress
+                 *
+                 */
+                void discoverResource(const RCSAddress& address, const std::string& relativeURI,
+                                      ResourceDiscoveredCallback cb);
 
-            /**
-             * Returns RCSDiscoveryManager instance.
-             *
-             */
-            static RCSDiscoveryManager* getInstance();
+                /**
+                 * API for discovering the resource of Interest by Resource type.
+                 *
+                 * @param address A RCSAddress object
+                 * @param resourceType Ressource Type
+                 * @param cb A callback to obtain discovered resource
+                 *
+                 * @throws InvalidParameterException If cb is empty.
+                 *
+                 * @note The callback will be invoked in an internal thread.
+                 *
+                 * @see RCSAddress
+                 *
+                 */
+                void discoverResourceByType(const RCSAddress& address, const std::string& resourceType,
+                                            ResourceDiscoveredCallback cb);
 
-            /**
-             * API for discovering the resource of Interest.
-             *
-             * @param address A RCSAddress object
-             * @param resourceURI The uri of resource to be searched
-             * @param cb A callback to obtain discovered resource
-             *
-             * @throws InvalidParameterException If cb is empty.
-             *
-             * @note The callback will be invoked in an internal thread.
-             *
-             * @see RCSAddress
-             *
-             */
-            void discoverResource(const RCSAddress& address, const std::string& resourceURI,
-                    ResourceDiscoveredCallback cb);
+                /**
+                 * API for discovering the resource of Interest by Resource type with provided relativeURI
+                 *
+                 * @param address A RCSAddress object
+                 * @param relativeURI The relative uri of resource to be searched
+                 * @param resourceType Ressource Type
+                 * @param cb A callback to obtain discovered resource
+                 *
+                 * @throws InvalidParameterException If cb is empty.
+                 *
+                 * @note The callback will be invoked in an internal thread.
+                 *
+                 * @see RCSAddress
+                 *
+                 */
+                void discoverResourceByType(const RCSAddress& address, const std::string& relativeURI,
+                                            const std::string& resourceType,
+                                            ResourceDiscoveredCallback cb);
 
-        private:
-            RCSDiscoveryManager() = default;
-            ~RCSDiscoveryManager() = default;
+            private:
 
+                RCSDiscoveryManager() = default;
+                ~RCSDiscoveryManager() = default;
         };
     }
 }
index 5ab8c92..193f21e 100644 (file)
@@ -96,7 +96,7 @@ namespace OIC
             class KeyValueVisitorHelper: public boost::static_visitor< >
             {
             public:
-                KeyValueVisitorHelper(VISITOR& visitor) :
+                KeyValueVisitorHelper(VISITOR& visitor) noexcept :
                         m_visitor( visitor )
                 {
                 }
@@ -159,7 +159,7 @@ namespace OIC
                  *
                  * @return Identifier of type.
                  */
-                TypeId getId() const;
+                TypeId getId() const noexcept;
 
                 /**
                  * Factory method to create Type instance from T.
@@ -171,18 +171,18 @@ namespace OIC
                  * @see is_supported_type
                  */
                 template < typename T >
-                static Type typeOf(const T& value)
+                static Type typeOf(const T& value) noexcept
                 {
                     return Type(value);
                 }
 
                 //! @cond
-                friend bool operator==(const Type&, const Type&);
+                friend bool operator==(const Type&, const Type&) noexcept;
                 //! @endcond
 
             private:
                 template < typename T >
-                explicit Type(const T&) :
+                explicit Type(const T&) noexcept :
                     m_which{ IndexOfType< T >::value }
                 {
                 }
@@ -207,7 +207,7 @@ namespace OIC
 
                 Value();
                 Value(const Value&);
-                Value(Value&&);
+                Value(Value&&) noexcept;
 
                 /**
                  * Constructs a Value if T is a supported type.<br/>
@@ -276,7 +276,7 @@ namespace OIC
                 /**
                  * Exchanges the content of the object by the content of the parameter.
                  */
-                void swap(Value&);
+                void swap(Value&) noexcept;
 
                 //! @cond
                 friend class RCSResourceAttributes;
@@ -328,32 +328,32 @@ namespace OIC
             /**
              * Returns an {@link iterator} referring to the first element.
              */
-            iterator begin();
+            iterator begin() noexcept;
 
             /**
              * Returns an {@link iterator} referring to the <i>past-the-end element</i>.
              */
-            iterator end();
+            iterator end() noexcept;
 
             /**
              * @copydoc cbegin()
              */
-            const_iterator begin() const;
+            const_iterator begin() const noexcept;
 
             /**
              * @copydoc cend()
              */
-            const_iterator end() const;
+            const_iterator end() const noexcept;
 
             /**
              * Returns a const_iterator referring to the first element.
              */
-            const_iterator cbegin() const;
+            const_iterator cbegin() const noexcept;
 
             /**
              * Returns a const_iterator referring to the <i>past-the-end element</i>.
              */
-            const_iterator cend() const;
+            const_iterator cend() const noexcept;
 
             /**
              * Accesses a value.
@@ -427,7 +427,7 @@ namespace OIC
             /**
              * Removes all elements.
              */
-            void clear();
+            void clear() noexcept;
 
             /**
              * Removes a single element.
@@ -452,14 +452,14 @@ namespace OIC
              *
              * @see size
              */
-            bool empty() const;
+            bool empty() const noexcept;
 
             /**
              * Returns the number of elements.
              *
              * @see empty
              */
-            size_t size() const;
+            size_t size() const noexcept;
 
         private:
             template< typename VISITOR >
@@ -538,7 +538,8 @@ namespace OIC
          *
          * @return true if the objects are equal, false otherwise.
          */
-        bool operator==(const RCSResourceAttributes::Type&, const RCSResourceAttributes::Type&);
+        bool operator==(const RCSResourceAttributes::Type&, const RCSResourceAttributes::Type&)
+                noexcept;
 
         /**
          * @relates RCSResourceAttributes::Type
@@ -547,7 +548,8 @@ namespace OIC
          *
          * @return true if the objects are not equal, false otherwise.
          */
-        bool operator!=(const RCSResourceAttributes::Type&, const RCSResourceAttributes::Type&);
+        bool operator!=(const RCSResourceAttributes::Type&, const RCSResourceAttributes::Type&)
+                noexcept;
 
         /**
          * @relates RCSResourceAttributes::Value
@@ -638,32 +640,32 @@ namespace OIC
             class KeyVisitor: public boost::static_visitor< const std::string& >
             {
             public:
-                result_type operator()(iterator*) const;
-                result_type operator()(const_iterator*) const;
+                result_type operator()(iterator*) const noexcept;
+                result_type operator()(const_iterator*) const noexcept;
             };
 
             class ValueVisitor: public boost::static_visitor< Value& >
             {
             public:
-                result_type operator()(iterator*);
+                result_type operator()(iterator*) noexcept;
                 result_type operator()(const_iterator*);
             };
 
             class ConstValueVisitor: public boost::static_visitor< const Value& >
             {
             public:
-                result_type operator()(iterator*) const;
-                result_type operator()(const_iterator*) const;
+                result_type operator()(iterator*) const noexcept;
+                result_type operator()(const_iterator*) const noexcept;
             };
 
         public:
-            const std::string& key() const;
-            const RCSResourceAttributes::Value& value() const;
+            const std::string& key() const noexcept;
+            const RCSResourceAttributes::Value& value() const noexcept;
             RCSResourceAttributes::Value& value();
 
         private:
             KeyValuePair(const KeyValuePair&) = default;
-            KeyValuePair(boost::variant< iterator*, const_iterator* >&&);
+            KeyValuePair(boost::variant< iterator*, const_iterator* >&&) noexcept;
 
             KeyValuePair& operator=(const KeyValuePair&) = default;
 
index 7c0c636..85c7848 100644 (file)
@@ -31,8 +31,6 @@
 #include <mutex>
 #include <thread>
 
-#include <boost/atomic.hpp>
-
 #include <RCSResourceAttributes.h>
 #include <RCSResponse.h>
 #include <RCSRequest.h>
@@ -59,6 +57,11 @@ namespace OIC
                 NoLockException(std::string &&what) : RCSException { std::move(what) } {}
         };
 
+        //! @cond
+        template < typename T >
+        class AtomicWrapper;
+        //! @endcond
+
         /**
          * @brief  RCSResourceObject represents a resource. It handles any requests from
          *        clients automatically with attributes.
@@ -76,6 +79,8 @@ namespace OIC
             private:
                 class WeakGuard;
 
+                typedef AtomicWrapper< std::thread::id > AtomicThreadId;
+
             public:
                 /**
                  * @brief represents the policy of AutoNotify function.
@@ -433,6 +438,10 @@ namespace OIC
 
             void expectOwnLock() const;
 
+            std::thread::id getLockOwner() const noexcept;
+
+            void setLockOwner(std::thread::id&&) const noexcept;
+
             void autoNotify(bool, AutoNotifyPolicy) const;
             void autoNotify(bool) const;
 
@@ -455,7 +464,7 @@ namespace OIC
             std::unordered_map< std::string, AttributeUpdatedListener >
                     m_keyAttributesUpdatedListeners;
 
-            mutable boost::atomic< std::thread::id > m_lockOwner;
+            mutable std::unique_ptr< AtomicThreadId > m_lockOwner;
             mutable std::mutex m_mutex;
 
             std::mutex m_mutexKeyAttributeUpdate;
index fd10311..e0d38be 100644 (file)
@@ -62,7 +62,7 @@ if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
 
 if target_os == 'android':
     rcs_common_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-    rcs_common_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
+    rcs_common_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
 
 rcs_common_env.AppendUnique(LIBS = ['dl', 'oc'])
 
@@ -91,42 +91,41 @@ rcs_common_shared = rcs_common_env.SharedLibrary('rcs_common', rcs_common_src)
 rcs_common_env.InstallTarget([rcs_common_static,rcs_common_shared], 'rcs_common')
 
 ######################################################################
-# Build Test primitive Resource
+# Build Test Expiry Timer and primitive Resource
 ######################################################################
-rcs_common_test_env = rcs_common_env.Clone();
-
-rcs_common_test_env.PrependUnique(CPPPATH = [
-    env.get('SRC_DIR')+'/extlibs/hippomocks-master',
-    gtest_dir + '/include',
-    'utils/include'
-    ])
-
-gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
-gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
-
-rcs_common_test_env.PrependUnique(LIBS = [
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
-    'coap',
-    'rcs_common',
-     gtest,
-     gtest_main,
-    'pthread'
-    ])
-
-rcs_common_test_src = [
-    env.Glob('primitiveResource/unittests/*.cpp'),
-    'expiryTimer/unittests/ExpiryTimerTest.cpp'
-    ]
-
-rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)
-Alias("rcs_common_test", rcs_common_test)
-env.AppendTarget('rcs_common_test')
-
-if env.get('TEST') == '1':
-    target_os = env.get('TARGET_OS')
-    if target_os == 'linux':
-        from tools.scons.RunTest import *
-        run_test(rcs_common_test_env, '',
-                'service/resource-encapsulation/src/common/rcs_common_test')
+if target_os == 'linux':
+       rcs_common_test_env = rcs_common_env.Clone();
+
+       rcs_common_test_env.PrependUnique(CPPPATH = [
+               env.get('SRC_DIR')+'/extlibs/hippomocks-master',
+               gtest_dir + '/include',
+               'utils/include'
+               ])
+
+       gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
+       gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
+
+       rcs_common_test_env.PrependUnique(LIBS = [
+               'octbstack',
+               'oc_logger',
+               'connectivity_abstraction',
+               'coap',
+               'rcs_common',
+               gtest,
+               gtest_main,
+               'pthread'
+               ])
+
+       rcs_common_test_src = [
+               env.Glob('primitiveResource/unittests/*.cpp'),
+               'expiryTimer/unittests/ExpiryTimerTest.cpp'
+               ]
+
+       rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)
+       Alias("rcs_common_test", rcs_common_test)
+       env.AppendTarget('rcs_common_test')
+
+       if env.get('TEST') == '1':
+               from tools.scons.RunTest import *
+               run_test(rcs_common_test_env, '',
+                       'service/resource-encapsulation/src/common/rcs_common_test')
index 99de4a6..dc4e53b 100644 (file)
@@ -103,13 +103,15 @@ namespace
     template< >
     struct TypeInfoConverter< std::nullptr_t >
     {
-        static constexpr RCSResourceAttributes::TypeId typeId = RCSResourceAttributes::TypeId::NULL_T;
+        static constexpr RCSResourceAttributes::TypeId typeId =
+                RCSResourceAttributes::TypeId::NULL_T;
     };
 
     template< >
     struct TypeInfoConverter< double >
     {
-        static constexpr RCSResourceAttributes::TypeId typeId = RCSResourceAttributes::TypeId::DOUBLE;
+        static constexpr RCSResourceAttributes::TypeId typeId =
+                RCSResourceAttributes::TypeId::DOUBLE;
     };
 
     template< >
@@ -121,13 +123,15 @@ namespace
     template< >
     struct TypeInfoConverter< std::string >
     {
-        static constexpr RCSResourceAttributes::TypeId typeId = RCSResourceAttributes::TypeId::STRING;
+        static constexpr RCSResourceAttributes::TypeId typeId =
+                RCSResourceAttributes::TypeId::STRING;
     };
 
     template< >
     struct TypeInfoConverter< RCSResourceAttributes >
     {
-        static constexpr RCSResourceAttributes::TypeId typeId = RCSResourceAttributes::TypeId::ATTRIBUTES;
+        static constexpr RCSResourceAttributes::TypeId typeId =
+                RCSResourceAttributes::TypeId::ATTRIBUTES;
     };
 
     struct TypeInfo
@@ -154,7 +158,7 @@ namespace
     };
 
     template< typename VARIANT, int POS >
-    constexpr inline std::vector< TypeInfo > getTypeInfo(Int2Type< POS >)
+    constexpr inline std::vector< TypeInfo > getTypeInfo(Int2Type< POS >) noexcept
     {
         auto&& vec = getTypeInfo< VARIANT >(Int2Type< POS - 1 >{ });
         vec.push_back(TypeInfo::get< VARIANT, POS >());
@@ -162,13 +166,13 @@ namespace
     }
 
     template< typename VARIANT >
-    constexpr inline std::vector< TypeInfo > getTypeInfo(Int2Type< 0 >)
+    constexpr inline std::vector< TypeInfo > getTypeInfo(Int2Type< 0 >) noexcept
     {
         return { TypeInfo::get< VARIANT, 0 >() };
     }
 
     template< typename VARIANT >
-    inline TypeInfo getTypeInfo(int which)
+    inline TypeInfo getTypeInfo(int which) noexcept
     {
         static constexpr int variantEnd = boost::mpl::size< typename VARIANT::types >::value - 1;
         static const std::vector< TypeInfo > typeInfos = getTypeInfo< VARIANT >(
@@ -196,12 +200,14 @@ namespace OIC
             return *m_valueRef.m_data == *rhs.m_valueRef.m_data;
         }
 
-        bool operator==(const RCSResourceAttributes::Type& lhs, const RCSResourceAttributes::Type& rhs)
+        bool operator==(const RCSResourceAttributes::Type& lhs,
+                const RCSResourceAttributes::Type& rhs) noexcept
         {
             return lhs.m_which == rhs.m_which;
         }
 
-        bool operator!=(const RCSResourceAttributes::Type& lhs, const RCSResourceAttributes::Type& rhs)
+        bool operator!=(const RCSResourceAttributes::Type& lhs,
+                const RCSResourceAttributes::Type& rhs) noexcept
         {
             return !(lhs == rhs);
         }
@@ -228,7 +234,7 @@ namespace OIC
             return !(lhs == rhs);
         }
 
-        auto RCSResourceAttributes::Type::getId() const -> TypeId
+        auto RCSResourceAttributes::Type::getId() const noexcept -> TypeId
         {
             return ::getTypeInfo< ValueVariant >(m_which).typeId;
         }
@@ -243,10 +249,10 @@ namespace OIC
         {
         }
 
-        RCSResourceAttributes::Value::Value(Value&& from) :
+        RCSResourceAttributes::Value::Value(Value&& from) noexcept :
                 m_data{ new ValueVariant{} }
         {
-            m_data->swap(*from.m_data);
+            m_data.swap(from.m_data);
         }
 
         RCSResourceAttributes::Value::Value(const char* value) :
@@ -289,24 +295,24 @@ namespace OIC
             return boost::apply_visitor(ToStringVisitor(), *m_data);
         }
 
-        void RCSResourceAttributes::Value::swap(Value& rhs)
+        void RCSResourceAttributes::Value::swap(Value& rhs) noexcept
         {
             m_data.swap(rhs.m_data);
         }
 
         auto RCSResourceAttributes::KeyValuePair::KeyVisitor::operator()(
-                iterator* iter) const -> result_type
+                iterator* iter) const noexcept -> result_type
         {
             return iter->m_cur->first;
         }
 
         auto RCSResourceAttributes::KeyValuePair::KeyVisitor::operator()(
-                const_iterator* iter) const -> result_type
+                const_iterator* iter) const noexcept -> result_type
         {
             return iter->m_cur->first;
         }
 
-        auto RCSResourceAttributes::KeyValuePair::ValueVisitor::operator() (iterator* iter)
+        auto RCSResourceAttributes::KeyValuePair::ValueVisitor::operator() (iterator* iter) noexcept
                 -> result_type
         {
             return iter->m_cur->second;
@@ -320,23 +326,23 @@ namespace OIC
         }
 
         auto RCSResourceAttributes::KeyValuePair::ConstValueVisitor::operator()(
-                iterator*iter) const -> result_type
+                iterator*iter) const noexcept -> result_type
         {
             return iter->m_cur->second;
         }
 
         auto RCSResourceAttributes::KeyValuePair::ConstValueVisitor::operator()(
-                const_iterator* iter) const -> result_type
+                const_iterator* iter) const noexcept -> result_type
         {
             return iter->m_cur->second;
         }
 
-        auto RCSResourceAttributes::KeyValuePair::key() const -> const std::string&
+        auto RCSResourceAttributes::KeyValuePair::key() const noexcept -> const std::string&
         {
             return boost::apply_visitor(m_keyVisitor, m_iterRef);
         }
 
-        auto RCSResourceAttributes::KeyValuePair::value() const -> const Value&
+        auto RCSResourceAttributes::KeyValuePair::value() const noexcept -> const Value&
         {
             return boost::apply_visitor(m_constValueVisitor, m_iterRef);
         }
@@ -347,7 +353,7 @@ namespace OIC
         }
 
         RCSResourceAttributes::KeyValuePair::KeyValuePair(boost::variant<iterator*,
-                const_iterator*>&& ref) :
+                const_iterator*>&& ref) noexcept :
                 m_iterRef{ ref }
         {
         }
@@ -415,8 +421,9 @@ namespace OIC
         {
         }
 
-        auto RCSResourceAttributes::const_iterator::operator=(const RCSResourceAttributes::iterator& iter)
-            -> const_iterator& {
+        auto RCSResourceAttributes::const_iterator::operator=(
+                const RCSResourceAttributes::iterator& iter) -> const_iterator&
+        {
             m_cur = iter.m_cur;
             return *this;
         }
@@ -425,6 +432,7 @@ namespace OIC
         {
             return m_keyValuePair;
         }
+
         auto RCSResourceAttributes::const_iterator::operator->() const -> pointer
         {
             return &m_keyValuePair;
@@ -453,32 +461,33 @@ namespace OIC
             return !(*this == rhs);
         }
 
-        auto RCSResourceAttributes::begin() -> iterator
+
+        auto RCSResourceAttributes::begin() noexcept -> iterator
         {
             return iterator{ m_values.begin() };
         }
 
-        auto RCSResourceAttributes::end() -> iterator
+        auto RCSResourceAttributes::end() noexcept -> iterator
         {
             return iterator{ m_values.end() };
         }
 
-        auto RCSResourceAttributes::begin() const -> const_iterator
+        auto RCSResourceAttributes::begin() const noexcept -> const_iterator
         {
             return const_iterator{ m_values.begin() };
         }
 
-        auto RCSResourceAttributes::end() const -> const_iterator
+        auto RCSResourceAttributes::end() const noexcept -> const_iterator
         {
             return const_iterator{ m_values.end() };
         }
 
-        auto RCSResourceAttributes::cbegin() const -> const_iterator
+        auto RCSResourceAttributes::cbegin() const noexcept -> const_iterator
         {
             return const_iterator{ m_values.begin() };
         }
 
-        auto RCSResourceAttributes::cend() const -> const_iterator
+        auto RCSResourceAttributes::cend() const noexcept -> const_iterator
         {
             return const_iterator{ m_values.end() };
         }
@@ -517,7 +526,7 @@ namespace OIC
             }
         }
 
-        void RCSResourceAttributes::clear()
+        void RCSResourceAttributes::clear() noexcept
         {
             return m_values.clear();
         }
@@ -532,12 +541,12 @@ namespace OIC
             return m_values.find(key) != m_values.end();
         }
 
-        bool RCSResourceAttributes::empty() const
+        bool RCSResourceAttributes::empty() const noexcept
         {
             return m_values.empty();
         }
 
-        size_t RCSResourceAttributes::size() const
+        size_t RCSResourceAttributes::size() const noexcept
         {
             return m_values.size();
         }
@@ -600,5 +609,6 @@ namespace OIC
 
             return replacedList;
         }
+
     }
 }
diff --git a/service/resource-encapsulation/src/common/utils/include/AtomicHelper.h b/service/resource-encapsulation/src/common/utils/include/AtomicHelper.h
new file mode 100644 (file)
index 0000000..9a48d37
--- /dev/null
@@ -0,0 +1,306 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef COMMON_UTILS_ATOMICHELPER_H
+#define COMMON_UTILS_ATOMICHELPER_H
+
+#include <atomic>
+#include <boost/version.hpp>
+
+#ifdef __GNUC__
+#define RCS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#endif
+
+#if defined(RCS_GCC_VERSION) && RCS_GCC_VERSION >= 40700
+#define RCS_USE_STD_ATOMIC
+#elif BOOST_VERSION >= 105300
+#include <boost/atomic.hpp>
+#define RCS_USE_BOOST_ATOMIC
+#else
+#define RCS_USE_CUSTOM_ATOMIC
+#endif
+
+namespace OIC
+{
+    namespace Service
+    {
+        namespace Detail
+        {
+
+            class ScopedLock
+            {
+            public:
+                explicit ScopedLock(std::atomic_flag& flag) noexcept :
+                        m_flag(flag)
+                {
+                    while (m_flag.test_and_set(std::memory_order_acquire));
+                }
+
+                ~ScopedLock() noexcept
+                {
+                    m_flag.clear(std::memory_order_release);
+                }
+
+                ScopedLock(const ScopedLock&) = delete;
+                ScopedLock& operator=(const ScopedLock&) = delete;
+
+            private:
+                std::atomic_flag& m_flag;
+            };
+
+            template< typename T >
+            class CustomAtomic
+            {
+            public:
+                CustomAtomic() noexcept :
+                    m_value { },
+                    m_flag { ATOMIC_FLAG_INIT }
+                {
+
+                }
+                ~CustomAtomic() = default;
+
+                CustomAtomic(const CustomAtomic&) = delete;
+
+                CustomAtomic& operator=(const CustomAtomic&) = delete;
+                CustomAtomic& operator=(const CustomAtomic&) volatile = delete;
+
+                explicit CustomAtomic(T v) noexcept :
+                    m_value{ v },
+                    m_flag { ATOMIC_FLAG_INIT }
+                {
+                }
+
+                operator T() const noexcept
+                {
+                    return load();
+                }
+
+                operator T() const volatile noexcept
+                {
+                    return load();
+                }
+
+                T operator=(T v) noexcept
+                {
+                    store(v);
+                    return v;
+                }
+
+                T operator=(T v) volatile noexcept
+                {
+                    store(v);
+                    return v;
+                }
+
+                bool is_lock_free() const noexcept
+                {
+                    return false;
+                }
+
+                bool is_lock_free() const volatile noexcept
+                {
+                    return false;
+                }
+
+                void store(T v, std::memory_order = std::memory_order_seq_cst) noexcept
+                {
+                    ScopedLock guard(m_flag);
+                    memcpy(&m_value, &v, sizeof(T));
+                }
+
+                void store(T v, std::memory_order = std::memory_order_seq_cst) volatile noexcept
+                {
+                    ScopedLock guard(m_flag);
+                    memcpy(&m_value, &v, sizeof(T));
+                }
+
+                T load(std::memory_order = std::memory_order_seq_cst) const noexcept
+                {
+                    ScopedLock guard(m_flag);
+
+                    T v;
+                    memcpy(&v, &m_value, sizeof(T));
+                    return v;
+                }
+
+                T load(std::memory_order = std::memory_order_seq_cst) const volatile noexcept
+                {
+                    ScopedLock guard(m_flag);
+
+                    T v;
+                    memcpy(&v, &m_value, sizeof(T));
+                    return v;
+                }
+
+                T exchange(T v, std::memory_order = std::memory_order_seq_cst) noexcept
+                {
+                    ScopedLock guard(m_flag);
+
+                    T tmp;
+                    memcpy(&tmp, &m_value, sizeof(T));
+
+                    memcpy(&m_value, &v, sizeof(T));
+                    return tmp;
+                }
+
+                T exchange(T v, std::memory_order = std::memory_order_seq_cst) volatile noexcept
+                {
+                    ScopedLock guard(m_flag);
+
+                    T tmp;
+                    memcpy(&tmp, &m_value, sizeof(T));
+
+                    memcpy(&m_value, &v, sizeof(T));
+                    return tmp;
+                }
+
+                bool compare_exchange_weak(T& expected, T desired, std::memory_order success,
+                        std::memory_order failure) volatile noexcept
+                {
+                    return compare_exchange_strong(expected, desired, success, failure);
+                }
+
+                bool compare_exchange_weak(T& expected, T desired,
+                        std::memory_order m = std::memory_order_seq_cst) volatile noexcept
+                {
+                    return compare_exchange_weak(expected, desired, m, m);
+                }
+
+                bool compare_exchange_strong(T& expected, T desired, std::memory_order /*success*/,
+                        std::memory_order /*failure*/) volatile noexcept
+                {
+                    ScopedLock guard(m_flag);
+
+                    if (memcmp(&m_value, &expected, sizeof(T)) == 0) {
+                        memcpy(&m_value, &desired, sizeof(T));
+                        return true;
+                    } else {
+                        memcpy(&expected, &m_value, sizeof(T));
+                        return false;
+                    }
+                }
+
+                bool compare_exchange_strong(T& expected, T desired,
+                        std::memory_order m = std::memory_order_seq_cst) volatile noexcept
+                {
+                    return compare_exchange_strong(expected, desired, m, m);
+                }
+
+            private:
+                T m_value;
+                mutable std::atomic_flag m_flag;
+            };
+
+#if defined(RCS_USE_BOOST_ATOMIC)
+            inline boost::memory_order convertMemoryOrder(std::memory_order m) noexcept
+            {
+                switch(m)
+                {
+                    case std::memory_order_relaxed: return boost::memory_order_relaxed;
+                    case std::memory_order_consume: return boost::memory_order_consume;
+                    case std::memory_order_acquire: return boost::memory_order_acquire;
+                    case std::memory_order_release: return boost::memory_order_release;
+                    case std::memory_order_acq_rel: return boost::memory_order_acq_rel;
+                    case std::memory_order_seq_cst: return boost::memory_order_seq_cst;
+                }
+                return boost::memory_order_seq_cst;
+            }
+#else
+            inline std::memory_order convertMemoryOrder(std::memory_order m) noexcept
+            {
+                return m;
+            }
+#endif
+
+        } // namespace detail
+
+        template < typename T >
+        struct AtomicBase
+        {
+#if defined(RCS_USE_STD_ATOMIC)
+        typedef std::atomic< T > type;
+#elif defined(RCS_USE_BOOST_ATOMIC)
+        typedef boost::atomic< T > type;
+#else
+        typedef typename std::conditional< std::is_integral< T >::value, std::atomic< T >,
+                Detail::CustomAtomic< T > >::type type;
+#endif
+        };
+
+        template< typename T >
+        class AtomicWrapper
+        {
+        public:
+            AtomicWrapper() = default;
+
+            AtomicWrapper(T v) :
+                m_base{ v }
+            {
+            }
+
+            AtomicWrapper(const AtomicWrapper&) = delete;
+            AtomicWrapper& operator=(const AtomicWrapper&) = delete;
+
+            operator T() const noexcept
+            {
+                return load();
+            }
+
+            operator T() const volatile noexcept
+            {
+                return load();
+            }
+
+            T operator=(T v) noexcept
+            {
+                store(v);
+                return v;
+            }
+
+            T operator=(T v) volatile noexcept
+            {
+                store(v);
+                return v;
+            }
+
+            T load(std::memory_order order = std::memory_order_seq_cst) const noexcept
+            {
+                return m_base.load(Detail::convertMemoryOrder(order));
+            }
+
+            T load(std::memory_order order = std::memory_order_seq_cst) const volatile noexcept
+            {
+                return m_base.load(Detail::convertMemoryOrder(order));
+            }
+
+            void store(T v, std::memory_order order = std::memory_order_seq_cst) noexcept
+            {
+                m_base.store(v, Detail::convertMemoryOrder(order));
+            }
+
+        private:
+            typename AtomicBase< T >::type m_base;
+        };
+
+    }
+}
+
+#endif // COMMON_UTILS_ATOMICHELPER_H
index acb54b6..220bc77 100644 (file)
@@ -24,7 +24,7 @@
 #include <functional>
 #include <list>
 #include <string>
-#include <boost/atomic.hpp>
+#include <atomic>
 #include <mutex>
 #include <condition_variable>
 
@@ -64,7 +64,7 @@ namespace OIC
             BROKER_MODE mode;
 
             bool isWithinTime;
-            boost::atomic_long receivedTime;
+            std::atomic_long receivedTime;
             std::mutex cbMutex;
             unsigned int timeoutHandle;
 
index e6ab0ef..bb80de3 100644 (file)
@@ -218,8 +218,7 @@ namespace OIC
             time(&currentTime);
             currentTime += 0L;
 
-            if((receivedTime.load(boost::memory_order_consume) == 0) ||
-              ((receivedTime + BROKER_SAFE_SECOND) > currentTime ))
+            if((receivedTime == 0) || ((receivedTime + BROKER_SAFE_SECOND) > currentTime ))
             {
                 this->isWithinTime = true;
                 return;
index c51b733..7e19d4d 100644 (file)
@@ -57,18 +57,39 @@ namespace OIC
         }
 
         void RCSDiscoveryManager::discoverResource(const RCSAddress& address,
-                const std::string& resourceURI, ResourceDiscoveredCallback cb)
+                ResourceDiscoveredCallback cb)
         {
-            SCOPE_LOG_F(DEBUG, TAG);
+            discoverResourceByType(address, OC_RSRVD_WELL_KNOWN_URI, "", std::move(cb));
+        }
+
+        void RCSDiscoveryManager::discoverResource(const RCSAddress& address,
+                const std::string& relativeURI, ResourceDiscoveredCallback cb)
+        {
+            discoverResourceByType(address, relativeURI, "", std::move(cb));
+        }
+
+        void RCSDiscoveryManager::discoverResourceByType(const RCSAddress& address,
+                const std::string& resourceType,
+                ResourceDiscoveredCallback cb)
+        {
+            discoverResourceByType(address, OC_RSRVD_WELL_KNOWN_URI, resourceType, std::move(cb));
+        }
 
+        void RCSDiscoveryManager::discoverResourceByType(const RCSAddress& address,
+                const std::string& relativeURI, const std::string& resourceType,
+                ResourceDiscoveredCallback cb)
+        {
             if (!cb)
             {
-                OC_LOG(ERROR, TAG, "discoverResource NULL Callback");
-                throw InvalidParameterException{ "discoverResource NULL Callback'" };
+                OC_LOG(ERROR, TAG, "discoverResourceByType NULL Callback");
+                throw InvalidParameterException { "discoverResourceByType NULL Callback'" };
             }
-
-            OIC::Service::discoverResource(address, resourceURI,
+            else
+            {
+                std::string resourceURI = relativeURI + "?rt=" + resourceType;
+                OIC::Service::discoverResource(address, resourceURI,
                     std::bind(findCallback, std::placeholders::_1, std::move(cb)));
+            }
         }
     }
 }
index 6bf95d1..2934a06 100644 (file)
@@ -93,7 +93,7 @@ if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
 
 if target_os == 'android':
     resource_container_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-    resource_container_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
+    resource_container_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
 
 try:
        resource_container_env.AppendUnique(LIBPATH = [os.environ['JAVA_LIB']])
@@ -127,24 +127,24 @@ resource_container_env.InstallTarget([res_container_static,res_container_shared]
 ######################################################################
 # build soft sensor sample bundle
 ######################################################################
+if target_os == 'linux':
+       ss_resource_bundle_env = resource_container_env.Clone()
+       ss_resource_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
+
+       SS_RESOURCE_BUNDLE_DIR = 'examples/SoftSensorSampleBundle/'
+       ss_resource_bundle_env.AppendUnique(CPPPATH = [
+                       SS_RESOURCE_BUNDLE_DIR + 'include',
+                       'include/',
+                       '../../include',
+                       ])
 
-ss_resource_bundle_env = resource_container_env.Clone()
-ss_resource_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
-
-SS_RESOURCE_BUNDLE_DIR = 'examples/SoftSensorSampleBundle/'
-ss_resource_bundle_env.AppendUnique(CPPPATH = [
-               SS_RESOURCE_BUNDLE_DIR + 'include',
-               'include/',
-               '../../include',
-               ])
-
-ss_resource_bundle_env.PrependUnique(LIBS = ['rcs_container'])
-
-ss_resource_bundle_src = [ Glob(SS_RESOURCE_BUNDLE_DIR + 'src/*.cpp')]
+       ss_resource_bundle_env.PrependUnique(LIBS = ['rcs_container'])
 
-SoftSensorBundle = ss_resource_bundle_env.SharedLibrary('SoftSensorBundle', ss_resource_bundle_src)
-ss_resource_bundle_env.InstallTarget(SoftSensorBundle, 'libSoftSensorBundle')
+       ss_resource_bundle_src = [ Glob(SS_RESOURCE_BUNDLE_DIR + 'src/*.cpp')]
 
+       SoftSensorBundle = ss_resource_bundle_env.SharedLibrary('SoftSensorBundle', ss_resource_bundle_src)
+       ss_resource_bundle_env.InstallTarget(SoftSensorBundle, 'libSoftSensorBundle')
+       
 ######################################################################
 # build hue sample bundle
 ######################################################################
@@ -182,7 +182,8 @@ else:
 ######################################################################
 # build resource container unit tests
 ######################################################################
-SConscript('unittests/SConscript')
+if target_os == 'linux':
+       SConscript('unittests/SConscript')
 
 ######################################################################
 # Build Container Sample
index 25164cf..f4dd364 100644 (file)
@@ -252,7 +252,7 @@ namespace OIC
             void *bundleHandle = m_bundles[id]->getBundleHandle();
             info_logger() << "Unregister bundle: " << m_bundles[id]->getID() << ", "
                           << m_bundles[id]->getID() << endl;
-            char *error;
+            const char *error;
             dlclose(bundleHandle);
             if ((error = dlerror()) != NULL)
             {
@@ -551,7 +551,7 @@ namespace OIC
 
         void ResourceContainerImpl::registerSoBundle(RCSBundleInfo *bundleInfo)
         {
-            char *error;
+            const char *error;
 
             activator_t *bundleActivator = NULL;
             deactivator_t *bundleDeactivator = NULL;
index 98e0cb7..1ec21b7 100644 (file)
@@ -42,6 +42,7 @@ release = env.get('RELEASE')
 ######################################################################
 server_builder_env.AppendUnique(CPPPATH = [
     '../common/primitiveResource/include',
+    '../common/utils/include',
     '../../include',
     ])
 
@@ -59,7 +60,7 @@ if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
 
 if target_os == 'android':
     server_builder_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-    server_builder_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
+    server_builder_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
 
 server_builder_env.AppendUnique(LIBS = ['dl', 'oc', 'rcs_common'])
 
@@ -83,37 +84,36 @@ server_builder_env.InstallTarget([server_builder_static, server_builder_shared],
 ######################################################################
 # Build Test
 ######################################################################
-server_builder_test_env = server_builder_env.Clone();
-
-server_builder_test_env.AppendUnique(CPPPATH = [
-    env.get('SRC_DIR')+'/extlibs/hippomocks-master',
-    gtest_dir + '/include',
-    '../common/utils/include'
-    ])
-
-gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
-gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
-
-server_builder_test_env.PrependUnique(LIBS = [
-    'rcs_server',
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
-    'coap',
-    gtest,
-    gtest_main,
-    'pthread',
-    ])
-
-server_builder_test_src = env.Glob('unittests/*.cpp')
-
-server_builder_test = server_builder_test_env.Program('rcs_server_test', server_builder_test_src)
-Alias("rcs_server_test", server_builder_test)
-env.AppendTarget('rcs_server_test')
-
-if env.get('TEST') == '1':
-    target_os = env.get('TARGET_OS')
-    if target_os == 'linux':
-        from tools.scons.RunTest import *
-        run_test(server_builder_test_env, '',
-                'service/resource-encapsulation/src/serverBuilder/rcs_server_test')
\ No newline at end of file
+if target_os == 'linux':
+       server_builder_test_env = server_builder_env.Clone();
+
+       server_builder_test_env.AppendUnique(CPPPATH = [
+               env.get('SRC_DIR')+'/extlibs/hippomocks-master',
+               gtest_dir + '/include',
+               '../common/utils/include'
+               ])
+
+       gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
+       gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
+
+       server_builder_test_env.PrependUnique(LIBS = [
+               'rcs_server',
+               'octbstack',
+               'oc_logger',
+               'connectivity_abstraction',
+               'coap',
+               gtest,
+               gtest_main,
+               'pthread',
+               ])
+
+       server_builder_test_src = env.Glob('unittests/*.cpp')
+
+       server_builder_test = server_builder_test_env.Program('rcs_server_test', server_builder_test_src)
+       Alias("rcs_server_test", server_builder_test)
+       env.AppendTarget('rcs_server_test')
+
+       if env.get('TEST') == '1':
+               from tools.scons.RunTest import *
+               run_test(server_builder_test_env, '',
+                       'service/resource-encapsulation/src/serverBuilder/rcs_server_test')
index 1d3a0cb..ffbf522 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <RequestHandler.h>
 #include <AssertUtils.h>
+#include <AtomicHelper.h>
 #include <ResourceAttributesConverter.h>
 
 #include <logger.h>
@@ -199,6 +200,7 @@ namespace OIC
                 m_mutex{ },
                 m_mutexKeyAttributeUpdate{ }
         {
+            m_lockOwner.reset(new AtomicThreadId);
         }
 
         RCSResourceObject::~RCSResourceObject()
@@ -306,12 +308,22 @@ namespace OIC
 
         void RCSResourceObject::expectOwnLock() const
         {
-            if (m_lockOwner != std::this_thread::get_id())
+            if (getLockOwner() != std::this_thread::get_id())
             {
                 throw NoLockException{ "Must acquire the lock first using LockGuard." };
             }
         }
 
+        std::thread::id RCSResourceObject::getLockOwner() const noexcept
+        {
+            return *m_lockOwner;
+        }
+
+        void RCSResourceObject::setLockOwner(std::thread::id&& id) const noexcept
+        {
+            m_lockOwner->store(std::move(id));
+        }
+
         bool RCSResourceObject::isObservable() const
         {
             return ::hasProperty(m_properties, OC_OBSERVABLE);
@@ -480,14 +492,14 @@ namespace OIC
             AttrKeyValuePairs replaced = requestHandler->applyAcceptanceMethod(
                     response.getAcceptanceMethod(), *this, attrs);
 
-            for (const auto& it : replaced)
+            for (const auto& attrKeyValPair : replaced)
             {
                 std::lock_guard<std::mutex> lock(m_mutexKeyAttributeUpdate);
 
-                auto keyAttribute = m_keyAttributesUpdatedListeners.find(it.first);
-                if(keyAttribute != m_keyAttributesUpdatedListeners.end())
+                auto keyAttrListener = m_keyAttributesUpdatedListeners.find(attrKeyValPair.first);
+                if(keyAttrListener != m_keyAttributesUpdatedListeners.end())
                 {
-                    keyAttribute-> second(it.second, attrs[it.first]);
+                    keyAttrListener-> second(attrKeyValPair.second, attrs[attrKeyValPair.first]);
                 }
             }
 
@@ -496,10 +508,8 @@ namespace OIC
         }
 
         OCEntityHandlerResult RCSResourceObject::handleObserve(
-                std::shared_ptr< OC::OCResourceRequest > request)
+                std::shared_ptr< OC::OCResourceRequest >)
         {
-            assert(request != nullptr);
-
             if (!isObservable())
             {
                 return OC_EH_ERROR;
@@ -549,17 +559,17 @@ namespace OIC
 
             if (m_isOwningLock)
             {
-                m_resourceObject.m_lockOwner = std::thread::id{ };
+                m_resourceObject.setLockOwner(std::thread::id{ });
                 m_resourceObject.m_mutex.unlock();
             }
         }
 
         void RCSResourceObject::LockGuard::init()
         {
-            if (m_resourceObject.m_lockOwner != std::this_thread::get_id())
+            if (m_resourceObject.getLockOwner() != std::this_thread::get_id())
             {
                 m_resourceObject.m_mutex.lock();
-                m_resourceObject.m_lockOwner = std::this_thread::get_id();
+                m_resourceObject.setLockOwner(std::this_thread::get_id());
                 m_isOwningLock = true;
             }
             m_autoNotifyFunc = ::createAutoNotifyInvoker(&RCSResourceObject::autoNotify,
@@ -571,10 +581,10 @@ namespace OIC
                 m_isOwningLock{ false },
                 m_resourceObject(resourceObject)
         {
-            if (resourceObject.m_lockOwner != std::this_thread::get_id())
+            if (m_resourceObject.getLockOwner() != std::this_thread::get_id())
             {
                 m_resourceObject.m_mutex.lock();
-                m_resourceObject.m_lockOwner = std::this_thread::get_id();
+                m_resourceObject.setLockOwner(std::this_thread::get_id());
                 m_isOwningLock = true;
             }
         }
@@ -583,7 +593,7 @@ namespace OIC
         {
             if (m_isOwningLock)
             {
-                m_resourceObject.m_lockOwner = std::thread::id{ };
+                m_resourceObject.setLockOwner(std::thread::id{ });
                 m_resourceObject.m_mutex.unlock();
             }
         }
@@ -592,5 +602,6 @@ namespace OIC
         {
             return m_isOwningLock;
         }
+
     }
 }
index 33cfaa6..435859d 100644 (file)
@@ -287,7 +287,8 @@ public:
     {
         auto request = make_shared<OCResourceRequest>();
 
-        OCEntityHandlerRequest ocEntityHandlerRequest { 0 };
+        OCEntityHandlerRequest ocEntityHandlerRequest;
+        memset(&ocEntityHandlerRequest, 0, sizeof(OCEntityHandlerRequest));
         OC::MessageContainer mc;
 
         mc.addRepresentation(ocRep);
index c51d1a5..08b58cd 100644 (file)
@@ -102,10 +102,11 @@ private:
     {
         while (checkObject())
         {
-            RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(),
-                    "/oic/res?rt=Resource.Hosting", std::bind(resourceDiscovered, this, finished,
-                            std::placeholders::_1));
-
+            const std::string uri  = "/oic/res";
+            const std::string type = "Resource.Hosting";
+            RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::multicast(),
+                     uri, type, std::bind(resourceDiscovered, this, finished,
+                           std::placeholders::_1));
             Wait(1000);
         }
     }
index 2679850..2171753 100644 (file)
@@ -37,9 +37,9 @@ import java.util.List;
 public class DataReader
 {
 
-        private int pDataReaderInstance;
+        private long pDataReaderInstance;
 
-        public DataReader(int dataReaderInstance)
+        private DataReader(long dataReaderInstance)
         {
             pDataReaderInstance = dataReaderInstance;
         }
index c276f83..fc408da 100644 (file)
@@ -36,9 +36,9 @@ package org.iotivity.service.ssm;
 public class ModelData
 {
 
-        private int pIModelDataInstance;
+        private long pIModelDataInstance;
 
-        public ModelData(int iModelDataInstance)
+        private ModelData(long iModelDataInstance)
         {
             pIModelDataInstance = iModelDataInstance;
         }
@@ -97,4 +97,4 @@ public class ModelData
             return CoreController.getInstance().getPropertyValue(
                        pIModelDataInstance, propertyIndex);
         }
-}
\ No newline at end of file
+}
index 348e51d..8acc1a9 100644 (file)
@@ -36,9 +36,9 @@ package org.iotivity.service.ssm;
 */
 public class QueryEngine
 {
-        private int pQueryEngineInstance;
+        private long pQueryEngineInstance;
 
-        public QueryEngine(int queryEngineInstance)
+        private QueryEngine(long queryEngineInstance)
         {
             pQueryEngineInstance = queryEngineInstance;
         }
@@ -50,7 +50,7 @@ public class QueryEngine
          * @return int - Instance of the query engine object, set on object's creation
          * 
          */
-        public int getQueryEngineInstance()
+        public long getQueryEngineInstance()
         {
             return pQueryEngineInstance;
         }
@@ -100,4 +100,4 @@ public class QueryEngine
             CoreController.getInstance().killContextQuery(pQueryEngineInstance,
             cqid);
         }
-}
\ No newline at end of file
+}
index f088ed2..05ec0d6 100644 (file)
@@ -109,14 +109,18 @@ class QueryEngineEventReceiver
                 env->GetMethodID(g_ClassQueryEngineEvent, "onQueryEngineEvent",
                                  "(ILorg/iotivity/service/ssm/DataReader;)V");
 
-            jmethodID cid_DataReader = env->GetMethodID(g_ClassDataReader, "<init>", "(I)V");
+            jmethodID cid_DataReader = env->GetMethodID(g_ClassDataReader, "<init>", "(J)V");
 
             if (cid_DataReader == NULL)
                 return SSM_E_FAIL;
 
-            env->CallVoidMethod(m_objQueryEngineEvent, midQueryEngineEvent,
+            env->CallVoidMethod(m_objQueryEngineEvent,
+                                midQueryEngineEvent,
                                 (jint)cqid,
-                                env->NewObject(g_ClassDataReader, cid_DataReader, (jint)pResult));
+                                env->NewObject(
+                                    g_ClassDataReader,
+                                    cid_DataReader,
+                                    reinterpret_cast<jlong>(pResult)));
 
             DETACH_CURRENT_THREAD(g_JVM);
 
@@ -240,12 +244,12 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_createQue
         return NULL;
     }
 
-    jmethodID cid_QueryEngine = env->GetMethodID(g_ClassQueryEngine, "<init>", "(I)V");
+    jmethodID cid_QueryEngine = env->GetMethodID(g_ClassQueryEngine, "<init>", "(J)V");
 
     if (cid_QueryEngine == NULL)
         return NULL;
 
-    return env->NewObject(g_ClassQueryEngine, cid_QueryEngine, (jint)pQueryEngine);
+    return env->NewObject(g_ClassQueryEngine, cid_QueryEngine, reinterpret_cast<jlong>(pQueryEngine));
 }
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_releaseQueryEngine
@@ -265,7 +269,7 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_releaseQuery
 }
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_executeContextQuery
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery)
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jstring jstrContextQuery)
 {
     int                 cqid = -1;
     if (jstrContextQuery == NULL)
@@ -289,7 +293,7 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_executeConte
 }
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerQueryEvent
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent)
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jobject queryEngineEvent)
 {
     IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
 
@@ -304,7 +308,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerQuer
 }
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_killContextQuery
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid)
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jint cqid)
 {
     IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
 
@@ -315,7 +319,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_killContextQ
 }
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getDataId
-(JNIEnv *env, jclass clz, jint pDataReaderInstance)
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance)
 {
     IModelData *pDataReader = (IModelData *)pDataReaderInstance;
 
@@ -323,7 +327,7 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getDataId
 }
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyCount
-(JNIEnv *env, jclass clz, jint pIModelDataInstance )
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
@@ -331,7 +335,7 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyC
 }
 
 JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyName
-(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
@@ -339,7 +343,7 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getProper
 }
 
 JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyValue
-(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex )
 {
     IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
@@ -347,7 +351,7 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getProper
 }
 
 JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getAffectedModels
-(JNIEnv *env, jclass clz, jint pDataReaderInstance)
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance)
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
     std::vector<std::string>    affectedModels;
@@ -372,7 +376,7 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getAffect
 }
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getModelDataCount
-(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName)
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance, jstring jstrModelName)
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
     int modelCount = 0;
@@ -389,7 +393,7 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getModelData
 }
 //return IModelData
 JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getModelData
-(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex )
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance, jstring jstrModelName, jint jintDataIndex )
 {
     IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
     IModelData *pModelData = NULL;
@@ -401,12 +405,12 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getModelD
         return NULL;
     }
 
-    jmethodID cid_ModelData = env->GetMethodID(g_ClassModelData, "<init>", "(I)V");
+    jmethodID cid_ModelData = env->GetMethodID(g_ClassModelData, "<init>", "(J)V");
 
     if (cid_ModelData == NULL)
         return NULL;
 
-    return env->NewObject(g_ClassModelData, cid_ModelData, (jint)pModelData);
+    return env->NewObject(g_ClassModelData, cid_ModelData, reinterpret_cast<jlong>(pModelData));
 }
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerReportReceiver
index d950bce..1d4a707 100644 (file)
@@ -45,34 +45,34 @@ JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_releaseQuery
 (JNIEnv *env, jclass clz, jobject queryEngine);
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_executeContextQuery
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery);
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jstring jstrContextQuery);
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerQueryEvent
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent);
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jobject queryEngineEvent);
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_killContextQuery
-(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid);
+(JNIEnv *env, jclass clz, jlong pQueryEngineInstance, jint cqid);
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getDataId
-(JNIEnv *env, jclass clz, jint pDataReaderInstance);
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance);
 
 JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getAffectedModels
-(JNIEnv *env, jclass clz, jint pDataReaderInstance);
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance);
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getModelDataCount
-(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName);
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance, jstring jstrModelName);
 
 JNIEXPORT jobject JNICALL Java_org_iotivity_service_ssm_CoreController_getModelData
-(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex );
+(JNIEnv *env, jclass clz, jlong pDataReaderInstance, jstring jstrModelName, jint jintDataIndex );
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyCount
-(JNIEnv *env, jclass clz, jint pIModelDataInstance );
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance );
 
 JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyName
-(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex );
 
 JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyValue
-(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
+(JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex );
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerReportReceiver
 (JNIEnv *env, jclass clz, jobject reportReceiver );
@@ -81,4 +81,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_service_ssm_CoreController_registerRepo
 }
 #endif
 
-#endif
\ No newline at end of file
+#endif
index 6ddeebc..6fda850 100644 (file)
@@ -78,11 +78,11 @@ if target_os == 'android':
        if target_arch == 'armeabi-v7a-hard':
                target_arch = 'armeabi-v7a'
 
-       if target_arch not in ['x86', 'armeabi', 'armeabi-v7a']:
+       if target_arch not in ['x86', 'x86_64','armeabi', 'armeabi-v7a']:
                if not env.GetOption('help') and not env.GetOption('clean'):
                        print '''
 *********************************** Warning ***********************************
-* current only x86, armeabi, armeabi-v7a libraries are provided!              *
+* current only x86, x86_64, armeabi, armeabi-v7a libraries are provided!              *
 *******************************************************************************
 '''
        else: