master
  1/**
  2 * This file has no copyright assigned and is placed in the Public Domain.
  3 * This file is part of the mingw-w64 runtime package.
  4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5 */
  6#ifndef _INC_BLUETOOTHAPIS
  7#define _INC_BLUETOOTHAPIS
  8
  9#include <_mingw.h>
 10#include <bthdef.h>
 11#include <bthsdpdef.h>
 12
 13#define BLUETOOTH_MAX_NAME_SIZE 248
 14#define BLUETOOTH_MAX_PASSKEY_SIZE 16
 15#define BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE (BLUETOOTH_MAX_PASSKEY_SIZE + 1)
 16#define BLUETOOTH_MAX_SERVICE_NAME_SIZE 256
 17#define BLUETOOTH_DEVICE_NAME_SIZE 256
 18
 19#define BLUETOOTH_SERVICE_DISABLE 0x00
 20#define BLUETOOTH_SERVICE_ENABLE 0x01
 21#define BLUETOOTH_SERVICE_MASK (BLUETOOTH_SERVICE_DISABLE | BLUETOOTH_SERVICE_ENABLE)
 22
 23#ifdef __cplusplus
 24extern "C" {
 25#endif
 26
 27typedef LPVOID HBLUETOOTH_DEVICE_FIND;
 28typedef LPVOID HBLUETOOTH_RADIO_FIND;
 29typedef LPVOID HBLUETOOTH_AUTHENTICATION_REGISTRATION;
 30typedef LPVOID HBLUETOOTH_CONTAINER_ELEMENT;
 31
 32typedef struct _BLUETOOTH_ADDRESS {
 33  __C89_NAMELESS union {
 34    BTH_ADDR ullLong;
 35    BYTE     rgBytes[6];
 36  };
 37} BLUETOOTH_ADDRESS_STRUCT;
 38
 39#define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT
 40
 41#define BLUETOOTH_NULL_ADDRESS ((ULONGLONG)0x0)
 42
 43typedef struct _BLUETOOTH_COD_PAIRS {
 44  ULONG   ulCODMask;
 45  LPCWSTR pcszDescription;
 46} BLUETOOTH_COD_PAIRS;
 47
 48typedef struct _BLUETOOTH_DEVICE_INFO {
 49  DWORD             dwSize;
 50  BLUETOOTH_ADDRESS Address;
 51  ULONG             ulClassofDevice;
 52  WINBOOL           fConnected;
 53  WINBOOL           fRemembered;
 54  WINBOOL           fAuthenticated;
 55  SYSTEMTIME        stLastSeen;
 56  SYSTEMTIME        stLastUsed;
 57  WCHAR             szName[BLUETOOTH_MAX_NAME_SIZE];
 58} BLUETOOTH_DEVICE_INFO_STRUCT;
 59
 60#define BLUETOOTH_DEVICE_INFO BLUETOOTH_DEVICE_INFO_STRUCT
 61
 62typedef BLUETOOTH_DEVICE_INFO *PBLUETOOTH_DEVICE_INFO;
 63
 64typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS {
 65  DWORD     dwSize;
 66  WINBOOL   fReturnAuthenticated;
 67  WINBOOL   fReturnRemembered;
 68  WINBOOL   fReturnUnknown;
 69  WINBOOL   fReturnConnected;
 70  WINBOOL   fIssueInquiry;
 71  UCHAR     cTimeoutMultiplier;
 72  HANDLE    hRadio;
 73} BLUETOOTH_DEVICE_SEARCH_PARAMS;
 74
 75typedef struct _BLUETOOTH_FIND_RADIO_PARAMS {
 76  DWORD dwSize;
 77} BLUETOOTH_FIND_RADIO_PARAMS;
 78
 79typedef struct _BLUETOOTH_RADIO_INFO {
 80  DWORD             dwSize;
 81  BLUETOOTH_ADDRESS address;
 82  WCHAR             szName[BLUETOOTH_MAX_NAME_SIZE];
 83  ULONG             ulClassofDevice;
 84  USHORT            lmpSubversion;
 85  USHORT            manufacturer;
 86} BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO;
 87
 88typedef enum _BLUETOOTH_AUTHENTICATION_METHOD {
 89  BLUETOOTH_AUTHENTICATION_METHOD_LEGACY                 = 0x1,
 90  BLUETOOTH_AUTHENTICATION_METHOD_OOB,
 91  BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPARISON,
 92  BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY_NOTIFICATION,
 93  BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY
 94} BLUETOOTH_AUTHENTICATION_METHOD, *PBLUETOOTH_AUTHENTICATION_METHOD;
 95
 96typedef enum _BLUETOOTH_IO_CAPABILITY {
 97  BLUETOOTH_IO_CAPABILITY_DISPLAYONLY       = 0x00,
 98  BLUETOOTH_IO_CAPABILITY_DISPLAYYESNO      = 0x01,
 99  BLUETOOTH_IO_CAPABILITY_KEYBOARDONLY      = 0x02,
100  BLUETOOTH_IO_CAPABILITY_NOINPUTNOOUTPUT   = 0x03,
101  BLUETOOTH_IO_CAPABILITY_UNDEFINED         = 0xff
102} BLUETOOTH_IO_CAPABILITY;
103
104typedef enum _BLUETOOTH_AUTHENTICATION_REQUIREMENTS {
105  BLUETOOTH_MITM_ProtectionNotRequired               = 0x0,
106  BLUETOOTH_MITM_ProtectionRequired                  = 0x1,
107  BLUETOOTH_MITM_ProtectionNotRequiredBonding        = 0x2,
108  BLUETOOTH_MITM_ProtectionRequiredBonding           = 0x3,
109  BLUETOOTH_MITM_ProtectionNotRequiredGeneralBonding = 0x4,
110  BLUETOOTH_MITM_ProtectionRequiredGeneralBonding    = 0x5,
111  BLUETOOTH_MITM_ProtectionNotDefined                = 0xff
112} BLUETOOTH_AUTHENTICATION_REQUIREMENTS;
113
114typedef struct _BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS {
115  BLUETOOTH_DEVICE_INFO                 deviceInfo;
116  BLUETOOTH_AUTHENTICATION_METHOD       authenticationMethod;
117  BLUETOOTH_IO_CAPABILITY               ioCapability;
118  BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirements;
119  __C89_NAMELESS union {
120    ULONG Numeric_Value;
121    ULONG Passkey;
122  } ;
123} BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, *PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS;
124
125typedef struct _BLUETOOTH_LOCAL_SERVICE_INFO {
126  WINBOOL           Enabled;
127  BLUETOOTH_ADDRESS btAddr;
128  WCHAR             szName[BLUETOOTH_MAX_SERVICE_NAME_SIZE];
129  WCHAR             szDeviceString[BLUETOOTH_DEVICE_NAME_SIZE];
130} BLUETOOTH_LOCAL_SERVICE_INFO_STRUCT;
131
132#define BLUETOOTH_LOCAL_SERVICE_INFO BLUETOOTH_LOCAL_SERVICE_INFO_STRUCT
133
134typedef BLUETOOTH_LOCAL_SERVICE_INFO *PBLUETOOTH_LOCAL_SERVICE_INFO;
135
136#define BTH_MAX_PIN_SIZE 16
137typedef struct _BLUETOOTH_PIN_INFO {
138  UCHAR pin[BTH_MAX_PIN_SIZE];
139  UCHAR pinLength;
140} BLUETOOTH_PIN_INFO, *PBLUETOOTH_PIN_INFO;
141
142typedef struct _BLUETOOTH_OOB_DATA_INFO {
143  UCHAR C[16];
144  UCHAR R[16];
145} BLUETOOTH_OOB_DATA_INFO, *PBLUETOOTH_OOB_DATA_INFO;
146
147typedef struct _BLUETOOTH_NUMERIC_COMPARISON_INFO {
148  ULONG NumericValue;
149} BLUETOOTH_NUMERIC_COMPARISON_INFO, *PBLUETOOTH_NUMERIC_COMPARISON_INFO;
150
151typedef struct _BLUETOOTH_PASSKEY_INFO {
152  ULONG passkey;
153} BLUETOOTH_PASSKEY_INFO, *PBLUETOOTH_PASSKEY_INFO;
154
155typedef struct _BLUETOOTH_AUTHENTICATE_RESPONSE {
156  BLUETOOTH_ADDRESS               bthAddressRemote;
157  BLUETOOTH_AUTHENTICATION_METHOD authMethod;
158  __C89_NAMELESS union {
159    BLUETOOTH_PIN_INFO                pinInfo;
160    BLUETOOTH_OOB_DATA_INFO           oobInfo;
161    BLUETOOTH_NUMERIC_COMPARISON_INFO numericCompInfo;
162    BLUETOOTH_PASSKEY_INFO            passkeyInfo;
163  };
164  UCHAR                           negativeResponse;
165} BLUETOOTH_AUTHENTICATE_RESPONSE, *PBLUETOOTH_AUTHENTICATE_RESPONSE;
166
167typedef WINBOOL (CALLBACK *PFN_DEVICE_CALLBACK)(LPVOID pvParam,const BLUETOOTH_DEVICE_INFO *pDevice);
168typedef WINBOOL (CALLBACK *PFN_AUTHENTICATION_CALLBACK_EX)(LPVOID pvParam,PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams);
169typedef WINBOOL (CALLBACK *PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam,PBLUETOOTH_DEVICE_INFO pDevice);
170typedef WINBOOL (CALLBACK *PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)(ULONG uAttribId,LPBYTE pValueStream,ULONG cbStreamSize,LPVOID pvParam);
171
172typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS {
173  DWORD                  dwSize;
174  ULONG                  cNumOfClasses;
175  BLUETOOTH_COD_PAIRS    *prgClassOfDevices;
176  LPWSTR                 pszInfo;
177  HWND                   hwndParent;
178  WINBOOL                fForceAuthentication;
179  WINBOOL                fShowAuthenticated;
180  WINBOOL                fShowRemembered;
181  WINBOOL                fShowUnknown;
182  WINBOOL                fAddNewDeviceWizard;
183  WINBOOL                fSkipServicesPage;
184  PFN_DEVICE_CALLBACK    pfnDeviceCallback;
185  LPVOID                 pvParam;
186  DWORD                  cNumDevices;
187  PBLUETOOTH_DEVICE_INFO pDevices;
188} BLUETOOTH_SELECT_DEVICE_PARAMS;
189
190DWORD WINAPI BluetoothAuthenticateMultipleDevices(
191    HWND hwndParent,
192    HANDLE hRadio,
193    DWORD cDevices,
194    BLUETOOTH_DEVICE_INFO *pbtdi
195);
196
197DWORD WINAPI BluetoothAuthenticateDevice(
198    HWND hwndParent,
199    HANDLE hRadio,
200    BLUETOOTH_DEVICE_INFO *pbtbi,
201    PWSTR pszPasskey,
202    ULONG ulPasskeyLength
203);
204
205DWORD WINAPI BluetoothAuthenticateDeviceEx(
206  HWND hwndParentIn,
207  HANDLE hRadioIn,
208  BLUETOOTH_DEVICE_INFO *pbtdiInout,
209  PBLUETOOTH_OOB_DATA_INFO pbtOobData,
210  AUTHENTICATION_REQUIREMENTS authenticationRequirement
211);
212
213WINBOOL WINAPI BluetoothDisplayDeviceProperties(
214    HWND hwndParent,
215    BLUETOOTH_DEVICE_INFO *pbtdi
216);
217
218WINBOOL WINAPI BluetoothEnableDiscovery(
219    HANDLE hRadio,
220    WINBOOL fEnabled
221);
222
223WINBOOL WINAPI BluetoothEnableIncomingConnections(
224    HANDLE hRadio,
225    WINBOOL fEnabled
226);
227
228DWORD WINAPI BluetoothEnumerateInstalledServices(
229    HANDLE hRadio,
230    const BLUETOOTH_DEVICE_INFO *pbtdi,
231    DWORD *pcServices,
232    GUID *pGuidServices
233);
234
235WINBOOL WINAPI BluetoothFindDeviceClose(
236    HBLUETOOTH_DEVICE_FIND hFind
237);
238
239HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice(
240    const BLUETOOTH_DEVICE_SEARCH_PARAMS *pbtsp,
241    BLUETOOTH_DEVICE_INFO *pbtdi
242);
243
244HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(
245  const BLUETOOTH_FIND_RADIO_PARAMS *pbtfrp,
246  HANDLE *phRadio
247);
248
249WINBOOL WINAPI BluetoothFindNextDevice(
250    HBLUETOOTH_DEVICE_FIND hFind,
251    BLUETOOTH_DEVICE_INFO *pbtdi
252);
253
254WINBOOL WINAPI BluetoothFindNextRadio(
255  HBLUETOOTH_RADIO_FIND hFind,
256  HANDLE *phRadio
257);
258
259WINBOOL WINAPI BluetoothFindRadioClose(
260    HBLUETOOTH_RADIO_FIND hFind
261);
262
263DWORD WINAPI BluetoothGetDeviceInfo(
264    HANDLE hRadio,
265    BLUETOOTH_DEVICE_INFO *pbtdi
266);
267
268DWORD WINAPI BluetoothGetRadioInfo(
269    HANDLE hRadio,
270    PBLUETOOTH_RADIO_INFO pRadioInfo
271);
272
273WINBOOL WINAPI BluetoothIsDiscoverable(
274    HANDLE hRadio
275);
276
277WINBOOL WINAPI BluetoothIsConnectable(
278    HANDLE hRadio
279);
280
281WINBOOL WINAPI BluetoothIsVersionAvailable(
282    UCHAR MajorVersion,
283    UCHAR MinorVersion
284);
285
286DWORD WINAPI BluetoothRegisterForAuthentication(
287    const BLUETOOTH_DEVICE_INFO *pbtdi,
288    HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandle,
289    PFN_AUTHENTICATION_CALLBACK pfnCallback,
290    PVOID pvParam
291);
292
293DWORD WINAPI BluetoothRegisterForAuthenticationEx(
294  const BLUETOOTH_DEVICE_INFO *pbtdiln,
295  HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandleOut,
296  PFN_AUTHENTICATION_CALLBACK_EX pfnCallbackIn,
297  PVOID pvParam
298);
299
300DWORD WINAPI BluetoothRemoveDevice(
301    const BLUETOOTH_ADDRESS *pAddress
302);
303
304WINBOOL WINAPI BluetoothSdpEnumAttributes(
305    LPBYTE pSDPStream,
306    ULONG cbStreamSize,
307    PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback,
308    LPVOID pvParam
309);
310
311DWORD WINAPI BluetoothSdpGetAttributeValue(
312  LPBYTE pRecordStream,
313  ULONG cbRecordLength,
314  USHORT usAttributeId,
315  PSDP_ELEMENT_DATA pAttributeData
316);
317
318DWORD WINAPI BluetoothSdpGetContainerElementData(
319  LPBYTE pContainerStream,
320  ULONG cbContainerLength,
321  HBLUETOOTH_CONTAINER_ELEMENT *pElement,
322  PSDP_ELEMENT_DATA pData
323);
324
325DWORD BluetoothSdpGetElementData(
326  LPBYTE pSdpStream,
327  ULONG cbSpdStreamLength,
328  PSDP_ELEMENT_DATA pData
329);
330
331DWORD BluetoothSdpGetString(
332  LPBYTE pRecordStream,
333  ULONG cbRecordLength,
334  const PSDP_STRING_TYPE_DATA pStringData,
335  USHORT usStringOffset,
336  PWCHAR pszString,
337  PULONG pcchStringLength
338);
339
340WINBOOL WINAPI BluetoothSelectDevices(
341    BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp
342);
343
344WINBOOL WINAPI BluetoothSelectDevicesFree(
345    BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp
346);
347
348DWORD WINAPI BluetoothSendAuthenticationResponse(
349    HANDLE hRadio,
350    const BLUETOOTH_DEVICE_INFO *pbtdi,
351    LPWSTR pszPasskey
352);
353
354DWORD WINAPI BluetoothSendAuthenticationResponseEx(
355  HANDLE hRadioIn,
356  PBLUETOOTH_AUTHENTICATE_RESPONSE pauthResponse
357);
358
359DWORD WINAPI BluetoothSetLocalServiceInfo(
360  HANDLE hRadioIn,
361  const GUID *pClassGuid,
362  ULONG ulInstance,
363  const BLUETOOTH_LOCAL_SERVICE_INFO *pServiceInfoIn
364);
365
366DWORD WINAPI BluetoothSetServiceState(
367    HANDLE hRadio,
368    const BLUETOOTH_DEVICE_INFO *pbtdi,
369    const GUID *pGuidService,
370    DWORD dwServiceFlags
371);
372
373WINBOOL WINAPI BluetoothUnregisterAuthentication(
374    HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle
375);
376
377DWORD WINAPI BluetoothUpdateDeviceRecord(
378    const BLUETOOTH_DEVICE_INFO *pbtdi
379);
380
381#ifdef __cplusplus
382}
383#endif
384
385#endif /*_INC_BLUETOOTHAPIS*/
386