mirror of
https://github.com/obgm/libcoap.git
synced 2026-10-31 23:15:48 +03:00
i/c/block.h: whitespace cleanup, reformatting, no changes
Just some cleanup like whitespace, punctiation marking and indentation issues.
This commit is contained in:
1 parent
e2683eb218
commit
4d7752ddf0
1 file changed
+51
-48
+51
-48
@@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2010--2012,2014,2015 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see
|
||||
* README for terms of use.
|
||||
* README for terms of use.
|
||||
*/
|
||||
|
||||
#ifndef _COAP_BLOCK_H_
|
||||
@@ -20,24 +20,23 @@
|
||||
|
||||
#ifndef COAP_MAX_BLOCK_SZX
|
||||
/**
|
||||
* The largest value for the SZX component in a Block option. Note
|
||||
* that 1 << (COAP_MAX_BLOCK_SZX + 4) should not exceed
|
||||
* COAP_MAX_PDU_SIZE.
|
||||
* The largest value for the SZX component in a Block option. Note that
|
||||
* 1 << (COAP_MAX_BLOCK_SZX + 4) should not exceed COAP_MAX_PDU_SIZE.
|
||||
*/
|
||||
#define COAP_MAX_BLOCK_SZX 4
|
||||
#endif /* COAP_MAX_BLOCK_SZX */
|
||||
|
||||
/**
|
||||
* Structure of Block options.
|
||||
* Structure of Block options.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int num; /**< block number */
|
||||
unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */
|
||||
unsigned int szx:3; /**< block size */
|
||||
unsigned int num; /**< block number */
|
||||
unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */
|
||||
unsigned int szx:3; /**< block size */
|
||||
} coap_block_t;
|
||||
|
||||
/**
|
||||
* Returns the value of the least significant byte of a Block option @p opt.
|
||||
* Returns the value of the least significant byte of a Block option @p opt.
|
||||
* For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST
|
||||
* returns @c NULL.
|
||||
*/
|
||||
@@ -53,8 +52,7 @@ typedef struct {
|
||||
(COAP_OPT_LENGTH(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0)
|
||||
|
||||
/**
|
||||
* Returns the value of field @c num in the given block option @p
|
||||
* block_opt.
|
||||
* Returns the value of field @c num in the given block option @p block_opt.
|
||||
*/
|
||||
unsigned int coap_opt_block_num(const coap_opt_t *block_opt);
|
||||
|
||||
@@ -78,56 +76,61 @@ coap_opt_block_set_m(coap_opt_t *block_opt, int m) {
|
||||
|
||||
/**
|
||||
* Initializes @p block from @p pdu. @p type must be either COAP_OPTION_BLOCK1
|
||||
* or COAP_OPTION_BLOCK2. When option @p type was found in @p pdu, @p block
|
||||
* is initialized with values from this option and the function returns the
|
||||
* value @c 1. Otherwise, @c 0 is returned.
|
||||
* or COAP_OPTION_BLOCK2. When option @p type was found in @p pdu, @p block is
|
||||
* initialized with values from this option and the function returns the value
|
||||
* @c 1. Otherwise, @c 0 is returned.
|
||||
*
|
||||
* @param pdu The pdu to search for option @p type.
|
||||
* @param type The option to search for (must be COAP_OPTION_BLOCK1 or
|
||||
* COAP_OPTION_BLOCK2)
|
||||
* @param type The option to search for (must be COAP_OPTION_BLOCK1 or
|
||||
* COAP_OPTION_BLOCK2).
|
||||
* @param block The block structure to initilize.
|
||||
* @return @c 1 on success, @c 0 otherwise.
|
||||
*
|
||||
* @return @c 1 on success, @c 0 otherwise.
|
||||
*/
|
||||
int coap_get_block(coap_pdu_t *pdu, unsigned short type, coap_block_t *block);
|
||||
|
||||
/**
|
||||
* Writes a block option of type @p type to message @p pdu. If the
|
||||
* requested block size is too large to fit in @p pdu, it is reduced
|
||||
* accordingly. An exception is made for the final block when less
|
||||
* space is required. The actual length of the resource is specified
|
||||
* in @p data_length.
|
||||
* Writes a block option of type @p type to message @p pdu. If the requested
|
||||
* block size is too large to fit in @p pdu, it is reduced accordingly. An
|
||||
* exception is made for the final block when less space is required. The actual
|
||||
* length of the resource is specified in @p data_length.
|
||||
*
|
||||
* This function may change *block to reflect the values written to
|
||||
* @p pdu. As the function takes into consideration the remaining space
|
||||
* @p pdu, no more options should be added after coap_write_block_opt()
|
||||
* has returned.
|
||||
* This function may change *block to reflect the values written to @p pdu. As
|
||||
* the function takes into consideration the remaining space @p pdu, no more
|
||||
* options should be added after coap_write_block_opt() has returned.
|
||||
*
|
||||
* @param block The block structure to use. On return, this object
|
||||
* is updated according to the values that have been
|
||||
* written to @p pdu.
|
||||
* @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2
|
||||
* @param pdu The message where the block option should be
|
||||
* written.
|
||||
* @param data_length The length of the actual data that will be added
|
||||
* the @p pdu by calling coap_add_block().
|
||||
* @return @c 1 on success, or a negative value on error.
|
||||
* @param block The block structure to use. On return, this object is
|
||||
* updated according to the values that have been written to
|
||||
* @p pdu.
|
||||
* @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2.
|
||||
* @param pdu The message where the block option should be written.
|
||||
* @param data_length The length of the actual data that will be added the @p
|
||||
* pdu by calling coap_add_block().
|
||||
*
|
||||
* @return @c 1 on success, or a negative value on error.
|
||||
*/
|
||||
int coap_write_block_opt(coap_block_t *block, unsigned short type,
|
||||
coap_pdu_t *pdu, size_t data_length);
|
||||
int coap_write_block_opt(coap_block_t *block,
|
||||
unsigned short type,
|
||||
coap_pdu_t *pdu,
|
||||
size_t data_length);
|
||||
|
||||
/**
|
||||
* Adds the @p block_num block of size 1 << (@p block_szx + 4) from
|
||||
* source @p data to @p pdu.
|
||||
/**
|
||||
* Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p
|
||||
* data to @p pdu.
|
||||
*
|
||||
* @param pdu The message to add the block
|
||||
* @param len The length of @p data.
|
||||
* @param data The source data to fill the block with
|
||||
* @param block_num The actual block number
|
||||
* @param block_szx Encoded size of block @p block_number
|
||||
* @return @c 1 on success, @c 0 otherwise.
|
||||
* @param pdu The message to add the block.
|
||||
* @param len The length of @p data.
|
||||
* @param data The source data to fill the block with.
|
||||
* @param block_num The actual block number.
|
||||
* @param block_szx Encoded size of block @p block_number.
|
||||
*
|
||||
* @return @c 1 on success, @c 0 otherwise.
|
||||
*/
|
||||
int coap_add_block(coap_pdu_t *pdu, unsigned int len, const unsigned char *data,
|
||||
unsigned int block_num, unsigned char block_szx);
|
||||
int coap_add_block(coap_pdu_t *pdu,
|
||||
unsigned int len,
|
||||
const unsigned char *data,
|
||||
unsigned int block_num,
|
||||
unsigned char block_szx);
|
||||
/**@}*/
|
||||
|
||||
#endif /* _COAP_BLOCK_H_ */
|
||||
Reference in new issue
Block a user