From: Vibhav Pant vibhavp@gmail.com
--- dlls/ws2_32/protocol.c | 14 ++++++++++++ dlls/ws2_32/socket.c | 11 ++++++++++ dlls/ws2_32/ws2_32_private.h | 3 +++ include/Makefile.in | 1 + include/ws2bth.h | 42 ++++++++++++++++++++++++++++++++++++ include/ws2def.h | 6 ++++-- 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 include/ws2bth.h
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 0b123136988..ca31ac800c5 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -23,6 +23,7 @@ */
#include "ws2_32_private.h" +#include "ws2bth.h"
WINE_DEFAULT_DEBUG_CHANNEL(winsock); WINE_DECLARE_DEBUG_CHANNEL(winediag); @@ -1794,7 +1795,20 @@ int WINAPI WSAAddressToStringA( struct sockaddr *addr, DWORD addr_len, sprintf( buffer + strlen( buffer ), "]:%u", ntohs( addr6->sin6_port ) ); break; } + case AF_BTH: + { + const SOCKADDR_BTH *sockaddr_bth = (const SOCKADDR_BTH *)addr; + BLUETOOTH_ADDRESS addr_bth = {0}; + + if (addr_len < sizeof(SOCKADDR_BTH)) return -1;
+ addr_bth.ullLong = sockaddr_bth->btAddr; + sprintf( buffer, "(%02X:%02X:%02X:%02X:%02X:%02X)", addr_bth.rgBytes[5], addr_bth.rgBytes[4], + addr_bth.rgBytes[3], addr_bth.rgBytes[2], addr_bth.rgBytes[1], addr_bth.rgBytes[0] ); + if (sockaddr_bth->port) + sprintf( buffer + 19, ":%lu", sockaddr_bth->port ); + break; + } default: SetLastError( WSAEINVAL ); return -1; diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index eb84558cbac..eb61c588c58 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -226,6 +226,17 @@ const char *debugstr_sockaddr( const struct sockaddr *a ) addr, ((const SOCKADDR_IRDA *)a)->irdaServiceName); } + case AF_BTH: + { + const SOCKADDR_BTH *addr = (SOCKADDR_BTH *)a; + BLUETOOTH_ADDRESS bth_addr = {0}; + + bth_addr.ullLong = addr->btAddr; + return wine_dbg_sprintf( "{ family AF_BTH, addr %02X:%02X:%02X:%02X:%02X:%02X, serviceClassId %s, port %ld }", + bth_addr.rgBytes[5], bth_addr.rgBytes[4], bth_addr.rgBytes[3], bth_addr.rgBytes[2], + bth_addr.rgBytes[1], bth_addr.rgBytes[0], wine_dbgstr_guid( &addr->serviceClassId ), + addr->port ); + } default: return wine_dbg_sprintf("{ family %d }", a->sa_family); } diff --git a/dlls/ws2_32/ws2_32_private.h b/dlls/ws2_32/ws2_32_private.h index 9e116de814d..9a4d0794151 100644 --- a/dlls/ws2_32/ws2_32_private.h +++ b/dlls/ws2_32/ws2_32_private.h @@ -36,6 +36,9 @@ #include "winnls.h" #include "winsock2.h" #include "mswsock.h" +#include "bthsdpdef.h" +#include "bluetoothapis.h" +#include "ws2bth.h" #include "ws2tcpip.h" #include "ws2spi.h" #include "wsipx.h" diff --git a/include/Makefile.in b/include/Makefile.in index 5938a0b05ba..6231c37fd2c 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1021,6 +1021,7 @@ SOURCES = \ wownt16.h \ wownt32.h \ wpcapi.idl \ + ws2bth.h \ ws2def.h \ ws2ipdef.h \ ws2spi.h \ diff --git a/include/ws2bth.h b/include/ws2bth.h new file mode 100644 index 00000000000..dfc6d8f608f --- /dev/null +++ b/include/ws2bth.h @@ -0,0 +1,42 @@ +/* + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WS2BTH_H__ +#define __WS2BTH_H__ + +#include <pshpack1.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _SOCKADDR_BTH +{ + USHORT addressFamily; + BTH_ADDR btAddr; + GUID serviceClassId; + ULONG port; +} SOCKADDR_BTH, *PSOCKADDR_BTH; + +#ifdef __cplusplus +} +#endif + +#include <poppack.h> + +#endif /* __WS2BTH_H__ */ diff --git a/include/ws2def.h b/include/ws2def.h index 46fb80db470..dd3892f9424 100644 --- a/include/ws2def.h +++ b/include/ws2def.h @@ -65,7 +65,8 @@ typedef struct WS(sockaddr) #define AF_CLUSTER 24 #define AF_12844 25 #define AF_IRDA 26 -#define AF_MAX 27 +#define AF_BTH 32 +#define AF_MAX 33 #else /* USE_WS_PREFIX */ #define WS_AF_UNSPEC 0 #define WS_AF_UNIX 1 @@ -96,7 +97,8 @@ typedef struct WS(sockaddr) #define WS_AF_CLUSTER 24 #define WS_AF_12844 25 #define WS_AF_IRDA 26 -#define WS_AF_MAX 27 +#define WS_AF_BTH 32 +#define WS_AF_MAX 33 #endif /* USE_WS_PREFIX */
#ifndef USE_WS_PREFIX