#ifndef cp_sta_mgr_h #define cp_sta_mgr_h /* Cesar project {{{ * * Copyright (C) 2008 Spidcom * * <<>> * * }}} */ /** * \file cp/sta/mgr/sta_mgr.h * \brief Station Manager. * \ingroup cp_sta_mgr * * Station and AVLN manager. */ #include "cp/sta/mgr/net.h" #include "cp/sta/mgr/sta_own_data.h" /* Forward declaration. */ typedef struct cp_sta_mgr_t cp_sta_mgr_t; BEGIN_DECLS /** * Add a AVLN to the manager list. * \param ctx the module context. * \param snid The AVLN's SNID to add. * \param nid The AVLN's nid to add. * \return A reference on the AVLN. */ cp_net_t * cp_sta_mgr_add_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid); /** * Remove an AVLN,. * \param ctx the module context. * \param snid The AVLN's snid to remove. * \param nid The AVLN's nid to remove. */ void cp_sta_mgr_remove_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid); /** * Get an AVLN from the net_list. * \param ctx the module context. * \param snid The AVLN's snid to get. * \param nid The AVLN's nid to get. * \return Get a reference on the AVLN. */ cp_net_t * cp_sta_mgr_get_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid); /** * Get first AVLN from the net_list. * \param ctx the module context. * \return Get a reference on the AVLN. */ cp_net_t * cp_sta_mgr_get_first_avln (cp_t *ctx); /** * Get next AVLN from the net_list. * \param ctx the module context. * \param prev previous one. * \return Get a reference on the AVLN. */ cp_net_t * cp_sta_mgr_get_next_avln (cp_t *ctx, cp_net_t *prev); /** * Initialise the sta manager. * \param ctx the module context. */ void cp_sta_mgr_init (cp_t *ctx); /** * Uninitialise the sta manager. * \param ctx the module context. */ void cp_sta_mgr_uninit (cp_t *ctx); /** * Lookup and return all the snids already in use in the different AVLN. * \param ctx the module context. * \return A bit field u16 corresponding to the SNID in use. * * The return data is a flag of 16 bits. The bit0 corresponds to the * the snid 0, the bit1 to the snid 1 and so on */ u16 cp_sta_mgr_get_present_snids (cp_t *ctx); /** * Call all the sub garbage functions. * \param ctx the module context. * */ void cp_sta_mgr_garbage (cp_t *ctx); /** * Returns a reference on our own station data. * \param ctx the module context. * \return A reference on the sta own data. Do not release It it not a block. */ cp_sta_own_data_t * cp_sta_mgr_get_sta_own_data (cp_t *ctx); /** * Get the network slot usage. * \param ctx the module context. * \return Return a 8 bit fields of slot usage for the beacon module. */ u8 cp_sta_mgr_get_slot_usage (cp_t *ctx); /** * Get the number of discovered station on all AVLNs. * \param ctx the module context. * \return the number of discovered station. */ u8 cp_sta_mgr_get_num_discovered_stas (cp_t *ctx); /** * Get the number of discovered networks. * \param ctx the module context. * \return the number of discovered networks. */ u8 cp_sta_mgr_get_num_discovered_net (cp_t *ctx); /** * Verify the net list status. * \param ctx the module context. * \return true if empty, false otherwise. */ bool cp_sta_mgr_net_list_is_empty (cp_t *ctx); /** * Get our AVLN. * \param ctx the CP context. * \return Our AVLN. * * \warn this function assert if the station is not associated. */ cp_net_t * cp_sta_mgr_get_our_avln (cp_t *ctx); /** * Set our AVLN. * \param ctx the CP context. * \param net the net to add as our net. */ void cp_sta_mgr_set_our_avln (cp_t *ctx, cp_net_t *net); /** * Release a station from our AVLN. * \param ctx the module context. * \param tei the station TEI. * * This function verifies if the own station is CCo, if its not, it asserts. */ void cp_sta_mgr_release_station (cp_t *ctx, cp_tei_t tei); /** * Add a station to the AVLN. * \param ctx the module context. * \param net the network. * \param tei Station's TEI. * \param mac_address Station's mac address. * \return A reference on the station just created. */ cp_sta_t * cp_sta_mgr_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address); /** * Remove the station from the AVLN. * \param ctx the module context. * \param net the network context. * \param tei The Station's TEI. * * Remove the station from the AVLN. */ void cp_sta_mgr_sta_remove_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei); /** * Remove an unassociated station from the list. * \param ctx the module context. * \param mac_addr The station's mac address. * */ void cp_sta_mgr_sta_remove_from_mac (cp_t *ctx, mac_t mac_addr); /** * Remove the station from the net. * \param ctx the module context. * \param sta The station to remove. * * The user shall release the reference */ void cp_sta_mgr_sta_remove (cp_t *ctx, cp_sta_t * sta); /** * Get the station identified by its TEI. * \param ctx the module context. * \param net the network context. * \param tei The station's tei. * \return A reference on the station. * * returns NULL if the station does not exists. It only returns a new * reference on the station (one reference is still kept by the network), * when the user does not use it any more, it must release it. */ cp_sta_t * cp_sta_mgr_sta_get_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei); /** * Get the associated station identified by its Mac address. * \param ctx the module context. * \param mac_address The station's mac_address. * \return A reference on the station. * * returns NULL if the station does not exists. It only returns a new * reference on the station (one reference is still kept by the network), * when the user does not use it any more, it must release it. */ cp_sta_t * cp_sta_mgr_sta_get_from_mac (cp_t *ctx, mac_t mac_addr); /** * Commit the changes of the AVLN. * \param ctx the module context. * * Use to commit the changes in the others databases. Only call this * function when all the stations have been added, or all stations have * been removed. This will check the modifications of the network station * list to update at least the mactotei table. It is useful to synchronize * those tables because the mactotei table does not have the possibility * to remove stations it only have the possibility to remove the station * by excluding it from the copy to the new one. */ void cp_sta_mgr_commit_to_dataplane (cp_t *ctx); /** * Parse the association list of our AVLN and confirm the full association of a * station if the last assoc.req emitted exceed CP_ASSOC_FULL_TIMEOUT_MS. * \param ctx the module context. * \param time_ms the current time in milliseconds. */ void cp_sta_mgr__assoc__timeout (cp_t *ctx, uint time_ms); END_DECLS #endif /* cp_sta_mgr_h */