开发者

How can I use a NETLINK socket to data from kernel space in PYTHON?

How can I use a NETLINK socket to data from kernel space in开发者_开发问答 PYTHON?


import socket
sock = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW)
sock.bind((0,0))
sock.send(<nlmsghdr>)
sock.recv()


I believe that the socket Python module has had support for AF_NETLINK sockets since Python 2.5 or so, although I have never used it. There are a few projects out there that use it and can serve as an example:

  • pynl80211

  • iotop

Searching Google for /usr/bin/python af_netlink comes up with a few more hits, although I will admit that most are not really useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