KNX IoT
KNX IoT Point API stack implementation
oc_blockwise.h File Reference

CoAP block wise transfer implementation. More...

#include "messaging/coap/coap.h"
#include "messaging/coap/transactions.h"
#include "oc_helpers.h"
#include "oc_ri.h"
#include "port/oc_connectivity.h"

Go to the source code of this file.

Data Structures

struct  oc_blockwise_request_state_s
 the blockwise request state More...
 
struct  oc_blockwise_response_state_s
 the blockwise response state More...
 

Typedefs

typedef struct oc_blockwise_request_state_s oc_blockwise_request_state_t
 the blockwise request state More...
 
typedef struct oc_blockwise_response_state_s oc_blockwise_response_state_t
 the blockwise response state More...
 
typedef struct oc_blockwise_state_s oc_blockwise_state_t
 

Enumerations

enum  oc_blockwise_role_t { OC_BLOCKWISE_CLIENT = 0 , OC_BLOCKWISE_SERVER }
 role of the transfer More...
 

Functions

oc_blockwise_state_t * oc_blockwise_alloc_request_buffer (const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method, oc_blockwise_role_t role)
 allocate the request buffer More...
 
oc_blockwise_state_t * oc_blockwise_alloc_response_buffer (const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method, oc_blockwise_role_t role)
 allocate the response buffer More...
 
const void * oc_blockwise_dispatch_block (oc_blockwise_state_t *buffer, uint32_t block_offset, uint32_t requested_block_size, uint32_t *payload_size)
 send the block More...
 
oc_blockwise_state_t * oc_blockwise_find_request_buffer (const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method, const char *query, size_t query_len, oc_blockwise_role_t role)
 find request buffer based on more information More...
 
oc_blockwise_state_t * oc_blockwise_find_request_buffer_by_client_cb (oc_endpoint_t *endpoint, void *client_cb)
 find the request by client callback & endpoint More...
 
oc_blockwise_state_t * oc_blockwise_find_request_buffer_by_mid (uint16_t mid)
 find the block wise request based on mid More...
 
oc_blockwise_state_t * oc_blockwise_find_request_buffer_by_token (uint8_t *token, uint8_t token_len)
 find the request by token More...
 
oc_blockwise_state_t * oc_blockwise_find_response_buffer (const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method, const char *query, size_t query_len, oc_blockwise_role_t role)
 find response buffer based on more information More...
 
oc_blockwise_state_t * oc_blockwise_find_response_buffer_by_client_cb (oc_endpoint_t *endpoint, void *client_cb)
 find the response by client callback & endpoint More...
 
oc_blockwise_state_t * oc_blockwise_find_response_buffer_by_mid (uint16_t mid)
 find the block wise response based on mid More...
 
oc_blockwise_state_t * oc_blockwise_find_response_buffer_by_token (uint8_t *token, uint8_t token_len)
 find the response by token More...
 
void oc_blockwise_free_request_buffer (oc_blockwise_state_t *buffer)
 free the request buffer More...
 
void oc_blockwise_free_response_buffer (oc_blockwise_state_t *buffer)
 free the response buffer More...
 
bool oc_blockwise_handle_block (oc_blockwise_state_t *buffer, uint32_t incoming_block_offset, const uint8_t *incoming_block, uint32_t incoming_block_size)
 handle the incoming block (partial message) More...
 
void oc_blockwise_scrub_buffers (bool all)
 free all blocks that are handled (ref_count = 0) More...
 
void oc_blockwise_scrub_buffers_for_client_cb (void *cb)
 scrub blocks for client side More...
 
oc_blockwise_state_t * oc_get_request_buffer_with_ptr (uint8_t *data)
 get blockwise buffer that contains data in its payload More...
 

Detailed Description

CoAP block wise transfer implementation.

Definition in file oc_blockwise.h.

Typedef Documentation

◆ oc_blockwise_request_state_t

the blockwise request state

◆ oc_blockwise_response_state_t

the blockwise response state

Enumeration Type Documentation

◆ oc_blockwise_role_t

role of the transfer

Enumerator
OC_BLOCKWISE_CLIENT 

client

OC_BLOCKWISE_SERVER 

server

Definition at line 37 of file oc_blockwise.h.

