From: Arend van Spriel Date: Thu, 5 Sep 2013 12:11:32 +0000 (+0200) Subject: python: add send and receive functions to Socket class X-Git-Tag: libnl3_2_23rc1~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9284bcded445a7d245a9c92ffcf3f94d549b621;p=thirdparty%2Flibnl.git 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 --- 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):