471,328 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 software developers and data experts.

netlink messages

Dear list,

I am writing a daemon in Python that listens on AF_NETLINK and
processes RTM_NETLINK messages. FWIW, code is below since there is
hardly any reference on the net yet.

As you can see from the code, the NETLINK message is all binary/hex.
Before I go about wrapping it in a Python class, I was wondering
whether such a class already existed or if someone is already
working on this.

Please let me know if you are or have any hints, and please keep me
on CC.

Thanks,
m
Python 2.5.1 (r251:54863, Apr 25 2007, 22:53:30)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>from socket import *
from select import *
s = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)
from os import getpid
RTMGRP_LINK = 1
s.bind((getpid(), RTMGRP_LINK))
p = select((s,), (), (), 0)
p
([], [], [])
>># connect device
...
>>p = select((s,), (), (), 0)
p
([<socket._socketobject object at 0xb7d9b374>], [], [])
>>s2 = p[0][0]
d = s2.recv(4096)
d
'\xf8\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x01\x00\x0c\x00\x00\x00\x0 2\x10\x00\x00\xff\xff\xff\xff\t\x00\x03\x00eth0\x0 0\x00\x00\x00\x08\x00\r\x00\xe8\x03\x00\x00\x08\x0 0\x0f\x00\x00\x00\x00\x00\x05\x00\x10\x00\x02\x00\ x00\x00\x05\x00\x11\x00\x00\x00\x00\x00\x08\x00\x0 4\x00\xdc\x05\x00\x00\t\x00\x06\x00noop\x00\x00\x0 0\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 0\x00\x00\x00\x00\x00\x00\x00\n\x00\x01\x00N\x80\x ba~4\x14\x00\x00\n\x00\x02\x00\xff\xff\xff\xff\xff \xff\x00\x00`\x00\x07\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
--
martin; (greetings from the heart of the sun.)
\____ echo mailto: !#^."<*>"|tr "<*mailto:" net@madduck

spamtraps: ma***********@madduck.net

"men always want to be a woman's first love.
women have a more subtle instinct:
what they like is to be a man's last romance."
-- oscar wilde

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGbSWEIgvIgzMMSnURAp95AJ45+oEDXXXGckKCdKwv4t 8n0up1gwCfVJ2o
sn3chcfYz2+ejJXEzYtazqE=
=wD9A
-----END PGP SIGNATURE-----

Jun 11 '07 #1
0 864

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by SJB | last post: by
5 posts views Thread by Adam | last post: by
18 posts views Thread by Grant Edwards | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.