/* Cesar project {{{ * * Copyright (C) 2011 Spidcom * * <<>> * * }}} */ /** * \file cl/src/brx_rx.c * \brief RX bridge Table for data only. * \ingroup cl */ #include "common/std.h" #include "hal/arch/arch.h" #include "cl/cl.h" #include "cl/brg_rx.h" #include "cl/inc/context.h" void cl_brg_rx_add (cl_t *ctx, mac_t smac, uint tei) { if (MAC_TEI_IS_STA (tei) && MAC_IS_VALID (smac)) { if (!ctx->brg_rx) { ctx->brg_rx = (cl_brg_rx_t*) blk_alloc (); ctx->brg_rx->nb_entry = 0; } if (ctx->brg_rx->nb_entry < CL_BRG_RX_ENTRY_NB) { /* Does the entry already exists ? */ bool found; uint i, nb_entry = ctx->brg_rx->nb_entry; for (i = 0, found = false; !found && i < nb_entry; i++) found = smac == ctx->brg_rx->entry[i].mac; if (!found) { ctx->brg_rx->entry[nb_entry].mac = smac; ctx->brg_rx->entry[nb_entry].tei = tei; ctx->brg_rx->nb_entry++; } } } } cl_brg_rx_t * cl_brg_rx_get (cl_t *ctx) { arch_dsr_lock (); cl_brg_rx_t *t = ctx->brg_rx; ctx->brg_rx = NULL; arch_dsr_unlock (); return t; } void cl_brg_rx_release (cl_t *ctx) { arch_dsr_lock (); if (ctx->brg_rx) blk_release (ctx->brg_rx); ctx->brg_rx = NULL; arch_dsr_unlock (); }