summaryrefslogtreecommitdiff
path: root/cesar/cp/conn
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/cp/conn
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp/conn')
-rw-r--r--cesar/cp/conn/Module1
-rw-r--r--cesar/cp/conn/conn.h29
-rw-r--r--cesar/cp/conn/inc/conn_actions.h17
-rw-r--r--cesar/cp/conn/inc/conn_defs.h118
-rw-r--r--cesar/cp/conn/inc/conn_priv.h39
-rw-r--r--cesar/cp/conn/src/conn.c113
6 files changed, 317 insertions, 0 deletions
diff --git a/cesar/cp/conn/Module b/cesar/cp/conn/Module
new file mode 100644
index 0000000000..124dd907ce
--- /dev/null
+++ b/cesar/cp/conn/Module
@@ -0,0 +1 @@
+SOURCES := conn.c \ No newline at end of file
diff --git a/cesar/cp/conn/conn.h b/cesar/cp/conn/conn.h
new file mode 100644
index 0000000000..e60f4a8bf1
--- /dev/null
+++ b/cesar/cp/conn/conn.h
@@ -0,0 +1,29 @@
+#ifndef CONN_H_
+#define CONN_H_
+
+#include "cp/conn/inc/conn_defs.h"
+
+
+void
+cp_conn_init(void);
+
+/**
+ * \brief create a new connection on the init side of it.
+ *
+ * \param osa : original source address
+ * \param oda : original destination address
+ * \param req_id : request id provided by the HLE, or 0 if the
+ * connection is created by the Auto Connect Service
+ * \param cspec :
+ * \param classifier_rules :
+ *
+ * \return void
+ */
+void
+cp_conn_create_init(mac_address_t osa,
+ mac_address_t oda,
+ u16 req_id,
+ cspec_t cspec,
+ classifier_rules_t classifier_rules);
+
+#endif /*CONN_H_*/
diff --git a/cesar/cp/conn/inc/conn_actions.h b/cesar/cp/conn/inc/conn_actions.h
new file mode 100644
index 0000000000..02be22d17c
--- /dev/null
+++ b/cesar/cp/conn/inc/conn_actions.h
@@ -0,0 +1,17 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/conn/inc/conn_actions.h
+ * \brief actions of the conn fsm
+ * \ingroup cp_conn
+ */
+
+#ifndef CONN_ACTIONS_H_
+#define CONN_ACTIONS_H_
+
+#endif /*CONN_ACTIONS_H_*/
diff --git a/cesar/cp/conn/inc/conn_defs.h b/cesar/cp/conn/inc/conn_defs.h
new file mode 100644
index 0000000000..4884f89500
--- /dev/null
+++ b/cesar/cp/conn/inc/conn_defs.h
@@ -0,0 +1,118 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/conn/inc/conn_types.h
+ * \brief basics types for the conn module
+ * \ingroup cp_conn
+ */
+
+#ifndef CONN_TYPES_H_
+#define CONN_TYPES_H_
+
+#include "cp/cp_types.h"
+#include "mac/common/defs.h"
+#include "lib/blk.h"
+
+/*
+ * max number of BLE intervalle for a link
+ */
+#define MAX_NB_BLE_INT 10
+/*
+ * max number of available connexions
+ */
+#define MAX_NB_CONN (MAC_TEI_STA_NB * MAC_LLID_NB)
+
+// TODO : move this structure to the LINK module
+typedef struct link_t
+{
+ u8 tl_flag; // 11.5.35
+ tei_t stei;
+ tei_t dtei[MAX_STA_NB];
+ u8 lid;
+} link_t;
+
+typedef enum conn_status_t
+{
+ CONN_FREE,
+ CONN_WAIT,
+ CONN_ECTED
+} __attribute__ ((packed)) conn_status_t;
+
+typedef enum mac_service_type_t
+{
+ CONN_CONTENTION_FREE = 0,
+ CONN_CONTENTION_BASED = 1,
+ CONN_CONTENTION_FREE_PREFERED = 2
+} __attribute__ ((packed)) mac_service_type_t;
+
+typedef struct cinfo_t // table 7-145
+{
+ u8 valid;
+ mac_service_type_t mac_service_type;
+ u8 user_priority;
+ u8 arrival_time_stamp;
+ u8 smoothing;
+} cinfo_t;
+
+typedef struct qmp_t // table 7-147
+{
+ u16 cf[0x1C];
+ u32 cfl[4];
+ u8 cdesc;
+} qmp_t;
+
+typedef struct cspec_t // table 7-144
+{
+ cinfo_t cinfo_fw;
+ cinfo_t cinfo_rv;
+ qmp_t qmp_fw;
+ qmp_t qmp_rv;
+} cspec_t;
+
+typedef struct ble_t // table 11-196
+{
+ u16 end_time;
+ u8 ble;
+} ble_t;
+
+typedef struct con_info_t
+{
+ cspec_t cspec;
+ u16 cid;
+ mac_address_t init;
+ mac_address_t term;
+ ble_t ble_fw[MAX_NB_BLE_INT];
+ ble_t ble_rv[MAX_NB_BLE_INT];
+} con_info_t;
+
+typedef struct classifier_rules_t // 6.3
+{
+ u8 rule_id;
+ u8 rule[16];
+} classifier_rules_t;
+
+#define NB_RULES (BLK_SIZE - (2*sizeof(link_t) + sizeof(con_info_t))) / sizeof(classifier_rules_t)
+
+
+typedef struct connexion_t
+{
+ link_t fl; // forward link
+ link_t rl; // reverse link
+ con_info_t con_info;
+ classifier_rules_t rules[NB_RULES];
+} connexion_t;
+
+typedef struct conn_data_t
+{
+ conn_status_t conn_status;
+ connexion_t *connexion;
+ u16 req_id; // the id given by HLE
+}conn_data_t;
+
+
+#endif /*CONN_TYPES_H_*/
diff --git a/cesar/cp/conn/inc/conn_priv.h b/cesar/cp/conn/inc/conn_priv.h
new file mode 100644
index 0000000000..fb28459ea2
--- /dev/null
+++ b/cesar/cp/conn/inc/conn_priv.h
@@ -0,0 +1,39 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/conn/inc/conn_priv.h
+ * \brief private functions for the conn module
+ * \ingroup cp_conn
+ */
+
+
+#ifndef CONN_PRIV_H_
+#define CONN_PRIV_H_
+
+
+
+/**
+ * \brief convert the CID of a connexion to it index
+ *
+ * \param cid
+ * \return index
+ */
+u16
+cp_conn_cid_2_index(u16 cid);
+
+/**
+ * \brief return an available connexion index
+ * the CID can be calculated from this index
+ * \param
+ * \return index
+ */
+u16
+cp_conn_get_new_conn_index(void);
+
+
+#endif /*CONN_PRIV_H_*/
diff --git a/cesar/cp/conn/src/conn.c b/cesar/cp/conn/src/conn.c
new file mode 100644
index 0000000000..febf31b806
--- /dev/null
+++ b/cesar/cp/conn/src/conn.c
@@ -0,0 +1,113 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/conn/src/conn.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+#include "cp/conn/inc/conn_defs.h"
+#include "cp/conn/inc/conn_priv.h"
+#include "lib/swap.h"
+#include <string.h>
+
+static conn_data_t conn_data[MAX_NB_CONN];
+
+/****************** private functions ************************/
+
+u16
+cp_conn_cid_2_index(u16 cid)
+{
+ tei_t tei;
+ u8 llid;
+ u16 index;
+
+ llid = cid & 0xFF;
+ tei = cid >> 8;
+ index = (llid - MAC_LLID_MIN) * MAC_TEI_STA_NB + tei - 1;
+ dbg_assert(index < COUNT(conn_data));
+ return index;
+}
+
+u16
+cp_conn_get_new_conn_index(void)
+{
+ tei_t tei;
+ u8 llid;
+ u16 index;
+
+ tei = cp_station_get_tei(NULL);
+ for(llid = MAC_LLID_MIN ; llid < MAC_LLID_MAX ; llid ++)
+ {
+ index = (llid - MAC_LLID_MIN) * MAC_TEI_STA_NB + tei - 1;
+ if(conn_data[index].conn_status == CONN_FREE)
+ {
+ return index;
+ }
+ }
+ // all connexion are used !!!
+ dbg_assert(0);
+ return 0;
+}
+
+
+/****************** public functions ************************/
+
+void
+cp_conn_init(void)
+{
+ u32 i;
+ for(i=0 ; i < COUNT(conn_data) ; i++)
+ {
+ conn_data[i].conn_status = CONN_FREE;
+ conn_data[i].connexion = NULL;
+ conn_data[i].req_id = 0;
+ }
+}
+
+bool
+cp_conn_is_multicast(mac_address_t ad)
+{
+
+}
+
+void
+cp_conn_create_init(mac_address_t osa,
+ mac_address_t oda,
+ u16 req_id,
+ cspec_t cspec,
+ classifier_rules_t classifier_rules)
+{
+ u16 index;
+
+ // check if the connection is compliant with the current network mode (5.2.3.1)
+ // TODO
+ // do the connection admission control procedure (7.8.3)
+ if(cspec.cinfo_fw.mac_service_type != CONN_CONTENTION_BASED)
+ {
+ // TODO
+ }
+ index = cp_conn_get_new_conn_index();
+ if(index)
+ { // create the new connection
+ // record the CSPEC
+ conn_data[index].connexion = blk_alloc_zero();
+ memcpy(&conn_data[index].connexion->con_info.cspec, &cspec, sizeof(cspec));
+ // record the connection info
+ memcpy(conn_data[index].connexion->con_info.init, osa, sizeof(mac_address_t));
+ memcpy(conn_data[index].connexion->con_info.term, oda, sizeof(mac_address_t));
+ memcpy(&conn_data[index].connexion->rules, &classifier_rules, sizeof(classifier_rules_t));
+ conn_data[index].req_id = req_id;
+ // send the connexion request to the other station(s)
+ conn_data[index].conn_status = CONN_WAIT;
+
+ }
+}