ws2bth.h 5.5 KB

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