#include <guiddef.h>
Go to the source code of this file.
#define DEFINE_OBEX_UUID | ( | name, | |||
l | ) | DEFINE_GUID( name, l, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB ); |
#define OBEX_PACKET_MAXIMUM_SIZE 65535 |
typedef int(*) AuthenticationResponseFunc(void *appData, byte *authResponse, word *authSize) |
Authentication response callback function.
This function is called by the obex client when client receives authentication challenge from server. The application then must respond by sending Authentication response. The response is passed to the obex using the authResponse and authSize parameters. The application must generate request-digest from the password and copy it to the buffer passed to the function. Obex then sends it to the server for authentication. See irOBEX specs 3.5, for more information.
appData | - Application data passed to the callback function. | |
authResponse | - The buffer where to copy the response-digest. | |
authSize | - In: The size of the buffer. Out: The size of the response-digest. |
Currently authentication is not supported and the function receiving the challenge returns OBEX_ERROR_UNSUPPORTED.
The callback must return OBEX_ERROR_AUTHENTICATION_FAILED when it doesn't want the authentication to go on.
typedef struct _BluetoothAddress BluetoothAddress |
Bluetooth address
typedef struct _BTConnection BTConnection |
typedef struct _ObexPacket ObexPacket |
typedef enum _ObexPacketHeader ObexPacketHeader |
Obex packet headers.
Values between 0x14 to 0x2F are reserved for future use (with all combinations of the upper 2 bits) Values between 0x30 to 0x3F are User defined (with all combinations of the upper 2 bits)
Read irObex spec p.13 OBEX headers how the 2 msb affect the size of the header data. 0x00 => unicode text 0x40 => byte sequence/ascii text 0x80 => 1 byte 0xC0 => 4 byte
typedef enum _ObexPacketOperation ObexPacketOperation |
Obex packet operations.
typedef enum _ObexResponseCode ObexResponseCode |
Obex response codes. Codes with final bit set has another purpose.
typedef struct _ObexSession ObexSession |
typedef enum _ObexSessionFlags ObexSessionFlags |
Obex session flags.
typedef struct _ObexTLVPacket ObexTLVPacket |
typedef struct _TagLengthValue TLV |
Tag-Length-Value
enum _ObexPacketHeader |
Obex packet headers.
Values between 0x14 to 0x2F are reserved for future use (with all combinations of the upper 2 bits) Values between 0x30 to 0x3F are User defined (with all combinations of the upper 2 bits)
Read irObex spec p.13 OBEX headers how the 2 msb affect the size of the header data. 0x00 => unicode text 0x40 => byte sequence/ascii text 0x80 => 1 byte 0xC0 => 4 byte
enum _ObexPacketOperation |
Obex packet operations.
enum _ObexResponseCode |
Obex response codes. Codes with final bit set has another purpose.
enum _ObexSessionFlags |
int closeBTConnection | ( | BTConnection * | connection | ) |
Close bluetooth connection.
Closes bluetooth connection. Calls WSACleanup.
connection | - Bluetooth connection to close. |
OBEX_ERROR_INVALID_PARAMETER if connection parameter is NULL.
int createBTConnection | ( | BTConnection ** | connection, | |
const BluetoothAddress * | device, | |||
const BluetoothAddress * | address, | |||
const OBEX_UUID * | service, | |||
byte | channel | |||
) |
Create Bluetooth connection.
Open bluetooth connection to remote device specified by bluetooth address and to specific channel or service. Uses windows sockets.
connection | - Out: Pointer to the created bluetooth connection. | |
device | - Address of local device/radio to be used with connection. Currently windows supports only one bluetooth radio. Must be set to NULL. | |
address | - Address of the remote device. | |
service | - Unique identifier specifying the service in whitch to connect to. | |
channel | - Channel to connect to. Valid channels range from 1 to 32. Zero if not used. |
Calls WSAStartup.
OBEX_INVALID_PARAMETER if one of the parameters is not valid. Connection must not be NULL. Device must be NULL. Either address or channel must be specified.
WSAGetLastError() if some other error occurs.
DEFINE_GUID | ( | SERVICE_TARGET_SYNCML_SYNC | , | |
0x53594e43 | , | |||
0x4d4c | , | |||
0x2d53 | , | |||
0x59 | , | |||
0x4e | , | |||
0x43 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | ||||
) |
DEFINE_GUID | ( | SERVICE_TARGET_IRMC_SYNC | , | |
0x49524D43 | , | |||
0x2D53 | , | |||
0x594E | , | |||
0x43 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | , | |||
0x00 | ||||
) |
DEFINE_GUID | ( | SERVICE_TARGET_FOLDER_BROWSING | , | |
0xF9EC7BC4 | , | |||
0x953C | , | |||
0x11D2 | , | |||
0x98 | , | |||
0x4E | , | |||
0x52 | , | |||
0x54 | , | |||
0x00 | , | |||
0xDC | , | |||
0x9E | , | |||
0x09 | ||||
) |
int obexPacketAddHeader | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word | size, | |||
void * | data | |||
) |
Add header to obex packet.
This function adds header and it's data to the packet. The size that the header needs depends on the ObexPacketHeader. Headers starting with 0x00 and 0x40 are 2 byte length prefixed headers and need 1 byte for header + 2 bytes for the size and n bytes for the data. The 2 byte size contain the size of the whole header(1+2+n). This function appends the header id,size and the data to the packet. Headers starting with 0x80 and 0xC0 need 2 or 5 bytes(header + 1byte or 4 bytes).
packet | - Packet where the heaeder is added to. | |
header | - Packet operation. | |
size | - Size of the header data in bytes. | |
data | - Pointer to the data. |
The data in the headers is in it's raw format(network byte order). One must convert it to the network byte order before using the function. obexPacketAddHeaderXXX functions and obexPacketGetHeaderXXX functions convert the data for the user.
The maximum size for the packet is 64K. It is possible to create bigger packets than session supports.
User defined headers are not supported. The function returns OBEX_ERROR_INVALID_PARAMETER.
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function, or if parameter combination is not valid according to specifications or packet already contains same header.
OBEX_ERROR_PACKET_TOO_LARGE if the header doesn't fit to the packet.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
int obexPacketAddHeaderAscii | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
const char * | string | |||
) |
Add ascii string type header to obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
string | - Null terminating ascii string. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not ascii type.
int obexPacketAddHeaderBin | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word | size, | |||
byte * | bytes | |||
) |
Add binary byte sequence to packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
size | - The number of bytes in the byte sequence. | |
bytes | - Pointer to the bytes. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not binary byte sequence type.
int obexPacketAddHeaderByte | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
byte | value | |||
) |
Add 1 byte unsigned integer to packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The integer value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not 1 byte unsigned integer type.
int obexPacketAddHeaderInt | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
dword | value | |||
) |
Add 4 byte unsigned integer to packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The integer value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not 4 byte unsigned integer type.
int obexPacketAddHeaderTLV | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
ObexTLVPacket * | tlvPacket | |||
) |
Add TLV packet to obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
tlvPacket | - TLV packet to be added. |
int obexPacketAddHeaderUnicode | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
const wchar_t * | string | |||
) |
Add unicode string type header to obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
string | - Null terminating unicode string. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not unicode type.
int obexPacketAddHeaderUUID | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
OBEX_UUID | value | |||
) |
Add UUID to packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The UUID value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not Unique identifier type.
int obexPacketClear | ( | ObexPacket * | packet, | |
ObexPacketOperation | operation, | |||
byte | flags | |||
) |
Clear obex packet.
Function clears used packet and initializes it for the given new operation.
packet | - Packet to be cleared. | |
operation | - New operation for the packet. | |
flags | - New operation flags. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
int obexPacketCreate | ( | ObexPacket ** | packet, | |
ObexPacketOperation | operation, | |||
byte | flags | |||
) |
Create obex packet.
Create packet for certain operation. Flags depend on the operation. See irOBEX specs operations for valid flags.
packet | - Out: Pointer to the created obex packet. | |
operation | - Packet operation. | |
flags | - Flags depending on the operation. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
OBEX_ERROR_UNSUPPORTED if SESSION operation is passed to function.
int obexPacketDestroy | ( | ObexPacket * | packet | ) |
Destroy packet.
packet | - Packet to be destroyed. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
int obexPacketGetHeaderAscii | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
char * | string, | |||
int | size | |||
) |
Get ascii string type header to obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. Only supported headers are TYPE and HTTP. | |
string | - Null terminating unicode string. | |
size | - Maximum size of the string in bytes. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not ascii type.
int obexPacketGetHeaderBin | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word * | size, | |||
byte * | bytes | |||
) |
Get binary byte sequence from packet.
packet | - The packet to add the header. | |
header | - Header to be added. BODY. | |
size | - In: The size of the buffer. Out: The number of bytes copied. | |
bytes | - Pointer to the bytes. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not binary byte sequence type.
int obexPacketGetHeaderByte | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
byte * | value | |||
) |
Get 1 byte unsigned int from packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The integer value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not 1 byte unsigned integer type.
int obexPacketGetHeaderData | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
void * | outData | |||
) |
Get header data.
Copy the header data from packet to user buffer. The buffer must be large enough to contain the whole header data. Use obexPacketHasHeader to get the size of the header.
packet | - Packet to get the header data from. | |
header | - The header to get the data from. | |
outData | - Pointer to memory where the function copies the data. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_UNDEFINED if packet doesn't have the header.
int obexPacketGetHeaderInt | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
dword * | value | |||
) |
Get 4 byte unsigned int from packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The integer value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not 4 byte unsigned integer type.
int obexPacketGetHeaderTLV | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
ObexTLVPacket ** | tlvPacket | |||
) |
Get TLV packet from obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
tlvPacket | - TLV packet to be added. |
int obexPacketGetHeaderUnicode | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
wchar_t * | string, | |||
int | size | |||
) |
Get unicode string type header to obex packet.
packet | - The packet to add the header. | |
header | - Header to be added. Only supported headers are NAME and DESCRIPTION. | |
string | - Null terminating unicode string. | |
size | - Maximum size of the string in bytes. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not unicode type.
int obexPacketGetHeaderUUID | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
OBEX_UUID * | value | |||
) |
Get UUID from packet.
packet | - The packet to add the header. | |
header | - Header to be added. | |
value | - The UUID value to be added. |
OBEX_ERROR_INVALID_PARAMETER if the header being added is not Unique identifier type.
byte obexPacketGetId | ( | ObexPacket * | packet | ) |
Get obex packet id.
Packet id is either operation code or full response code. To get ObexResponseCode from the id call obexResponseCode function.
packet | - Packet to get the id from. |
word obexPacketGetSize | ( | ObexPacket * | packet | ) |
Get obex packet size.
packet | - Packet to get the size from. |
word obexPacketGetSizeLeft | ( | ObexSession * | session, | |
ObexPacket * | packet | |||
) |
Get size left in a packet supported by session.
Same as obexSessionGetMaximumRequestSize(session) - obexPacketGetSize(packet).
session | - Session where the packet is supposed to be sent. | |
packet | - Packet to get the size left from. |
int obexPacketHasHeader | ( | ObexPacket * | packet, | |
ObexPacketHeader | header, | |||
word * | headerSize | |||
) |
Query packet headers.
packet | - Packet to be queried from. | |
header | - Header to be queried. | |
headerSize | - Out: Size of the header in bytes returned by the function. Can be NULL. |
ObexResponseCode obexResponseCode | ( | byte | packetId, | |
int * | finalBitSet | |||
) |
Convert response packet id to response code and final bit.
packetId | - Id from the response packet. | |
finalBitSet | - Out: set to zero if final bit not set. |
OBEX_RESPONCE_CODE_UNKNOWN if unknown response code.
int obexSessionClose | ( | ObexSession * | session | ) |
Close obex session.
Sends DISCONNECT to the server.
session | - Session to be closed. |
OBEX_ERROR_INVALID_PARAMETER if session parameter is NULL.
ObexResponseCode if the server returns something other that OBEX_RESPONCE_CODE_SUCCESS.
dword obexSessionGetConnectionId | ( | ObexSession * | session | ) |
Get the connection id from session.
The session id is assigned by server to session when using obexSessionOpen with target specified. Though not all sessions get assigned by session id. The session id must be the first header in a packet when it is used.
session | - Session to ask the id from. |
int obexSessionGetConnectionTarget | ( | ObexSession * | session, | |
OBEX_UUID * | uuid | |||
) |
Get the connection target.
Get the connection target returned by server. Should be the same as the target passed to obexSessionOpen.
session | - Session to ask the target from. | |
uuid | - Out: The connection target returned by server; |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
word obexSessionGetMaximumRequestSize | ( | ObexSession * | session | ) |
Get the maximum packet size supported by session.
The maximum packet size is negotiated when calling obexSessionOpen function.
session | - Session to ask the maximum packet size from. |
int obexSessionOpen | ( | ObexSession ** | session, | |
BTConnection * | connection, | |||
ObexPacket * | request, | |||
ObexPacket ** | response, | |||
const OBEX_UUID * | target, | |||
AuthenticationResponseFunc | authFunc, | |||
void * | appData, | |||
ObexSessionFlags | flags | |||
) |
Open obex session to the obex server.
Sends CONNECT to the server and negotiate maximum packet size.
session | - Out: Pointer to the opened session. | |
connection | - Opened bluetooth connection to be used by session. | |
request | - Optional request packet by user. If NULL the function uses default packet. | |
response | - Handle to response packet returned by the server if not NULL. | |
target | - UUID for target header or NULL. | |
authFunc | - Application defined callback function for authentication response. | |
appData | - Optional application data passed to authentication function. | |
flags | - Session opening flags. |
The authentication function is called when server requests authentication.
The authentication function is also called if the OBEX_SESSION_FLAGS_AUTHENTICATE is passed to the function.
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
OBEX_ERROR_UNSUPPORTED if server returned authentication response or request parameter is not NULL.
OBEX_ERROR_INVALID_PACKET if server returned garbage.
ObexResponseCode if the server returns something other that OBEX_RESPONCE_CODE_SUCCESS.
int obexSessionSend | ( | ObexSession * | session, | |
ObexPacket * | request, | |||
ObexPacket ** | response | |||
) |
Send obex packet and receive the response.
session | - Session handle to be used in the send. | |
request | - Obex packet that contains the request. | |
response | - Handle to obex packet containing the response. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_INVALID_PACKET if server returned garbage.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
OBEX_ERROR_PACKET_TOO_LARGE if the packet passed to function exceeds session maximum packet size.
int obexTLVAddValue | ( | ObexTLVPacket * | tlvPacket, | |
TLV * | tlv | |||
) |
Add new triplet to packet.
tlvPacket | - Packet where the triplet is added to. | |
tlv | - TLV triplet to be added to the packet. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
OBEX_ERROR_PACKET_TOO_LARGE if the triplet doesn't fit to the packet.
int obexTLVCreate | ( | ObexTLVPacket ** | tlvPacket | ) |
Create new Tag-Length-Value triplet packet.
tlvPacket | - Handle to the created packet. |
OBEX_ERROR_INVALID_PARAMETER if tlvPacket parameter is NULL.
OBEX_ERROR_OUT_OF_MEMORY if out of memory.
int obexTLVDestroy | ( | ObexTLVPacket * | tlvPacket | ) |
Destroy Tag-Length-Value triplet packet.
tlvPacket | - Packet to be destroyed |
OBEX_ERROR_INVALID_PARAMETER if tlvPacket parameter is NULL.
byte obexTLVGetCount | ( | ObexTLVPacket * | tlvPacket | ) |
Get the number of triplets in packet.
tlvPacket | - The packet to get the count from. |
word obexTLVGetSize | ( | ObexTLVPacket * | tlvPacket | ) |
Get the size of the TLV packet in bytes.
tlvPacket | - The packet to get the size from. |
int obexTLVGetValue | ( | ObexTLVPacket * | tlvPacket, | |
byte | index, | |||
TLV * | tlv | |||
) |
Get the TLV from a packet.
tlvPacket | - The packet to get the value from. | |
index | - The zero based index of the triplet. | |
tlv | - Returned tlv value. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
int peekBTConnection | ( | BTConnection * | connection, | |
dword * | available | |||
) |
Peek available data in connection.
connection | - Connection where to peek. | |
available | - Amount of data available to be read from connection. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
WSAGetLastError() if some other error occurs.
int readBTConnection | ( | BTConnection * | connection, | |
dword * | size, | |||
void * | data | |||
) |
Read data from connection.
connection | - Connection where to read the data from. | |
size | - In: the amount of bytes to read. Out: The amount of bytes read. | |
data | - Pointer to memory where the data is read. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
WSAGetLastError() if some other error occurs.
int writeBTConnection | ( | BTConnection * | connection, | |
dword * | size, | |||
void * | data | |||
) |
Write data to connection.
connection | - Connection where to write the data to. | |
size | - In: Amount of data in bytes to be written. Out: Amout of bytes written. | |
data | - Pointer to memory where the data is red. |
OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.
WSAGetLastError() if some other error occurs.