Home | History | Annotate | Download | only in include
      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_WS2BTH
      7 #define _INC_WS2BTH
      8 #include <bthdef.h>
      9 #include <bthsdpdef.h>
     10 
     11 #ifdef __cplusplus
     12 extern "C" {
     13 #endif
     14 
     15 /*
     16   constants as found on
     17   http://www.koders.com/delphi/fid882B076395C727550B1DA378430A79672B587941.aspx
     18 */
     19 
     20 #define BT_PORT_ANY       ((ULONG)-1)
     21 #define BT_PORT_MIN       0x0001
     22 #define BT_PORT_MAX       0xffff
     23 #define BT_PORT_DYN_FIRST 0x1001
     24 
     25 #define BTH_ADDR_STRING_SIZE 12
     26 
     27 #define BTHPROTO_RFCOMM 0x0003
     28 #define BTHPROTO_L2CAP  0x0100
     29 
     30 #define SOL_RFCOMM BTHPROTO_RFCOMM
     31 #define SOL_L2CAP  BTHPROTO_L2CAP
     32 #define SOL_SDP    0x0101
     33 
     34 #define SO_BTH_AUTHENTICATE 0x80000001
     35 #define SO_BTH_ENCRYPT      0x00000002
     36 #define SO_BTH_MTU          0x80000007
     37 #define SO_BTH_MTU_MAX      0x80000008
     38 #define SO_BTH_MTU_MIN      0x8000000a
     39 
     40 #define RFCOMM_MAX_MTU 0x029a
     41 #define RFCOMM_MIN_MTU 0x0017
     42 
     43 #define BTH_SDP_VERSION 1
     44 
     45 #define SDP_DEFAULT_INQUIRY_SECONDS       6
     46 #define SDP_MAX_INQUIRY_SECONDS           60
     47 #define SDP_DEFAULT_INQUIRY_MAX_RESPONSES 255
     48 
     49 #define SDP_SERVICE_SEARCH_REQUEST           1
     50 #define SDP_SERVICE_ATTRIBUTE_REQUEST        2
     51 #define SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST 3
     52 
     53 #define BTHNS_RESULT_DEVICE_CONNECTED     0x00010000
     54 #define BTHNS_RESULT_DEVICE_REMEMBERED    0x00020000
     55 #define BTHNS_RESULT_DEVICE_AUTHENTICATED 0x00040000
     56 
     57 #define SIO_BTH_PING                _WSAIORW(IOC_VENDOR, 8)
     58 #define SIO_BTH_INFO                _WSAIORW(IOC_VENDOR, 9)
     59 
     60 #define SIO_RFCOMM_SEND_COMMAND     _WSAIORW(IOC_VENDOR, 101)
     61 #define SIO_RFCOMM_WAIT_COMMAND     _WSAIORW(IOC_VENDOR, 102)
     62 #define SIO_RFCOMM_SESSION_FLOW_OFF _WSAIORW(IOC_VENDOR, 103)
     63 #define SIO_RFCOMM_TEST             _WSAIORW(IOC_VENDOR, 104)
     64 #define SIO_RFCOMM_USECFC           _WSAIORW(IOC_VENDOR, 105)
     65 
     66 #define BIT(b) (1 << (b))
     67 
     68 //TODO #define MSC_EA_BIT
     69 #define MSC_FC_BIT    BIT(1)
     70 #define MSC_RTC_BIT   BIT(2)
     71 #define MSC_RTR_BIT   BIT(3)
     72 #define MSC_RESERVED  (BIT(4) | BIT(5))
     73 #define MSC_IC_BIT    BIT(6)
     74 #define MSC_DV_BIT    BIT(7)
     75 #define MSC_BREAK_BIT BIT(1)
     76 
     77 #define MSC_SET_BREAK_LENGTH(b, l) ((b) = ((b) & 0x03) | (((l) & 0x0f) << 4))
     78 
     79 #define RLS_ERROR   0x01
     80 #define RLS_OVERRUN 0x02
     81 #define RLS_PARITY  0x04
     82 #define RLS_FRAMING 0x08
     83 
     84 #define RPN_BAUD_2400   0
     85 #define RPN_BAUD_4800   1
     86 #define RPN_BAUD_7200   2
     87 #define RPN_BAUD_9600   3
     88 #define RPN_BAUD_19200  4
     89 #define RPN_BAUD_38400  5
     90 #define RPN_BAUD_57600  6
     91 #define RPN_BAUD_115200 7
     92 #define RPN_BAUD_230400 8
     93 
     94 #define RPN_DATA_5 0
     95 #define RPN_DATA_6 1
     96 #define RPN_DATA_7 2
     97 #define RPN_DATA_8 3
     98 
     99 #define RPN_STOP_1   0
    100 #define RPN_STOP_1_5 4
    101 
    102 #define RPN_PARITY_NONE  0x00
    103 #define RPN_PARITY_ODD   0x08
    104 #define RPN_PARITY_EVEN  0x18
    105 #define RPN_PARITY_MARK  0x28
    106 #define RPN_PARITY_SPACE 0x38
    107 
    108 #define RPN_FLOW_X_IN    0x01
    109 #define RPN_FLOW_X_OUT   0x02
    110 #define RPN_FLOW_RTR_IN  0x04
    111 #define RPN_FLOW_RTR_OUT 0x08
    112 #define RPN_FLOW_RTC_IN  0x10
    113 #define RPN_FLOW_RTC_OUT 0x20
    114 
    115 #define RPN_PARAM_BAUD   0x01
    116 #define RPN_PARAM_DATA   0x02
    117 #define RPN_PARAM_STOP   0x04
    118 #define RPN_PARAM_PARITY 0x08
    119 #define RPN_PARAM_P_TYPE 0x10
    120 #define RPN_PARAM_XON    0x20
    121 #define RPN_PARAM_XOFF   0x40
    122 
    123 #define RPN_PARAM_X_IN    0x01
    124 #define RPN_PARAM_X_OUT   0x02
    125 #define RPN_PARAM_RTR_IN  0x04
    126 #define RPN_PARAM_RTR_OUT 0x08
    127 #define RPN_PARAM_RTC_IN  0x10
    128 #define RPN_PARAM_RTC_OUT 0x20
    129 
    130 #define RFCOMM_CMD_NONE         0
    131 #define RFCOMM_CMD_MSC          1
    132 #define RFCOMM_CMD_RLS          2
    133 #define RFCOMM_CMD_RPN          3
    134 #define RFCOMM_CMD_RPN_REQUEST  4
    135 #define RFCOMM_CMD_RPN_RESPONSE 5
    136 
    137 typedef struct _BTH_QUERY_SERVICE {
    138   ULONG             type;
    139   ULONG             serviceHandle;
    140   SdpQueryUuid      uuids[MAX_UUIDS_IN_QUERY];
    141   ULONG             numRange;
    142   SdpAttributeRange pRange[1];
    143 } BTH_QUERY_SERVICE, *PBTH_QUERY_SERVICE;
    144 
    145 typedef struct _BTH_QUERY_DEVICE {
    146   ULONG LAP;
    147   UCHAR length;
    148 } BTH_QUERY_DEVICE, *PBTH_QUERY_DEVICE;
    149 
    150 typedef struct _BTH_SET_SERVICE {
    151   PULONG pSdpVersion;
    152   HANDLE *pRecordHandle;
    153   ULONG  fCodService;
    154   ULONG  Reserved[5];
    155   ULONG  ulRecordLength;
    156   UCHAR  pRecord[1];
    157 } BTH_SET_SERVICE, *PBTH_SET_SERVICE;
    158 
    159 typedef struct _SOCKADDR_BTH {
    160   USHORT   addressFamily;
    161   BTH_ADDR btAddr;
    162   GUID     serviceClassId;
    163   ULONG    port;
    164 } SOCKADDR_BTH, *PSOCKADDR_BTH;
    165 
    166 #ifdef __cplusplus
    167 }
    168 #endif
    169 #endif /*_INC_WS2BTH*/
    170