37  {
oc_blockwise_role_t
role of the transfer
Definition: oc_blockwise.h:37
@ OC_BLOCKWISE_SERVER
server
Definition: oc_blockwise.h:39
@ OC_BLOCKWISE_CLIENT
client
Definition: oc_blockwise.h:38

Function Documentation

◆ oc_blockwise_alloc_request_buffer()

oc_blockwise_state_t* oc_blockwise_alloc_request_buffer ( const char *  href,
size_t  href_len,
oc_endpoint_t endpoint,
oc_method_t  method,
oc_blockwise_role_t  role 
)

allocate the request buffer

Parameters
hrefthe href
href_lenthe href length
endpointthe endpoint
methodthe CoAP method
rolethe role (clien or server)
Returns
oc_blockwise_state_t*

◆ oc_blockwise_alloc_response_buffer()

oc_blockwise_state_t* oc_blockwise_alloc_response_buffer ( const char *  href,
size_t  href_len,
oc_endpoint_t endpoint,
oc_method_t  method,
oc_blockwise_role_t  role 
)

allocate the response buffer

Parameters
hrefthe href
href_lenthe href length
endpointthe endpoint
methodthe CoAP method
rolethe role (client or server)
Returns
oc_blockwise_state_t*

◆ oc_blockwise_dispatch_block()

const void* oc_blockwise_dispatch_block ( oc_blockwise_state_t *  buffer,
uint32_t  block_offset,
uint32_t  requested_block_size,
uint32_t *  payload_size 
)

send the block

Parameters
bufferthe buffer (whole message)
block_offsetthe block offset
requested_block_sizeblock size to be send
payload_sizethe send payload size
Returns
const void*

◆ oc_blockwise_find_request_buffer()

oc_blockwise_state_t* oc_blockwise_find_request_buffer ( const char *  href,
size_t  href_len,
oc_endpoint_t endpoint,
oc_method_t  method,
const char *  query,
size_t  query_len,
oc_blockwise_role_t  role 
)

find request buffer based on more information

Parameters
hrefthe href
href_lenthe href length
endpointthe endpoint
methodthe method
querythe query parameters
query_lenthe query length
rolethe role (client or server)
Returns
oc_blockwise_state_t*

◆ oc_blockwise_find_request_buffer_by_client_cb()

oc_blockwise_state_t* oc_blockwise_find_request_buffer_by_client_cb ( oc_endpoint_t endpoint,
void *  client_cb 
)

find the request by client callback & endpoint

Parameters
endpointthe endpoint
client_cbthe callback
Returns
oc_blockwise_state_t*

◆ oc_blockwise_find_request_buffer_by_mid()

oc_blockwise_state_t* oc_blockwise_find_request_buffer_by_mid ( uint16_t  mid)

find the block wise request based on mid

Parameters
midthe message id
Returns
oc_blockwise_state_t* the block transfer

◆ oc_blockwise_find_request_buffer_by_token()

oc_blockwise_state_t* oc_blockwise_find_request_buffer_by_token ( uint8_t *  token,
uint8_t  token_len 
)

find the request by token

Parameters
tokenthe token
token_lenthe token length
Returns
oc_blockwise_state_t* the block transfer

◆ oc_blockwise_find_response_buffer()

oc_blockwise_state_t* oc_blockwise_find_response_buffer ( const char *  href,
size_t  href_len,
oc_endpoint_t endpoint,
oc_method_t  method,
const char *  query,
size_t  query_len,
oc_blockwise_role_t  role 
)

find response buffer based on more information

Parameters
hrefthe href
href_lenthe href length
endpointthe endpoint
methodthe method
querythe query parameters
query_lenthe query length
rolethe role (client or server)
Returns
oc_blockwise_state_t*

◆ oc_blockwise_find_response_buffer_by_client_cb()

oc_blockwise_state_t* oc_blockwise_find_response_buffer_by_client_cb ( oc_endpoint_t endpoint,
void *  client_cb 
)

find the response by client callback & endpoint

Parameters
endpointthe endpoint
client_cbthe callback
Returns
oc_blockwise_state_t*

◆ oc_blockwise_find_response_buffer_by_mid()

oc_blockwise_state_t* oc_blockwise_find_response_buffer_by_mid ( uint16_t  mid)

find the block wise response based on mid

Parameters
midthe message id
Returns
oc_blockwise_state_t* the block transfer

◆ oc_blockwise_find_response_buffer_by_token()

oc_blockwise_state_t* oc_blockwise_find_response_buffer_by_token ( uint8_t *  token,
uint8_t  token_len 
)

find the response by token

Parameters
tokenthe token
token_lenthe token length
Returns
oc_blockwise_state_t* the block transfer

◆ oc_blockwise_free_request_buffer()

void oc_blockwise_free_request_buffer ( oc_blockwise_state_t *  buffer)

free the request buffer

Parameters
bufferthe buffer to be freed

◆ oc_blockwise_free_response_buffer()

void oc_blockwise_free_response_buffer ( oc_blockwise_state_t *  buffer)

free the response buffer

Parameters
bufferthe response buffer to be freed

◆ oc_blockwise_handle_block()

bool oc_blockwise_handle_block ( oc_blockwise_state_t *  buffer,
uint32_t  incoming_block_offset,
const uint8_t *  incoming_block,
uint32_t  incoming_block_size 
)

handle the incoming block (partial message)

Parameters
bufferthe whole message
incoming_block_offsetthe block offset
incoming_blockthe incoming block to be added
incoming_block_sizethe size of the incoming block
Returns
true
false

◆ oc_blockwise_scrub_buffers()

void oc_blockwise_scrub_buffers ( bool  all)

free all blocks that are handled (ref_count = 0)

Parameters
all: including ref count != 0

◆ oc_blockwise_scrub_buffers_for_client_cb()

void oc_blockwise_scrub_buffers_for_client_cb ( void *  cb)

scrub blocks for client side

Parameters
cbthe callback

◆ oc_get_request_buffer_with_ptr()

oc_blockwise_state_t* oc_get_request_buffer_with_ptr ( uint8_t *  data)

get blockwise buffer that contains data in its payload

Parameters
datapointer suspected to be inside a blockwise buffer
Returns
oc_blockwise_request_state_t* the blockwise state that contains the data, or NULL if not found