summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-03-28 13:33:33 +0000
committerlaranjeiro2008-03-28 13:33:33 +0000
commite807c0ce6aa0fdf24ffd17ccea87308a4a0ce6e1 (patch)
treec6a65b3f39d50079ad317d3ad8ca4d3134d808c0
parentf184d16826377e4eefda0f08fb1ecf33c9736280 (diff)
CP2: Sta manager, data and net_list functions.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1685 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cp2/sta/data/inc/sta_data.h33
-rw-r--r--cp2/sta/data/net_list.h83
-rw-r--r--cp2/sta/data/sta_data.h122
-rw-r--r--cp2/sta/mgr/sta_mgr.h154
4 files changed, 392 insertions, 0 deletions
diff --git a/cp2/sta/data/inc/sta_data.h b/cp2/sta/data/inc/sta_data.h
new file mode 100644
index 0000000000..9bfe395837
--- /dev/null
+++ b/cp2/sta/data/inc/sta_data.h
@@ -0,0 +1,33 @@
+#ifndef cp2_sta_data_inc_sta_data_h
+#define cp2_sta_data_inc_sta_data_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp2/sta/data/inc/sta_data.h
+ * \brief Sta private paramters.
+ * \ingroup cp_sta_data
+ *
+ */
+
+struct cp_sta_private_t
+{
+ /** TEI of the station. */
+ u8 tei;
+ /** STA's mac address. */
+ mac_t mac_address;
+ /** boolean associated. */
+ bool assoc;
+ /** CCo status. */
+ bool cco_status;
+ /** PCo status. */
+ bool pco_status;
+ /** backup CCo status. */
+ bool backup_cco_status;
+};
+
+#endif /* cp2_sta_data_inc_sta_data_h */
diff --git a/cp2/sta/data/net_list.h b/cp2/sta/data/net_list.h
new file mode 100644
index 0000000000..52f1ff1d8e
--- /dev/null
+++ b/cp2/sta/data/net_list.h
@@ -0,0 +1,83 @@
+#ifndef cp2_sta_data_net_list_h
+#define cp2_sta_data_net_list_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp2/sta/data/net_list.h
+ * \brief CP Net list managing an AVLN.
+ * \ingroup cp_sta_data
+ *
+ * The Network list data for one AVLN.
+ */
+
+#include "cp2/sta/data/sta_list.h"
+
+struct cp_net_list_t
+{
+ /** Short Network ID. */
+ u16 snid;
+ /** Network ID. */
+ u64 nid;
+ /** Network Membership Key. */
+ uint nmk;
+ /** Network password. */
+ u128 npw;
+ /** Network present. */
+ bool present;
+ /** CCo in the AVLN. */
+ cp_sta_t cco;
+ /** PCo in the AVLN. */
+ cp_sta_t pco;
+};
+typedef struct cp_net_list_t cp_net_list_t;
+
+/** Add a sta to this AVLN.
+ * \param net_list the net list to add the sta.
+ * \param sta the sta to add.
+ */
+void
+cp_net_list_add_sta(cp_net_list_t *net_list, cp_sta_t *sta);
+
+/** Remove a station from the AVLN.
+ * \param net_list the list to remove ths sta.
+ * \param the sta to remove.
+ */
+void
+cp_net_list_remove_sta(cp_net_list_t *net_list, cp_sta_t *sta);
+
+/** Remove the sta by providing the STA's tei from this AVLN.
+ * \param net_list the net_list from the one the sta shall be removed.
+ * \param tei the station's tei.
+ */
+void
+cp_net_list_remove_sta_from_tei(cp_net_list_t *net_list, u8 tei);
+
+/** Get the station from the AVLN.
+ * \param net_list the net_list to get the station.
+ * \param tei the tei of the station.
+ * \return the station if it is in the AVLN, NULL otherwise.
+ */
+cp_sta_t *
+cp_net_list_get_sta(cp_net_list_t *net_list, u8 tei);
+
+/** Get the first station of the AVLN.
+ * \param net_list the AVLN list to get it's first sta.
+ * \return the first station if the AVLN has one.
+ */
+cp_sta_t *
+cp_net_list_first_sta(cp_net_list_t *net_list);
+
+/** Get the next station from the AVLN.
+ * \param net_list the AVLN net list.
+ * \param sta the current station to get the next one.
+ * \return the next station of the one provided.
+ */
+cp_sta_t *
+cp_sta_t cp_net_list_next_sta(cp_net_list_t *net_list, cp_sta_t *sta);
+
+#endif /* cp2_sta_data_net_list_h */
diff --git a/cp2/sta/data/sta_data.h b/cp2/sta/data/sta_data.h
new file mode 100644
index 0000000000..d7dba97021
--- /dev/null
+++ b/cp2/sta/data/sta_data.h
@@ -0,0 +1,122 @@
+#ifndef cp2_sta_data_sta_data_h
+#define cp2_sta_data_sta_data_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp2/sta/data/sta_data.h
+ * \brief Sta data.
+ * \ingroup cp_sta_data
+ *
+ * Sta data.
+ */
+
+/* forward declaration. */
+typedef struct cp_sta_data_private_t cp_sta_data_private_t;
+
+struct cp_msg_reassembly_ctx_t
+{
+
+};
+typedef struct cp_msg_reassembly_ctx_t cp_msg_reassembly_ctx_t;
+
+struct cp_sta_data_t
+{
+ /** Private part. */
+ cp_sta_data_private_t private;
+ /** Visible true if the STA is visible by out STA. */
+ bool visible;
+ /** Last seen. */
+ uint last_seen_ntb;
+ /** Reassembly context. */
+ cp_msg_reassembly_ctx_t rea;
+};
+typedef struct cp_sta_data_t cp_sta_data_t;
+
+/** Get the TEI of the station.
+ * \param sta the station.
+ * \return the sta's tei.
+ */
+u8
+cp_sta_get_tei(cp_sta_t *sta);
+
+/** Get the mac address of the station.
+ * \param sta the station.
+ * \return the sta's mac address.
+ */
+mac_t
+cp_sta_get_mac_address(cp_sta_t *sta);
+
+/** Set the associated status of the station.
+ * \param sta the station.
+ * \param associated the association status, true if associated, false
+ * otherwise.
+ */
+void
+cp_sta_set_associated (cp_sta_t *sta, bool associated);
+
+/** Get the association status.
+ * \param sta the station.
+ * \return the association status.
+ *
+ * This function will return true if the station is associated, false
+ * otherwise.
+ */
+bool
+cp_sta_is_associated (cp_sta_t *sta);
+
+/** Set the CCo status of the station.
+ * \param sta the station.
+ * \param cco the cco status, true if the sta is cco, false otherwise.
+ */
+void
+cp_sta_set_cco_status (cp_sta_t *sta, bool cco);
+
+/** Get the station CCo's status.
+ * \param sta the station.
+ * \return the cco status of the sta.
+ *
+ * This function will return true if the Station is CCo, false otherwise.
+ */
+bool
+cp_sta_is_cco_status (cp_sta_t *sta);
+
+/** Set the PCo status of the station.
+ * \param sta the station.
+ * \param pco the pco status, true if the sta is pco false otherwise.
+ */
+void
+cp_sta_set_pco_status (cp_sta_t *sta, bool pco);
+
+/** Get the PCo status of the station.
+ * \param sta the station.
+ * \return the PCo's station status.
+ *
+ * This will return true if the STA is PCo, false otherwise.
+ */
+bool
+cp_sta_is_pco_status (cp_sta_t *sta);
+
+/** Set the backup CCo status of the station.
+ * \param sta the station.
+ * \param backup_cco the backup cco status.
+ *
+ * This shall set true if the station is backup CCo, false otherwise.
+ */
+void
+cp_sta_set_backup_cco_status (cp_sta_t *sta, bool backup_cco);
+
+/** Get the backup CCo of the station.
+ * \param sta the sta.
+ * \return the sta's backup cco status.
+ *
+ * This will return true if the station is backup cco, false otherwise.
+ */
+bool
+cp_sta_is_backup_cco_status (cp_sta_t *sta);
+
+#endif /* cp2_sta_data_sta_data_h */
diff --git a/cp2/sta/mgr/sta_mgr.h b/cp2/sta/mgr/sta_mgr.h
new file mode 100644
index 0000000000..b874fcdd82
--- /dev/null
+++ b/cp2/sta/mgr/sta_mgr.h
@@ -0,0 +1,154 @@
+#ifndef cp2_sta_data_sta_mgr_h
+#define cp2_sta_data_sta_mgr_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp2/sta/data/sta_mgr.h
+ * \brief Station and AVLN manager.
+ * \ingroup cp_sta_data
+ *
+ * Manage the network list and its Stations. The station manager job it to
+ * keep the integrity of the differents databases.
+ */
+
+#include "cp2/sta/data/net_list.h"
+#include "cp2/sta/data/sta_data.h"
+
+struct cp_sta_mgr_t
+{
+ u16 current_sta_avln;
+};
+typedef struct cp_sta_mgr_t cp_sta_mgr_t;
+
+/** Initialise the sta manager.
+ * \return the sta manager context.
+ */
+cp_sta_mgr_t *
+cp_sta_mgr_init(void);
+
+/** Uninitialise the sta manager.
+ * \param ctx the sta manager context.
+ */
+void
+cp_sta_mgr_uninit(cp_sta_mgr_t *ctx);
+
+/** Get an AVLN from the sta manager.
+ * \param ctx the sta manager context.
+ * \return the avln identified by its snid.
+ *
+ * This function shall return an avln with the snid provided or NULL if the
+ * avln does not exists.
+ */
+cp_net_list_t*
+cp_sta_mgr_get_avln(cp_sta_mgr_t *ctx, u16 snid);
+
+/** Get our AVLN.
+ * \param ctx the sta manager context.
+ * \return Our AVLN.
+ */
+cp_net_list_t*
+cp_sta_mgr_get_our_avln(cp_sta_mgr_t *ctx);
+
+/** Add an AVLN.
+ * \param ctx the sta manager context.
+ * \param snid the new avln's snid.
+ * \return the new avln.
+ */
+cp_net_list_t*
+cp_sta_mgr_add_avln(cp_sta_mgr_t *ctx, u16 snid);
+
+/** Remove an AVLN from the list and all the STAs associated in it.
+ * \param ctx the sta manager context.
+ * \param snid the avln snid.
+ *
+ * This function shall not remove our AVLN.
+ */
+void
+cp_sta_mgr_remove_avln(u16 snid);
+
+/** Add a station to a specified AVLN.
+ * \param ctx the sta manager context.
+ * \param tei the tei of the station
+ * \param mac_addr the mac address
+ * \param added true if the station was just create, flase otherwise.
+ * \return the station just created.
+ *
+ * This function shall return the station just created and fill the added
+ * boolean parameters with true value if the station has just been created or
+ * false if the station already exists.
+ */
+cp_sta_t*
+cp_sta_mgr_add_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei, mac_t mac_addr,
+ bool added);
+
+/** Remove a sta from the specified AVLN.
+ * \param ctx the sta manager context.
+ * \param snid the AVLN's snid.
+ * \param tei the station tei.
+ */
+void
+cp_sta_mgr_remove_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei);
+
+/** Add a STA to our AVLN.
+ * \param ctx the sta manager context.
+ * \param tei the station tei
+ * \param mac_address the station mac address.
+ * \param added true if the station was just create, flase otherwise.
+ * \return the station just created.
+ *
+ * This function shall return the station just created and fill the added
+ * boolean parameters with true value if the station has just been created or
+ * false if the station already exists.
+ */
+cp_sta_t*
+cp_sta_mgr_add_sta_our_avln(cp_sta_mgr_t *ctx, u8 tei, mac_t mac_address);
+
+/** Remove a STA of our AVLN.
+ * \param ctx the sta manager context.
+ * \param tei the station tei.
+ */
+void
+cp_sta_mgr_remove_sta_our_avln(cp_sta_mgr_t *ctx, u8 tei);
+
+/** Get a STA from an AVLN.
+ * \param ctx the sta manager context.
+ * \param snid the AVLN's snid.
+ * \param tei the STA's tei.
+ * \return The station associated of NULL of no tei is associated.
+ */
+cp_sta_t*
+cp_sta_mgr_get_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei);
+
+/** Get the STA in our AVLN corresponding to the tei provided.
+ * \param ctx the sta manager context.
+ * \param tei the station's tei
+ * \return the station corresponding to the tei.
+ */
+cp_sta_t*
+cp_sta_mgr_get_sta_in_avln(cp_sta_mgr_t *ctx, u8 tei);
+
+/** Update the STA data in our AVLN.
+ * \param ctx the sta manager context.
+ * \param sta the station to update
+ * \param tei the station's new tei
+ * \param mac address the station's new mac address.
+ */
+void
+cp_sta_mgr_update_sta_in_avln(cp_sta_mgr_t *ctx, cp_sta_t *sta,
+ u8 tei, mac_t mac_addr);
+
+/** Update the STA data in any AVLN.
+ * \param ctx the sta manager context.
+ * \param sta the station to update the data.
+ * \param tei the station new tei.
+ * \param mac_addr the station's new mac address.
+ */
+void
+cp_sta_mgr_update_sta(cp_sta_t sta, u8 tei, mac_t mac_addr);
+
+#endif /* cp2_sta_data_sta_mgr_h */