Update snapshot(2017-12-06)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / ip_adapter / tizen / caipnwmonitor.c
index 7d5d295..079ecd5 100644 (file)
@@ -42,7 +42,7 @@
 #include <coap/utlist.h>
 
 #define TAG "OIC_CA_IP_MONITOR"
-
+#define MAX_INTERFACE_INFO_LENGTH (1024)
 #define NETLINK_MESSAGE_LENGTH  (4096)
 #define IFC_LABEL_LOOP          "lo"
 #define IFC_ADDR_LOOP_IPV4      "127.0.0.1"
@@ -167,20 +167,26 @@ u_arraylist_t *CAFindInterfaceChange()
         {
             continue;
         }
+
         struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
         if (!ifi)
         {
             continue;
         }
 
-        int ifiIndex = ifi->ifi_index;
+        if (RTM_DELADDR == nh->nlmsg_type)
+        {
+            CloseMulticastSocket();
+        }
 
+        int ifiIndex = ifi->ifi_index;
         iflist = CAIPGetInterfaceInformation(ifiIndex);
         if (!iflist)
         {
             OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
             return NULL;
         }
+        CreateMulticastSocket();
     }
     return iflist;
 }
@@ -380,6 +386,8 @@ static CAInterface_t *CANewInterfaceItem(int index, char *name, int family,
 
 void CAIPConnectionStateChangedCb(connection_type_e type, void* userData)
 {
+    (void)userData;
+
     switch (type)
     {
         case CONNECTION_TYPE_DISCONNECTED: