Add translation from rtnetlink scope to CAPI link scope value 39/202139/2 accepted/tizen/unified/20190327.025229 submit/tizen/20190326.081614
authorYu <jiung.yu@samsung.com>
Mon, 25 Mar 2019 07:17:55 +0000 (16:17 +0900)
committerYu <jiung.yu@samsung.com>
Mon, 25 Mar 2019 07:26:53 +0000 (16:26 +0900)
Change-Id: I09df3a7fdf7768e95a81ca19b9727f3f19e67458
Signed-off-by: Yu Jiung <jiung.yu@samsung.com>
packaging/inm-manager.spec
src/inm-rtnl.c

index 1ec38a42537f7f4d782fb658b546e0e221c72fc8..d6aaf2e7f4a8946d343ac258d0162c2a4d86b93a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       inm-manager
 Summary:    INM(Intelligent Network Monitoring) daemon
-Version:    0.0.16
+Version:    0.0.17
 Release:    1
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index 503752ca229ee0f585d5526a212758f1ef831ed7..0c2d0ff0da3ec421996e9d7714f1535aaca82910 100644 (file)
@@ -28,6 +28,7 @@
 #include <inttypes.h>
 
 #include <net/if.h>
+#include <linux/rtnetlink.h>
 #include <netlink/addr.h>
 #include <netlink/route/addr.h>
 #include <netlink/route/link.h>
@@ -44,6 +45,14 @@ static inm_util_nl_data_s nl_data_arr[INM_UTIL_RTNL_TYPE_MAX];
 static gboolean is_initialized = FALSE;
 static GList *g_list_links;
 
+typedef enum {
+       INM_RTNL_LINK_SCOPE_NOWHERE,
+       INM_RTNL_LINK_SCOPE_HOST,
+       INM_RTNL_LINK_SCOPE_LINK,
+       INM_RTNL_LINK_SCOPE_SITE,
+       INM_RTNL_LINK_SCOPE_UNIVERSE,
+} inm_link_scope_e;
+
 typedef struct {
        int if_idx;
        int family;
@@ -416,6 +425,9 @@ static inline void __rtnl_addr_log(struct rtnl_addr *p_rtnl_addr)
        g_string_append_printf(rtnl_addr_gs,
                        "<Rtnl addr address:%s>",
                        nl_addr2str(p_nl_addr, buf, sizeof(buf)));
+       g_string_append_printf(rtnl_addr_gs,
+                       "<Rtnl addr scope:%d>",
+                       rtnl_addr_get_scope(p_rtnl_addr));
 
        log_str = g_string_free(rtnl_addr_gs, FALSE);
        if (log_str) {
@@ -1162,11 +1174,38 @@ static GVariant *__inm_rtnl_addr_get_prefix_length(inm_rtnl_addr_s *p_addr)
        return ret;
 }
 
+static inline int __translate_rt_to_link_scope(int scope)
+{
+       int link_scope;
+
+       switch (scope) {
+       case RT_SCOPE_UNIVERSE:
+               link_scope = INM_RTNL_LINK_SCOPE_UNIVERSE;
+               break;
+       case RT_SCOPE_SITE:
+               link_scope = INM_RTNL_LINK_SCOPE_SITE;
+               break;
+       case RT_SCOPE_LINK:
+               link_scope = INM_RTNL_LINK_SCOPE_LINK;
+               break;
+       case RT_SCOPE_HOST:
+               link_scope = INM_RTNL_LINK_SCOPE_HOST;
+               break;
+       case RT_SCOPE_NOWHERE:
+               link_scope = INM_RTNL_LINK_SCOPE_NOWHERE;
+               break;
+       default:
+               link_scope = INM_RTNL_LINK_SCOPE_NOWHERE;
+               break;
+       }
+       return link_scope;
+}
+
 static GVariant *__inm_rtnl_addr_get_scope(inm_rtnl_addr_s *p_addr)
 {
        GVariant *ret = NULL;
 
-       ret = g_variant_new_int32(p_addr->scope);
+       ret = g_variant_new_int32(__translate_rt_to_link_scope(p_addr->scope));
 
        return ret;
 }