]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libnl-3.0.vapi: extend VAPI
authorMaciej Borzecki <maciej.borzecki@open-rnd.pl>
Tue, 8 Mar 2016 10:58:08 +0000 (11:58 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 7 Apr 2016 18:50:04 +0000 (20:50 +0200)
The patch extends VAPI of libnl-3.0 with cache
manager (nl_cache_mngr_*), additional methods of LinkCache and a helper
CachedLink type. The CachedLink type is a wrapper for the Link object,
however since the object is obtained from cache, rtnl_link_put() must be
used a free function.

Signed-off-by: Maciej Borzecki <maciek.borzecki@gmail.com>
Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
Fixes bug 763303

vapi/libnl-3.0.vapi

index 6998b2d48b10e156c756d7b402575536a2294b85..b82df3912b03da665ce4f876ab2837ccb3dfaced 100644 (file)
@@ -153,6 +153,34 @@ namespace Netlink {
         public void  mngt_unprovide();
     }
 
+    [CCode (cname = "int", cprefix = "NL_ACT_", has_type_id = false, cheader_filename = "netlink/cache.h")]
+    public enum CacheAction {
+        NEW,
+        DEL,
+        GET,
+        SET,
+        CHANGE,
+    }
+
+    [CCode (cname = "change_func_t", cheader_filename = "netlink/cache.h", instance_pos = -1)]
+    public delegate void ChangeCallbackFunc (Cache cache, Object obj, CacheAction act);
+
+    [Compact]
+    [CCode (cprefix = "nl_cache_mngr_", cname = "struct nl_cache_mngr", free_function = "nl_cache_mngr_free", cheader_filename = "netlink/cache.h")]
+    public class CacheManager {
+        public static int alloc (Socket? sk, int protocol, int flags, out CacheManager c);
+
+        public int add_cache(Cache cache, ChangeCallbackFunc cb);
+        public int add(string name, ChangeCallbackFunc cb, out unowned Cache cache);
+
+        public int get_fd();
+        public int poll(int timeout);
+
+        public int data_ready();
+        public void info(DumpParams params);
+    }
+
+
     [Compact]
     [CCode (cprefix = "nl_cb_", cname = "struct nl_cb", free_function = "", cheader_filename = "netlink/netlink.h")]
     public class Callback {
@@ -201,6 +229,10 @@ namespace Netlink {
         public int name2i (string name);
         [CCode (cname = "rtnl_link_i2name")]
         public unowned string i2name( int idx, char[] buffer );
+        [CCode (cname = "rtnl_link_get")]
+        public CachedLink? get(int idx);
+        [CCode (cname = "rtnl_link_get_by_name")]
+        public CachedLink? get_by_name(string idx);
     }
 
     [Compact]
@@ -359,6 +391,13 @@ namespace Netlink {
         public unowned string? get_qdisc();
     }
 
+    [Compact]
+    [CCode (cprefix = "rtnl_link_", cname = "struct rtnl_link", free_function = "rtnl_link_put", cheader_filename = "netlink/route/link.h")]
+    public class CachedLink : Link
+    {
+    }
+
+
     [Compact]
     [CCode (cprefix = "rtnl_route_", cname = "struct rtnl_route", cheader_filename = "netlink/route/route.h")]
     public class Route