From: Vibhav Pant vibhavp@gmail.com
--- configure | 19 +++++++++++++++ configure.ac | 8 +++++++ dlls/ws2_32/socket.c | 15 ++++++++++++ dlls/ws2_32/tests/sock.c | 3 +-- include/config.h.in | 6 +++++ server/sock.c | 50 +++++++++++++++++++++++++++++++++++++--- 6 files changed, 96 insertions(+), 5 deletions(-)
diff --git a/configure b/configure index 763ba364d3e..1d605f5536a 100755 --- a/configure +++ b/configure @@ -7703,6 +7703,12 @@ if test "x$ac_cv_header_asm_user_h" = xyes then : printf "%s\n" "#define HAVE_ASM_USER_H 1" >>confdefs.h
+fi +ac_fn_c_check_header_compile "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default" +if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes +then : + printf "%s\n" "#define HAVE_BLUETOOTH_BLUETOOTH_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "elf.h" "ac_cv_header_elf_h" "$ac_includes_default" if test "x$ac_cv_header_elf_h" = xyes @@ -8831,6 +8837,19 @@ then : fi
+ac_fn_c_check_header_compile "$LINENO" "bluetooth/rfcomm.h" "ac_cv_header_bluetooth_rfcomm_h" " +#ifdef HAVE_BLUETOOTH_BLUETOOTH_H +#include <bluetooth/bluetooth.h> +#endif + +" +if test "x$ac_cv_header_bluetooth_rfcomm_h" = xyes +then : + printf "%s\n" "#define HAVE_BLUETOOTH_RFCOMM_H 1" >>confdefs.h + +fi + + if test "x$ac_cv_header_sys_xattr_h" = xyes then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether getxattr takes additional arguments" >&5 diff --git a/configure.ac b/configure.ac index 9e32070f610..2c6b4835648 100644 --- a/configure.ac +++ b/configure.ac @@ -379,6 +379,7 @@ AC_CHECK_HEADERS(\ asm/termbits.h \ asm/types.h \ asm/user.h \ + bluetooth/bluetooth.h \ elf.h \ gettext-po.h \ link.h \ @@ -581,6 +582,13 @@ AC_CHECK_HEADERS([libprocstat.h],,, #include <sys/queue.h> #endif])
+AC_CHECK_HEADERS([bluetooth/rfcomm.h],,, +[ +#ifdef HAVE_BLUETOOTH_BLUETOOTH_H +#include <bluetooth/bluetooth.h> +#endif +]) + if test "x$ac_cv_header_sys_xattr_h" = xyes then AC_CACHE_CHECK([whether getxattr takes additional arguments], wine_cv_xattr_extra_args, diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index eb61c588c58..4170d89c255 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -167,6 +167,21 @@ static const WSAPROTOCOL_INFOW supported_protocols[] = .dwMessageSize = UINT_MAX, .szProtocol = L"SPX II", }, + { + .dwServiceFlags1 = XP1_IFS_HANDLES | XP1_GRACEFUL_CLOSE | XP1_GUARANTEED_ORDER | + XP1_GUARANTEED_DELIVERY, + .dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO, + .ProviderId = {0x9fc48064, 0x7298, 0x43e4, {0xb7, 0xbd, 0x18, 0x1f, 0x20, 0x89, 0x79, 0x2a}}, + .dwCatalogEntryId = 1040, + .ProtocolChain.ChainLen = 1, + .iVersion = 2, + .iAddressFamily = AF_BTH, + .iMinSockAddr = sizeof(SOCKADDR_BTH), + .iMaxSockAddr = sizeof(SOCKADDR_BTH), + .iSocketType = SOCK_STREAM, + .iProtocol = BTHPROTO_RFCOMM, + .szProtocol = L"MSAFD RfComm [Bluetooth]", + }, };
DECLARE_CRITICAL_SECTION(cs_socket_list); diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 0cfe1b62155..578cc2e6907 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -3383,8 +3383,7 @@ static void test_WSASocket(void) { SetLastError( 0xdeadbeef ); sock = WSASocketA( tests[i].family, tests[i].type, tests[i].protocol, NULL, 0, 0 ); - todo_wine_if (i == 7) - ok(WSAGetLastError() == tests[i].error, "Test %u: got wrong error %u\n", i, WSAGetLastError()); + ok(WSAGetLastError() == tests[i].error, "Test %u: got wrong error %u\n", i, WSAGetLastError()); if (tests[i].error) { ok(sock == INVALID_SOCKET, "Test %u: expected failure\n", i); diff --git a/include/config.h.in b/include/config.h.in index a9a282040f3..7ac924a077c 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -21,6 +21,12 @@ /* Define to 1 if you have the <asm/user.h> header file. */ #undef HAVE_ASM_USER_H
+/* Define to 1 if you have the <bluetooth/bluetooth.h> header file. */ +#undef HAVE_BLUETOOTH_BLUETOOTH_H + +/* Define to 1 if you have the <bluetooth/rfcomm.h> header file. */ +#undef HAVE_BLUETOOTH_RFCOMM_H + /* Define to 1 if you have the <capi20.h> header file. */ #undef HAVE_CAPI20_H
diff --git a/server/sock.c b/server/sock.c index 32d622aaebc..b77d3d19013 100644 --- a/server/sock.c +++ b/server/sock.c @@ -87,6 +87,14 @@ # define HAS_IRDA #endif
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H +# include <bluetooth/bluetooth.h> +# ifdef HAVE_BLUETOOTH_RFCOMM_H +# include <bluetooth/rfcomm.h> +# define HAS_BLUETOOTH +# endif +#endif + #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" @@ -98,6 +106,10 @@ #include "tcpmib.h" #include "wsipx.h" #include "af_irda.h" +#include "bthsdpdef.h" +#include "bluetoothapis.h" +#include "bthdef.h" +#include "ws2bth.h" #include "wine/afd.h" #include "wine/rbtree.h"
@@ -148,6 +160,9 @@ union unix_sockaddr #ifdef HAS_IRDA struct sockaddr_irda irda; #endif +#ifdef HAS_BLUETOOTH + struct sockaddr_rc rfcomm; +#endif };
static struct list poll_list = LIST_INIT( poll_list ); @@ -569,6 +584,21 @@ static int sockaddr_from_unix( const union unix_sockaddr *uaddr, struct WS_socka } #endif
+#ifdef HAS_BLUETOOTH + case AF_BLUETOOTH: + { + SOCKADDR_BTH win = {0}; + BLUETOOTH_ADDRESS addr = {0}; + + if (wsaddrlen < sizeof(win)) return -1; + win.addressFamily = WS_AF_BTH; + + memcpy( addr.rgBytes, uaddr->rfcomm.rc_bdaddr.b, sizeof( addr.rgBytes )); + win.btAddr = addr.ullLong; + win.port = uaddr->rfcomm.rc_channel; + return sizeof(win); + } +#endif case AF_UNSPEC: return 0;
@@ -1794,6 +1824,9 @@ static int get_unix_family( int family ) #endif #ifdef AF_IRDA case WS_AF_IRDA: return AF_IRDA; +#endif +#ifdef AF_BLUETOOTH + case WS_AF_BTH: return AF_BLUETOOTH; #endif case WS_AF_UNSPEC: return AF_UNSPEC; default: return -1; @@ -1811,11 +1844,16 @@ static int get_unix_type( int type ) } }
-static int get_unix_protocol( int protocol ) +static int get_unix_protocol( int family, int protocol ) { if (protocol >= WS_NSPROTO_IPX && protocol <= WS_NSPROTO_IPX + 255) return protocol;
+#ifdef HAS_BLUETOOTH + if (family == WS_AF_BTH) + return protocol == WS_BTHPROTO_RFCOMM ? BTPROTO_RFCOMM : -1; +#endif + switch (protocol) { case WS_IPPROTO_ICMP: return IPPROTO_ICMP; @@ -1868,11 +1906,13 @@ static int init_socket( struct sock *sock, int family, int type, int protocol )
unix_family = get_unix_family( family ); unix_type = get_unix_type( type ); - unix_protocol = get_unix_protocol( protocol ); + unix_protocol = get_unix_protocol( family, protocol );
if (unix_protocol < 0) { - if (type && unix_type < 0) + if (family && unix_family < 0) + set_win32_error( WSAEAFNOSUPPORT ); + else if (type && unix_type < 0) set_win32_error( WSAESOCKTNOSUPPORT ); else set_win32_error( WSAEPROTONOSUPPORT ); @@ -1908,6 +1948,10 @@ static int init_socket( struct sock *sock, int family, int type, int protocol ) if (sockfd == -1) { if (errno == EINVAL) set_win32_error( WSAESOCKTNOSUPPORT ); +#ifdef AF_BLUETOOTH + else if (errno == ESOCKTNOSUPPORT && unix_family == AF_BLUETOOTH) + set_win32_error( WSAEAFNOSUPPORT ); +#endif else set_win32_error( sock_get_error( errno )); return -1; }