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

Side by Side Diff: Modules/socketmodule.c

Issue 27744: Add AF_ALG (Linux Kernel crypto) to socket module
Patch Set: Created 3 years, 6 months ago
Left:
Right:
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 unified diff | Download patch
« Lib/test/test_socket.py ('K') | « Lib/test/test_socket.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Socket module */ 1 /* Socket module */
2 2
3 /* 3 /*
4 4
5 This module provides an interface to Berkeley socket IPC. 5 This module provides an interface to Berkeley socket IPC.
6 6
7 Limitations: 7 Limitations:
8 8
9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a 9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a
10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported 10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 #ifdef HAVE_SYS_TYPES_H 277 #ifdef HAVE_SYS_TYPES_H
278 #include <sys/types.h> 278 #include <sys/types.h>
279 #endif 279 #endif
280 280
281 #ifdef HAVE_SYS_SOCKET_H 281 #ifdef HAVE_SYS_SOCKET_H
282 #include <sys/socket.h> 282 #include <sys/socket.h>
283 #endif 283 #endif
284 284
285 #ifdef HAVE_NET_IF_H 285 #ifdef HAVE_NET_IF_H
286 #include <net/if.h> 286 #include <net/if.h>
287 #endif
288
289 #ifdef HAVE_SOCKADDR_ALG
290 #include <linux/if_alg.h>
291 #ifndef AF_ALG
292 #define AF_ALG 38
293 #endif
294 #ifndef SOL_ALG
295 #define SOL_ALG 279
296 #endif
287 #endif 297 #endif
288 298
289 /* Generic socket object definitions and includes */ 299 /* Generic socket object definitions and includes */
290 #define PySocket_BUILDING_SOCKET 300 #define PySocket_BUILDING_SOCKET
291 #include "socketmodule.h" 301 #include "socketmodule.h"
292 302
293 /* Addressing includes */ 303 /* Addressing includes */
294 304
295 #ifndef MS_WINDOWS 305 #ifndef MS_WINDOWS
296 306
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 { 1376 {
1367 struct sockaddr_ctl *a = (struct sockaddr_ctl *)addr; 1377 struct sockaddr_ctl *a = (struct sockaddr_ctl *)addr;
1368 return Py_BuildValue("(II)", a->sc_id, a->sc_unit); 1378 return Py_BuildValue("(II)", a->sc_id, a->sc_unit);
1369 } 1379 }
1370 #endif 1380 #endif
1371 default: 1381 default:
1372 PyErr_SetString(PyExc_ValueError, 1382 PyErr_SetString(PyExc_ValueError,
1373 "Invalid address type"); 1383 "Invalid address type");
1374 return 0; 1384 return 0;
1375 } 1385 }
1386 #endif
1387
1388 #ifdef HAVE_SOCKADDR_ALG
1389 case AF_ALG:
1390 {
1391 struct sockaddr_alg *a = (struct sockaddr_alg *)addr;
1392 return Py_BuildValue("s#s#HH",
1393 a->salg_type,
1394 strnlen((const char*)a->salg_type,
1395 sizeof(a->salg_type)),
1396 a->salg_name,
1397 strnlen((const char*)a->salg_name,
1398 sizeof(a->salg_name)),
1399 a->salg_feat,
1400 a->salg_mask);
1401 }
1376 #endif 1402 #endif
1377 1403
1378 /* More cases here... */ 1404 /* More cases here... */
1379 1405
1380 default: 1406 default:
1381 /* If we don't know the address family, don't raise an 1407 /* If we don't know the address family, don't raise an
1382 exception -- return it as an (int, bytes) tuple. */ 1408 exception -- return it as an (int, bytes) tuple. */
1383 return Py_BuildValue("iy#", 1409 return Py_BuildValue("iy#",
1384 addr->sa_family, 1410 addr->sa_family,
1385 addr->sa_data, 1411 addr->sa_data,
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1958
1933 *len_ret = sizeof(*addr); 1959 *len_ret = sizeof(*addr);
1934 return 1; 1960 return 1;
1935 } 1961 }
1936 #endif 1962 #endif
1937 default: 1963 default:
1938 PyErr_SetString(PyExc_OSError, 1964 PyErr_SetString(PyExc_OSError,
1939 "getsockaddrarg: unsupported PF_SYSTEM protocol"); 1965 "getsockaddrarg: unsupported PF_SYSTEM protocol");
1940 return 0; 1966 return 0;
1941 } 1967 }
1968 #endif
1969 #ifdef HAVE_SOCKADDR_ALG
1970 case AF_ALG:
1971 {
1972 struct sockaddr_alg *sa;
1973 char *type;
1974 char *name;
1975 sa = (struct sockaddr_alg *)addr_ret;
1976
1977 memset(sa, 0, sizeof(*sa));
1978 sa->salg_family = AF_ALG;
1979
1980 if (!PyArg_ParseTuple(args, "ss|HH:getsockaddrarg",
1981 &type, &name, &sa->salg_feat, &sa->salg_mask))
1982 return 0;
1983 if (strlen(type) > sizeof(sa->salg_type)) {
1984 PyErr_SetString(PyExc_ValueError, "AF_ALG type too long.");
1985 return 0;
1986 }
1987 strncpy((char *)sa->salg_type, type, sizeof(sa->salg_type));
1988 if (strlen(name) > sizeof(sa->salg_name)) {
1989 PyErr_SetString(PyExc_ValueError, "AF_ALG name too long.");
1990 return 0;
1991 }
1992 strncpy((char *)sa->salg_name, name, sizeof(sa->salg_name));
1993
1994 *len_ret = sizeof(*sa);
1995 return 1;
1996 }
1942 #endif 1997 #endif
1943 1998
1944 /* More cases here... */ 1999 /* More cases here... */
1945 2000
1946 default: 2001 default:
1947 PyErr_SetString(PyExc_OSError, "getsockaddrarg: bad family"); 2002 PyErr_SetString(PyExc_OSError, "getsockaddrarg: bad family");
1948 return 0; 2003 return 0;
1949 2004
1950 } 2005 }
1951 } 2006 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 #ifdef SYSPROTO_CONTROL 2108 #ifdef SYSPROTO_CONTROL
2054 case SYSPROTO_CONTROL: 2109 case SYSPROTO_CONTROL:
2055 *len_ret = sizeof (struct sockaddr_ctl); 2110 *len_ret = sizeof (struct sockaddr_ctl);
2056 return 1; 2111 return 1;
2057 #endif 2112 #endif
2058 default: 2113 default:
2059 PyErr_SetString(PyExc_OSError, "getsockaddrlen: " 2114 PyErr_SetString(PyExc_OSError, "getsockaddrlen: "
2060 "unknown PF_SYSTEM protocol"); 2115 "unknown PF_SYSTEM protocol");
2061 return 0; 2116 return 0;
2062 } 2117 }
2118 #endif
2119 #ifdef HAVE_SOCKADDR_ALG
2120 case AF_ALG:
2121 {
2122 *len_ret = sizeof (struct sockaddr_alg);
2123 return 1;
2124 }
2063 #endif 2125 #endif
2064 2126
2065 /* More cases here... */ 2127 /* More cases here... */
2066 2128
2067 default: 2129 default:
2068 PyErr_SetString(PyExc_OSError, "getsockaddrlen: bad family"); 2130 PyErr_SetString(PyExc_OSError, "getsockaddrlen: bad family");
2069 return 0; 2131 return 0;
2070 2132
2071 } 2133 }
2072 } 2134 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 2275
2214 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) 2276 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
2215 /* accept4() is available on Linux 2.6.28+ and glibc 2.10 */ 2277 /* accept4() is available on Linux 2.6.28+ and glibc 2.10 */
2216 static int accept4_works = -1; 2278 static int accept4_works = -1;
2217 #endif 2279 #endif
2218 2280
2219 static int 2281 static int
2220 sock_accept_impl(PySocketSockObject *s, void *data) 2282 sock_accept_impl(PySocketSockObject *s, void *data)
2221 { 2283 {
2222 struct sock_accept *ctx = data; 2284 struct sock_accept *ctx = data;
2285 struct sockaddr *addr = SAS2SA(ctx->addrbuf);
2286 socklen_t *addrlen = ctx->addrlen;
2287 #ifdef HAVE_SOCKADDR_ALG
2288 /* AF_ALG does not support accept() with addr and raises
2289 * ECONNABORTED instead. */
2290 if (s->sock_family == AF_ALG) {
2291 addr = NULL;
2292 addrlen = NULL;
2293 *ctx->addrlen = 0;
haypo 2016/08/17 13:20:25 Is it needed to set address length to zero since y
2294 }
2295 #endif
2223 2296
2224 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) 2297 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
2225 if (accept4_works != 0) { 2298 if (accept4_works != 0) {
2226 ctx->result = accept4(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen, 2299 ctx->result = accept4(s->sock_fd, addr, addrlen,
2227 SOCK_CLOEXEC); 2300 SOCK_CLOEXEC);
2228 if (ctx->result == INVALID_SOCKET && accept4_works == -1) { 2301 if (ctx->result == INVALID_SOCKET && accept4_works == -1) {
2229 /* On Linux older than 2.6.28, accept4() fails with ENOSYS */ 2302 /* On Linux older than 2.6.28, accept4() fails with ENOSYS */
2230 accept4_works = (errno != ENOSYS); 2303 accept4_works = (errno != ENOSYS);
2231 } 2304 }
2232 } 2305 }
2233 if (accept4_works == 0) 2306 if (accept4_works == 0)
2234 ctx->result = accept(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen); 2307 ctx->result = accept(s->sock_fd, addr, addrlen);
2235 #else 2308 #else
2236 ctx->result = accept(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen); 2309 ctx->result = accept(s->sock_fd, addr, addrlen);
2237 #endif 2310 #endif
2238 2311
2239 #ifdef MS_WINDOWS 2312 #ifdef MS_WINDOWS
2240 return (ctx->result != INVALID_SOCKET); 2313 return (ctx->result != INVALID_SOCKET);
2241 #else 2314 #else
2242 return (ctx->result >= 0); 2315 return (ctx->result >= 0);
2243 #endif 2316 #endif
2244 } 2317 }
2245 2318
2246 /* s._accept() -> (fd, address) */ 2319 /* s._accept() -> (fd, address) */
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3988 as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n\ 4061 as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n\
3989 cmsg_data), where cmsg_level and cmsg_type are integers specifying the\n\ 4062 cmsg_data), where cmsg_level and cmsg_type are integers specifying the\n\
3990 protocol level and protocol-specific type respectively, and cmsg_data\n\ 4063 protocol level and protocol-specific type respectively, and cmsg_data\n\
3991 is a bytes-like object holding the associated data. The flags\n\ 4064 is a bytes-like object holding the associated data. The flags\n\
3992 argument defaults to 0 and has the same meaning as for send(). If\n\ 4065 argument defaults to 0 and has the same meaning as for send(). If\n\
3993 address is supplied and not None, it sets a destination address for\n\ 4066 address is supplied and not None, it sets a destination address for\n\
3994 the message. The return value is the number of bytes of non-ancillary\n\ 4067 the message. The return value is the number of bytes of non-ancillary\n\
3995 data sent."); 4068 data sent.");
3996 #endif /* CMSG_LEN */ 4069 #endif /* CMSG_LEN */
3997 4070
4071 #ifdef HAVE_SOCKADDR_ALG
4072 static PyObject*
4073 sock_algset(PySocketSockObject *self, PyObject *args, PyObject *kwds)
4074 {
4075 PyObject *retval = NULL;
4076 Py_buffer iv = {NULL, NULL};
4077 int type = -1;
4078 int assoclen = -1;
4079 unsigned int *uiptr;
4080 int flags = 0;
4081 struct msghdr msg;
4082 struct cmsghdr *header = NULL;
4083 struct af_alg_iv *alg_iv = NULL;
4084 struct sock_sendmsg ctx;
4085 Py_ssize_t controllen;
4086 void *controlbuf = NULL;
4087 static char *keywords[] = {"op", "iv", "assoclen", "flags", 0};
haypo 2016/08/17 13:20:25 Hum, it would be nice to start using Argument Clin
4088
4089 if (self->sock_family != AF_ALG) {
4090 PyErr_SetString(PyExc_OSError,
4091 "algset is only supported for AF_ALG");
4092 return NULL;
4093 }
4094
4095 if (!PyArg_ParseTupleAndKeywords(args, kwds,
4096 "|$iy*ii:socket", keywords,
4097 &type, &iv, &assoclen, &flags))
haypo 2016/08/17 13:20:25 I'm a little bit confused. The Python parameter is
4098 return NULL;
4099
4100 if (type < 0) {
4101 PyErr_SetString(PyExc_TypeError,
4102 "Required argument 'op' (pos 1) not found");
haypo 2016/08/17 13:20:25 Hum, the error message can be confusing if you exp
4103 goto finally;
4104 }
4105
4106 memset(&msg, 0, sizeof(msg));
4107
4108 controllen = CMSG_SPACE(4);
4109 if (iv.buf != NULL) {
4110 controllen += CMSG_SPACE(sizeof(*alg_iv) + iv.len);
4111 }
4112 if (assoclen >= 0) {
4113 controllen += CMSG_SPACE(4);
4114 }
4115
4116 controlbuf = PyMem_Malloc(controllen);
4117 if (controlbuf == NULL) {
4118 return PyErr_NoMemory();
4119 }
4120 memset(controlbuf, 0, controllen);
haypo 2016/08/17 13:20:25 FYI there is a PyMem_Calloc() function.
4121
4122 msg.msg_controllen = controllen;
4123 msg.msg_control = controlbuf;
4124
4125 /* set operation to encrypt or decrypt */
4126 header = CMSG_FIRSTHDR(&msg);
4127 if (header == NULL) {
4128 PyErr_SetString(PyExc_RuntimeError,
4129 "unexpected NULL result from CMSG_FIRSTHDR");
4130 goto finally;
4131 }
4132 header->cmsg_level = SOL_ALG;
4133 header->cmsg_type = ALG_SET_OP;
4134 header->cmsg_len = CMSG_LEN(4);
4135 uiptr = (void*)CMSG_DATA(header);
4136 *uiptr = (unsigned int)type;
4137
4138 /* set initialization vector */
4139 if (iv.buf != NULL) {
4140 header = CMSG_NXTHDR(&msg, header);
4141 if (header == NULL) {
4142 PyErr_SetString(PyExc_RuntimeError,
4143 "unexpected NULL result from CMSG_NXTHDR(iv)");
4144 goto finally;
4145 }
4146 header->cmsg_level = SOL_ALG;
4147 header->cmsg_type = ALG_SET_IV;
4148 header->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv.len);
4149 alg_iv = (void*)CMSG_DATA(header);
4150 alg_iv->ivlen = iv.len;
4151 memcpy(alg_iv->iv, iv.buf, iv.len);
4152 }
4153
4154 /* set length of associated data for AEAD */
4155 if (assoclen >= 0) {
4156 header = CMSG_NXTHDR(&msg, header);
4157 if (header == NULL) {
4158 PyErr_SetString(PyExc_RuntimeError,
4159 "unexpected NULL result from CMSG_NXTHDR(assoc)");
4160 goto finally;
4161 }
4162 header->cmsg_level = SOL_ALG;
4163 header->cmsg_type = ALG_SET_AEAD_ASSOCLEN;
4164 header->cmsg_len = CMSG_LEN(4);
4165 uiptr = (void*)CMSG_DATA(header);
4166 *uiptr = (unsigned int)assoclen;
4167 }
4168
4169 ctx.msg = &msg;
4170 ctx.flags = flags;
4171 if (sock_call(self, 1, sock_sendmsg_impl, &ctx) < 0)
4172 goto finally;
haypo 2016/08/17 13:20:25 nit: PEP 7 now requires { ... } even for single li
4173
4174 retval = PyLong_FromSsize_t(ctx.result);
4175
4176 finally:
4177 if (iv.buf != NULL)
4178 PyBuffer_Release(&iv);
4179 if (controlbuf != NULL)
haypo 2016/08/17 13:20:25 PyMem_Free(NULL) is well defined: it does nothing,
4180 PyMem_Free(controlbuf);
4181 return retval;
4182 }
4183
4184 PyDoc_STRVAR(algset_doc,
4185 "algset(op[, iv[, assoclen[, flags]]])\n\
4186 \n\
4187 Set operation mode, IV and length of associated data for an AF_ALG\n\
4188 operation socket.");
4189 #endif
3998 4190
3999 /* s.shutdown(how) method */ 4191 /* s.shutdown(how) method */
4000 4192
4001 static PyObject * 4193 static PyObject *
4002 sock_shutdown(PySocketSockObject *s, PyObject *arg) 4194 sock_shutdown(PySocketSockObject *s, PyObject *arg)
4003 { 4195 {
4004 int how; 4196 int how;
4005 int res; 4197 int res;
4006 4198
4007 how = _PyLong_AsInt(arg); 4199 how = _PyLong_AsInt(arg);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 setsockopt_doc}, 4358 setsockopt_doc},
4167 {"shutdown", (PyCFunction)sock_shutdown, METH_O, 4359 {"shutdown", (PyCFunction)sock_shutdown, METH_O,
4168 shutdown_doc}, 4360 shutdown_doc},
4169 #ifdef CMSG_LEN 4361 #ifdef CMSG_LEN
4170 {"recvmsg", (PyCFunction)sock_recvmsg, METH_VARARGS, 4362 {"recvmsg", (PyCFunction)sock_recvmsg, METH_VARARGS,
4171 recvmsg_doc}, 4363 recvmsg_doc},
4172 {"recvmsg_into", (PyCFunction)sock_recvmsg_into, METH_VARARGS, 4364 {"recvmsg_into", (PyCFunction)sock_recvmsg_into, METH_VARARGS,
4173 recvmsg_into_doc,}, 4365 recvmsg_into_doc,},
4174 {"sendmsg", (PyCFunction)sock_sendmsg, METH_VARARGS, 4366 {"sendmsg", (PyCFunction)sock_sendmsg, METH_VARARGS,
4175 sendmsg_doc}, 4367 sendmsg_doc},
4368 #endif
4369 #ifdef HAVE_SOCKADDR_ALG
4370 {"algset", (PyCFunction)sock_algset, METH_VARARGS | METH_KEYWORDS ,
4371 algset_doc},
4176 #endif 4372 #endif
4177 {NULL, NULL} /* sentinel */ 4373 {NULL, NULL} /* sentinel */
4178 }; 4374 };
4179 4375
4180 /* SockObject members */ 4376 /* SockObject members */
4181 static PyMemberDef sock_memberlist[] = { 4377 static PyMemberDef sock_memberlist[] = {
4182 {"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "t he socket family"}, 4378 {"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "t he socket family"},
4183 {"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the s ocket type"}, 4379 {"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the s ocket type"},
4184 {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"}, 4380 {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"},
4185 {0}, 4381 {0},
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
6269 /* Multiprotocol bridge */ 6465 /* Multiprotocol bridge */
6270 PyModule_AddIntMacro(m, AF_BRIDGE); 6466 PyModule_AddIntMacro(m, AF_BRIDGE);
6271 #endif 6467 #endif
6272 #ifdef AF_ATMPVC 6468 #ifdef AF_ATMPVC
6273 /* ATM PVCs */ 6469 /* ATM PVCs */
6274 PyModule_AddIntMacro(m, AF_ATMPVC); 6470 PyModule_AddIntMacro(m, AF_ATMPVC);
6275 #endif 6471 #endif
6276 #ifdef AF_AAL5 6472 #ifdef AF_AAL5
6277 /* Reserved for Werner's ATM */ 6473 /* Reserved for Werner's ATM */
6278 PyModule_AddIntMacro(m, AF_AAL5); 6474 PyModule_AddIntMacro(m, AF_AAL5);
6475 #endif
6476 #ifdef HAVE_SOCKADDR_ALG
6477 PyModule_AddIntMacro(m, AF_ALG); /* Linux crypto */
6279 #endif 6478 #endif
6280 #ifdef AF_X25 6479 #ifdef AF_X25
6281 /* Reserved for X.25 project */ 6480 /* Reserved for X.25 project */
6282 PyModule_AddIntMacro(m, AF_X25); 6481 PyModule_AddIntMacro(m, AF_X25);
6283 #endif 6482 #endif
6284 #ifdef AF_INET6 6483 #ifdef AF_INET6
6285 PyModule_AddIntMacro(m, AF_INET6); /* IP version 6 */ 6484 PyModule_AddIntMacro(m, AF_INET6); /* IP version 6 */
6286 #endif 6485 #endif
6287 #ifdef AF_ROSE 6486 #ifdef AF_ROSE
6288 /* Amateur Radio X.25 PLP */ 6487 /* Amateur Radio X.25 PLP */
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
6482 #ifdef TIPC_SUB_CANCEL 6681 #ifdef TIPC_SUB_CANCEL
6483 /* doesn't seem to be available everywhere */ 6682 /* doesn't seem to be available everywhere */
6484 PyModule_AddIntMacro(m, TIPC_SUB_CANCEL); 6683 PyModule_AddIntMacro(m, TIPC_SUB_CANCEL);
6485 #endif 6684 #endif
6486 PyModule_AddIntMacro(m, TIPC_WAIT_FOREVER); 6685 PyModule_AddIntMacro(m, TIPC_WAIT_FOREVER);
6487 PyModule_AddIntMacro(m, TIPC_PUBLISHED); 6686 PyModule_AddIntMacro(m, TIPC_PUBLISHED);
6488 PyModule_AddIntMacro(m, TIPC_WITHDRAWN); 6687 PyModule_AddIntMacro(m, TIPC_WITHDRAWN);
6489 PyModule_AddIntMacro(m, TIPC_SUBSCR_TIMEOUT); 6688 PyModule_AddIntMacro(m, TIPC_SUBSCR_TIMEOUT);
6490 PyModule_AddIntMacro(m, TIPC_CFG_SRV); 6689 PyModule_AddIntMacro(m, TIPC_CFG_SRV);
6491 PyModule_AddIntMacro(m, TIPC_TOP_SRV); 6690 PyModule_AddIntMacro(m, TIPC_TOP_SRV);
6691 #endif
6692
6693 #ifdef HAVE_SOCKADDR_ALG
6694 /* Socket options */
haypo 2016/08/17 13:20:26 indent the comment?
6695 PyModule_AddIntMacro(m, ALG_SET_KEY);
6696 PyModule_AddIntMacro(m, ALG_SET_IV);
6697 PyModule_AddIntMacro(m, ALG_SET_OP);
6698 PyModule_AddIntMacro(m, ALG_SET_AEAD_ASSOCLEN);
6699 PyModule_AddIntMacro(m, ALG_SET_AEAD_AUTHSIZE);
6700
6701 /* Operations */
6702 PyModule_AddIntMacro(m, ALG_OP_DECRYPT);
6703 PyModule_AddIntMacro(m, ALG_OP_ENCRYPT);
6492 #endif 6704 #endif
6493 6705
6494 /* Socket types */ 6706 /* Socket types */
6495 PyModule_AddIntMacro(m, SOCK_STREAM); 6707 PyModule_AddIntMacro(m, SOCK_STREAM);
6496 PyModule_AddIntMacro(m, SOCK_DGRAM); 6708 PyModule_AddIntMacro(m, SOCK_DGRAM);
6497 /* We have incomplete socket support. */ 6709 /* We have incomplete socket support. */
6498 #ifdef SOCK_RAW 6710 #ifdef SOCK_RAW
6499 /* SOCK_RAW is marked as optional in the POSIX specification */ 6711 /* SOCK_RAW is marked as optional in the POSIX specification */
6500 PyModule_AddIntMacro(m, SOCK_RAW); 6712 PyModule_AddIntMacro(m, SOCK_RAW);
6501 #endif 6713 #endif
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
6741 PyModule_AddIntConstant(m, "CAN_BCM_RX_DELETE", RX_DELETE); 6953 PyModule_AddIntConstant(m, "CAN_BCM_RX_DELETE", RX_DELETE);
6742 PyModule_AddIntConstant(m, "CAN_BCM_RX_READ", RX_READ); 6954 PyModule_AddIntConstant(m, "CAN_BCM_RX_READ", RX_READ);
6743 PyModule_AddIntConstant(m, "CAN_BCM_TX_STATUS", TX_STATUS); 6955 PyModule_AddIntConstant(m, "CAN_BCM_TX_STATUS", TX_STATUS);
6744 PyModule_AddIntConstant(m, "CAN_BCM_TX_EXPIRED", TX_EXPIRED); 6956 PyModule_AddIntConstant(m, "CAN_BCM_TX_EXPIRED", TX_EXPIRED);
6745 PyModule_AddIntConstant(m, "CAN_BCM_RX_STATUS", RX_STATUS); 6957 PyModule_AddIntConstant(m, "CAN_BCM_RX_STATUS", RX_STATUS);
6746 PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT); 6958 PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT);
6747 PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED); 6959 PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED);
6748 #endif 6960 #endif
6749 #ifdef SOL_RDS 6961 #ifdef SOL_RDS
6750 PyModule_AddIntMacro(m, SOL_RDS); 6962 PyModule_AddIntMacro(m, SOL_RDS);
6963 #endif
6964 #ifdef HAVE_SOCKADDR_ALG
6965 PyModule_AddIntMacro(m, SOL_ALG);
6751 #endif 6966 #endif
6752 #ifdef RDS_CANCEL_SENT_TO 6967 #ifdef RDS_CANCEL_SENT_TO
6753 PyModule_AddIntMacro(m, RDS_CANCEL_SENT_TO); 6968 PyModule_AddIntMacro(m, RDS_CANCEL_SENT_TO);
6754 #endif 6969 #endif
6755 #ifdef RDS_GET_MR 6970 #ifdef RDS_GET_MR
6756 PyModule_AddIntMacro(m, RDS_GET_MR); 6971 PyModule_AddIntMacro(m, RDS_GET_MR);
6757 #endif 6972 #endif
6758 #ifdef RDS_FREE_MR 6973 #ifdef RDS_FREE_MR
6759 PyModule_AddIntMacro(m, RDS_FREE_MR); 6974 PyModule_AddIntMacro(m, RDS_FREE_MR);
6760 #endif 6975 #endif
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
7358 return NULL; 7573 return NULL;
7359 memcpy(&packed_addr, src, sizeof(packed_addr)); 7574 memcpy(&packed_addr, src, sizeof(packed_addr));
7360 return strncpy(dst, inet_ntoa(packed_addr), size); 7575 return strncpy(dst, inet_ntoa(packed_addr), size);
7361 } 7576 }
7362 /* Should set errno to EAFNOSUPPORT */ 7577 /* Should set errno to EAFNOSUPPORT */
7363 return NULL; 7578 return NULL;
7364 } 7579 }
7365 7580
7366 #endif 7581 #endif
7367 #endif 7582 #endif
OLDNEW
« Lib/test/test_socket.py ('K') | « Lib/test/test_socket.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+