Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ created. Socket addresses are represented as follows:

- :const:`BTPROTO_SCO` accepts ``bdaddr`` where ``bdaddr`` is a
:class:`bytes` object containing the Bluetooth address in a
string format. (ex. ``b'12:23:34:45:56:67'``) This protocol is not
supported under FreeBSD.
string format. (ex. ``b'12:23:34:45:56:67'``)

.. versionchanged:: next
FreeBSD support added.

- :const:`AF_ALG` is a Linux-only socket based interface to Kernel
cryptography. An algorithm socket is configured with a tuple of two to four
Expand Down
7 changes: 2 additions & 5 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2619,9 +2619,7 @@ def testBluetoothConstants(self):
socket.BTPROTO_HCI
socket.SOL_HCI
socket.BTPROTO_L2CAP

if not sys.platform.startswith("freebsd"):
socket.BTPROTO_SCO
socket.BTPROTO_SCO

def testCreateRfcommSocket(self):
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:
Expand All @@ -2637,8 +2635,7 @@ def testCreateHciSocket(self):
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI) as s:
pass

@unittest.skipIf(sys.platform == "win32" or sys.platform.startswith("freebsd"),
"windows and freebsd do not support SCO sockets")
@unittest.skipIf(sys.platform == "win32", "windows does not support SCO sockets")
def testCreateScoSocket(self):
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_SCO) as s:
pass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for :data:`~socket.BTPROTO_SCO` in sockets on FreeBSD.
16 changes: 8 additions & 8 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,15 +1536,15 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
return ret;
#endif
}
#endif /* BTPROTO_HCI */

#if !defined(__FreeBSD__)
#ifdef BTPROTO_SCO
case BTPROTO_SCO:
{
struct sockaddr_sco *a = (struct sockaddr_sco *) addr;
return makebdaddr(&_BT_SCO_MEMB(a, bdaddr));
}
#endif /* !__FreeBSD__ */
#endif /* BTPROTO_HCI */
#endif /* BTPROTO_SCO */

default:
PyErr_SetString(PyExc_ValueError,
Expand Down Expand Up @@ -2149,7 +2149,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
*len_ret = sizeof *addr;
return 1;
}
#if !defined(__FreeBSD__)
#endif /* BTPROTO_HCI */
#ifdef BTPROTO_SCO
case BTPROTO_SCO:
{
const char *straddr;
Expand All @@ -2168,8 +2169,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
*len_ret = sizeof *addr;
return 1;
}
#endif /* !__FreeBSD__ */
#endif /* BTPROTO_HCI */
#endif /* BTPROTO_SCO */
default:
PyErr_Format(PyExc_OSError,
"%s(): unknown Bluetooth protocol", caller);
Expand Down Expand Up @@ -2719,11 +2719,11 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
case BTPROTO_HCI:
*len_ret = sizeof (struct sockaddr_hci);
return 1;
#if !defined(__FreeBSD__)
#endif /* BTPROTO_HCI */
#ifdef BTPROTO_SCO
case BTPROTO_SCO:
*len_ret = sizeof (struct sockaddr_sco);
return 1;
#endif /* !__FreeBSD__ */
#endif /* BTPROTO_HCI */
default:
PyErr_SetString(PyExc_OSError, "getsockaddrlen: "
Expand Down
Loading