#include "obex.h"
#include <winsock2.h>
#include <bthdef.h>
#include <Bthsdpdef.h>
#include <BluetoothAPIs.h>
Go to the source code of this file.
Data Structures | |
struct | _BTConnection |
struct | _HeaderOffsetEntry |
struct | _ObexDataBuffer |
struct | _ObexPacket |
struct | _ObexSession |
Defines | |
#define | OBEX_BLUETOOTH_MAX_CHANNEL 32 |
#define | OBEX_CONNECT_REQ_SIZE 7 |
#define | OBEX_CONNECT_RES_SIZE 7 |
#define | OBEX_DEFAULT_REQ_SIZE 3 |
#define | OBEX_DEFAULT_RES_SIZE 3 |
#define | OBEX_DEFAULT_VERSION 0x10 |
#define | OBEX_MINUMUM_RESPONSE_SIZE 3 |
#define | OBEX_SETPATH_REQ_SIZE 5 |
#define | OBEX_SOCKET_VERSION MAKEWORD( 2, 2 ) |
#define | obexAlloc(size) malloc(size) |
#define | obexDealloc(ptr) free(ptr); |
Typedefs | |
typedef _HeaderOffsetEntry | HeaderOffsetEntry |
typedef _ObexDataBuffer | ObexDataBuffer |
typedef enum _ObexPacketType | ObexPacketType |
typedef enum _ObexSessionState | ObexSessionState |
Enumerations | |
enum | _ObexPacketType { OBEX_PACKET_TYPE_UNKNOWN = 0, OBEX_PACKET_TYPE_REQUEST = 1, OBEX_PACKET_TYPE_RESPONSE } |
enum | _ObexSessionState { OBEX_SESSION_STATE_UNKNOWN = 0, OBEX_SESSION_STATE_UNINITIALIZED = 1, OBEX_SESSION_STATE_OPERATING, OBEX_SESSION_STATE_SUSPENDED, OBEX_SESSION_STATE_DISCONNECTED, OBEX_SESSION_STATE_FORCE_DWORD = 0xffffffff } |
Functions | |
BOOL | checkPacketHeader (ObexPacket *packet, ObexPacketHeader header, word size) |
check packet header | |
BOOL | exclusiveHeader (ObexPacketHeader header1, ObexPacketHeader header2) |
check if 2 headers are exclusive | |
BOOL | legalOperationFlag (ObexPacketOperation operation, byte flags) |
Check if flags are valid for operation. | |
BOOL | legalPacketHeader (ObexPacketHeader header) |
Check if ObexPacketHeader passed to function is legal. | |
BOOL | legalPacketOperation (ObexPacketOperation operation) |
Check if ObexPacketOperation passed to function is legal. | |
void | MD5 (void *dest, void *orig, int len) |
create md5 hash value | |
int | obexDataBufferRead (ObexDataBuffer *buffer, dword *size, void *data) |
Read from data buffer. | |
int | obexDataBufferWrite (ObexDataBuffer *buffer, dword size, void *data) |
Write to data buffer. | |
int | obexPacketAddHeaderOffset (ObexPacket *packet, ObexPacketHeader header, word offset, word size) |
Add header offset information to packet. | |
word | obexPacketGetEmptyPacketSize (ObexPacketOperation operation) |
Get initial packet size. | |
int | obexPacketGetMaximumPacketSize (ObexPacket *packet, word *size) |
Get maximum packet size from response packet. | |
int | obexPacketGetVersion (ObexPacket *packet, byte *minor, byte *major) |
Get OBEX version from response packet. | |
int | obexPacketInitialize (ObexPacket *newPacket, ObexPacketOperation operation, byte flags) |
Initialize new packet for operation. | |
int | obexPacketParseResponse (ObexPacket *request, ObexPacket *response) |
Parse response. | |
int | obexPacketSetMaximumPacketSize (ObexPacket *packet, word size) |
Set maximum packet size from request packet. | |
int | obexPacketSetVersion (ObexPacket *packet, byte minor, byte major) |
Set version number to CONNECT request packet. | |
int | obexPacketTransfer (BTConnection *connection, ObexPacket *request, ObexPacket **response) |
Transfer packet. |
#define OBEX_BLUETOOTH_MAX_CHANNEL 32 |
Definition at line 29 of file obex_def.h.
#define OBEX_CONNECT_REQ_SIZE 7 |
Definition at line 33 of file obex_def.h.
#define OBEX_CONNECT_RES_SIZE 7 |
Definition at line 37 of file obex_def.h.
#define OBEX_DEFAULT_REQ_SIZE 3 |
Definition at line 35 of file obex_def.h.
#define OBEX_DEFAULT_RES_SIZE 3 |
Definition at line 38 of file obex_def.h.
#define OBEX_DEFAULT_VERSION 0x10 |
Definition at line 40 of file obex_def.h.
#define OBEX_MINUMUM_RESPONSE_SIZE 3 |
Definition at line 31 of file obex_def.h.
#define OBEX_SETPATH_REQ_SIZE 5 |
Definition at line 34 of file obex_def.h.
#define OBEX_SOCKET_VERSION MAKEWORD( 2, 2 ) |
Definition at line 28 of file obex_def.h.
#define obexAlloc | ( | size | ) | malloc(size) |
Definition at line 425 of file obex_def.h.
#define obexDealloc | ( | ptr | ) | free(ptr); |
Definition at line 426 of file obex_def.h.
typedef struct _HeaderOffsetEntry HeaderOffsetEntry |
Structure that contains offset data to the packet data.
typedef struct _ObexDataBuffer ObexDataBuffer |
Data buffer structure used when pulling/pushing to/from memory.
typedef enum _ObexPacketType ObexPacketType |
Packet types
typedef enum _ObexSessionState ObexSessionState |
Session states.
enum _ObexPacketType |
Packet types
Definition at line 127 of file obex_def.h.
enum _ObexSessionState |
Session states.
Definition at line 45 of file obex_def.h.
BOOL checkPacketHeader | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word | size | |||
) |
check packet header
This function checks if header can be added to packet. Used by obexPacketAddHeader function. Whether or not the header can be added to the packet depends on many thisgs.
1. The packet cannot contain more than 1 header of the same kind
2. Connection id and target are exclusive in request packet
3. Body and end of body are exclusive
4. The packet data size exceeds maximum packet size or it can't fit to it
5. COUNT header is allowen only in CONNECT
6. Connection id must be first header
7. The size must match header id.
packet | - The packet to check against | |
header | - The header that is going to be added to the packet | |
size | - The size of the data in the header |
BOOL exclusiveHeader | ( | ObexPacketHeader | header1, | |
ObexPacketHeader | header2 | |||
) |
check if 2 headers are exclusive
Checks if 2 headers can not be in the same packet. Used by checkPacketHeader function.
header1 | - Header 1 | |
header2 | - Header 2 |
BOOL legalOperationFlag | ( | ObexPacketOperation | operation, | |
byte | flags | |||
) |
Check if flags are valid for operation.
operation | - operation | |
flags | - flags |
BOOL legalPacketHeader | ( | ObexPacketHeader | header | ) |
Check if ObexPacketHeader passed to function is legal.
Checks if header is legal. The header is not legal if the constant is not in the enumerated values. It is possible to pass undefined values to functions even when the type is enumerated. Used by many packet functions. Currently does not recognise user defined headers.
header | - value to check |
BOOL legalPacketOperation | ( | ObexPacketOperation | operation | ) |
Check if ObexPacketOperation passed to function is legal.
Checks if header is legal. The operation is not legal if the constant is not in the enumerated values. It is possible to pass undefined values to functions even when the parameter type is enumerated. Used by many packet functions.
operation | - value to check |
void MD5 | ( | void * | dest, | |
void * | orig, | |||
int | len | |||
) |
create md5 hash value
dest | - Destination, 16 byte buffer | |
orig | - Source data to hash | |
len | - length of the source |
int obexDataBufferRead | ( | ObexDataBuffer * | buffer, | |
dword * | size, | |||
void * | data | |||
) |
Read from data buffer.
buffer | - DataBuffer to read | |
size | - In: size to read. Out: Size actually read. | |
data | - Buffer to read the data to |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters were passed to function
int obexDataBufferWrite | ( | ObexDataBuffer * | buffer, | |
dword | size, | |||
void * | data | |||
) |
Write to data buffer.
buffer | - DataBuffer to write | |
size | - In: size to write. Out: Size actually written. | |
data | - Buffer to write the data from |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters were passed to function
int obexPacketAddHeaderOffset | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word | offset, | |||
word | size | |||
) |
Add header offset information to packet.
The function adds header offset information and size information to packet.
packet | - Packet that contains the header data the offset data refers to | |
header | - The header id | |
offset | - Offset from the beginning of the packetData to the beginning of the header data(header id is always the first byte) | |
size | - The size of the header data(not contaning the id and size) |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_OUT_OF_MEMORY if out of memory
word obexPacketGetEmptyPacketSize | ( | ObexPacketOperation | operation | ) |
Get initial packet size.
The function returns the initial size of the empty packet depending on the operation
operation | - The operation of the packet |
int obexPacketGetMaximumPacketSize | ( | ObexPacket * | packet, | |
word * | size | |||
) |
Get maximum packet size from response packet.
The function gets the maximum packet size word from packetData. Packet must be response. This function is used after the client has sent CONNECT request to server and it has responded.
packet | - Packet where to get the size from | |
size | - Out: The maximum packet size supported by the server |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_INVALID_PACKET if packet is not response packet or its too small
int obexPacketGetVersion | ( | ObexPacket * | packet, | |
byte * | minor, | |||
byte * | major | |||
) |
Get OBEX version from response packet.
The function gets the minor and major version numbers from response packet to connect request.
packet | - Packet to set the version to | |
minor | - Out: minor version number | |
major | - Out: major version number |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_INVALID_PACKET if packet is not response packet or its too small
int obexPacketInitialize | ( | ObexPacket * | newPacket, | |
ObexPacketOperation | operation, | |||
byte | flags | |||
) |
Initialize new packet for operation.
The function initializes new request packet for the operation specified by the operation parameter. The new packet must have been allocated using obexAlloc.
newPacket | - New packet to be initiaized | |
operation | - The operation performed by the packet | |
flags | - operation specific fklags |
OBEX_ERROR_OUT_OF_MEMORY if out of memory
int obexPacketParseResponse | ( | ObexPacket * | request, | |
ObexPacket * | response | |||
) |
Parse response.
The function goes trough the data returned by the server and constructs response packet from it. The data that is parsed is in the response packet.
request | - Information from request is needed in parsing | |
response | - In: unconstructed response packet. Out: valid response packet. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_INVALID_PACKET if data returned by the server is incorrect
int obexPacketSetMaximumPacketSize | ( | ObexPacket * | packet, | |
word | size | |||
) |
Set maximum packet size from request packet.
The function sets the maximum packet size word to packetData. Packet must be request. This function is used before the client has sent CONNECT request to server.
packet | - Packet to set the size to | |
size | - The size supported by our client |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_INVALID_PACKET if packet is not CONNECT request packet or its too small
int obexPacketSetVersion | ( | ObexPacket * | packet, | |
byte | minor, | |||
byte | major | |||
) |
Set version number to CONNECT request packet.
The function sets the minor and major version numbers to CONNECT request which is 1.0
packet | - Packet to set the version to | |
minor | - Minor version number | |
major | - Major version number |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_INVALID_PACKET if packet is not CONNECT request packet or its too small
int obexPacketTransfer | ( | BTConnection * | connection, | |
ObexPacket * | request, | |||
ObexPacket ** | response | |||
) |
Transfer packet.
The main function for sending request packet and receiving response packet. Sends the request packet and receives response packet data. Constructs response packet from the response and checks it is valid.
connection | - Bluetooth connection used in the transfer | |
request | - Pointer to request packet to be send | |
response | - Handle to response packet received and validated by the function |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function
OBEX_ERROR_OUT_OF_MEMORY if out of memory