⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btifdefinitions.h

📁 基于widcomm的蓝牙传输功能程序
💻 H
📖 第 1 页 / 共 4 页
字号:

// BtIfObexHeaders.cpp : Definitions for the OBEX headers objects.
//

#define OBEX_MINIMUM_MTU            (255)
#define OBEX_MAX_CLIENTS            4
#define OBEX_MAX_SERVERS            4


#ifdef _WIN32_WCE
    #define OBEX_MAX_CSESSIONS          1
    #define OBEX_MAX_SSESSIONS          1           /* Current version only allows 1 session per server */
#else
    #define OBEX_MAX_CSESSIONS          4
    #define OBEX_MAX_SSESSIONS          7
#endif

#define OBEX_MAX_TARGET             3
#define OBEX_MAX_AUTH_CHALLENGE     3
#define OBEX_MAX_AUTH_RESPONSE      3
#define OBEX_MAX_HTTP               3
#define OBEX_MAX_APP_PARAM          3
#define OBEX_MAX_USER_HDR           4
#define OBEX_TIMER_SEED             60
#define OBEX_IDLE_TIMER_SEED        180

#define OBEX_TIME_LOCAL     0x01
#define OBEX_TIME_UTC       0x02
#define OBEX_API 
#define OBEX_CLIENT_INCLUDED        (TRUE)
#define OBEX_SERVER_INCLUDED        (TRUE)

#ifndef BT_TYPES_H
#define GKI_BUF3_SIZE           700
#endif
#define OBEX_DATA_POOL_SIZE         (GKI_BUF3_SIZE)

#define OBEX_DATA_BUFFER_OVERHEAD   (41)
// for now, limit MTU to 640 - overhead 
#ifndef BT_TYPES_H
#define OBEX_DESIRED_MTU            (OBEX_DATA_POOL_SIZE - OBEX_DATA_BUFFER_OVERHEAD)
#endif
#if (OBEX_DESIRED_MTU + OBEX_DATA_BUFFER_OVERHEAD > OBEX_DATA_POOL_SIZE)
#define OBEX_DEFAULT_MTU            (OBEX_DATA_POOL_SIZE - OBEX_DATA_BUFFER_OVERHEAD)
#else
#define OBEX_DEFAULT_MTU            (OBEX_DESIRED_MTU)
#endif

/*
** Define OBEX Request Codes
*/
#define OBEX_REQ_CONNECT                0x00
#define OBEX_REQ_DISCONNECT             0x01
#define OBEX_REQ_PUT                    0x02
#define OBEX_REQ_GET                    0x03
#define OBEX_REQ_SETPATH                0x05
#define OBEX_REQ_ABORT                  0x7f
#define OBEX_FINAL                      0x80
#define OBEX_UNREGISTER                 0xff

/*
** Define well-known OBEX Client data types
*/
typedef UINT32  tOBEX_CLIENT_HANDLE;    /* Application Handle */
typedef UINT32  tOBEX_CSESSION_HANDLE;  /* Session Handle */

/*
** Define well-known OBEX Server data types
*/
typedef UINT32   tOBEX_SERVER_HANDLE;    /* Application Handle */
typedef UINT32   tOBEX_SSESSION_HANDLE;  /* Session Handle */


/*
** Define OBEX error codes returned by OBEX API Functions and Application
** Callback Functions
*/
typedef enum
{
    OBEX_SUCCESS = 0,       /* Operation was successful or accepted */
    OBEX_FAIL,              /* Operation failed or was rejected */
    OBEX_ERROR,             /* Internal OBEX error */
    OBEX_ERR_RESOURCES,     /* Insufficient resources */
    OBEX_ERR_NO_CB,         /* Calback for request is missing */
    OBEX_ERR_DUP_SERVER,    /* Server for 'Target' already register with OBEX */
    OBEX_ERR_RESPONSE,      /* Peer rejected request */
    OBEX_ERR_UNK_APP,       /* Unknown Application Handle (unregistered?) */
    OBEX_ERR_PARAM,         /* Invalid or missing parameter value */
    OBEX_ERR_CLOSED,        /* Session is closed */
    OBEX_ERR_ABORTED,       /* Operation was aborted */
    OBEX_ERR_STATE,         /* Request is invalid for current state */
    OBEX_ERR_NA,            /* API call not allowed at this time */
    OBEX_ERR_HEADER,        /* Invalid data in tOBEX_HEADERS */
    OBEX_ERR_TOO_BIG,       /* The data presented in the tOBEX_HEADERS */
                            /* structure is larger than the maximum */
                            /* size allowed for the request */
    OBEX_ERR_TIMEOUT        /* Timeout */
} tOBEX_ERRORS;
#define OBEX_MAX_ERROR OBEX_ERR_TIMEOUT

