From b9284bcded445a7d245a9c92ffcf3f94d549b621 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 5 Sep 2013 14:11:32 +0200 Subject: [PATCH] python: add send and receive functions to Socket class Adding class methods send_auto_complete() and recvmsgs() that call their swig capi equivalent function. Signed-off-by: Arend van Spriel Signed-off-by: Thomas Graf --- 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): -- 2.40.0