Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3059)

Unified Diff: Modules/socketmodule.c

Issue 1522400: irda socket support
Patch Set: Created 1 year, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Modules/socketmodule.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1262,6 +1262,16 @@
}
#endif
+#ifdef AF_IRDA
+ case AF_IRDA:
+ {
+ struct sockaddr_irda *a = (struct sockaddr_irda *)addr;
+
+ return Py_BuildValue("iO&", a->sir_addr,
+ PyUnicode_DecodeFSDefault, a->sir_name);
+ }
+#endif
+
/* More cases here... */
default:
@@ -1759,6 +1769,47 @@
}
#endif
+#ifdef HAVE_IRDA_H
+ case AF_IRDA:
+ {
+ struct sockaddr_irda *addr;
+ int daddr;
+ PyObject *service;
+ addr = (struct sockaddr_irda *)addr_ret;
+ Py_ssize_t len;
+
+ if (!PyArg_ParseTuple(args, "iO&", &daddr,
+ PyUnicode_FSConverter, &service))
+ return 0;
+
+ len = PyBytes_GET_SIZE(service);
+
+ if (len <= 0 || len >= sizeof(addr->sir_name)) {
+ PyErr_SetString(PyExc_OSError, "AF_IRDA service name too long");
+ Py_DECREF(service);
+ return 0;
+ }
+
+#ifdef HAVE_LINUX_IRDA_H
+ addr->sir_family = AF_IRDA;
+ addr->sir_lsap_sel = LSAP_ANY;
+ addr->sir_addr = daddr;
+ strcpy(addr->sir_name, PyBytes_AS_STRING(service));
+#else /* Windows */
+ addr->irdaAddressFamily = AF_IRDA;
+ addr->irdaDeviceID[0] = (daddr >> 24) & Oxff;
+ addr->irdaDeviceID[1] = (daddr >> 16) & Oxff;
+ addr->irdaDeviceID[2] = (daddr >> 8) & Oxff;
+ addr->irdaDeviceID[3] = daddr & Oxff;
+ strcpy(addr->irdaServiceName, PyBytes_AS_STRING(service));
+#endif
+
+ Py_DECREF(service);
+ *len_ret = sizeof(*addr);
+ return 1;
+ }
+#endif
+
/* More cases here... */
default:
@@ -1880,6 +1931,14 @@
}
#endif
+#ifdef AF_IRDA
+ case AF_IRDA:
+ {
+ *len_ret = sizeof (struct sockaddr_irda);
+ return 1;
+ }
+#endif
+
/* More cases here... */
default:
@@ -5823,6 +5882,14 @@
PyModule_AddIntConstant(m, "AF_SYSTEM", AF_SYSTEM);
#endif
+/* Infrared Data Association */
+#ifdef AF_IRDA
+ PyModule_AddIntConstant(m, "AF_IRDA", AF_IRDA);
+#endif
+#ifdef PF_IRDA
+ PyModule_AddIntConstant(m, "PF_IRDA", PF_IRDA);
+#endif
+
#ifdef AF_PACKET
PyModule_AddIntMacro(m, AF_PACKET);
#endif
@@ -5895,6 +5962,13 @@
PyModule_AddIntConstant(m, "TIPC_TOP_SRV", TIPC_TOP_SRV);
#endif
+#ifdef HAVE_IRDA_H
+ PyModule_AddIntConstant(m, "SOL_IRLMP", SOL_IRLMP);
+ PyModule_AddIntConstant(m, "IRLMP_ENUMDEVICES", IRLMP_ENUMDEVICES);
+ PyModule_AddIntConstant(m, "IRLMP_IAS_SET", IRLMP_IAS_SET);
+ PyModule_AddIntConstant(m, "IRLMP_IAS_QUERY", IRLMP_IAS_QUERY);
+#endif
+
/* Socket types */
PyModule_AddIntConstant(m, "SOCK_STREAM", SOCK_STREAM);
PyModule_AddIntConstant(m, "SOCK_DGRAM", SOCK_DGRAM);
« no previous file with comments | « no previous file | Modules/socketmodule.h » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7