xref: /reactos/sdk/include/psdk/ws2bth.h (revision 4561998a)
1 #pragma once
2 
3 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
4 
5 #include <bthdef.h>
6 
7 #include <pshpack1.h>
8 
9 #define BT_PORT_ANY          ((ULONG)-1)
10 #define BT_PORT_MIN          0x1
11 #define BT_PORT_MAX          0xffff
12 #define BT_PORT_DYN_FIRST    0x1001
13 
14 #ifndef AF_BTH
15 #define AF_BTH 32
16 #endif
17 #ifndef PF_BTH
18 #define PF_BTH AF_BTH
19 #endif
20 #ifndef NS_BTH
21 #define NS_BTH 16
22 #endif
23 
24 DEFINE_GUID(SVCID_BTH_PROVIDER, 0x6aa63e0, 0x7d60, 0x41ff, 0xaf, 0xb2, 0x3e, 0xe6, 0xd2, 0xd9, 0x39, 0x2d);
25 
26 #define BTH_ADDR_STRING_SIZE           12
27 
28 #define BTHPROTO_RFCOMM      0x0003
29 #define BTHPROTO_L2CAP       0x0100
30 
31 #define SOL_RFCOMM           BTHPROTO_RFCOMM
32 #define SOL_L2CAP            BTHPROTO_L2CAP
33 #define SOL_SDP              0x0101
34 
35 #define SO_BTH_AUTHENTICATE  0x80000001
36 #define SO_BTH_ENCRYPT       0x00000002
37 #define SO_BTH_MTU           0x80000007
38 #define SO_BTH_MTU_MAX       0x80000008
39 #define SO_BTH_MTU_MIN       0x8000000a
40 
41 #define RFCOMM_MAX_MTU       0x000003F3
42 #define RFCOMM_MIN_MTU       0x00000017
43 
44 #define BTH_SDP_VERSION      1
45 
46 #define SDP_DEFAULT_INQUIRY_SECONDS    6
47 #define SDP_MAX_INQUIRY_SECONDS        60
48 
49 #define SDP_DEFAULT_INQUIRY_MAX_RESPONSES        255
50 
51 #define SDP_SERVICE_SEARCH_REQUEST               1
52 #define SDP_SERVICE_ATTRIBUTE_REQUEST            2
53 #define SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST     3
54 
55 #define BTHNS_RESULT_DEVICE_CONNECTED       0x00010000
56 #define BTHNS_RESULT_DEVICE_REMEMBERED      0x00020000
57 #define BTHNS_RESULT_DEVICE_AUTHENTICATED   0x00040000
58 
59 #define SIO_RFCOMM_SEND_COMMAND        _WSAIORW (IOC_VENDOR, 101)
60 #define SIO_RFCOMM_WAIT_COMMAND        _WSAIORW (IOC_VENDOR, 102)
61 
62 #define SIO_BTH_PING                      _WSAIORW (IOC_VENDOR, 8)
63 #define SIO_BTH_INFO                      _WSAIORW (IOC_VENDOR, 9)
64 #define SIO_RFCOMM_SESSION_FLOW_OFF       _WSAIORW (IOC_VENDOR, 103)
65 #define SIO_RFCOMM_TEST                   _WSAIORW (IOC_VENDOR, 104)
66 #define SIO_RFCOMM_USECFC                 _WSAIORW (IOC_VENDOR, 105)
67 
68 #ifndef BIT
69 #define BIT(b) (1<<(b))
70 #endif
71 
72 #define MSC_EA_BIT      EA_BIT
73 #define MSC_FC_BIT      BIT(1)
74 #define MSC_RTC_BIT     BIT(2)
75 #define MSC_RTR_BIT     BIT(3)
76 #define MSC_RESERVED    (BIT(4)|BIT(5))
77 #define MSC_IC_BIT      BIT(6)
78 #define MSC_DV_BIT      BIT(7)
79 #define MSC_BREAK_BIT   BIT(1)
80 #define MSC_SET_BREAK_LENGTH(b, l) ((b) = ((b)&0x3) | (((l)&0xf) << 4))
81 
82 #define RLS_ERROR            0x01
83 #define RLS_OVERRUN          0x02
84 #define RLS_PARITY           0x04
85 #define RLS_FRAMING          0x08
86 
87 #define RPN_BAUD_2400       0
88 #define RPN_BAUD_4800       1
89 #define RPN_BAUD_7200       2
90 #define RPN_BAUD_9600       3
91 #define RPN_BAUD_19200      4
92 #define RPN_BAUD_38400      5
93 #define RPN_BAUD_57600      6
94 #define RPN_BAUD_115200     7
95 #define RPN_BAUD_230400     8
96 
97 #define RPN_DATA_5          0x0
98 #define RPN_DATA_6          0x1
99 #define RPN_DATA_7          0x2
100 #define RPN_DATA_8          0x3
101 
102 #define RPN_STOP_1          0x0
103 #define RPN_STOP_1_5        0x4
104 
105 #define RPN_PARITY_NONE     0x00
106 #define RPN_PARITY_ODD      0x08
107 #define RPN_PARITY_EVEN     0x18
108 #define RPN_PARITY_MARK     0x28
109 #define RPN_PARITY_SPACE    0x38
110 
111 #define RPN_FLOW_X_IN       0x01
112 #define RPN_FLOW_X_OUT      0x02
113 #define RPN_FLOW_RTR_IN     0x04
114 #define RPN_FLOW_RTR_OUT    0x08
115 #define RPN_FLOW_RTC_IN     0x10
116 #define RPN_FLOW_RTC_OUT    0x20
117 
118 #define RPN_PARAM_BAUD      0x01
119 #define RPN_PARAM_DATA      0x02
120 #define RPN_PARAM_STOP      0x04
121 #define RPN_PARAM_PARITY    0x08
122 #define RPN_PARAM_P_TYPE    0x10
123 #define RPN_PARAM_XON       0x20
124 #define RPN_PARAM_XOFF      0x40
125 #define RPN_PARAM_X_IN      0x01
126 #define RPN_PARAM_X_OUT     0x02
127 #define RPN_PARAM_RTR_IN    0x04
128 #define RPN_PARAM_RTR_OUT   0x08
129 #define RPN_PARAM_RTC_IN    0x10
130 #define RPN_PARAM_RTC_OUT   0x20
131 
132 #define RFCOMM_CMD_NONE             0
133 #define RFCOMM_CMD_MSC              1
134 #define RFCOMM_CMD_RLS              2
135 #define RFCOMM_CMD_RPN              3
136 #define RFCOMM_CMD_RPN_REQUEST      4
137 #define RFCOMM_CMD_RPN_RESPONSE     5
138 
139 
140 
141 
142 
143 
144 
145 typedef struct _SOCKADDR_BTH {
146   USHORT addressFamily;
147   BTH_ADDR btAddr;
148   GUID serviceClassId;
149   ULONG port;
150 } SOCKADDR_BTH, *PSOCKADDR_BTH;
151 
152 typedef struct _BTH_SET_SERVICE {
153   PULONG pSdpVersion;
154   HANDLE *pRecordHandle;
155   ULONG fCodService;
156   ULONG Reserved[5];
157   ULONG ulRecordLength;
158   UCHAR pRecord[1];
159 } BTH_SET_SERVICE, *PBTH_SET_SERVICE;
160 
161 typedef struct _BTH_QUERY_DEVICE {
162   ULONG LAP;
163   UCHAR length;
164 } BTH_QUERY_DEVICE, *PBTH_QUERY_DEVICE;
165 
166 typedef struct _BTH_QUERY_SERVICE {
167   ULONG type;
168   ULONG serviceHandle;
169   SdpQueryUuid uuids[MAX_UUIDS_IN_QUERY];
170   ULONG numRange;
171   SdpAttributeRange pRange[1];
172 } BTH_QUERY_SERVICE, *PBTH_QUERY_SERVICE;
173 
174 typedef struct _RFCOMM_MSC_DATA {
175   UCHAR Signals;
176   UCHAR Break;
177 } RFCOMM_MSC_DATA, *PRFCOMM_MSC_DATA;
178 
179 typedef struct _RFCOMM_RLS_DATA {
180   UCHAR LineStatus;
181 } RFCOMM_RLS_DATA, *PRFCOMM_RLS_DATA;
182 
183 typedef struct _RFCOMM_RPN_DATA {
184   UCHAR Baud;
185   UCHAR Data;
186   UCHAR FlowControl;
187   UCHAR XonChar;
188   UCHAR XoffChar;
189   UCHAR ParameterMask1;
190   UCHAR ParameterMask2;
191 } RFCOMM_RPN_DATA, *PRFCOMM_RPN_DATA;
192 
193 typedef struct _RFCOMM_COMMAND {
194   ULONG CmdType;
195   union {
196     RFCOMM_MSC_DATA MSC;
197     RFCOMM_RLS_DATA RLS;
198     RFCOMM_RPN_DATA RPN;
199   } Data;
200 } RFCOMM_COMMAND, *PRFCOMM_COMMAND;
201 
202 typedef struct _BTH_PING_REQ {
203   BTH_ADDR btAddr;
204   UCHAR dataLen;
205   UCHAR data[MAX_L2CAP_PING_DATA_LENGTH];
206 } BTH_PING_REQ, *PBTH_PING_REQ;
207 
208 typedef struct _BTH_PING_RSP {
209   UCHAR dataLen;
210   UCHAR data[MAX_L2CAP_PING_DATA_LENGTH];
211 } BTH_PING_RSP, *PBTH_PING_RSP;
212 
213 typedef struct _BTH_INFO_REQ {
214   BTH_ADDR btAddr;
215   USHORT infoType;
216 } BTH_INFO_REQ, *PBTH_INFO_REQ;
217 
218 typedef struct _BTH_INFO_RSP {
219   USHORT result;
220   UCHAR dataLen;
221   union {
222     USHORT connectionlessMTU;
223     UCHAR data[MAX_L2CAP_INFO_DATA_LENGTH];
224   };
225 } BTH_INFO_RSP, *PBTH_INFO_RSP;
226 
227 typedef struct _BTH_SET_SERVICE BTHNS_SETBLOB, *PBTHNS_SETBLOB;
228 typedef struct _BTH_QUERY_DEVICE BTHNS_INQUIRYBLOB, *PBTHNS_INQUIRYBLOB;
229 typedef struct _BTH_QUERY_SERVICE BTHNS_RESTRICTIONBLOB, *PBTHNS_RESTRICTIONBLOB;
230 
231 #include <poppack.h>
232 
233 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
234