[PATCH 8/8] python: add send and receive functions to Socket class

Arend van Spriel arend at broadcom.com
Thu Sep 5 08:11:32 EDT 2013


Adding class methods send_auto_complete() and recvmsgs()
that call their swig capi equivalent function.

Signed-off-by: Arend van Spriel <arend at broadcom.com>
---
 python/netlink/core.py |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/python/netlink/core.py b/python/netlink/core.py
index 886ae2a..ee40b0d 100644
--- a/python/netlink/core.py
+++ b/python/netlink/core.py
@@ -241,6 +241,21 @@ class Socket(object):
         else:
             return ret
 
+    def send_auto_complete(self, msg):
+        if not isinstance(msg, Message):
+            raise Exception('must provide Message instance')
+        ret = capi.nl_send_auto_complete(self._sock, msg._msg)
+        if ret < 0:
+            raise Exception('send_auto_complete failed: ret=%d' % ret)
+        return ret
+
+    def recvmsgs(self, recv_cb):
+        if not isinstance(recv_cb, Callback):
+            raise Exception('must provide Callback instance')
+        ret = capi.nl_recvmsgs(self._sock, recv_cb._cb)
+        if ret < 0:
+            raise Exception('recvmsg failed: ret=%d' % ret)
+
 _sockets = {}
 
 def lookup_socket(protocol):
-- 
1.7.10.4





More information about the libnl mailing list