[Python-Dev] PATCH/RFC for AF_NETLINK support (original) (raw)

Philippe Biondi phil at secdev.org
Mon Jan 10 17:17:49 CET 2005


Hi,

I've done a small patch to use linux AF_NETLINK sockets (see below). Please comment!

Is there a reason for recvmsg() and sendmsg() not to be implemented yet in socketmodule ?

The integration with autoconf has not been done, even if this patch should be ok :

--- configure.in.ori 2005-01-10 17:09:32.000000000 +0100 +++ configure.in 2005-01-06 18:53:18.000000000 +0100 @@ -967,7 +967,7 @@ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h
sys/modem.h
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h
-sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h
+sys/un.h linux/netlink.h sys/utsname.h sys/wait.h pty.h libutil.h
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h
bluetooth/bluetooth.h) AC_HEADER_DIRENT --- pyconfig.h.ori 2005-01-10 17:11:11.000000000 +0100 +++ pyconfig.h 2005-01-06 19:27:33.000000000 +0100 @@ -559,6 +559,9 @@ /* Define to 1 if you have the <sys/un.h> header file. */ #define HAVE_SYS_UN_H 1

+/* Define to 1 if you have the <linux/netlink.h> header file. / +#define HAVE_LINUX_NETLINK_H 1 + / Define to 1 if you have the <sys/utsname.h> header file. */ #define HAVE_SYS_UTSNAME_H 1

--- socketmodule.h.ori 2005-01-07 19:25:18.000000000 +0100 +++ socketmodule.h 2005-01-06 18:20:54.000000000 +0100 @@ -32,6 +32,12 @@

undef AF_UNIX

#endif

+#ifdef HAVE_LINUX_NETLINK_H +# include <linux/netlink.h> +#else +# undef AF_NETLINK +#endif + #ifdef HAVE_BLUETOOTH_BLUETOOTH_H #include <bluetooth/bluetooth.h> #include <bluetooth/rfcomm.h> @@ -87,6 +93,9 @@ typedef struct { #ifdef AF_UNIX struct sockaddr_un un; #endif +#ifdef AF_NETLINK

+#endif #ifdef ENABLE_IPV6 struct sockaddr_in6 in6; struct sockaddr_storage storage; --- socketmodule.c.ori 2005-01-07 19:25:19.000000000 +0100 +++ socketmodule.c 2005-01-10 17:04:38.000000000 +0100 @@ -948,6 +948,14 @@ makesockaddr(int sockfd, struct sockaddr } #endif /* AF_UNIX */

+#if defined(AF_NETLINK)

+#endif /* AF_NETLINK */ + #ifdef ENABLE_IPV6 case AF_INET6: { @@ -1084,6 +1092,31 @@ getsockaddrarg(PySocketSockObject s, Py } #endif / AF_UNIX */

+#if defined(AF_NETLINK)

+#endif + case AF_INET: { struct sockaddr_in* addr; @@ -1280,6 +1313,13 @@ getsockaddrlen(PySocketSockObject s, so return 1; } #endif / AF_UNIX */ +#if defined(AF_NETLINK)

+#endif

    case AF_INET:
    {

@@ -3938,8 +3978,20 @@ init_socket(void) PyModule_AddIntConstant(m, "AF_KEY", AF_KEY); #endif #ifdef AF_NETLINK

#endif #ifdef AF_ROUTE /* Alias to emulate 4.4BSD */

-- Philippe Biondi <phil@ secdev.org> SecDev.org Security Consultant/R&D http://www.secdev.org PGP KeyID:3D9A43E2 FingerPrint:C40A772533730E39330DC0985EE8FF5F3D9A43E2



More information about the Python-Dev mailing list