commit 74020f34811a0434a442fc1f22acb044cf853baa
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Aug 16 09:54:42 2013 +0200
ConnectionHandler: handle NetlinkSockets
This commit adds the ability to recieve data from NetlinkSockets. The
data is also parsed and decoded by a NETLINK_ROUTE marshaller, since
that is the only type of netlink socket we will be using at the moment.
The order of the if/elif statements is important and the NetlinkSocket
must come before the socket.SocketType check.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/ConnectionHandler.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/ConnectionHandler.py b/lnst/Common/ConnectionHandler.py
index 80a9538..b44f159 100644
--- a/lnst/Common/ConnectionHandler.py
+++ b/lnst/Common/ConnectionHandler.py
@@ -15,6 +15,8 @@ import select
import cPickle
import socket
from _multiprocessing import Connection
+from pyroute2.netlink import NetlinkSocket
+from pyroute2.netlink.iproute import MarshalRtnl
def send_data(s, data):
try:
@@ -33,7 +35,12 @@ def send_data(s, data):
return True
def recv_data(s):
- if isinstance(s, socket.SocketType):
+ if isinstance(s, NetlinkSocket):
+ marshaller = MarshalRtnl()
+ msg = s.recv(16384)
+ decoded_msg = marshaller.parse(msg)
+ data = {"type": "netlink", "data": decoded_msg}
+ elif isinstance(s, socket.SocketType):
length = ""
while True:
c = s.recv(1)
Show replies by date