#ifndef ETHERLIB_CBD_TABLE_H #define ETHERLIB_CBD_TABLE_H #include #include "connection_block.h" #define CBD_LOWEST_DESCRIPTOR (4) /** * Custom type for connection block descriptor. */ typedef uint8_t cbd; #define CBDT_ERR ((cbd)(~0)) /** * Connection block descriptor table */ typedef struct { cbd maxEntries; ///< Maximum number of entries cbd level; ///< Fill level ConnBlock cbs[]; ///< Array of connection blocks } CbdTable; /** * Create new connecion block table. * @param size number of maximum entries * @return pointer to newly created connection block descriptor table */ CbdTable * cbdt_new(uint8_t size); /** * Allocate new connection block * @param cbdt pointer to CBDT * @return connection block descriptor OR CBDT_ERR */ cbd cbdt_alloc_new(CbdTable * cbdt, const ConnBlock * connBlock); /** * Release connection block. * @param cbdt pointer to CBDT * @param d CBD value */ void cbdt_release(CbdTable * cbdt, cbd d); /** * Get connection block * @param cbdt pointer to CBDT * @param d CBD value * @param connBlock pointer to connection block where the results will be written * @return indicates that fetch was successful or not */ bool cbdt_get_connection_block(CbdTable * cbdt, cbd d, ConnBlock * connBlock); /** * Set connection block sieve tag. * @param cbdt pointer to CBDT * @param d CBD value * @param tag tag getting stored * @return operation successful (d was valid) */ bool cbdt_set_tag(CbdTable * cbdt, cbd d, PcktSieveLayerTag tag); /** * Retrieve connection block sieve tag. * @param cbdt pointer to CBDT * @param d CBD value * @param tag pointer to area where tag is written * @return operation successful (d was valid) */ bool cbdt_get_tag(CbdTable * cbdt, cbd d, PcktSieveLayerTag * tag); /** * Print report on connection block descriptors. * @param cbdt pointer to CBD table */ void cbdt_report(const CbdTable * cbdt); #endif //ETHERLIB_CBD_TABLE_H