/*
** Define OBEX Response Code values used in OBEX Responses sent by
** the OBEX Server to the OBEX Client.  These codes are taken 
** from the 'IrDA Object Exchange Protocol (IROBEX)' specification
** with the high bit (final bit) removed.  The OBEX Core internally
** manages the 'final bit'.
*/
typedef enum
{
    OBEX_RSP_DEFAULT                        = 0x00,
    OBEX_RSP_CONTINUE                       = 0x10,
    OBEX_RSP_OK                             = 0x20,
    OBEX_RSP_CREATED                        = 0x21,
    OBEX_RSP_ACCEPTED                       = 0x22,
    OBEX_RSP_NON_AUTHORITATIVE_INFO         = 0x23,
    OBEX_RSP_NO_CONTENT                     = 0x24,
    OBEX_RSP_RESET_CONTENT                  = 0x25,
    OBEX_RSP_PARTIAL_CONTENT                = 0x26,
    OBEX_RSP_MULTIPLE_CHOICES               = 0x30,
    OBEX_RSP_MOVED_PERMANENTLY              = 0x31,
    OBEX_RSP_MOVED_TEMPORARILY              = 0x32,
    OBEX_RSP_SEE_OTHER                      = 0x33,
    OBEX_RSP_NOT_MODIFIED                   = 0x34,
    OBEX_RSP_USE_PROXY                      = 0x35,
    OBEX_RSP_BAD_REQUEST                    = 0x40,
    OBEX_RSP_UNAUTHORIZED                   = 0x41,
    OBEX_RSP_PAYMENT_REQUIRED               = 0x42,
    OBEX_RSP_FORBIDDEN                      = 0x43,
    OBEX_RSP_NOT_FOUND                      = 0x44,
    OBEX_RSP_METHOD_NOT_ALLOWED             = 0x45,
    OBEX_RSP_NOT_ACCEPTABLE                 = 0x46,
    OBEX_RSP_PROXY_AUTHENTICATION_REQUIRED  = 0x47,
    OBEX_RSP_REQUEST_TIME_OUT               = 0x48,
    OBEX_RSP_CONFLICT                       = 0x49,
    OBEX_RSP_GONE                           = 0x4A,
    OBEX_RSP_LENGTH_REQUIRED                = 0x4B,
    OBEX_RSP_PRECONDITION_FAILED            = 0x4C,
    OBEX_RSP_REQUESTED_ENTITY_TOO_LARGE     = 0x4D,
    OBEX_RSP_REQUEST_URL_TOO_LARGE          = 0x4E,
    OBEX_RSP_UNSUPPORTED_MEDIA_TYPE         = 0x4F,
    OBEX_RSP_INTERNAL_SERVER_ERROR          = 0x50,
    OBEX_RSP_NOT_IMPLEMENTED                = 0x51,
    OBEX_RSP_BAD_GATEWAY                    = 0x52,
    OBEX_RSP_SERVICE_UNAVAILABLE            = 0x53,
    OBEX_RSP_GATEWAY_TIMEOUT                = 0x54,
    OBEX_RSP_HTTP_VERSION_NOT_SUPPORTED     = 0x55,
    OBEX_RSP_DATABASE_FULL                  = 0x60,
    OBEX_RSP_DATABASE_LOCKED                = 0x61
} tOBEX_RESPONSE_CODE;

/*
** The tOBEX_CLIENT_HANDLE, tOBEX_SERVER_HANDLE, tOBEX_CSESSION_HANDLE 
** and tOBEX_SSESSION_HANDLE each consist of two 16 bit values.  The high 
** order 16 bits contain an arbitrary ordinal assigned when the client
** or server registers or when a session is opened.  The low order 16
** bits contain the tOBEX_GLOBAL_CLIENT.client_ctrl, 
** tOBEX_GLOBAL_SERVER.server_ctrl, tOBEX_CLIENT_CTRL.cses_ctrl or
** tOBEX_SERVER_CTRL.sses_ctrl index value for the client, server or 
** session.  The following macros encode an ordinal and index into a
** tOBEX_CLIENT_HANDLE, tOBEX_SERVER_HANDLE, tOBEX_CSESSION_HANDLE or
** tOBEX_SSESSION_HANDLE and decode an ordinal and index from a
** handle.
*/
#define OBEX_ENCODE_HANDLE(handle,ordinal,index) (handle = ((ordinal << 16) | (index & 0xFFFF)))
#define OBEX_DECODE_HANDLE(handle,ordinal,index) (ordinal = (handle >> 16), index = (handle & 0xFFFF))

