#ifndef mac_ca_inc_alloc_h #define mac_ca_inc_alloc_h /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file mac/ca/inc/alloc.h * \brief Beacon period and schedule related functions header. * \ingroup mac_ca */ /** Get the next beacon period index in the circular buffer. */ #define CA_ALLOC_NEXT_BEACON_PERIOD(x) (((x) + 1) % CA_BEACON_PERIOD_NB) /** Is the specified LID a CSMA one. Theses are the LID used in beacon * entries. */ #define CA_ALLOC_IS_CSMA(lid) ((lid) == MAC_LID_SHARED_CSMA \ || (lid) == MAC_LID_LOCAL_CSMA) /** Is the specified LID usable for transmission? */ #define CA_ALLOC_IS_USABLE(lid) ((lid) != MAC_LID_SPC_HOLE \ && (lid) != MAC_LID_CFPI) /** Should transmissions in the specified allocation use hybrid frame * controls according to the specified coexistence mode. An additional test * should be done for proxy beacon MFS. */ #define CA_ALLOC_IS_HYBRID(coex, lid) \ (coex == MAC_COEXISTENCE_FULL_HYBRID_MODE \ || coex == MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE \ || ((lid) == MAC_LID_SHARED_CSMA \ && coex == MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE) \ || lid == MAC_LID_SPC_HOLE \ || lid == MAC_LID_SPC_CENTRAL \ || lid == MAC_LID_DISCOVER) /** * Find the beacon period index corresponding to the given date. * \param ctx ca context * \param date date to search * \return index in the beacon periods circular buffer or buffer tail if no * beacon period corresponding (no beacon period at all or first beacon period * after the given date) * * Dates have more chance to be at the begin of the circular buffer, in the * current beacon period. Start search at the buffer begin. */ uint ca_alloc_find_beacon_period (const ca_t *ctx, u32 date); /** * Find the allocation corresponding to the given date offset. * \param sched schedule * \param offset_tck offset to search * \return allocation index, or allocations_nb if not found * * Use dichotomy, no prior assumption about dates repartition. */ uint ca_alloc_find (const ca_schedule_t *sched, uint offset_tck); #endif /* mac_ca_inc_alloc_h */