#ifndef cp_beacon_inc_beacons_ctx_h #define cp_beacon_inc_beacons_ctx_h /* Cesar project {{{ * * Copyright (C) 2008 Spidcom * * <<>> * * }}} */ /** * \file cp/beacon/inc/beacons_ctx.h * \brief beacon modules. * \ingroup cp_beacon * * « long description » */ #include "lib/trace.h" #include "hal/phy/phy.h" #include "interface/interface.h" #include "cp/station/station.h" #include "cp/secu/inc/secu_types.h" #include "cp/secu/secu.h" #include "cp/beacon/inc/trace.h" #include "cp/beacon/inc/bentry.h" #include "hal/timer/timer.h" #include "mac/pbproc/pbproc.h" #define CP_BEACON_K 6 // 2^7 when the shift operator is use. #define CP_BEACON_DEFAULT_SCHEDULE_TIME 12 #define CP_BEACON_DEFAULT_BP_WIDTH (CP_BEACON_DEFAULT_SCHEDULE_TIME*1000000/4) enum regions_type_t { CP_REGION_RESERVED, CP_REGION_SHARED_CSMA, CP_REGION_LOCAL_CSMA, CP_REGION_STAYOUT, CP_REGION_PROTECTED, CP_REGION_BEACON }; struct cp_beacon_desc_alloc_t { ca_schedule_t *ca_sched; uint next_alloc; }; struct cp_beacon_payload_t { /** Beacon payload. */ u8 beacon_mpdu_payload [8]; u8 nbe; /** First bentry. */ u8 bmis[119]; /** Frame control. */ pbproc_rx_beacon_params_t fc; }; struct cp_beacon_desc_t { /** Not use. */ u8 *next; /** Beacon payload. */ cp_beacon_payload_t *payload; /** Beacon nid first four bytes. */ uint nid_msb; }; struct cp_pw_line_t { /** Beacon period width. */ uint bp_ntb; /** pw line time between two zero crosses. */ uint pwzc_ntb; /** Array containing the previous value of the register */ uint date_ntb[2]; /** Detection done */ u8 detection; }; struct cp_beacon_common_t { /** Estimated date. */ uint btse_ntb[4]; /** Data common to each beacon containing the BPSTO and the four BTOs. */ pbproc_tx_beacon_params_t bto_bpsto; /** Count the number of beacon saw or generated. */ uint beacon_nb; /** beacon period estimated in Time Allocation Unit. */ uint bp_tau[4]; /** last beacon period computed. */ uint per_ntb; /** Last central beacon received. */ cp_beacon_desc_t *last_beacon; /** MFS use to send the beacons */ mfs_tx_t *mfs; /** Last becon period start date. */ ca_beacon_period_t last_bp; }; struct cp_beacon_t { /** station context plane context. */ cp_sta_t *sta; /** The phy context */ phy_t *phy; /** PW line properties. */ cp_pw_line_t pwl; /** Security layer context. */ cp_secu_t *secu; /** CCo context. */ cp_cco_t *cco; /** CA layer context. */ ca_t *ca; /** Mac store context. */ mac_store_t *mac_store; /** Pbproc context. */ pbproc_t *pbproc; /** Interface the interface context. */ interface_t *interface; /** Central beacon data. */ cp_beacon_common_t cbeacon; /** Proxy beacon data. */ //cp_proxy_beaocn_t pbeacon; /** Discover beacon data. */ cp_beacon_common_t dbeacon; /** bentries data. */ cp_bentries_data_t bentries_data; /** Hybrid mode. */ u8 hm; /** Last sta requested to send a discover beacon. */ u8 last_sta; /** Schedule index. */ uint schedule_index; /** Pbproc Activated. */ bool pbproc_activated; /** Awake value to program the timer in ticks. */ uint awake_time; /** API timer context. */ hal_timer_t *timer; /** API timer context. */ hal_timer_instance_t instance; /** user data provide on the function callback for the CP. */ void *cp_user_data; /** Function to call to add the event. */ cp_beacon_timer_cb_t cp_cb; /** Trace system. */ #if CONFIG_TRACE /** cp_beacon Trace */ trace_buffer_t trace; #endif /* !CONFIG_TRACE */ }; #endif /* cp_beacon_inc_beacons_ctx_h */