goep_server: add goep_server_response_get_max_body_size

This commit is contained in:
Matthias Ringwald 2022-05-13 16:23:13 +02:00
parent e23a847672
commit 1a9eef6299
2 changed files with 20 additions and 0 deletions

View File

@ -601,6 +601,17 @@ uint8_t goep_server_response_create_general(uint16_t goep_cid, uint8_t opcode){
return obex_message_builder_response_create_general(buffer, buffer_len, opcode);
}
uint16_t goep_server_response_get_max_body_size(uint16_t goep_cid){
goep_server_connection_t * connection = goep_server_get_connection_for_goep_cid(goep_cid);
if (connection == NULL) {
return 0;
}
uint8_t * buffer = goep_server_get_outgoing_buffer(connection);
uint16_t buffer_len = goep_server_get_outgoing_buffer_len(connection);
uint16_t pos = big_endian_read_16(buffer, 1);
return buffer_len - pos;
}
uint8_t goep_server_header_add_end_of_body(uint16_t goep_cid, const uint8_t * end_of_body, uint16_t length){
goep_server_connection_t * connection = goep_server_get_connection_for_goep_cid(goep_cid);
if (connection == NULL) {

View File

@ -151,6 +151,15 @@ uint8_t goep_server_response_create_connect(uint16_t goep_cid, uint8_t obex_vers
*/
uint8_t goep_server_response_create_general(uint16_t goep_cid, uint8_t opcode);
/**
* @brief Get max size of body data that can be added to current response with goep_server_header_add_end_of_body
* @param goep_cid
* @param data
* @param length
* @return size in bytes or 0
*/
uint16_t goep_server_response_get_max_body_size(uint16_t goep_cid);
/**
* @brief Add who header to current response
* @param goep_cid