added some documentation

This commit is contained in:
Joakim Eriksson 2017-12-10 20:34:50 +01:00
parent 34f598002f
commit bd6de2401f
2 changed files with 90 additions and 17 deletions

View File

@ -128,6 +128,6 @@ uipbuf_clr_attr_flag(uint16_t flag)
uint16_t
uipbuf_is_attr_flag(uint16_t flag)
{
return (uipbuf_attrs[UIPBUF_ATTR_FLAGS] & flag) > 0;
return (uipbuf_attrs[UIPBUF_ATTR_FLAGS] & flag) == flag;
}
/*---------------------------------------------------------------------------*/

View File

@ -35,33 +35,106 @@
#include "contiki.h"
/* Get the next header given the buffer - start indicates that this is
start of the IPv6 header - needs to be set to 0 when in an ext hdr */
/**
* \brief Get the next IPv6 header.
* \param buffer A pointer to the buffer holding the IPv6 packet
* \param size The size of the data in the buffer
* \param protocol A pointer to a variable where the protocol of the header will be stored
* \param start A flag that indicates if this is expected to be the IPv6 packet header or a later header (Extension header)
* \retval returns address of the starting position of the next header
*
* This function moves to the next header in a IPv6 packet.
*/
uint8_t* uipbuf_get_next_header(uint8_t *buffer, uint16_t size, uint8_t *protocol, uint8_t start);
/* Get the final header given the buffer - that is assumed to be at start
of an IPv6 header */
/**
* \brief Get the last IPv6 header.
* \param buffer A pointer to the buffer holding the IPv6 packet
* \param size The size of the data in the buffer
* \param protocol A pointer to a variable where the protocol of the header will be stored
* \retval returns address of the starting position of the next header
*
* This function moves to the last header of the IPv6 packet.
*/
uint8_t* uipbuf_get_last_header(uint8_t *buffer, uint16_t size, uint8_t *protocol);
/* Attributes relating to the current packet in uipbuf */
/**
* \brief Get the value of the attribute
* \param type The attribute to get the value of
* \retval the value of the attribute
*
* This function gets the value of a specific uipbuf attribute.
*/
uint16_t uipbuf_get_attr(uint8_t type);
void uipbuf_set_attr_flag(uint16_t flag);
void uipbuf_clr_attr_flag(uint16_t flag);
uint16_t uipbuf_is_attr_flag(uint16_t flag);
/**
* \brief Set the value of the attribute
* \param type The attribute to set the value of
* \param value The value to set
* \retval 0 - indicates failure of setting the value
* \retval 1 - indicates success of setting the value
*
* This function sets the value of a specific uipbuf attribute.
*/
int uipbuf_set_attr(uint8_t type, uint16_t value);
/**
* \brief Set bits in the uipbuf attribute flags.
* \param flag_bits The bits to set in the flag.
*
* This function sets the uipbuf attributes flag of specified bits.
*/
void uipbuf_set_attr_flag(uint16_t flag_bits);
/**
* \brief Clear bits in the uipbuf attribute flags.
* \param flag_bits The bits to clear in the flag.
*
* This function clears the uipbuf attributes flag of specified bits.
*/
void uipbuf_clr_attr_flag(uint16_t flag_bits);
/**
* \brief Check if bits in the uipbuf attribute flag are set.
* \param flag_bits The bits to check in the flag.
*
* This function checks if the specified bits are set in the
* uipbuf attributes flag.
*/
uint16_t uipbuf_is_attr_flag(uint16_t flag_bits);
/**
* \brief Clear all attributes.
*
* This function clear all attributes in the uipbuf attributes
* including all flags.
*/
void uipbuf_clear_attr(void);
/* These flags will be used for being */
/**
* \brief The bits defined for uipbuf attributes flag.
*
*/
/* Avoid using NHC compression on the packet (6LoWPAN) */
#define UIPBUF_ATTR_FLAGS_6LOWPAN_NO_NHC_COMPRESSION 0x01
/* Avoid using prefix compression on the packet (6LoWPAN) */
#define UIPBUF_ATTR_FLAGS_6LOWPAN_NO_PREFIX_COMPRESSION 0x02
/**
* \brief The attributes defined for uipbuf attributes function.
*
*/
enum {
UIPBUF_ATTR_LLSEC_LEVEL,
UIPBUF_ATTR_LLSEC_KEY_ID,
UIPBUF_ATTR_INTERFACE_ID,
UIPBUF_ATTR_PHYSICAL_NETWORK_ID,
UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS,
UIPBUF_ATTR_FLAGS,
UIPBUF_ATTR_LLSEC_LEVEL, /**< Control link layer security level. */
UIPBUF_ATTR_LLSEC_KEY_ID, /**< Control link layer security key ID. */
UIPBUF_ATTR_INTERFACE_ID, /**< The interface to output packet on */
UIPBUF_ATTR_PHYSICAL_NETWORK_ID, /**< Physical network ID (mapped to PAN ID)*/
UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, /**< MAX transmissions of the packet MAC */
UIPBUF_ATTR_FLAGS, /**< Flags that can control lower layers. see above. */
UIPBUF_ATTR_MAX
};