summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c51
-rw-r--r--Modules/socketmodule.h12
2 files changed, 61 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index adaefad556..9149641fce 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -7,8 +7,8 @@ This module provides an interface to Berkeley socket IPC.
Limitations:
- Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a
- portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported
- under Linux.
+ portable manner, though AF_PACKET, AF_NETLINK, AF_QIPCRTR and AF_TIPC are
+ supported under Linux.
- No read/write operations (use sendall/recv or makefile instead).
- Additional restrictions apply on some non-Unix platforms (compensated
for by socket.py).
@@ -55,6 +55,8 @@ Module interface:
the Ethernet protocol number to be received. For example:
("eth0",0x1234). Optional 3rd,4th,5th elements in the tuple
specify packet-type and ha-type/addr.
+- an AF_QIPCRTR socket address is a (node, port) tuple where the
+ node and port are non-negative integers.
- an AF_TIPC socket address is expressed as
(addr_type, v1, v2, v3 [, scope]); where addr_type can be one of:
TIPC_ADDR_NAMESEQ, TIPC_ADDR_NAME, and TIPC_ADDR_ID;
@@ -1293,6 +1295,14 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
}
#endif /* AF_NETLINK */
+#if defined(AF_QIPCRTR)
+ case AF_QIPCRTR:
+ {
+ struct sockaddr_qrtr *a = (struct sockaddr_qrtr *) addr;
+ return Py_BuildValue("II", a->sq_node, a->sq_port);
+ }
+#endif /* AF_QIPCRTR */
+
#if defined(AF_VSOCK)
case AF_VSOCK:
{
@@ -1668,6 +1678,30 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
}
#endif /* AF_NETLINK */
+#if defined(AF_QIPCRTR)
+ case AF_QIPCRTR:
+ {
+ struct sockaddr_qrtr* addr;
+ unsigned int node, port;
+ addr = (struct sockaddr_qrtr *)addr_ret;
+ if (!PyTuple_Check(args)) {
+ PyErr_Format(
+ PyExc_TypeError,
+ "getsockaddrarg: "
+ "AF_QIPCRTR address must be tuple, not %.500s",
+ Py_TYPE(args)->tp_name);
+ return 0;
+ }
+ if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &node, &port))
+ return 0;
+ addr->sq_family = AF_QIPCRTR;
+ addr->sq_node = node;
+ addr->sq_port = port;
+ *len_ret = sizeof(*addr);
+ return 1;
+ }
+#endif /* AF_QIPCRTR */
+
#if defined(AF_VSOCK)
case AF_VSOCK:
{
@@ -2263,6 +2297,14 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
}
#endif /* AF_NETLINK */
+#if defined(AF_QIPCRTR)
+ case AF_QIPCRTR:
+ {
+ *len_ret = sizeof (struct sockaddr_qrtr);
+ return 1;
+ }
+#endif /* AF_QIPCRTR */
+
#if defined(AF_VSOCK)
case AF_VSOCK:
{
@@ -6983,6 +7025,11 @@ PyInit__socket(void)
#endif
#endif /* AF_NETLINK */
+#ifdef AF_QIPCRTR
+ /* Qualcomm IPCROUTER */
+ PyModule_AddIntMacro(m, AF_QIPCRTR);
+#endif
+
#ifdef AF_VSOCK
PyModule_AddIntConstant(m, "AF_VSOCK", AF_VSOCK);
PyModule_AddIntConstant(m, "SO_VM_SOCKETS_BUFFER_SIZE", 0);
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index 0b2edc1587..dff1f8f4e9 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -54,6 +54,15 @@ typedef int socklen_t;
# undef AF_NETLINK
#endif
+#ifdef HAVE_LINUX_QRTR_H
+# ifdef HAVE_ASM_TYPES_H
+# include <asm/types.h>
+# endif
+# include <linux/qrtr.h>
+#else
+# undef AF_QIPCRTR
+#endif
+
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
@@ -203,6 +212,9 @@ typedef union sock_addr {
#ifdef HAVE_SOCKADDR_ALG
struct sockaddr_alg alg;
#endif
+#ifdef AF_QIPCRTR
+ struct sockaddr_qrtr sq;
+#endif
#ifdef AF_VSOCK
struct sockaddr_vm vm;
#endif