#ifndef CL_MACTOTEI_H_ #define CL_MACTOTEI_H_ /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file cl/cl_mactotei.h * \brief MAC to TEI table interface between the CL and the CP. * \ingroup cl * * The MAC to TEI table associate a MAC address to a TEI and a tag. The tag is * used to know if the entry is bridged entry or not (in case of a bridge * entry, the tag will correspond to the entry acting as a bridge for this MAC * address). */ #include "cl/cl.h" #include "lib/mac_lookup_table.h" /** * Sorted MAC to TEI table. * It is based on the indexed MAC lookup table. */ typedef struct mac_lookup_table_t cl_mactotei_table_t; /** * Non-sorted MAC to TEI table. * It is based on the non-sorted MAC lookup table. */ typedef struct mac_lookup_block_header_t cl_mactotei_blk_t; BEGIN_DECLS /** * Create a new table to be filled by the CP. * * \return a pointer to the new block to be fill with the mac to tei table * data */ cl_mactotei_blk_t * cl_mactotei_new (void); /** * Add a new tupple (Mac address, TEI) to the MAC to TEI table. * * \param table the non-sorted MAC to TEI table. * \param mac_addr the mac addr to add. * \param tei the TEI corresponding to the MAC address. * \param tag a tag provided by the CP. */ void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr, uint tei, uint tag); /** * Request the CL to copy all the entries from the actual MAC to TEI table * corresponding to a TEI and a tag to the new one. * * \param ctx the CL context. * \param table the new MAC to TEI table to fill. * \param tei the corresponding TEI entries to copy. * \param tag the corresponding tag entries to copy. */ void cl_mactotei_copy_tei_and_tag (cl_t *ctx, cl_mactotei_blk_t *table, uint tei, uint tag); /** * Request the CL to copy all the entries from the actual MAC to TEI table * corresponding to a TEI. * * \param ctx the CL context. * \param table the new MAC to TEI table to fill. * \param tei the corresponding TEI entries to copy. */ void cl_mactotei_copy_tei (cl_t *ctx, cl_mactotei_blk_t *table, uint tei); /** * Find a mac address in the table using a dichotomy search. * * \param ctx the CL context. * \param mac the mac address to look for. * \return the TEI corresponding to the mac address if the entry exists. * Otherwise, it returns MAC_TEI_UNASSOCIATED. */ uint cl_mactotei_table_find_tei_from_mac (cl_t *ctx, mac_t mac); /** * Find the tei and tag associated to a mac address in the table. * \param ctx the CL context. * \param mac the mac address to look for. * \param tag the tag associated with the tei for this mac. * \return the TEI corresponding to the mac address if the entry exists. * Otherwise, it returns MAC_TEI_UNASSOCIATED. */ uint cl_mactotei_table_find_tei_and_tag_from_mac (cl_t *ctx, mac_t mac, uint *tag); /** * Request the CL to use the new table and remove the old one. * * \param ctx the CL context. * \param table the new table to use. */ void cl_mactotei_use_table (cl_t *ctx, cl_mactotei_blk_t *table); /** * Release the complete table from the memory. * * \param ctx the convergence layer context */ void cl_mactotei_release_table (cl_t *ctx); /** * Copy all the entries from the current MAC to TEI table except the ones with * a specific tag. * \param ctx the CL context. * \param table the table where to add copied entries. * \param tag the matching tag. * * This function can be used when you want to replace bridged entries of the * MAC lookup table by removing all the "old" one. */ void cl_mactotei_copy_except_tag (cl_t *ctx, cl_mactotei_blk_t *table, uint tag); /** * Copy all the entries from the current MAC to TEI table except the ones with * a specific tei. * \param ctx the CL context. * \param table the table where to add copied entries. * \param tei the matching tei. */ void cl_mactotei_copy_except_tei (cl_t *ctx, cl_mactotei_blk_t *table, uint tei); /** * Cancel the creation of a table. * \param table the table to cancel. * * This function is quite like \see cl_mactotei_release_table. The difference, * is that it takes a block as argument and not a table. You should use this * function when you create a new table and realise that you should cancel its * creation and keep the old one. */ void cl_mactotei_cancel (cl_mactotei_blk_t *table); END_DECLS #endif /*CL_MACTOTEI_H_*/