Merge master to cloud-interface branch
[platform/upstream/iotivity.git] / resource / csdk / connectivity / api / cacommon.h
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;