/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file cp/station/src/station_data.c * \brief * \ingroup cp_station */ #include "common/std.h" #include "cp/beacon/beacons.h" #include "cp/beacon/inc/beacons_ctx.h" #include "cp/beacon/forward.h" #include "cp/station/station.h" static avln_t m_avln[MAX_AVLN_NB]; static u_station_t m_u_sta[MAX_AVLN_NB + MAX_STA_NB]; static u8 m_tei; static u8 m_number_of_assoc_sta; static bool m_is_cco; mac_store_t *m_mac_store_ctx = NULL; cl_t *m_cl_ctx = NULL; pbproc_t *m_pbproc_ctx = NULL; /* cl_t * station_get_cl_ctx(void) { return m_interf_cl_ctx; } mac_store_t * station_get_mac_store_ctx(void) { return m_mac_store_ctx; } */ nid_t cp_station_get_nid(cp_sta_t *ctx) { #if 0 return m_avln[0].nid; #else return ctx->nid; #endif } snid_t cp_station_get_snid(void) { return m_avln[0].snid; } u8 cp_station_get_cco_capa(void) { return m_avln[0].sta[m_tei].cco_capa; } u8 cp_station_get_number_of_assoc(void) { return m_number_of_assoc_sta; } void cp_station_set_tei(const tei_t new_tei, const u16 lease_time) { tei_t old_tei; old_tei = m_tei; m_tei = new_tei; memcpy(&m_avln[0].sta[new_tei], &m_avln[0].sta[old_tei], sizeof(m_avln[0].sta[new_tei])); m_avln[0].sta[new_tei].tei_lease_time = cyg_current_time() + lease_time * MINUTES_TO_TICK_FACTOR; } tei_t cp_station_get_tei(void *v) { return m_tei; } void cp_station_set_mac_address(cp_sta_t *ctx, mac_address_t mac_address) { #if 0 memcpy(m_avln[0].sta[m_tei].mac_address, mac_address, sizeof(mac_address_t)); #else memcpy(&(ctx->cp_sta_flash_params.mac_address), mac_address, sizeof(mac_address_t)); #endif } void cp_station_get_mac_address(cp_sta_t *ctx, mac_address_t *mac_address) { #if 0 memcpy(mac_address, &m_avln[0].sta[m_tei].mac_address, sizeof(mac_address_t)); #else memcpy(mac_address, &(ctx->cp_sta_flash_params.mac_address), sizeof(mac_address_t)); #endif } void cp_station_clear_assoc_sta_list(void) { memset(m_avln, 0, sizeof(m_avln)); m_number_of_assoc_sta = 0; } void cp_station_data_init(mac_store_t *mac_store_ctx, cl_t *interf_cl_ctx, pbproc_t *pbproc_ctx) { //printf("%s\n", __FUNCTION__); // erase the usta list memset(m_u_sta, 0, sizeof(m_u_sta)); // erase the associated stations list cp_station_clear_assoc_sta_list(); // set the tei to not attibuted m_tei = 0; m_is_cco = false; m_mac_store_ctx = mac_store_ctx; m_cl_ctx = interf_cl_ctx; m_pbproc_ctx = pbproc_ctx; // TODO remplir les champ nid et snid de m_avln[0] // TODO remplir les champs cco_capa, etc de m_avln[0].sta[0] } void cp_station_add_usta(const mac_address_t mac_address, const u8 cco_capa, const nid_t nid) { unsigned int i=0; //printf("%s\n", __FUNCTION__); // search for the first empty slot while( (memcmp(m_u_sta[i].mac_address, ZEROS_MAC_AD, sizeof(mac_address_t))) && (ihoip; } /** * Set the Handover in progress status. * * \param sta context. * \param hoip handover in progress. */ void cp_station_set_hoip(cp_sta_t *sta, uint hoip) { dbg_assert (sta); sta->hoip = hoip; } /** * get the rstbf flag * * \param sta the sta context. */ bool cp_station_get_rtsbf(cp_sta_t *sta) { dbg_assert (sta); return sta->mac_config->rts_broadcast; } /** * Set the sta rtsbf * * \param sta the station context * \param rstbf the flag */ void cp_station_set_rtsbf (cp_sta_t *sta, bool rtsbf) { dbg_assert (sta); sta->mac_config->rts_broadcast = true; } /** * Get the number of distant STAs * * \param sta the station context * \return the number of distant stations */ u8 cp_station_get_num_dis_sta(cp_sta_t *sta) { dbg_assert (sta); return sta->numDisSta; } /** * Get number of distant networks. * * \param sta the sta context. * \return the number of distant networks. */ u8 cp_station_get_num_dis_net(cp_sta_t *sta) { dbg_assert (sta); return sta->numDisNet; }