[vala] libnl-2.0: bind attributes, message headers, callbacks
- From: Michael Lauer <mlauer src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] libnl-2.0: bind attributes, message headers, callbacks
- Date: Sun, 3 Jan 2010 11:53:08 +0000 (UTC)
commit 6a3139ecbd978902ee914a440c6573f8898f60df
Author: Michael 'Mickey' Lauer <mickey vanille-media de>
Date: Sun Jan 3 12:52:34 2010 +0100
libnl-2.0: bind attributes, message headers, callbacks
vapi/libnl-2.0.vapi | 189 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 175 insertions(+), 14 deletions(-)
---
diff --git a/vapi/libnl-2.0.vapi b/vapi/libnl-2.0.vapi
index 0537240..e1b466f 100644
--- a/vapi/libnl-2.0.vapi
+++ b/vapi/libnl-2.0.vapi
@@ -1,6 +1,7 @@
-/* libnl-2.0.vapi
+/**
+ * libnl-2.0.vapi
*
- * Copyright (C) 2009 Michael 'Mickey' Lauer <mlauer vanille-media de>
+ * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer vanille-media de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,11 +22,17 @@
[CCode (lower_case_cprefix = "nl_", cheader_filename = "netlink/netlink.h")]
namespace Netlink {
+ [CCode (cname = "nl_geterror", cheader_filename = "netlink/netlink.h")]
+ public static unowned string strerror( int number );
+
[CCode (instance_pos = -1)]
- public delegate void Callback (Object obj);
+ public delegate void CallbackFunc (Object obj);
+
+ [CCode (cname = "nl_recmsg_msg_cb_t", cheader_filename = "netlink/netlink.h", instance_pos = -1)]
+ public delegate int MessageCallbackFunc (Message msg);
[Compact]
- [CCode (cprefix = "nl_addr_", cname = "struct nl_addr", free_function = "", cheader_filename = "netlink/addr.h")]
+ [CCode (cprefix = "nl_addr_", cname = "struct nl_addr", free_function = "", cheader_filename = "netlink/netlink.h")]
public class Address : Object {
[CCode (cname = "nl_addr_alloc")]
public Address();
@@ -60,8 +67,41 @@ namespace Netlink {
}
}
+ [CCode (cprefix = "nla_", cname = "struct nlattr", free_function = "", cheader_filename = "netlink/netlink.h")]
+ public struct Attribute {
+ }
+
+ [Compact]
+ [CCode (cname = "struct nla_policy", free_function = "")]
+ public class AttributePolicy {
+ [CCode (cname = "")]
+ public AttributePolicy( AttributeType type = AttributeType.UNSPEC, uint16 minlen = 0, uint16 maxlen = 65535 )
+ {
+ this.type = type;
+ this.minlen = minlen;
+ this.maxlen = maxlen;
+ }
+ public uint16 type;
+ public uint16 minlen;
+ public uint16 maxlen;
+ }
+
+ [CCode (cprefix = "NLA_", cname = "int", cheader_filename = "netlink/attr.h")]
+ public enum AttributeType {
+ UNSPEC, /**< Unspecified type, binary data chunk */
+ U8, /**< 8 bit integer */
+ U16, /**< 16 bit integer */
+ U32, /**< 32 bit integer */
+ U64, /**< 64 bit integer */
+ STRING, /**< NUL terminated character string */
+ FLAG, /**< Flag */
+ MSECS, /**< Micro seconds (64bit) */
+ NESTED, /**< Nested attributes */
+ TYPE_MAX
+ }
+
[Compact]
- [CCode (cprefix = "rtnl_addr_", cname = "struct rtnl_addr", free_function = "", cheader_filename = "netlink/route/addr.h")]
+ [CCode (cprefix = "rtnl_addr_", cname = "struct rtnl_addr", free_function = "", cheader_filename = "netlink/route/netlink.h")]
public class RouteAddress : Address {
[CCode (cname = "rtnl_addr_alloc")]
public RouteAddress();
@@ -76,29 +116,106 @@ namespace Netlink {
}
[Compact]
- [CCode (cprefix = "nl_cache_", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/cache.h")]
+ [CCode (cprefix = "nl_cache_", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/netlink.h")]
public class Cache {
public static int alloc_name (string name, out Cache c);
- public void @foreach (Callback cb);
- public void foreach_filter (Object obj, Callback cb);
+ public void @foreach (CallbackFunc cb);
+ public void foreach_filter (Object obj, CallbackFunc cb);
}
[Compact]
- [CCode (cprefix = "nl_link_cache_", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/cache.h")]
+ [CCode (cprefix = "nl_cb_", cname = "struct nl_cb", free_function = "", cheader_filename = "netlink/netlink.h")]
+ public class Callback {
+ [CCode (cname = "nl_cb_alloc")]
+ public Callback (CallbackKind kind = CallbackKind.DEFAULT);
+ [CCode (cname = "nl_cb_set")]
+ public int @set (CallbackType type, CallbackKind kind, MessageCallbackFunc func);
+ [CCode (cname = "nl_cb_set_all")]
+ public int set_all (CallbackKind kind, MessageCallbackFunc func);
+ }
+
+ [CCode (cname = "enum nl_cb_action", cprefix = "NL_", cheader_filename = "netlink/netlink.h")]
+ public enum CallbackAction {
+ OK, // Proceed with whatever comes next.
+ SKIP, // Skip this message.
+ STOP, // Stop parsing altogether and discard remaining messages.
+ }
+
+ [CCode (cname = "enum nl_cb_kind", cprefix = "NL_CB_", cheader_filename = "netlink/netlink.h")]
+ public enum CallbackKind {
+ DEFAULT, // Default handlers (quiet).
+ VERBOSE, // Verbose default handlers (error messages printed).
+ DEBUG, // Debug handlers for debugging.
+ CUSTOM, // Customized handler specified by the user.
+ }
+
+ [CCode (cname = "enum nl_cb_type", cprefix = "NL_CB_", cheader_filename = "netlink/netlink.h")]
+ public enum CallbackType {
+ VALID, // Message is valid.
+ FINISH, // Last message in a series of multi part messages received.
+ OVERRUN, // Report received that data was lost.
+ SKIPPED, // Message wants to be skipped.
+ ACK, // Message is an acknowledge.
+ MSG_IN, // Called for every message received.
+ MSG_OUT, // Called for every message sent out except for nl_sendto().
+ INVALID, // Message is malformed and invalid.
+ SEQ_CHECK, // Called instead of internal sequence number checking.
+ SEND_ACK, // Sending of an acknowledge message has been requested.
+ }
+
+ [Compact]
+ [CCode (cprefix = "nl_link_cache_", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/netlink.h")]
public class LinkCache : Cache {
[CCode (cname = "rtnl_link_name2i")]
public int name2i (string name);
}
[Compact]
- [CCode (cprefix = "nl_addr_cache", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/cache.h")]
+ [CCode (cprefix = "nl_addr_cache", cname = "struct nl_cache", free_function = "nl_cache_free", cheader_filename = "netlink/netlink.h")]
public class AddrCache : Cache {
}
[Compact]
- [CCode (cname = "struct nl_msg", free_function = "nl_msg_free", cheader_filename = "netlink/msg.h")]
+ [CCode (cprefix = "nl_msg_", cname = "struct nl_msg", free_function = "nl_msg_free", cheader_filename = "netlink/netlink.h")]
public class Message {
+ public void dump (Posix.FILE file);
+ public int parse (CallbackFunc func);
+ [CCode (cname = "nlmsg_hdr")]
+ public MessageHeader header ();
+ }
+
+ [Compact]
+ [CCode (cprefix = "nlmsg_", cname = "struct nlmsghdr", free_function = "", cheader_filename = "netlink/netlink.h")]
+ public class MessageHeader {
+ // field access
+ public uint32 nlmsg_len;
+ public uint16 nlmsg_type;
+ public uint16 nlmsg_flags;
+ public uint32 nlmsg_seq;
+ public uint32 nlmsg_pid;
+
+ // size calculations
+ public static int msg_size (int payload);
+ public static int total_size (int payload);
+ public static int padlen (int payload);
+
+ // payload access
+ public void* data ();
+ public int len ();
+ public void* tail ();
+
+ // attribute access
+ public Attribute attrdata (int hdrlen);
+ public int attrlen (int hdrlen);
+
+ // message parsing
+ public bool valid_hdr (int hdrlen);
+ public bool ok (int remaining);
+ public MessageHeader next (out int remaining);
+ public int parse (int hdrlen, [CCode (array_length = "false")] out Attribute[] attributes, AttributeType maxtype, AttributePolicy policy);
+ public Attribute find_attr (int hdrlen, AttributeType type);
+ public int validate (int hdrlen, AttributeType maxtype, AttributePolicy policy);
}
[Compact]
@@ -108,12 +225,56 @@ namespace Netlink {
public Socket();
[CCode (cname = "rtnl_link_alloc_cache")]
- public int link_alloc_cache (out LinkCache c);
+ public int link_alloc_cache (out LinkCache c);
[CCode (cname = "rtnl_addr_alloc_cache")]
- public int addr_alloc_cache (out AddrCache c);
+ public int addr_alloc_cache (out AddrCache c);
+ // connection management
+ [CCode (cname = "nl_close")]
+ public int close ();
[CCode (cname = "nl_connect")]
- public int connect (int family);
+ public int connect (int family);
+
+ // group management
+ public int add_memberships (int group, ...);
+ public int add_membership (int group);
+ public int drop_memberships (int group, ...);
+ public int drop_membership (int group);
+ public uint32 get_peer_port ();
+ public void set_peer_port (uint32 port);
+
+ // callback management
+ public Callback get_cb ();
+ public void set_cb (Callback cb);
+ public int modify_cb (CallbackType type, CallbackKind kind, MessageCallbackFunc callback);
+
+ // configuration
+ public int set_buffer_size (int rxbuf, int txbuf);
+ public int set_passcred (bool on);
+ public int recv_pktinfo (bool on);
+
+ public void disable_seq_check ();
+ public uint use_seq ();
+ public void disable_auto_ack ();
+ public void enable_auto_ack ();
+
+ public int get_fd ();
+ public int set_nonblocking ();
+ public void enable_msg_peek ();
+ public void disable_msg_peek ();
+
+ // receiving messages
+ [CCode (cname = "nl_recv")]
+ public int recv (out Linux.Netlink.SockAddrNl addr, out char[] buf, out Linux.Socket.ucred cred);
+
+ [CCode (cname = "nl_recvmsgs")]
+ public int recvmsgs (Callback cb);
+
+ [CCode (cname = "nl_recvmsgs_default")]
+ public int recvmsgs_default ();
+
+ [CCode (cname = "nl_wait_for_ack")]
+ public int wait_for_ack ();
}
[Compact]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]