/*
* The following defines and describes the tOBEX_HEADERS structure
* and the other structures that are embedded in the tOBEX_HEADERS
* structure.
*
* The tOBEX_HEADERS structure is used by many calls to OBEX API 
* and Application Callback Functions.  It contains the information 
* found in the OBEX Headers supported by this implementation of 
* OBEX as defined in the 'IrDA Object Exchange Protocol (IrOBEX)' 
* specification.  
*
* When an application wants to send information to the peer 
* application it creates an instance of the tOBEX_HEADERS structure
* and passes a pointer to the structure to the appropriate OBEX API
* Function.  OBEX will process the information found in the 
* structure and return to the application.  If the application has
* registered with OBEX as being 'well behaved' (see OBEX_ClientRegister
* and OBEX_ServerRegister functions), OBEX will assume that the 
* tOBEX_HEADERS pointer points to a GKI buffer (without the BT_HDR
* prefix) and will assume ownership of the buffer.  If the application
* has not registered as 'well behaved', OBEX will assume that the 
* tOBEX_HEADERS pointer points to static memory and will not alter
* the memory pointed to by the pointer.  For best performance, it
* is recommended that applications be well behaved.
*
* When OBEX receives information from the peer OBEX that it needs to
* deliver to the application, it creates an instance of the 
* tOBEX_HEADERS structure and passes a pointer to it to the appropriate
* Application Callback Function.  The tOBEX_HEADERS structure resides
* in a GKI buffer (without the BT_HDR prefix).  If the application has
* registered as 'well behaved', OBEX assumes that the application will
* assume ownership of the buffer and release it as appropriate.  If the
* application has not registered as 'well behaved', OBEX assumes that 
* the application treats the buffer as static memory and once the
* Application Callback Function returns to OBEX, OBEX will dispose of
* the buffer appropriately.
*/


/*
* The tOBEX_UNI_HDR structure is embedded in the tOBEX_HEADERS 
* structure.  It is used to hold the contents of an OBEX 
* 'UNICODE' type header.  These headers contain null-terminated
* UNICODE text strings.  The struct contains a 'p_string' member
* that points to the null-terminated UNICODE string and a 'str_len'
* member that indicates the number of characters in the UNICODE string.
* NOTE: The 'str_len' member includes the terminating NULL
* character.  Therefore, by example, if a Name header contains
* the UNICODE text string "JUMAR.TXT", the 'p_string' member of the
* struct will point to a data area containing
* the hex values (displayed in Big-endian format):
* "00 4A 00 55 00 4D 00 41 00 52 00 2E 00 54 00 58 00 54 00 00"
* and the 'str_len' member will contain the value 10.
*
* If a 'UNICODE' type header present in an OBEX request or
* response, the contents of that header will be stored in a 
* tOBEX_UNI_HDR struct and the 'flag' member of the tOBEX_HEADERS
* struct will indicate that the header is present.  Some headers may
* be present but contain no data.  In such a case, the 'flag' member
* of the tOBEX_HEADERS struct will indicate that the header is 
* present but the 'str_len' member and 'p_string' member of the 
* associated header struct will be zero.
*
* If the application has registered with OBEX as being 'well behaved',
* it is assumed that each 'p_string' member in use points to a GKI
* buffer and ownership of each buffer will follow the rules specified
* above for the tOBEX_HEADERS structure.  If the application has not
* registered with OBEX as being 'well behaved', the OBEX API functions
* assume that each 'p_string' member points to static memory it does
* not alter that memory.  OBEX also assumes that the Application
* Callback Functions will treat the memory pointed to by each 'p_string'
* member as static and will not alter that memory.
*/

/* OBEX UNICODE Type Header - null terminated UNICODE string */
typedef struct
{ 
    UINT32 str_len; 
    WCHAR  *p_string; 
} tOBEX_UNI_HDR; 


