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

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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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
297
298 /* Linux 3.19 */
299 #ifndef ALG_SET_AEAD_ASSOCLEN
300 #define ALG_SET_AEAD_ASSOCLEN 4
301 #endif
302 #ifndef ALG_SET_AEAD_AUTHSIZE
303 #define ALG_SET_AEAD_AUTHSIZE 5
304 #endif
305 /* Linux 4.8 */
306 #ifndef ALG_SET_PUBKEY
307 #define ALG_SET_PUBKEY 6
308 #endif
309
310 #ifndef ALG_OP_SIGN
311 #define ALG_OP_SIGN 2
312 #endif
313 #ifndef ALG_OP_VERIFY
314 #define ALG_OP_VERIFY 3
315 #endif
316
317 #endif /* HAVE_SOCKADDR_ALG */
288 318
289 /* Generic socket object definitions and includes */ 319 /* Generic socket object definitions and includes */
290 #define PySocket_BUILDING_SOCKET 320 #define PySocket_BUILDING_SOCKET
291 #include "socketmodule.h" 321 #include "socketmodule.h"
292 322
293 /* Addressing includes */ 323 /* Addressing includes */
294 324
295 #ifndef MS_WINDOWS 325 #ifndef MS_WINDOWS
296 326
297 /* Non-MS WINDOWS includes */ 327 /* Non-MS WINDOWS includes */
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 { 1396 {
1367 struct sockaddr_ctl *a = (struct sockaddr_ctl *)addr; 1397 struct sockaddr_ctl *a = (struct sockaddr_ctl *)addr;
1368 return Py_BuildValue("(II)", a->sc_id, a->sc_unit); 1398 return Py_BuildValue("(II)", a->sc_id, a->sc_unit);
1369 } 1399 }
1370 #endif 1400 #endif
1371 default: 1401 default:
1372 PyErr_SetString(PyExc_ValueError, 1402 PyErr_SetString(PyExc_ValueError,
1373 "Invalid address type"); 1403 "Invalid address type");
1374 return 0; 1404 return 0;
1375 } 1405 }
1406 #endif
1407
1408 #ifdef HAVE_SOCKADDR_ALG
1409 case AF_ALG:
1410 {
1411 struct sockaddr_alg *a = (struct sockaddr_alg *)addr;
1412 return Py_BuildValue("s#s#HH",
1413 a->salg_type,
1414 strnlen((const char*)a->salg_type,
1415 sizeof(a->salg_type)),
1416 a->salg_name,
1417 strnlen((const char*)a->salg_name,
1418 sizeof(a->salg_name)),
1419 a->salg_feat,
1420 a->salg_mask);
1421 }
1376 #endif 1422 #endif
1377 1423
1378 /* More cases here... */ 1424 /* More cases here... */
1379 1425
1380 default: 1426 default:
1381 /* If we don't know the address family, don't raise an 1427 /* If we don't know the address family, don't raise an
1382 exception -- return it as an (int, bytes) tuple. */ 1428 exception -- return it as an (int, bytes) tuple. */
1383 return Py_BuildValue("iy#", 1429 return Py_BuildValue("iy#",
1384 addr->sa_family, 1430 addr->sa_family,
1385 addr->sa_data, 1431 addr->sa_data,
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1978
1933 *len_ret = sizeof(*addr); 1979 *len_ret = sizeof(*addr);
1934 return 1; 1980 return 1;
1935 } 1981 }
1936 #endif 1982 #endif
1937 default: 1983 default:
1938 PyErr_SetString(PyExc_OSError, 1984 PyErr_SetString(PyExc_OSError,
1939 "getsockaddrarg: unsupported PF_SYSTEM protocol"); 1985 "getsockaddrarg: unsupported PF_SYSTEM protocol");
1940 return 0; 1986 return 0;
1941 } 1987 }
1988 #endif
1989 #ifdef HAVE_SOCKADDR_ALG
1990 case AF_ALG:
1991 {
1992 struct sockaddr_alg *sa;
1993 char *type;
1994 char *name;
1995 sa = (struct sockaddr_alg *)addr_ret;
1996
1997 memset(sa, 0, sizeof(*sa));
1998 sa->salg_family = AF_ALG;
1999
2000 if (!PyArg_ParseTuple(args, "ss|HH:getsockaddrarg",
2001 &type, &name, &sa->salg_feat, &sa->salg_mask))
2002 return 0;
2003 if (strlen(type) > sizeof(sa->salg_type)) {
2004 PyErr_SetString(PyExc_ValueError, "AF_ALG type too long.");
2005 return 0;
2006 }
2007 strncpy((char *)sa->salg_type, type, sizeof(sa->salg_type));
2008 if (strlen(name) > sizeof(sa->salg_name)) {
2009 PyErr_SetString(PyExc_ValueError, "AF_ALG name too long.");
2010 return 0;
2011 }
2012 strncpy((char *)sa->salg_name, name, sizeof(sa->salg_name));
2013
2014 *len_ret = sizeof(*sa);
2015 return 1;
2016 }
1942 #endif 2017 #endif
1943 2018
1944 /* More cases here... */ 2019 /* More cases here... */
1945 2020
1946 default: 2021 default:
1947 PyErr_SetString(PyExc_OSError, "getsockaddrarg: bad family"); 2022 PyErr_SetString(PyExc_OSError, "getsockaddrarg: bad family");
1948 return 0; 2023 return 0;
1949 2024
1950 } 2025 }
1951 } 2026 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 #ifdef SYSPROTO_CONTROL 2128 #ifdef SYSPROTO_CONTROL
2054 case SYSPROTO_CONTROL: 2129 case SYSPROTO_CONTROL:
2055 *len_ret = sizeof (struct sockaddr_ctl); 2130 *len_ret = sizeof (struct sockaddr_ctl);
2056 return 1; 2131 return 1;
2057 #endif 2132 #endif
2058 default: 2133 default:
2059 PyErr_SetString(PyExc_OSError, "getsockaddrlen: " 2134 PyErr_SetString(PyExc_OSError, "getsockaddrlen: "
2060 "unknown PF_SYSTEM protocol"); 2135 "unknown PF_SYSTEM protocol");
2061 return 0; 2136 return 0;
2062 } 2137 }
2138 #endif
2139 #ifdef HAVE_SOCKADDR_ALG
2140 case AF_ALG:
2141 {
2142 *len_ret = sizeof (struct sockaddr_alg);
2143 return 1;
2144 }
2063 #endif 2145 #endif
2064 2146
2065 /* More cases here... */ 2147 /* More cases here... */
2066 2148
2067 default: 2149 default:
2068 PyErr_SetString(PyExc_OSError, "getsockaddrlen: bad family"); 2150 PyErr_SetString(PyExc_OSError, "getsockaddrlen: bad family");
2069 return 0; 2151 return 0;
2070 2152
2071 } 2153 }
2072 } 2154 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 2295
2214 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) 2296 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
2215 /* accept4() is available on Linux 2.6.28+ and glibc 2.10 */ 2297 /* accept4() is available on Linux 2.6.28+ and glibc 2.10 */
2216 static int accept4_works = -1; 2298 static int accept4_works = -1;
2217 #endif 2299 #endif
2218 2300
2219 static int 2301 static int
2220 sock_accept_impl(PySocketSockObject *s, void *data) 2302 sock_accept_impl(PySocketSockObject *s, void *data)
2221 { 2303 {
2222 struct sock_accept *ctx = data; 2304 struct sock_accept *ctx = data;
2305 struct sockaddr *addr = SAS2SA(ctx->addrbuf);
2306 socklen_t *addrlen = ctx->addrlen;
2307 #ifdef HAVE_SOCKADDR_ALG
2308 /* AF_ALG does not support accept() with addr and raises
2309 * ECONNABORTED instead. */
2310 if (s->sock_family == AF_ALG) {
2311 addr = NULL;
2312 addrlen = NULL;
2313 *ctx->addrlen = 0;
2314 }
2315 #endif
2223 2316
2224 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) 2317 #if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
2225 if (accept4_works != 0) { 2318 if (accept4_works != 0) {
2226 ctx->result = accept4(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen, 2319 ctx->result = accept4(s->sock_fd, addr, addrlen,
2227 SOCK_CLOEXEC); 2320 SOCK_CLOEXEC);
2228 if (ctx->result == INVALID_SOCKET && accept4_works == -1) { 2321 if (ctx->result == INVALID_SOCKET && accept4_works == -1) {
2229 /* On Linux older than 2.6.28, accept4() fails with ENOSYS */ 2322 /* On Linux older than 2.6.28, accept4() fails with ENOSYS */
2230 accept4_works = (errno != ENOSYS); 2323 accept4_works = (errno != ENOSYS);
2231 } 2324 }
2232 } 2325 }
2233 if (accept4_works == 0) 2326 if (accept4_works == 0)
2234 ctx->result = accept(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen); 2327 ctx->result = accept(s->sock_fd, addr, addrlen);
2235 #else 2328 #else
2236 ctx->result = accept(s->sock_fd, SAS2SA(ctx->addrbuf), ctx->addrlen); 2329 ctx->result = accept(s->sock_fd, addr, addrlen);
2237 #endif 2330 #endif
2238 2331
2239 #ifdef MS_WINDOWS 2332 #ifdef MS_WINDOWS
2240 return (ctx->result != INVALID_SOCKET); 2333 return (ctx->result != INVALID_SOCKET);
2241 #else 2334 #else
2242 return (ctx->result >= 0); 2335 return (ctx->result >= 0);
2243 #endif 2336 #endif
2244 } 2337 }
2245 2338
2246 /* s._accept() -> (fd, address) */ 2339 /* s._accept() -> (fd, address) */
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 } 2521 }
2429 2522
2430 PyDoc_STRVAR(gettimeout_doc, 2523 PyDoc_STRVAR(gettimeout_doc,
2431 "gettimeout() -> timeout\n\ 2524 "gettimeout() -> timeout\n\
2432 \n\ 2525 \n\
2433 Returns the timeout in seconds (float) associated with socket \n\ 2526 Returns the timeout in seconds (float) associated with socket \n\
2434 operations. A timeout of None indicates that timeouts on socket \n\ 2527 operations. A timeout of None indicates that timeouts on socket \n\
2435 operations are disabled."); 2528 operations are disabled.");
2436 2529
2437 /* s.setsockopt() method. 2530 /* s.setsockopt() method.
2438 With an integer third argument, sets an integer option. 2531 With an integer third argument, sets an integer optval with optlen=4.
2532 With None as third argument and an integer fourth argument, set
2533 optval=NULL with unsigned int as optlen.
2439 With a string third argument, sets an option from a buffer; 2534 With a string third argument, sets an option from a buffer;
2440 use optional built-in module 'struct' to encode the string. */ 2535 use optional built-in module 'struct' to encode the string.
2536 */
2441 2537
2442 static PyObject * 2538 static PyObject *
2443 sock_setsockopt(PySocketSockObject *s, PyObject *args) 2539 sock_setsockopt(PySocketSockObject *s, PyObject *args)
2444 { 2540 {
2445 int level; 2541 int level;
2446 int optname; 2542 int optname;
2447 int res; 2543 int res;
2448 Py_buffer optval; 2544 Py_buffer optval;
2449 int flag; 2545 int flag;
2546 socklen_t socklen;
2547 PyObject *none;
2450 2548
2549 /* setsockopt(level, opt, flag) */
2451 if (PyArg_ParseTuple(args, "iii:setsockopt", 2550 if (PyArg_ParseTuple(args, "iii:setsockopt",
2452 &level, &optname, &flag)) { 2551 &level, &optname, &flag)) {
2453 res = setsockopt(s->sock_fd, level, optname, 2552 res = setsockopt(s->sock_fd, level, optname,
2454 (char*)&flag, sizeof flag); 2553 (char*)&flag, sizeof flag);
2554 goto done;
2455 } 2555 }
2456 else { 2556
2457 PyErr_Clear(); 2557 PyErr_Clear();
2458 if (!PyArg_ParseTuple(args, "iiy*:setsockopt", 2558 /* setsockopt(level, opt, (None, flag)) */
2459 &level, &optname, &optval)) 2559 if (PyArg_ParseTuple(args, "iiO!I:setsockopt",
2460 return NULL; 2560 &level, &optname, Py_TYPE(Py_None), &none, &socklen)) {
2561 res = setsockopt(s->sock_fd, level, optname,
2562 NULL, socklen);
2563 goto done;
2564 }
2565
2566 PyErr_Clear();
2567 /* setsockopt(level, opt, buffer) */
2568 if (!PyArg_ParseTuple(args, "iiy*:setsockopt",
2569 &level, &optname, &optval))
2570 return NULL;
2571
2461 #ifdef MS_WINDOWS 2572 #ifdef MS_WINDOWS
2462 if (optval.len > INT_MAX) { 2573 if (optval.len > INT_MAX) {
2463 PyBuffer_Release(&optval); 2574 PyBuffer_Release(&optval);
2464 PyErr_Format(PyExc_OverflowError, 2575 PyErr_Format(PyExc_OverflowError,
2465 "socket option is larger than %i bytes", 2576 "socket option is larger than %i bytes",
2466 INT_MAX); 2577 INT_MAX);
2467 return NULL; 2578 return NULL;
2468 } 2579 }
2469 res = setsockopt(s->sock_fd, level, optname, 2580 res = setsockopt(s->sock_fd, level, optname,
2470 optval.buf, (int)optval.len); 2581 optval.buf, (int)optval.len);
2471 #else 2582 #else
2472 res = setsockopt(s->sock_fd, level, optname, optval.buf, optval.len); 2583 res = setsockopt(s->sock_fd, level, optname, optval.buf, optval.len);
2473 #endif 2584 #endif
2474 PyBuffer_Release(&optval); 2585 PyBuffer_Release(&optval);
2475 } 2586
2587 done:
2476 if (res < 0) { 2588 if (res < 0) {
2477 return s->errorhandler(); 2589 return s->errorhandler();
2478 } 2590 }
2479 2591
2480 Py_RETURN_NONE; 2592 Py_RETURN_NONE;
2481 } 2593 }
2482 2594
2483 PyDoc_STRVAR(setsockopt_doc, 2595 PyDoc_STRVAR(setsockopt_doc,
2484 "setsockopt(level, option, value)\n\ 2596 "setsockopt(level, option, value[, intvalue])\n\
haypo 2016/08/28 23:53:21 Hum, the documentation is unclear. I suggest to do
christian.heimes 2016/08/29 08:10:37 I don't know which platforms support this kind of
2485 \n\ 2597 \n\
2486 Set a socket option. See the Unix manual for level and option.\n\ 2598 Set a socket option. See the Unix manual for level and option.\n\
2487 The value argument can either be an integer or a string."); 2599 The value argument can either be an integer, a string buffer or None\n\
2600 with intvalue.");
2488 2601
2489 2602
2490 /* s.getsockopt() method. 2603 /* s.getsockopt() method.
2491 With two arguments, retrieves an integer option. 2604 With two arguments, retrieves an integer option.
2492 With a third integer argument, retrieves a string buffer of that size; 2605 With a third integer argument, retrieves a string buffer of that size;
2493 use optional built-in module 'struct' to decode the string. */ 2606 use optional built-in module 'struct' to decode the string. */
2494 2607
2495 static PyObject * 2608 static PyObject *
2496 sock_getsockopt(PySocketSockObject *s, PyObject *args) 2609 sock_getsockopt(PySocketSockObject *s, PyObject *args)
2497 { 2610 {
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 3878
3766 3879
3767 /* The sendmsg() and recvmsg[_into]() methods require a working 3880 /* The sendmsg() and recvmsg[_into]() methods require a working
3768 CMSG_LEN(). See the comment near get_CMSG_LEN(). */ 3881 CMSG_LEN(). See the comment near get_CMSG_LEN(). */
3769 #ifdef CMSG_LEN 3882 #ifdef CMSG_LEN
3770 struct sock_sendmsg { 3883 struct sock_sendmsg {
3771 struct msghdr *msg; 3884 struct msghdr *msg;
3772 int flags; 3885 int flags;
3773 ssize_t result; 3886 ssize_t result;
3774 }; 3887 };
3888
3889 static int
3890 sock_sendmsg_iovec(PySocketSockObject *s, PyObject *data_arg,
3891 struct msghdr *msg,
3892 Py_buffer **databufsout, Py_ssize_t *ndatabufsout) {
3893 Py_ssize_t ndataparts, ndatabufs = 0;
3894 int result = -1;
3895 struct iovec *iovs = NULL;
3896 PyObject *data_fast = NULL;
3897 Py_buffer *databufs = NULL;
3898
3899 /* Fill in an iovec for each message part, and save the Py_buffer
3900 structs to release afterwards. */
3901 if ((data_fast = PySequence_Fast(data_arg,
3902 "sendmsg() argument 1 must be an "
3903 "iterable")) == NULL)
3904 goto finally;
3905 ndataparts = PySequence_Fast_GET_SIZE(data_fast);
3906 if (ndataparts > INT_MAX) {
3907 PyErr_SetString(PyExc_OSError, "sendmsg() argument 1 is too long");
3908 goto finally;
3909 }
3910 msg->msg_iovlen = ndataparts;
3911 if (ndataparts > 0 &&
3912 ((msg->msg_iov = iovs = PyMem_New(struct iovec, ndataparts)) == NULL ||
3913 (databufs = PyMem_New(Py_buffer, ndataparts)) == NULL)) {
3914 PyErr_NoMemory();
3915 goto finally;
3916 }
3917 for (; ndatabufs < ndataparts; ndatabufs++) {
3918 if (!PyArg_Parse(PySequence_Fast_GET_ITEM(data_fast, ndatabufs),
3919 "y*;sendmsg() argument 1 must be an iterable of "
3920 "bytes-like objects",
3921 &databufs[ndatabufs]))
3922 goto finally;
3923 iovs[ndatabufs].iov_base = databufs[ndatabufs].buf;
3924 iovs[ndatabufs].iov_len = databufs[ndatabufs].len;
3925 }
3926 result = 0;
3927 finally:
3928 *databufsout = databufs;
3929 *ndatabufsout = ndatabufs;
3930 Py_XDECREF(data_fast);
3931 return result;
3932 }
3775 3933
3776 static int 3934 static int
3777 sock_sendmsg_impl(PySocketSockObject *s, void *data) 3935 sock_sendmsg_impl(PySocketSockObject *s, void *data)
3778 { 3936 {
3779 struct sock_sendmsg *ctx = data; 3937 struct sock_sendmsg *ctx = data;
3780 3938
3781 ctx->result = sendmsg(s->sock_fd, ctx->msg, ctx->flags); 3939 ctx->result = sendmsg(s->sock_fd, ctx->msg, ctx->flags);
3782 return (ctx->result >= 0); 3940 return (ctx->result >= 0);
3783 } 3941 }
3784 3942
3785 /* s.sendmsg(buffers[, ancdata[, flags[, address]]]) method */ 3943 /* s.sendmsg(buffers[, ancdata[, flags[, address]]]) method */
3786 3944
3787 static PyObject * 3945 static PyObject *
3788 sock_sendmsg(PySocketSockObject *s, PyObject *args) 3946 sock_sendmsg(PySocketSockObject *s, PyObject *args)
3789 { 3947 {
3790 Py_ssize_t i, ndataparts, ndatabufs = 0, ncmsgs, ncmsgbufs = 0; 3948 Py_ssize_t i, ndatabufs = 0, ncmsgs, ncmsgbufs = 0;
3791 Py_buffer *databufs = NULL; 3949 Py_buffer *databufs = NULL;
3792 struct iovec *iovs = NULL;
3793 sock_addr_t addrbuf; 3950 sock_addr_t addrbuf;
3794 struct msghdr msg = {0}; 3951 struct msghdr msg = {0};
3795 struct cmsginfo { 3952 struct cmsginfo {
3796 int level; 3953 int level;
3797 int type; 3954 int type;
3798 Py_buffer data; 3955 Py_buffer data;
3799 } *cmsgs = NULL; 3956 } *cmsgs = NULL;
3800 void *controlbuf = NULL; 3957 void *controlbuf = NULL;
3801 size_t controllen, controllen_last; 3958 size_t controllen, controllen_last;
3802 int addrlen, flags = 0; 3959 int addrlen, flags = 0;
3803 PyObject *data_arg, *cmsg_arg = NULL, *addr_arg = NULL, *data_fast = NULL, 3960 PyObject *data_arg, *cmsg_arg = NULL, *addr_arg = NULL,
3804 *cmsg_fast = NULL, *retval = NULL; 3961 *cmsg_fast = NULL, *retval = NULL;
3805 struct sock_sendmsg ctx; 3962 struct sock_sendmsg ctx;
3806 3963
3807 if (!PyArg_ParseTuple(args, "O|OiO:sendmsg", 3964 if (!PyArg_ParseTuple(args, "O|OiO:sendmsg",
3808 &data_arg, &cmsg_arg, &flags, &addr_arg)) 3965 &data_arg, &cmsg_arg, &flags, &addr_arg))
3809 return NULL; 3966 return NULL;
3810 3967
3811 /* Parse destination address. */ 3968 /* Parse destination address. */
3812 if (addr_arg != NULL && addr_arg != Py_None) { 3969 if (addr_arg != NULL && addr_arg != Py_None) {
3813 if (!getsockaddrarg(s, addr_arg, SAS2SA(&addrbuf), &addrlen)) 3970 if (!getsockaddrarg(s, addr_arg, SAS2SA(&addrbuf), &addrlen))
3814 goto finally; 3971 goto finally;
3815 msg.msg_name = &addrbuf; 3972 msg.msg_name = &addrbuf;
3816 msg.msg_namelen = addrlen; 3973 msg.msg_namelen = addrlen;
3817 } 3974 }
3818 3975
3819 /* Fill in an iovec for each message part, and save the Py_buffer 3976 /* Fill in an iovec for each message part, and save the Py_buffer
3820 structs to release afterwards. */ 3977 structs to release afterwards. */
3821 if ((data_fast = PySequence_Fast(data_arg, 3978 if (sock_sendmsg_iovec(s, data_arg, &msg, &databufs, &ndatabufs) == -1) {
3822 "sendmsg() argument 1 must be an "
3823 "iterable")) == NULL)
3824 goto finally; 3979 goto finally;
3825 ndataparts = PySequence_Fast_GET_SIZE(data_fast);
3826 if (ndataparts > INT_MAX) {
3827 PyErr_SetString(PyExc_OSError, "sendmsg() argument 1 is too long");
3828 goto finally;
3829 }
3830 msg.msg_iovlen = ndataparts;
3831 if (ndataparts > 0 &&
3832 ((msg.msg_iov = iovs = PyMem_New(struct iovec, ndataparts)) == NULL ||
3833 (databufs = PyMem_New(Py_buffer, ndataparts)) == NULL)) {
3834 PyErr_NoMemory();
3835 goto finally;
3836 }
3837 for (; ndatabufs < ndataparts; ndatabufs++) {
3838 if (!PyArg_Parse(PySequence_Fast_GET_ITEM(data_fast, ndatabufs),
3839 "y*;sendmsg() argument 1 must be an iterable of "
3840 "bytes-like objects",
3841 &databufs[ndatabufs]))
3842 goto finally;
3843 iovs[ndatabufs].iov_base = databufs[ndatabufs].buf;
3844 iovs[ndatabufs].iov_len = databufs[ndatabufs].len;
3845 } 3980 }
3846 3981
3847 if (cmsg_arg == NULL) 3982 if (cmsg_arg == NULL)
3848 ncmsgs = 0; 3983 ncmsgs = 0;
3849 else { 3984 else {
3850 if ((cmsg_fast = PySequence_Fast(cmsg_arg, 3985 if ((cmsg_fast = PySequence_Fast(cmsg_arg,
3851 "sendmsg() argument 2 must be an " 3986 "sendmsg() argument 2 must be an "
3852 "iterable")) == NULL) 3987 "iterable")) == NULL)
3853 goto finally; 3988 goto finally;
3854 ncmsgs = PySequence_Fast_GET_SIZE(cmsg_fast); 3989 ncmsgs = PySequence_Fast_GET_SIZE(cmsg_fast);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 4100
3966 finally: 4101 finally:
3967 PyMem_Free(controlbuf); 4102 PyMem_Free(controlbuf);
3968 for (i = 0; i < ncmsgbufs; i++) 4103 for (i = 0; i < ncmsgbufs; i++)
3969 PyBuffer_Release(&cmsgs[i].data); 4104 PyBuffer_Release(&cmsgs[i].data);
3970 PyMem_Free(cmsgs); 4105 PyMem_Free(cmsgs);
3971 Py_XDECREF(cmsg_fast); 4106 Py_XDECREF(cmsg_fast);
3972 for (i = 0; i < ndatabufs; i++) 4107 for (i = 0; i < ndatabufs; i++)
3973 PyBuffer_Release(&databufs[i]); 4108 PyBuffer_Release(&databufs[i]);
3974 PyMem_Free(databufs); 4109 PyMem_Free(databufs);
3975 PyMem_Free(iovs);
3976 Py_XDECREF(data_fast);
3977 return retval; 4110 return retval;
3978 } 4111 }
3979 4112
3980 PyDoc_STRVAR(sendmsg_doc, 4113 PyDoc_STRVAR(sendmsg_doc,
3981 "sendmsg(buffers[, ancdata[, flags[, address]]]) -> count\n\ 4114 "sendmsg(buffers[, ancdata[, flags[, address]]]) -> count\n\
3982 \n\ 4115 \n\
3983 Send normal and ancillary data to the socket, gathering the\n\ 4116 Send normal and ancillary data to the socket, gathering the\n\
3984 non-ancillary data from a series of buffers and concatenating it into\n\ 4117 non-ancillary data from a series of buffers and concatenating it into\n\
3985 a single message. The buffers argument specifies the non-ancillary\n\ 4118 a single message. The buffers argument specifies the non-ancillary\n\
3986 data as an iterable of bytes-like objects (e.g. bytes objects).\n\ 4119 data as an iterable of bytes-like objects (e.g. bytes objects).\n\
3987 The ancdata argument specifies the ancillary data (control messages)\n\ 4120 The ancdata argument specifies the ancillary data (control messages)\n\
3988 as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n\ 4121 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\ 4122 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\ 4123 protocol level and protocol-specific type respectively, and cmsg_data\n\
3991 is a bytes-like object holding the associated data. The flags\n\ 4124 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\ 4125 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\ 4126 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\ 4127 the message. The return value is the number of bytes of non-ancillary\n\
3995 data sent."); 4128 data sent.");
3996 #endif /* CMSG_LEN */ 4129 #endif /* CMSG_LEN */
3997 4130
4131 #ifdef HAVE_SOCKADDR_ALG
4132 static PyObject*
4133 sock_sendmsg_afalg(PySocketSockObject *self, PyObject *args, PyObject *kwds)
4134 {
4135 PyObject *retval = NULL;
4136
4137 Py_ssize_t i, ndatabufs = 0;
4138 Py_buffer *databufs = NULL;
4139 PyObject *data_arg = NULL;
4140
4141 Py_buffer iv = {NULL, NULL};
4142
4143 PyObject *opobj = NULL;
4144 int op = -1;
4145
4146 PyObject *assoclenobj = NULL;
4147 int assoclen = -1;
4148
4149 unsigned int *uiptr;
4150 int flags = 0;
4151
4152 struct msghdr msg;
4153 struct cmsghdr *header = NULL;
4154 struct af_alg_iv *alg_iv = NULL;
4155 struct sock_sendmsg ctx;
4156 Py_ssize_t controllen;
4157 void *controlbuf = NULL;
4158 static char *keywords[] = {"msg", "op", "iv", "assoclen", "flags", 0};
4159
4160 if (self->sock_family != AF_ALG) {
4161 PyErr_SetString(PyExc_OSError,
4162 "algset is only supported for AF_ALG");
4163 return NULL;
4164 }
4165
4166 if (!PyArg_ParseTupleAndKeywords(args, kwds,
4167 "|O$O!y*O!i:sendmsg_afalg", keywords,
4168 &data_arg,
4169 &PyLong_Type, &opobj, &iv,
4170 &PyLong_Type, &assoclenobj, &flags))
4171 return NULL;
4172
4173 /* op is a required, keyword-only argument >= 0 */
4174 if (opobj != NULL) {
4175 op = _PyLong_AsInt(opobj);
4176 }
4177 if (op < 0) {
4178 /* override exception from _PyLong_AsInt() */
4179 PyErr_SetString(PyExc_TypeError,
4180 "Invalid or missing argument 'op'");
4181 goto finally;
4182 }
4183 /* assoclen is optional but must be >= 0 */
4184 if (assoclenobj != NULL) {
4185 assoclen = _PyLong_AsInt(assoclenobj);
4186 if (assoclen == -1 && PyErr_Occurred()) {
4187 goto finally;
4188 }
4189 if (assoclen < 0) {
4190 PyErr_SetString(PyExc_TypeError,
4191 "assoclen must be positive");
4192 goto finally;
4193 }
4194 }
4195
4196 controllen = CMSG_SPACE(4);
4197 if (iv.buf != NULL) {
4198 controllen += CMSG_SPACE(sizeof(*alg_iv) + iv.len);
4199 }
4200 if (assoclen >= 0) {
4201 controllen += CMSG_SPACE(4);
4202 }
4203
4204 controlbuf = PyMem_Malloc(controllen);
4205 if (controlbuf == NULL) {
4206 return PyErr_NoMemory();
4207 }
4208 memset(controlbuf, 0, controllen);
4209
4210 memset(&msg, 0, sizeof(msg));
4211 msg.msg_controllen = controllen;
4212 msg.msg_control = controlbuf;
4213
4214 /* Fill in an iovec for each message part, and save the Py_buffer
4215 structs to release afterwards. */
4216 if (data_arg != NULL) {
4217 if (sock_sendmsg_iovec(self, data_arg, &msg, &databufs, &ndatabufs) == - 1) {
4218 goto finally;
4219 }
4220 }
4221
4222 /* set operation to encrypt or decrypt */
4223 header = CMSG_FIRSTHDR(&msg);
4224 if (header == NULL) {
4225 PyErr_SetString(PyExc_RuntimeError,
4226 "unexpected NULL result from CMSG_FIRSTHDR");
4227 goto finally;
4228 }
4229 header->cmsg_level = SOL_ALG;
4230 header->cmsg_type = ALG_SET_OP;
4231 header->cmsg_len = CMSG_LEN(4);
4232 uiptr = (void*)CMSG_DATA(header);
4233 *uiptr = (unsigned int)op;
4234
4235 /* set initialization vector */
4236 if (iv.buf != NULL) {
4237 header = CMSG_NXTHDR(&msg, header);
4238 if (header == NULL) {
4239 PyErr_SetString(PyExc_RuntimeError,
4240 "unexpected NULL result from CMSG_NXTHDR(iv)");
4241 goto finally;
4242 }
4243 header->cmsg_level = SOL_ALG;
4244 header->cmsg_type = ALG_SET_IV;
4245 header->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv.len);
4246 alg_iv = (void*)CMSG_DATA(header);
4247 alg_iv->ivlen = iv.len;
4248 memcpy(alg_iv->iv, iv.buf, iv.len);
4249 }
4250
4251 /* set length of associated data for AEAD */
4252 if (assoclen >= 0) {
4253 header = CMSG_NXTHDR(&msg, header);
4254 if (header == NULL) {
4255 PyErr_SetString(PyExc_RuntimeError,
4256 "unexpected NULL result from CMSG_NXTHDR(assoc)");
4257 goto finally;
4258 }
4259 header->cmsg_level = SOL_ALG;
4260 header->cmsg_type = ALG_SET_AEAD_ASSOCLEN;
4261 header->cmsg_len = CMSG_LEN(4);
4262 uiptr = (void*)CMSG_DATA(header);
4263 *uiptr = (unsigned int)assoclen;
4264 }
4265
4266 ctx.msg = &msg;
4267 ctx.flags = flags;
4268 if (sock_call(self, 1, sock_sendmsg_impl, &ctx) < 0)
4269 goto finally;
4270
4271 retval = PyLong_FromSsize_t(ctx.result);
4272
4273 finally:
4274 PyMem_Free(controlbuf);
4275 if (iv.buf != NULL) {
4276 PyBuffer_Release(&iv);
4277 }
4278 for (i = 0; i < ndatabufs; i++)
4279 PyBuffer_Release(&databufs[i]);
4280 PyMem_Free(databufs);
4281 return retval;
4282 }
4283
4284 PyDoc_STRVAR(sendmsg_afalg_doc,
4285 "sendmsg_afalg([msg], *, op[, iv[, assoclen[, flags=MSG_MORE]]])\n\
4286 \n\
4287 Set operation mode, IV and length of associated data for an AF_ALG\n\
4288 operation socket.");
4289 #endif
3998 4290
3999 /* s.shutdown(how) method */ 4291 /* s.shutdown(how) method */
4000 4292
4001 static PyObject * 4293 static PyObject *
4002 sock_shutdown(PySocketSockObject *s, PyObject *arg) 4294 sock_shutdown(PySocketSockObject *s, PyObject *arg)
4003 { 4295 {
4004 int how; 4296 int how;
4005 int res; 4297 int res;
4006 4298
4007 how = _PyLong_AsInt(arg); 4299 how = _PyLong_AsInt(arg);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 setsockopt_doc}, 4458 setsockopt_doc},
4167 {"shutdown", (PyCFunction)sock_shutdown, METH_O, 4459 {"shutdown", (PyCFunction)sock_shutdown, METH_O,
4168 shutdown_doc}, 4460 shutdown_doc},
4169 #ifdef CMSG_LEN 4461 #ifdef CMSG_LEN
4170 {"recvmsg", (PyCFunction)sock_recvmsg, METH_VARARGS, 4462 {"recvmsg", (PyCFunction)sock_recvmsg, METH_VARARGS,
4171 recvmsg_doc}, 4463 recvmsg_doc},
4172 {"recvmsg_into", (PyCFunction)sock_recvmsg_into, METH_VARARGS, 4464 {"recvmsg_into", (PyCFunction)sock_recvmsg_into, METH_VARARGS,
4173 recvmsg_into_doc,}, 4465 recvmsg_into_doc,},
4174 {"sendmsg", (PyCFunction)sock_sendmsg, METH_VARARGS, 4466 {"sendmsg", (PyCFunction)sock_sendmsg, METH_VARARGS,
4175 sendmsg_doc}, 4467 sendmsg_doc},
4468 #endif
4469 #ifdef HAVE_SOCKADDR_ALG
4470 {"sendmsg_afalg", (PyCFunction)sock_sendmsg_afalg, METH_VARARGS | METH_K EYWORDS,
4471 sendmsg_afalg_doc},
4176 #endif 4472 #endif
4177 {NULL, NULL} /* sentinel */ 4473 {NULL, NULL} /* sentinel */
4178 }; 4474 };
4179 4475
4180 /* SockObject members */ 4476 /* SockObject members */
4181 static PyMemberDef sock_memberlist[] = { 4477 static PyMemberDef sock_memberlist[] = {
4182 {"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "t he socket family"}, 4478 {"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"}, 4479 {"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the s ocket type"},
4184 {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"}, 4480 {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"},
4185 {0}, 4481 {0},
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
6269 /* Multiprotocol bridge */ 6565 /* Multiprotocol bridge */
6270 PyModule_AddIntMacro(m, AF_BRIDGE); 6566 PyModule_AddIntMacro(m, AF_BRIDGE);
6271 #endif 6567 #endif
6272 #ifdef AF_ATMPVC 6568 #ifdef AF_ATMPVC
6273 /* ATM PVCs */ 6569 /* ATM PVCs */
6274 PyModule_AddIntMacro(m, AF_ATMPVC); 6570 PyModule_AddIntMacro(m, AF_ATMPVC);
6275 #endif 6571 #endif
6276 #ifdef AF_AAL5 6572 #ifdef AF_AAL5
6277 /* Reserved for Werner's ATM */ 6573 /* Reserved for Werner's ATM */
6278 PyModule_AddIntMacro(m, AF_AAL5); 6574 PyModule_AddIntMacro(m, AF_AAL5);
6575 #endif
6576 #ifdef HAVE_SOCKADDR_ALG
6577 PyModule_AddIntMacro(m, AF_ALG); /* Linux crypto */
6279 #endif 6578 #endif
6280 #ifdef AF_X25 6579 #ifdef AF_X25
6281 /* Reserved for X.25 project */ 6580 /* Reserved for X.25 project */
6282 PyModule_AddIntMacro(m, AF_X25); 6581 PyModule_AddIntMacro(m, AF_X25);
6283 #endif 6582 #endif
6284 #ifdef AF_INET6 6583 #ifdef AF_INET6
6285 PyModule_AddIntMacro(m, AF_INET6); /* IP version 6 */ 6584 PyModule_AddIntMacro(m, AF_INET6); /* IP version 6 */
6286 #endif 6585 #endif
6287 #ifdef AF_ROSE 6586 #ifdef AF_ROSE
6288 /* Amateur Radio X.25 PLP */ 6587 /* Amateur Radio X.25 PLP */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6330 #endif 6629 #endif
6331 #ifdef NETLINK_ROUTE6 6630 #ifdef NETLINK_ROUTE6
6332 PyModule_AddIntMacro(m, NETLINK_ROUTE6); 6631 PyModule_AddIntMacro(m, NETLINK_ROUTE6);
6333 #endif 6632 #endif
6334 PyModule_AddIntMacro(m, NETLINK_IP6_FW); 6633 PyModule_AddIntMacro(m, NETLINK_IP6_FW);
6335 #ifdef NETLINK_DNRTMSG 6634 #ifdef NETLINK_DNRTMSG
6336 PyModule_AddIntMacro(m, NETLINK_DNRTMSG); 6635 PyModule_AddIntMacro(m, NETLINK_DNRTMSG);
6337 #endif 6636 #endif
6338 #ifdef NETLINK_TAPBASE 6637 #ifdef NETLINK_TAPBASE
6339 PyModule_AddIntMacro(m, NETLINK_TAPBASE); 6638 PyModule_AddIntMacro(m, NETLINK_TAPBASE);
6639 #endif
6640 #ifdef NETLINK_CRYPTO
6641 PyModule_AddIntMacro(m, NETLINK_CRYPTO);
6340 #endif 6642 #endif
6341 #endif /* AF_NETLINK */ 6643 #endif /* AF_NETLINK */
6342 #ifdef AF_ROUTE 6644 #ifdef AF_ROUTE
6343 /* Alias to emulate 4.4BSD */ 6645 /* Alias to emulate 4.4BSD */
6344 PyModule_AddIntMacro(m, AF_ROUTE); 6646 PyModule_AddIntMacro(m, AF_ROUTE);
6345 #endif 6647 #endif
6346 #ifdef AF_LINK 6648 #ifdef AF_LINK
6347 PyModule_AddIntMacro(m, AF_LINK); 6649 PyModule_AddIntMacro(m, AF_LINK);
6348 #endif 6650 #endif
6349 #ifdef AF_ASH 6651 #ifdef AF_ASH
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6482 #ifdef TIPC_SUB_CANCEL 6784 #ifdef TIPC_SUB_CANCEL
6483 /* doesn't seem to be available everywhere */ 6785 /* doesn't seem to be available everywhere */
6484 PyModule_AddIntMacro(m, TIPC_SUB_CANCEL); 6786 PyModule_AddIntMacro(m, TIPC_SUB_CANCEL);
6485 #endif 6787 #endif
6486 PyModule_AddIntMacro(m, TIPC_WAIT_FOREVER); 6788 PyModule_AddIntMacro(m, TIPC_WAIT_FOREVER);
6487 PyModule_AddIntMacro(m, TIPC_PUBLISHED); 6789 PyModule_AddIntMacro(m, TIPC_PUBLISHED);
6488 PyModule_AddIntMacro(m, TIPC_WITHDRAWN); 6790 PyModule_AddIntMacro(m, TIPC_WITHDRAWN);
6489 PyModule_AddIntMacro(m, TIPC_SUBSCR_TIMEOUT); 6791 PyModule_AddIntMacro(m, TIPC_SUBSCR_TIMEOUT);
6490 PyModule_AddIntMacro(m, TIPC_CFG_SRV); 6792 PyModule_AddIntMacro(m, TIPC_CFG_SRV);
6491 PyModule_AddIntMacro(m, TIPC_TOP_SRV); 6793 PyModule_AddIntMacro(m, TIPC_TOP_SRV);
6794 #endif
6795
6796 #ifdef HAVE_SOCKADDR_ALG
6797 /* Socket options */
6798 PyModule_AddIntMacro(m, ALG_SET_KEY);
6799 PyModule_AddIntMacro(m, ALG_SET_IV);
6800 PyModule_AddIntMacro(m, ALG_SET_OP);
6801 PyModule_AddIntMacro(m, ALG_SET_AEAD_ASSOCLEN);
6802 PyModule_AddIntMacro(m, ALG_SET_AEAD_AUTHSIZE);
6803 PyModule_AddIntMacro(m, ALG_SET_PUBKEY);
6804
6805 /* Operations */
6806 PyModule_AddIntMacro(m, ALG_OP_DECRYPT);
6807 PyModule_AddIntMacro(m, ALG_OP_ENCRYPT);
6808 PyModule_AddIntMacro(m, ALG_OP_SIGN);
6809 PyModule_AddIntMacro(m, ALG_OP_VERIFY);
6492 #endif 6810 #endif
6493 6811
6494 /* Socket types */ 6812 /* Socket types */
6495 PyModule_AddIntMacro(m, SOCK_STREAM); 6813 PyModule_AddIntMacro(m, SOCK_STREAM);
6496 PyModule_AddIntMacro(m, SOCK_DGRAM); 6814 PyModule_AddIntMacro(m, SOCK_DGRAM);
6497 /* We have incomplete socket support. */ 6815 /* We have incomplete socket support. */
6498 #ifdef SOCK_RAW 6816 #ifdef SOCK_RAW
6499 /* SOCK_RAW is marked as optional in the POSIX specification */ 6817 /* SOCK_RAW is marked as optional in the POSIX specification */
6500 PyModule_AddIntMacro(m, SOCK_RAW); 6818 PyModule_AddIntMacro(m, SOCK_RAW);
6501 #endif 6819 #endif
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
6753 PyModule_AddIntConstant(m, "CAN_BCM_RX_DELETE", RX_DELETE); 7071 PyModule_AddIntConstant(m, "CAN_BCM_RX_DELETE", RX_DELETE);
6754 PyModule_AddIntConstant(m, "CAN_BCM_RX_READ", RX_READ); 7072 PyModule_AddIntConstant(m, "CAN_BCM_RX_READ", RX_READ);
6755 PyModule_AddIntConstant(m, "CAN_BCM_TX_STATUS", TX_STATUS); 7073 PyModule_AddIntConstant(m, "CAN_BCM_TX_STATUS", TX_STATUS);
6756 PyModule_AddIntConstant(m, "CAN_BCM_TX_EXPIRED", TX_EXPIRED); 7074 PyModule_AddIntConstant(m, "CAN_BCM_TX_EXPIRED", TX_EXPIRED);
6757 PyModule_AddIntConstant(m, "CAN_BCM_RX_STATUS", RX_STATUS); 7075 PyModule_AddIntConstant(m, "CAN_BCM_RX_STATUS", RX_STATUS);
6758 PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT); 7076 PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT);
6759 PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED); 7077 PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED);
6760 #endif 7078 #endif
6761 #ifdef SOL_RDS 7079 #ifdef SOL_RDS
6762 PyModule_AddIntMacro(m, SOL_RDS); 7080 PyModule_AddIntMacro(m, SOL_RDS);
7081 #endif
7082 #ifdef HAVE_SOCKADDR_ALG
7083 PyModule_AddIntMacro(m, SOL_ALG);
6763 #endif 7084 #endif
6764 #ifdef RDS_CANCEL_SENT_TO 7085 #ifdef RDS_CANCEL_SENT_TO
6765 PyModule_AddIntMacro(m, RDS_CANCEL_SENT_TO); 7086 PyModule_AddIntMacro(m, RDS_CANCEL_SENT_TO);
6766 #endif 7087 #endif
6767 #ifdef RDS_GET_MR 7088 #ifdef RDS_GET_MR
6768 PyModule_AddIntMacro(m, RDS_GET_MR); 7089 PyModule_AddIntMacro(m, RDS_GET_MR);
6769 #endif 7090 #endif
6770 #ifdef RDS_FREE_MR 7091 #ifdef RDS_FREE_MR
6771 PyModule_AddIntMacro(m, RDS_FREE_MR); 7092 PyModule_AddIntMacro(m, RDS_FREE_MR);
6772 #endif 7093 #endif
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
7370 return NULL; 7691 return NULL;
7371 memcpy(&packed_addr, src, sizeof(packed_addr)); 7692 memcpy(&packed_addr, src, sizeof(packed_addr));
7372 return strncpy(dst, inet_ntoa(packed_addr), size); 7693 return strncpy(dst, inet_ntoa(packed_addr), size);
7373 } 7694 }
7374 /* Should set errno to EAFNOSUPPORT */ 7695 /* Should set errno to EAFNOSUPPORT */
7375 return NULL; 7696 return NULL;
7376 } 7697 }
7377 7698
7378 #endif 7699 #endif
7379 #endif 7700 #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+