| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,8 +164,10 @@ created. Socket addresses are represented as follows: | |||
| 164 | 164 | ||
| 165 | 165 | - :const:`BTPROTO_SCO` accepts ``bdaddr`` where ``bdaddr`` is a | |
| 166 | 166 | :class:`bytes` object containing the Bluetooth address in a | |
| 167 | - string format. (ex. ``b'12:23:34:45:56:67'``) This protocol is not | ||
| 168 | - supported under FreeBSD. | ||
| 167 | + string format. (ex. ``b'12:23:34:45:56:67'``) | ||
| 168 | + | ||
| 169 | + .. versionchanged:: next | ||
| 170 | + FreeBSD support added. | ||
| 169 | 171 | ||
| 170 | 172 | - :const:`AF_ALG` is a Linux-only socket based interface to Kernel | |
| 171 | 173 | cryptography. An algorithm socket is configured with a tuple of two to four | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2620,9 +2620,7 @@ def testBluetoothConstants(self): | |||
| 2620 | 2620 | socket.BTPROTO_HCI | |
| 2621 | 2621 | socket.SOL_HCI | |
| 2622 | 2622 | socket.BTPROTO_L2CAP | |
| 2623 | - | ||
| 2624 | - if not sys.platform.startswith("freebsd"): | ||
| 2625 | - socket.BTPROTO_SCO | ||
| 2623 | + socket.BTPROTO_SCO | ||
| 2626 | 2624 | ||
| 2627 | 2625 | def testCreateRfcommSocket(self): | |
| 2628 | 2626 | with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s: | |
@@ -2638,8 +2636,7 @@ def testCreateHciSocket(self): | |||
| 2638 | 2636 | with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI) as s: | |
| 2639 | 2637 | pass | |
| 2640 | 2638 | ||
| 2641 | - @unittest.skipIf(sys.platform == "win32" or sys.platform.startswith("freebsd"), | ||
| 2642 | - "windows and freebsd do not support SCO sockets") | ||
| 2639 | + @unittest.skipIf(sys.platform == "win32", "windows does not support SCO sockets") | ||
| 2643 | 2640 | def testCreateScoSocket(self): | |
| 2644 | 2641 | with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_SCO) as s: | |
| 2645 | 2642 | pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Add support for :data:`~socket.BTPROTO_SCO` in sockets on FreeBSD. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -466,6 +466,7 @@ remove_unusable_flags(PyObject *m) | |||
| 466 | 466 | #define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP | |
| 467 | 467 | #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM | |
| 468 | 468 | #define BTPROTO_HCI BLUETOOTH_PROTO_HCI | |
| 469 | + #define BTPROTO_SCO BLUETOOTH_PROTO_SCO | ||
| 469 | 470 | #define SOL_HCI SOL_HCI_RAW | |
| 470 | 471 | #define HCI_FILTER SO_HCI_RAW_FILTER | |
| 471 | 472 | #define sockaddr_l2 sockaddr_l2cap | |
@@ -474,6 +475,7 @@ remove_unusable_flags(PyObject *m) | |||
| 474 | 475 | #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) | |
| 475 | 476 | #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) | |
| 476 | 477 | #define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb) | |
| 478 | + #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb) | ||
| 477 | 479 | #elif defined(__NetBSD__) || defined(__DragonFly__) | |
| 478 | 480 | #define sockaddr_l2 sockaddr_bt | |
| 479 | 481 | #define sockaddr_rc sockaddr_bt | |
@@ -1536,15 +1538,15 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) | |||
| 1536 | 1538 | return ret; | |
| 1537 | 1539 | #endif | |
| 1538 | 1540 | } | |
| 1541 | + #endif /* BTPROTO_HCI */ | ||
| 1539 | 1542 | ||
| 1540 | - #if !defined(__FreeBSD__) | ||
| 1543 | + #ifdef BTPROTO_SCO | ||
| 1541 | 1544 | case BTPROTO_SCO: | |
| 1542 | 1545 | { | |
| 1543 | 1546 | struct sockaddr_sco *a = (struct sockaddr_sco *) addr; | |
| 1544 | 1547 | return makebdaddr(&_BT_SCO_MEMB(a, bdaddr)); | |
| 1545 | 1548 | } | |
| 1546 | - #endif /* !__FreeBSD__ */ | ||
| 1547 | - #endif /* BTPROTO_HCI */ | ||
| 1549 | + #endif /* BTPROTO_SCO */ | ||
| 1548 | 1550 | ||
| 1549 | 1551 | default: | |
| 1550 | 1552 | PyErr_SetString(PyExc_ValueError, | |
@@ -2156,7 +2158,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, | |||
| 2156 | 2158 | *len_ret = sizeof *addr; | |
| 2157 | 2159 | return 1; | |
| 2158 | 2160 | } | |
| 2159 | - #if !defined(__FreeBSD__) | ||
| 2161 | + #endif /* BTPROTO_HCI */ | ||
| 2162 | + #ifdef BTPROTO_SCO | ||
| 2160 | 2163 | case BTPROTO_SCO: | |
| 2161 | 2164 | { | |
| 2162 | 2165 | const char *straddr; | |
@@ -2176,8 +2179,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, | |||
| 2176 | 2179 | *len_ret = sizeof *addr; | |
| 2177 | 2180 | return 1; | |
| 2178 | 2181 | } | |
| 2179 | - #endif /* !__FreeBSD__ */ | ||
| 2180 | - #endif /* BTPROTO_HCI */ | ||
| 2182 | + #endif /* BTPROTO_SCO */ | ||
| 2181 | 2183 | default: | |
| 2182 | 2184 | PyErr_Format(PyExc_OSError, | |
| 2183 | 2185 | "%s(): unknown Bluetooth protocol", caller); | |
@@ -2732,11 +2734,11 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret) | |||
| 2732 | 2734 | case BTPROTO_HCI: | |
| 2733 | 2735 | *len_ret = sizeof (struct sockaddr_hci); | |
| 2734 | 2736 | return 1; | |
| 2735 | - #if !defined(__FreeBSD__) | ||
| 2737 | + #endif /* BTPROTO_HCI */ | ||
| 2738 | + #ifdef BTPROTO_SCO | ||
| 2736 | 2739 | case BTPROTO_SCO: | |
| 2737 | 2740 | *len_ret = sizeof (struct sockaddr_sco); | |
| 2738 | 2741 | return 1; | |
| 2739 | - #endif /* !__FreeBSD__ */ | ||
| 2740 | 2742 | #endif /* BTPROTO_HCI */ | |
| 2741 | 2743 | default: | |
| 2742 | 2744 | PyErr_SetString(PyExc_OSError, "getsockaddrlen: " | |
| Back | FazBrowse Home | New Git URL |
0 commit comments