/*
* The tOBEX_OCTET_HDR structure is embedded in the tOBEX_HEADERS 
* structure.  It is used to hold the contents of an OBEX 
* 'octet-array' type header.  These headers contain unstructured octet 
* arrays.  The struct contains a 'p_array' member that points to an 
* array of octets and a 'length' member that indicates the length of 
* the array.
*
* If a header of the 'octet-array' type is present in an OBEX request or
* response, the contents of that header will be stored in its 
* corresponding struct and the 'flag' member of the tOBEX_HEADERS
* struct will indicate that the header is present.  Some headers may
* be present but contain no data.  In such a case, the 'flag' member
* of the tOBEX_HEADERS struct will indicate that the header is 
* present but the 'length' member and 'p_array' member of the 
* associated header struct will be zero.
*
* Some header types may occur multiple times in a request or response.
* For these types of headers, the tOBEX_HEADERS structure contains
* an array of embedded structures for that header type and a counter
* indicating the number of those headers that are present.  The 
* 'flag' member of the tOBEX_HEADERS struct will indicate that at 
* least one instance of the header is present in the request/response
* and the corresponding 'num_...' member of the tOBEX_HEADERS struct
* will indicate the actual number of instances included in the array
* of structures.
*
* If the application has registered with OBEX as being 'well behaved',
* it is assumed that each 'p_array' member in use points to a GKI
* buffer and ownership of each buffer will follow the rules specified
* above for the tOBEX_HEADERS structure.  If the application has not
* registered with OBEX as being 'well behaved', the OBEX API functions
* assume that each 'p_array' member points to static memory it does
* not alter that memory.  OBEX also assumes that the Application
* Callback Functions will treat the memory pointed to by each 'p_array'
* member as static and will not alter that memory.
*/

/* OBEX Octet-Array Type Header - unstructured octet array */
typedef struct
{ 
    UINT32 length; 
    UINT8 *p_array; 
} tOBEX_OCTET_HDR; 



/*
* The tOBEX_HEADERS structure contains three arrays of the 
* following tOBEX_HDR_TRIPLET structure to hold information 
* found in the OBEX Application Request-Response Parameters 
* Header, the Authenticate Challenge Header and the 
* Authenticate Response Header.  Each of these headers contain
* one or more 'Triplets' and each triplet is stored in an
* entry in its associated tOBEX_HDR_TRIPLET array.  The 
* tOBEX_HEADERS structure contains a 'num_app_params' member
* that indicates the number of triplets contained in the 
* Application Request-Response Parameters Header, a 
* 'num_auth_challenge' member that indicates the number of
* triplets contained in the Authenticate Challenge Header and
* a 'num_auth_response' member that indicates the number of
* triplets contains in the Authenticate Response Header.
*
* If the application has registered with OBEX as being 'well behaved',
* it is assumed that each 'p_array' member in use points to a GKI
* buffer and ownership of each buffer will follow the rules specified
* above for the tOBEX_HEADERS structure.  If the application has not
* registered with OBEX as being 'well behaved', the OBEX API functions
* assume that each 'p_array' member points to static memory it does
* not alter that memory.  OBEX also assumes that the Application
* Callback Functions will treat the memory pointed to by each 'p_array'
* member as static and will not alter that memory.
*/
typedef struct obex_hdr_triplet_s 
{ 
    UINT8   tag;
    UINT8   length;
    UINT8   *p_array;
} tOBEX_HDR_TRIPLET;

/*
* The tOBEX_HEADERS structure contains an array of the 
* following tOBEX_USER_HDR structure to hold information 
* found in the OBEX User Defined Headers.  The OBEX User
* Defined Header is formatted according to the 'IrDA Object 
* Exchange Protocol (IrOBEX)' specification.  The specification
* requires that the two high-order bits of the first octet of 
* the header indicate the format and, by implication, the size 
* of the data contained in the header and the remaining bits of 
* the first octet be within the range of 0x30 to 0x3F.
*
* By performing a logical AND on the 'id' member of the 
* tOBEX_USER_HDR structure and the OBEX_USER_TYPE_MASK constant
* and comparing the results with each of the other 
* 'OBEX_USER_TYPE_....' constants, the User Defined Header 
* format can be determined.  The appropriate member of the 
* 'value' union can then be accessed and the 'length' member
* can be interpreted as follows:
*
*   ---------------------- ----------- -------------------
*  |  If the high-order   |           |                   |
*  |  2 bits of id are    |  Then     |  Contains         |
*  |----------------------|-----------|-------------------|

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -