diff options
author | Greg Bowser <topnotcher@gmail.com> | 2019-08-02 20:29:52 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@python.org> | 2019-08-02 20:29:52 (GMT) |
commit | 8fbece135d7615e836a845ca39223097046c8b8b (patch) | |
tree | 1fa62c02a29b7aa27de4a2d495c4358dc9c4693a /Modules/socketmodule.h | |
parent | cb65b3a4f484ce71dcb76a918af98c7015513025 (diff) | |
download | cpython-8fbece135d7615e836a845ca39223097046c8b8b.zip cpython-8fbece135d7615e836a845ca39223097046c8b8b.tar.gz cpython-8fbece135d7615e836a845ca39223097046c8b8b.tar.bz2 |
bpo-36590: Add Bluetooth RFCOMM and support for Windows. (GH-12767)
Support for RFCOMM, L2CAP, HCI, SCO is based on the BTPROTO_* macros
being defined. Winsock only supports RFCOMM, even though it has a
BTHPROTO_L2CAP macro. L2CAP support would build on windows, but not
necessarily work.
This also adds some basic unittests for constants (all of which existed
prior to this commit, just not on windows) and creating sockets.
pair: Nate Duarte <slacknate@gmail.com>
Diffstat (limited to 'Modules/socketmodule.h')
-rwxr-xr-x[-rw-r--r--] | Modules/socketmodule.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h index dff1f8f..3d95fe7 100644..100755 --- a/Modules/socketmodule.h +++ b/Modules/socketmodule.h @@ -14,6 +14,47 @@ #else /* MS_WINDOWS */ # include <winsock2.h> + +/* + * If Windows has bluetooth support, include bluetooth constants. + */ +#ifdef AF_BTH +# include <ws2bth.h> +# include <pshpack1.h> + +/* + * The current implementation assumes the bdaddr in the sockaddr structs + * will be a bdaddr_t. We treat this as an opaque type: on *nix systems, it + * will be a struct with a single member (an array of six bytes). On windows, + * we typedef this to ULONGLONG to match the Windows definition. + */ +typedef ULONGLONG bdaddr_t; + +/* + * Redefine SOCKADDR_BTH to provide names compatible with _BT_RC_MEMB() macros. + */ +struct SOCKADDR_BTH_REDEF { + union { + USHORT addressFamily; + USHORT family; + }; + + union { + ULONGLONG btAddr; + bdaddr_t bdaddr; + }; + + GUID serviceClassId; + + union { + ULONG port; + ULONG channel; + }; + +}; +# include <poppack.h> +#endif + /* Windows 'supports' CMSG_LEN, but does not follow the POSIX standard * interface at all, so there is no point including the code that * attempts to use it. @@ -199,6 +240,8 @@ typedef union sock_addr { struct sockaddr_rc bt_rc; struct sockaddr_sco bt_sco; struct sockaddr_hci bt_hci; +#elif defined(MS_WINDOWS) + struct SOCKADDR_BTH_REDEF bt_rc; #endif #ifdef HAVE_NETPACKET_PACKET_H struct sockaddr_ll ll; |