summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-05-09 12:27:00 +0000
committerlaranjeiro2008-05-09 12:27:00 +0000
commit579887cf953d5fb86475034fd7a9f36887f32a50 (patch)
tree89746df995561c2b2832d8d1424996320943e511
parent928a7e3cea03141478179e91db8bcc6dbb594f7a (diff)
cco_action: Added the first test and documentation.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1965 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp2/cco/action/Module1
-rw-r--r--cesar/cp2/cco/action/cco_action.h22
-rw-r--r--cesar/cp2/cco/action/doc/cco_action.odtbin177626 -> 189729 bytes
-rw-r--r--cesar/cp2/cco/action/doc/cco_action.xmi190
-rw-r--r--cesar/cp2/cco/action/inc/cco_action.h29
-rw-r--r--cesar/cp2/cco/action/src/cco_action.c298
-rw-r--r--cesar/cp2/cco/action/test/Makefile9
-rw-r--r--cesar/cp2/cco/action/test/doc/cco_action.txt26
-rw-r--r--cesar/cp2/cco/action/test/ecos.ecc.sh5
-rwxr-xr-xcesar/cp2/cco/action/test/src/action-test.c321
10 files changed, 804 insertions, 97 deletions
diff --git a/cesar/cp2/cco/action/Module b/cesar/cp2/cco/action/Module
new file mode 100644
index 0000000000..9cde29712e
--- /dev/null
+++ b/cesar/cp2/cco/action/Module
@@ -0,0 +1 @@
+SOURCES := cco_action.c
diff --git a/cesar/cp2/cco/action/cco_action.h b/cesar/cp2/cco/action/cco_action.h
index 540a80f11d..6939f36e52 100644
--- a/cesar/cp2/cco/action/cco_action.h
+++ b/cesar/cp2/cco/action/cco_action.h
@@ -14,6 +14,10 @@
*
*/
+#include "cp2/cp.h"
+#include "cp2/mme.h"
+#include "cp2/beacon/forward.h"
+
/** Forward declaration. */
typedef struct cp_cco_action_t cp_cco_action_t;
@@ -64,18 +68,6 @@ void
cp_cco_action_gen_nek (cp_t *ctx, u8 sl);
/**
- * treat various interesting info for a CCo (or, may be, even a STA) from
- * within a received beacon.
- * \param ctx the module context.
- * \param beacon received beacon
- *
- * treat other infos from within the beacon (useful infos for the CCo
- * or STA)
- */
-void
-cp_cco_action_manage_rx_beacon (cp_t *ctx, cp_beacon_desc_t * beacon);
-
-/**
* manage association of a station.
* \param ctx the module context.
* \param assoc_req CM_ASSOC.REQ MME msg having being received
@@ -91,7 +83,7 @@ cp_cco_action_manage_rx_beacon (cp_t *ctx, cp_beacon_desc_t * beacon);
* confirmation, put a STA_JOINED event in the FSM
*/
void
-cp_cco_action_manage_sta_assoc (cp_t *ctx, mme_rx_t * assoc_req);
+cp_cco_action_manage_sta_assoc (cp_t *ctx, cp_mme_rx_t * assoc_req);
/**
* manage authentication of a station.
@@ -104,7 +96,7 @@ cp_cco_action_manage_sta_assoc (cp_t *ctx, mme_rx_t * assoc_req);
* back to the STA that sent the auth (get key) request
*/
void
-cp_cco_action_manage_sta_auth (cp_t *ctx, mme_rx_t * get_key_req);
+cp_cco_action_manage_sta_auth (cp_t *ctx, cp_mme_rx_t * get_key_req);
/**
* manage explicit leave request of a station.
@@ -114,6 +106,6 @@ cp_cco_action_manage_sta_auth (cp_t *ctx, mme_rx_t * get_key_req);
* Remove the station from the station manager
*/
void
-cp_cco_action_manage_sta_leave (cp_t *ctx, mme_rx_t * leave_req);
+cp_cco_action_manage_sta_leave (cp_t *ctx, cp_mme_rx_t * leave_req);
#endif /* cp2_cco_action_h */
diff --git a/cesar/cp2/cco/action/doc/cco_action.odt b/cesar/cp2/cco/action/doc/cco_action.odt
index 6b1c776701..ef94dc3af7 100644
--- a/cesar/cp2/cco/action/doc/cco_action.odt
+++ b/cesar/cp2/cco/action/doc/cco_action.odt
Binary files differ
diff --git a/cesar/cp2/cco/action/doc/cco_action.xmi b/cesar/cp2/cco/action/doc/cco_action.xmi
index 1d3640e600..7a916e224f 100644
--- a/cesar/cp2/cco/action/doc/cco_action.xmi
+++ b/cesar/cp2/cco/action/doc/cco_action.xmi
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<XMI xmlns:UML="http://schema.omg.org/spec/UML/1.3" verified="false" timestamp="2008-05-06T11:30:46" xmi.version="1.2" >
+<XMI xmlns:UML="http://schema.omg.org/spec/UML/1.3" verified="false" timestamp="2008-05-07T15:21:56" xmi.version="1.2" >
<XMI.header>
<XMI.documentation>
<XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
@@ -13,6 +13,7 @@
<UML:Namespace.ownedElement>
<UML:Stereotype isSpecification="false" isLeaf="false" visibility="public" namespace="m1" xmi.id="folder" isRoot="false" isAbstract="false" name="folder" />
<UML:Stereotype isSpecification="false" isLeaf="false" visibility="public" namespace="m1" xmi.id="datatype" isRoot="false" isAbstract="false" name="datatype" />
+ <UML:Stereotype isSpecification="false" isLeaf="false" visibility="public" namespace="m1" xmi.id="enum" isRoot="false" isAbstract="false" name="enum" />
<UML:Model stereotype="folder" isSpecification="false" isLeaf="false" visibility="public" namespace="m1" xmi.id="Logical View" isRoot="false" isAbstract="false" name="Logical View" >
<UML:Namespace.ownedElement>
<UML:Package stereotype="folder" isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="Datatypes" isRoot="false" isAbstract="false" name="Datatypes" >
@@ -46,108 +47,84 @@
</UML:Package>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="BzDeGrof35i3" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="GOqMBpWPMxBt" aggregation="aggregate" type="AdYl289wjpBd" name="" multiplicity="1" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="3klnQBxwzDj9" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="8" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="shXnRuge4vgg" aggregation="aggregate" type="AdYl289wjpBd" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="v4EbsUNNCW2E" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="8" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="DWwHbcINxulG" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="dc9exafDzTXA" aggregation="aggregate" type="L2ASUCoHdFZ0" name="" multiplicity="1" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="I1adyjU0RDlr" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="1Xv8eSFW8kHZ" aggregation="aggregate" type="L2ASUCoHdFZ0" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="exBjtrPmtcLj" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="1" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="UODsawo5TGgC" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="OinNtUXW7eA2" aggregation="aggregate" type="AdYl289wjpBd" name="" multiplicity="1" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="FpDEJkMZkwCg" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="*" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="6h7GD9TEeONI" aggregation="aggregate" type="AdYl289wjpBd" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="oanwL4Tx0egr" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="*" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="c6v3mGeXVqXR" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="ehg5uRxJ8ie1" aggregation="none" type="L2ASUCoHdFZ0" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="DBYIogK3UVFl" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="V4dMgw6kdDyr" aggregation="none" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="MR5ypQFc12WK" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="T1xzpUO46GR3" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="DbKxWVeAAIF4" aggregation="none" type="L2ASUCoHdFZ0" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="kALqr0r29NIx" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="40H2ewt80UUe" aggregation="none" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="RaM4lKv5mz4Z" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="8xImlyaBNYwN" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="4ayW5DHInZGJ" aggregation="aggregate" type="AdYl289wjpBd" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="4sREAeHunake" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="PJ9OJgiNg0QI" aggregation="aggregate" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="uHQumtWBRsFD" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="fVlZqtZMrzdT" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="aaeivwdxWcTb" aggregation="aggregate" type="AdYl289wjpBd" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="niraI7rMzIb8" aggregation="none" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="A9Iu8KUVdduw" aggregation="aggregate" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="JaIxYgESxeMh" aggregation="none" type="L2ASUCoHdFZ0" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="2uIgsGr4ejEG" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="xq2kQlMzJ0hE" aggregation="aggregate" type="L2ASUCoHdFZ0" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="wKAQudziMqGe" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="Vqsxg88pHOjN" aggregation="aggregate" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="jDsMpkH6LZ4t" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="0UqhrhEJ8WDS" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="y8yvQX3NN45o" aggregation="aggregate" type="AdYl289wjpBd" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="nRn4RSGLkQlf" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="FGMAugsOVkLB" aggregation="aggregate" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="qR05piSYvJtk" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="Vd6MhjybKlo7" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="2kLOZb0VjwQ8" aggregation="composite" type="L2ASUCoHdFZ0" name="" multiplicity="1" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="USTpUZdF0OJQ" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="3ApOhrGw7a61" aggregation="composite" type="L2ASUCoHdFZ0" name="" multiplicity="1" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="EwNjhgtV7rbx" aggregation="none" type="AdYl289wjpBd" name="" multiplicity="1" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="JD1yKqZUviuE" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="oZlZ0VE2DZOm" aggregation="none" type="L2ASUCoHdFZ0" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="AMHsIg0k6RaY" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="Z1TTKMBOU0kB" aggregation="none" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="ry5yWAyl6LSl" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Association isSpecification="false" visibility="public" namespace="Logical View" xmi.id="Dv7QUbCmB2YY" name="" >
<UML:Association.connection>
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="0BnzY6PMd8vb" aggregation="none" type="L2ASUCoHdFZ0" name="" />
- <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="b7bnexXnJpfa" aggregation="none" type="AdYl289wjpBd" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="false" xmi.id="2LF7Bq4irWBA" aggregation="none" type="L2ASUCoHdFZ0" name="" />
+ <UML:AssociationEnd isSpecification="false" visibility="public" changeability="changeable" isNavigable="true" xmi.id="qNWLNGUDDaBj" aggregation="none" type="AdYl289wjpBd" name="" />
</UML:Association.connection>
</UML:Association>
<UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="L2ASUCoHdFZ0" isRoot="false" isAbstract="false" name="cp_cco_action_t" >
<UML:Classifier.feature>
<UML:Attribute comment="The set containing the STA ordered by the TEI lease." isSpecification="false" visibility="private" xmi.id="wJK4orddFvYy" type="3JjrtT9nxOIX" name="tei_lease_expiration" />
- <UML:Operation comment="Search for an available TEI in the AVLN list.
-Get the AVLN from the station manager (our AVLN).
-Lookup in the station a hole of TEIs. It no hole is found and no more STAs are available it means that all the TEIs are used in the AVLN.
-\Warn The TEI = 0 is reserved and 255 too." isSpecification="false" isLeaf="false" visibility="private" xmi.id="zsD44qakozbG" isRoot="false" isAbstract="false" isQuery="false" name="tei_lease_create" >
- <UML:BehavioralFeature.parameter>
- <UML:Parameter kind="return" xmi.id="Wr6j2wz4Mytl" type="7IVPdQ5yFmJq" />
- </UML:BehavioralFeature.parameter>
- </UML:Operation>
- <UML:Operation comment="check for TEI lease expiration.
-
-called by the cco action garbage-collector function for each TEI lease
-in the list of TEI lease
-
-for the given TEI lease, check whether current clock &lt; (TEI creation time + TEI lease time) " isSpecification="false" isLeaf="false" visibility="private" xmi.id="Mi2ghtQGosJT" isRoot="false" isAbstract="false" isQuery="false" name="tei_lease_check" />
- <UML:Operation comment="Return true if the left node is lesser than the right node. This function shall compare the expuiration lease of the stations." isSpecification="false" isLeaf="false" visibility="private" xmi.id="uUHWZwfWD0Yz" isRoot="false" isAbstract="false" isQuery="false" name="tei_lease_less" >
- <UML:BehavioralFeature.parameter>
- <UML:Parameter kind="return" xmi.id="pBa3681kSBrD" type="BsXuVmQldfSS" />
- <UML:Parameter comment="The left node." isSpecification="false" visibility="private" xmi.id="ft1vqSvak3XH" value="" type="ClVcxKp0dXpU" name="left" />
- <UML:Parameter comment="The right node." isSpecification="false" visibility="private" xmi.id="SxpSSK1tnd7i" value="" type="ClVcxKp0dXpU" name="right" />
- </UML:BehavioralFeature.parameter>
- </UML:Operation>
+ <UML:Attribute comment="List of the TEI already in use." isSpecification="false" visibility="private" xmi.id="IVOTagMalq8Q" type="oZHHg64PKBaq" name="tei_flags [8]" />
<UML:Operation comment="initialisation of CCo action module." isSpecification="false" isLeaf="false" visibility="public" xmi.id="qHxkg2dtESUh" isRoot="false" isAbstract="false" isQuery="false" name="init" />
<UML:Operation comment="Uninitialisation of CCo action module." isSpecification="false" isLeaf="false" visibility="public" xmi.id="2gQknmKqTzYm" isRoot="false" isAbstract="false" isQuery="false" name="uninit" />
<UML:Operation comment="Change the SNID.
It shall request the SNIDs in use from the station manager to choose one randomly in the available SNIDs." isSpecification="false" isLeaf="false" visibility="public" xmi.id="Wf52IeS60CA2" isRoot="false" isAbstract="false" isQuery="false" name="snid_change" />
- <UML:Operation comment="perform garbage actions of CCo's responsability.
-
-Call the tei_lease_check function.
-" isSpecification="false" isLeaf="false" visibility="public" xmi.id="TgOyCXvyx6rl" isRoot="false" isAbstract="true" isQuery="false" name="garbage" />
<UML:Operation comment="generate a new NEK value.
NEK shall be used no more than 1 hour, so must be changed after 1 hour
@@ -159,14 +136,10 @@ a new NEK value shall be generated by calling this function
<UML:Parameter comment="security level" isSpecification="false" visibility="private" xmi.id="2OY7BT7QLV4m" value="" type="nnvOyvzkSE17" name="sl" />
</UML:BehavioralFeature.parameter>
</UML:Operation>
- <UML:Operation comment="treat various interesting info for a CCo (or, may be, even a STA) from
-within a received beacon.
+ <UML:Operation comment="perform garbage actions of CCo's responsability.
-treat other infos from within the beacon (useful infos for the CCo or STA) " isSpecification="false" isLeaf="false" visibility="public" xmi.id="caUk0iXQP1G3" isRoot="false" isAbstract="false" isQuery="false" name="manage_rx_beacon" >
- <UML:BehavioralFeature.parameter>
- <UML:Parameter comment="received beacon" isSpecification="false" visibility="private" xmi.id="h680cAmEkEwj" value="" type="pTgoiQ7YHojW" name="beacon" />
- </UML:BehavioralFeature.parameter>
- </UML:Operation>
+Call the tei_lease_check function.
+" isSpecification="false" isLeaf="false" visibility="public" xmi.id="TgOyCXvyx6rl" isRoot="false" isAbstract="false" isQuery="false" name="garbage" />
<UML:Operation comment="manage association of a station.
1) if CC_ASSOC.REQ ReqType field value is &quot;join&quot;, call create_tei_lease()
@@ -197,17 +170,83 @@ Remove the station from the station manager." isSpecification="false" isLeaf="fa
<UML:Parameter comment="The MME leave req message." isSpecification="false" visibility="private" xmi.id="SQ8diR5NEycA" value="" type="CQBdOKlCTu2N" name="leave_req" />
</UML:BehavioralFeature.parameter>
</UML:Operation>
+ <UML:Operation comment="Search for an available TEI in the AVLN list.
+Get the AVLN from the station manager (our AVLN).
+Lookup in the station a hole of TEIs. It no hole is found and no more STAs are available it means that all the TEIs are used in the AVLN.
+\Warn The TEI = 0 is reserved and 255 too." isSpecification="false" isLeaf="false" visibility="private" xmi.id="zsD44qakozbG" isRoot="false" isAbstract="false" isQuery="false" name="tei_compute" >
+ <UML:BehavioralFeature.parameter>
+ <UML:Parameter kind="return" xmi.id="Wr6j2wz4Mytl" type="nnvOyvzkSE17" />
+ </UML:BehavioralFeature.parameter>
+ </UML:Operation>
+ <UML:Operation comment="Release a TEI." isSpecification="false" isLeaf="false" visibility="private" xmi.id="pzdLQr60HhdP" isRoot="false" isAbstract="false" isQuery="false" name="tei_release" >
+ <UML:BehavioralFeature.parameter>
+ <UML:Parameter comment="The TEI value to release." isSpecification="false" visibility="private" xmi.id="6mggkLl0L6nY" value="" type="nnvOyvzkSE17" name="tei" />
+ </UML:BehavioralFeature.parameter>
+ </UML:Operation>
+ <UML:Operation comment="Return true if the left node is lesser than the right node. This function shall compare the expuiration lease of the stations." isSpecification="false" isLeaf="false" visibility="private" xmi.id="uUHWZwfWD0Yz" isRoot="false" isAbstract="false" isQuery="false" name="tei_lease_less" >
+ <UML:BehavioralFeature.parameter>
+ <UML:Parameter kind="return" xmi.id="pBa3681kSBrD" type="BsXuVmQldfSS" />
+ <UML:Parameter comment="The left node." isSpecification="false" visibility="private" xmi.id="ft1vqSvak3XH" value="" type="ClVcxKp0dXpU" name="left" />
+ <UML:Parameter comment="The right node." isSpecification="false" visibility="private" xmi.id="SxpSSK1tnd7i" value="" type="ClVcxKp0dXpU" name="right" />
+ </UML:BehavioralFeature.parameter>
+ </UML:Operation>
+ </UML:Classifier.feature>
+ </UML:Class>
+ <UML:Class comment="Association request data." isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="7z9AcGCqg0oV" isRoot="false" isAbstract="false" name="cc_assoc_req_t" >
+ <UML:Classifier.feature>
+ <UML:Attribute comment="Request type." isSpecification="false" visibility="public" xmi.id="w9oABNcQk8tU" type="LYg9EevkY5Yi" name="request_type" />
+ <UML:Attribute comment="The NID of the AVLN." isSpecification="false" visibility="public" xmi.id="q1U9qSCXi0ay" type="QPMsbNxuTUYh" name="nid" />
+ <UML:Attribute comment="The Station CCo Capability." isSpecification="false" visibility="public" xmi.id="rwYL7p0EYPAf" type="nnvOyvzkSE17" name="cco_cap" />
+ <UML:Attribute comment="The Station proxy capability." isSpecification="false" visibility="public" xmi.id="DdCYvWsjWLqK" type="nnvOyvzkSE17" name="Proxy_cap" />
</UML:Classifier.feature>
</UML:Class>
+ <UML:Enumeration stereotype="enum" isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="LYg9EevkY5Yi" isRoot="false" isAbstract="false" name="cc_assoc_req_request_type_t" >
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="LYg9EevkY5Yi" xmi.id="ke44NNWgvApA" isRoot="false" isAbstract="false" name="CC_ASSOC_REQ_NEW" />
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="LYg9EevkY5Yi" xmi.id="iDwUjrOSWSWr" isRoot="false" isAbstract="false" name="CC_ASSOC_REQ_RENEW" />
+ </UML:Enumeration>
+ <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="h7zBSqWEqMgp" isRoot="false" isAbstract="false" name="cc_assoc_cnf_t" >
+ <UML:Classifier.feature>
+ <UML:Attribute comment="The result of the previous request." isSpecification="false" visibility="public" xmi.id="k6g55qVry99W" type="iTyn7lva5s2U" name="result" />
+ <UML:Attribute comment="AVLN's NID." isSpecification="false" visibility="public" xmi.id="w8HLJYczfZA6" type="QPMsbNxuTUYh" name="nid" />
+ <UML:Attribute comment="SNID's AVLN." isSpecification="false" visibility="public" xmi.id="PeKEyy1j4fo8" type="J5WdE6USg2qD" name="snid" />
+ <UML:Attribute comment="The station TEI." isSpecification="false" visibility="public" xmi.id="TKzSR9yNFDhZ" type="nnvOyvzkSE17" name="sta_tei" />
+ <UML:Attribute comment="The lease time for the TEI." isSpecification="false" visibility="public" xmi.id="jHWMqeSGHkSF" type="J5WdE6USg2qD" name="lease_time" />
+ </UML:Classifier.feature>
+ </UML:Class>
+ <UML:Enumeration stereotype="enum" isSpecification="false" isLeaf="false" visibility="public" namespace="Logical View" xmi.id="iTyn7lva5s2U" isRoot="false" isAbstract="false" name="cc_assoc_cnf_result_t" >
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="iTyn7lva5s2U" xmi.id="ufuBQKP6mNrt" isRoot="false" isAbstract="false" name="SUCCESS" />
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="iTyn7lva5s2U" xmi.id="3ZQrpdViHOrh" isRoot="false" isAbstract="false" name="FAILURE_TEMPORARY_RESSOURCE_EXHAUSTION" />
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="iTyn7lva5s2U" xmi.id="DYZb2M95wYuj" isRoot="false" isAbstract="false" name="FAILURE_PERMANANT_RESSOURCE_EXHAUSTION" />
+ <UML:EnumerationLiteral isSpecification="false" isLeaf="false" visibility="public" namespace="iTyn7lva5s2U" xmi.id="HsihwnbZgPL4" isRoot="false" isAbstract="false" name="FAILURE_OTHER_REASON" />
+ </UML:Enumeration>
</UML:Namespace.ownedElement>
<XMI.extension xmi.extender="umbrello" >
<diagrams>
<diagram snapgrid="0" showattsig="1" fillcolor="#ffffc0" linewidth="0" zoom="100" showgrid="0" showopsig="1" usefillcolor="1" snapx="10" canvaswidth="978" snapy="10" showatts="1" xmi.id="bZ62yFKbgidF" documentation="" type="1" showops="1" showpackage="0" name="diagramme de classes" localid="" showstereotype="0" showscope="1" snapcsgrid="0" font="Sans Serif,9,-1,5,50,0,0,0,0,0" linecolor="#ff0000" canvasheight="853" >
<widgets>
<classwidget usesdiagramfillcolor="0" width="395" showattsigs="601" x="73" fillcolor="#ffffc0" y="56" showopsigs="601" linewidth="none" height="224" usefillcolor="1" showpubliconly="0" showattributes="1" isinstance="0" xmi.id="L2ASUCoHdFZ0" showoperations="1" showpackage="0" showscope="1" usesdiagramusefillcolor="0" font="Sans Serif,9,-1,5,50,1,0,0,0,0" linecolor="#ff0000" />
+ <classwidget usesdiagramfillcolor="0" width="303" showattsigs="601" x="37" fillcolor="#ffffc0" y="586" showopsigs="601" linewidth="none" height="88" usefillcolor="1" showpubliconly="0" showattributes="1" isinstance="0" xmi.id="7z9AcGCqg0oV" showoperations="1" showpackage="0" showscope="1" usesdiagramusefillcolor="0" font="Sans Serif,9,-1,5,75,0,0,0,0,0" linecolor="#ff0000" />
+ <enumwidget usesdiagramfillcolor="0" width="203" x="86" fillcolor="#ffffc0" y="464" linewidth="none" height="64" usefillcolor="1" isinstance="0" xmi.id="LYg9EevkY5Yi" showpackage="0" usesdiagramusefillcolor="0" font="Sans Serif,9,-1,5,75,1,0,0,0,0" linecolor="#ff0000" />
+ <classwidget usesdiagramfillcolor="0" width="209" showattsigs="601" x="417" fillcolor="#ffffc0" y="594" showopsigs="601" linewidth="none" height="104" usefillcolor="1" showpubliconly="0" showattributes="1" isinstance="0" xmi.id="h7zBSqWEqMgp" showoperations="1" showpackage="0" showscope="1" usesdiagramusefillcolor="0" font="Sans Serif,9,-1,5,75,0,0,0,0,0" linecolor="#ff0000" />
+ <enumwidget usesdiagramfillcolor="0" width="303" x="369" fillcolor="#ffffc0" y="448" linewidth="none" height="96" usefillcolor="1" isinstance="0" xmi.id="iTyn7lva5s2U" showpackage="0" usesdiagramusefillcolor="0" font="Sans Serif,9,-1,5,75,1,0,0,0,0" linecolor="#ff0000" />
</widgets>
<messages/>
- <associations/>
+ <associations>
+ <assocwidget totalcounta="2" indexa="1" visibilityB="200" totalcountb="2" indexb="1" linewidth="none" widgetbid="LYg9EevkY5Yi" widgetaid="7z9AcGCqg0oV" xmi.id="w9oABNcQk8tU" type="510" changeabilityA="900" changeabilityB="900" linecolor="none" visibilityA="200" >
+ <linepath>
+ <startpoint startx="188" starty="586" />
+ <endpoint endx="187" endy="528" />
+ </linepath>
+ <floatingtext usesdiagramfillcolor="1" width="100" x="189" fillcolor="none" y="530" linewidth="none" posttext="" role="710" height="20" usefillcolor="1" pretext="+" isinstance="0" xmi.id="5IrMaWCGh7lO" text="request_type" usesdiagramusefillcolor="1" font="Sans Serif,9,-1,5,50,0,0,0,0,0" linecolor="none" />
+ </assocwidget>
+ <assocwidget totalcounta="2" indexa="1" visibilityB="200" totalcountb="2" indexb="1" linewidth="none" widgetbid="iTyn7lva5s2U" widgetaid="h7zBSqWEqMgp" xmi.id="k6g55qVry99W" type="510" changeabilityA="900" changeabilityB="900" linecolor="none" visibilityA="200" >
+ <linepath>
+ <startpoint startx="521" starty="594" />
+ <endpoint endx="520" endy="544" />
+ </linepath>
+ <floatingtext usesdiagramfillcolor="1" width="54" x="522" fillcolor="none" y="546" linewidth="none" posttext="" role="710" height="20" usefillcolor="1" pretext="+" isinstance="0" xmi.id="Naeo1S56udvo" text="result" usesdiagramusefillcolor="1" font="Sans Serif,9,-1,5,50,0,0,0,0,0" linecolor="none" />
+ </assocwidget>
+ </associations>
</diagram>
</diagrams>
</XMI.extension>
@@ -242,25 +281,38 @@ manage sta association
manage authentication with relevant keys (NEK, NMK) and security-level
-Initialisation of SNID &amp; management of SNID conflicts" uniqueid="SxpSSK1tnd7i" />
+Initialisation of SNID &amp; management of SNID conflicts" uniqueid="A09EO9VnalKh" />
<listview>
<listitem open="1" type="800" label="Vues" >
<listitem open="1" type="801" id="Logical View" >
<listitem open="0" type="807" id="bZ62yFKbgidF" label="diagramme de classes" />
+ <listitem open="1" type="813" id="h7zBSqWEqMgp" >
+ <listitem open="0" type="814" id="k6g55qVry99W" />
+ <listitem open="0" type="814" id="w8HLJYczfZA6" />
+ <listitem open="0" type="814" id="PeKEyy1j4fo8" />
+ <listitem open="0" type="814" id="TKzSR9yNFDhZ" />
+ <listitem open="0" type="814" id="jHWMqeSGHkSF" />
+ </listitem>
+ <listitem open="1" type="813" id="7z9AcGCqg0oV" >
+ <listitem open="0" type="814" id="w9oABNcQk8tU" />
+ <listitem open="0" type="814" id="q1U9qSCXi0ay" />
+ <listitem open="0" type="814" id="rwYL7p0EYPAf" />
+ <listitem open="0" type="814" id="DdCYvWsjWLqK" />
+ </listitem>
<listitem open="1" type="813" id="L2ASUCoHdFZ0" >
<listitem open="0" type="814" id="wJK4orddFvYy" />
- <listitem open="0" type="815" id="zsD44qakozbG" />
- <listitem open="0" type="815" id="Mi2ghtQGosJT" />
- <listitem open="0" type="815" id="uUHWZwfWD0Yz" />
+ <listitem open="0" type="814" id="IVOTagMalq8Q" />
<listitem open="0" type="815" id="qHxkg2dtESUh" />
<listitem open="0" type="815" id="2gQknmKqTzYm" />
<listitem open="0" type="815" id="Wf52IeS60CA2" />
- <listitem open="0" type="815" id="TgOyCXvyx6rl" />
<listitem open="0" type="815" id="RhTqdgLYcIeT" />
- <listitem open="0" type="815" id="caUk0iXQP1G3" />
+ <listitem open="0" type="815" id="TgOyCXvyx6rl" />
<listitem open="0" type="815" id="SwOagcKvW3p0" />
<listitem open="0" type="815" id="PU4v0VmG0hH6" />
<listitem open="0" type="815" id="wZIl1SxKS9HT" />
+ <listitem open="0" type="815" id="zsD44qakozbG" />
+ <listitem open="0" type="815" id="pzdLQr60HhdP" />
+ <listitem open="0" type="815" id="uUHWZwfWD0Yz" />
</listitem>
<listitem open="1" type="830" id="Datatypes" >
<listitem open="1" type="829" id="BsXuVmQldfSS" />
@@ -289,6 +341,16 @@ Initialisation of SNID &amp; management of SNID conflicts" uniqueid="SxpSSK1tnd7
<listitem open="1" type="829" id="hz7D2ZH5u80l" />
<listitem open="1" type="829" id="tFhSKvrguqen" />
</listitem>
+ <listitem open="1" type="831" id="iTyn7lva5s2U" >
+ <listitem open="0" type="839" id="ufuBQKP6mNrt" />
+ <listitem open="0" type="839" id="3ZQrpdViHOrh" />
+ <listitem open="0" type="839" id="DYZb2M95wYuj" />
+ <listitem open="0" type="839" id="HsihwnbZgPL4" />
+ </listitem>
+ <listitem open="1" type="831" id="LYg9EevkY5Yi" >
+ <listitem open="0" type="839" id="ke44NNWgvApA" />
+ <listitem open="0" type="839" id="iDwUjrOSWSWr" />
+ </listitem>
</listitem>
<listitem open="1" type="802" id="Use Case View" >
<listitem open="1" type="811" id="g2RmQlkG6CqM" />
diff --git a/cesar/cp2/cco/action/inc/cco_action.h b/cesar/cp2/cco/action/inc/cco_action.h
index e15f15e055..23b65bb51a 100644
--- a/cesar/cp2/cco/action/inc/cco_action.h
+++ b/cesar/cp2/cco/action/inc/cco_action.h
@@ -1,5 +1,5 @@
-#ifndef cp2_cco_action_h
-#define cp2_cco_action_h
+#ifndef cp2_cco_inc_cco_action_h
+#define cp2_cco_inc_cco_action_h
/* Cesar project {{{
*
* Copyright (C) 2008 Spidcom
@@ -15,12 +15,15 @@
*/
#include "lib/set.h"
-#include "cp2/cco/cco_action.h"
+#include "cp2/cco/action/cco_action.h"
+
+#define CP_CCO_ACTION_TEI_FLAGS_ROW 8
+#define CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS 32 /* 32 bits. */
struct cp_cco_action_t
{
- /** Public data. */
- cp_cco_action_t public_data;
+ /** TEI in use. */
+ uint tei_flags [CP_CCO_ACTION_TEI_FLAGS_ROW];
/**
* The set containing the STA ordered by the TEI lease.
@@ -39,22 +42,19 @@ struct cp_cco_action_t
* is reserved and 255 too
*/
u8
-cp_cco_action_tei_lease_create (cp_cco_action_t *ctx);
+cp_cco_action_tei_compute (cp_cco_action_t *ctx);
/**
- * check for TEI lease expiration.
+ * Release a TEI.
* \param ctx the module context.
+ * \param tei The TEI value to release.
*
- * called by the cco action garbage-collector function for each TEI
- * lease in the list of TEI lease for the given TEI lease, check whether
- * current clock < (TEI creation time + TEI lease time)
*/
void
-cp_cco_action_tei_lease_check (cp_cco_action_t *ctx);
+cp_cco_action_tei_release (cp_cco_action_t *ctx, u8 tei);
/**
* Return true if the left node is lesser than the right node.
- * \param ctx the module context.
* \param left The left node.
* \param right The right node.
* \return true if left is lesser than right.
@@ -62,7 +62,6 @@ cp_cco_action_tei_lease_check (cp_cco_action_t *ctx);
* This function shall compare the expiration lease of the stations
*/
bool
-cp_cco_action_tei_lease_less (cp_cco_action_t *ctx,
- set_node_t * left, set_node_t * right);
+cp_cco_action_tei_lease_less (set_node_t * left, set_node_t * right);
-#endif /* cp_cco_action_private_h */
+#endif /* cp2_cco_inc_cco_action_h */
diff --git a/cesar/cp2/cco/action/src/cco_action.c b/cesar/cp2/cco/action/src/cco_action.c
new file mode 100644
index 0000000000..201b27279f
--- /dev/null
+++ b/cesar/cp2/cco/action/src/cco_action.c
@@ -0,0 +1,298 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp2/cco/action/src/cco_action.c
+ * \brief CCo Action functions.
+ * \ingroup cp2_cco
+ *
+ */
+#include "common/std.h"
+
+#include "lib/set.h"
+#include "lib/utils.h"
+#include "lib/rnd.h"
+
+#include "mac/common/ntb.h"
+
+#include "cp2/defs.h"
+#include "cp2/cp.h"
+#include "cp2/cco/action/cco_action.h"
+#include "cp2/sta/mgr/sta_mgr.h"
+#include "cp2/sta/mgr/sta.h"
+
+#include "cp2/beacon/beacon.h"
+
+#include "cp2/inc/context.h"
+#include "cp2/cco/action/inc/cco_action.h"
+
+/**
+ * Search for an available TEI in the AVLN list.
+ * \param ctx the module context.
+ * \return return the TEI found.
+ *
+ * Get the AVLN from the station manager (our AVLN). Lookup in the station
+ * a hole of TEIs. It no hole is found and no more STAs are available
+ * it means that all the TEIs are used in the AVLN. \Warn The TEI = 0
+ * is reserved and 255 too
+ */
+u8
+cp_cco_action_tei_compute (cp_cco_action_t *ctx)
+{
+ uint flag;
+ uint flag_rot;
+ uint index;
+ uint i;
+ uint tei;
+ dbg_assert (ctx);
+
+ for (index = 0; index < CP_CCO_ACTION_TEI_FLAGS_ROW; index ++)
+ {
+ flag = ~ctx->tei_flags[index];
+ flag_rot = flag;
+ for (i = (index == 0 ? 1 : 0) ;
+ i < sizeof(uint) * 8
+ && ((index == CP_CCO_ACTION_TEI_FLAGS_ROW - 1) ?
+ (flag_rot == 0x80000000 ? 0 : 1) : flag_rot);
+ i++)
+ {
+ flag_rot = flag >> i;
+ tei = flag_rot & BITS_ONES(i);
+ if (tei == true)
+ {
+ // Store the bit in the correct position.
+ flag_rot = (1 << i);
+ ctx->tei_flags[index] |= flag_rot;
+
+ // Compute the TEI value.
+ tei = i + (index * sizeof(uint) * 8) + 1;
+ return tei;
+ }
+ }
+ }
+
+ // No TEI are available.
+ return 0;
+}
+
+/**
+ * Release a TEI.
+ * \param ctx the module context.
+ * \param tei The TEI value to release.
+ */
+void
+cp_cco_action_tei_release (cp_cco_action_t *ctx, u8 tei)
+{
+ uint row;
+
+ dbg_assert (ctx);
+ dbg_assert (tei);
+
+ row = tei / CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS;
+
+ ctx->tei_flags[row] &= ~(1 << ((tei - 1)
+ % CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS));
+}
+
+
+/**
+ * Return true if the left node is lesser than the right node.
+ * \param left The left node.
+ * \param right The right node.
+ * \return true if left is lesser than right.
+ *
+ * This function shall compare the expiration lease of the stations
+ */
+bool
+cp_cco_action_tei_lease_less (set_node_t * left, set_node_t * right)
+{
+ cp_sta_t *sta_left;
+ cp_sta_t *sta_right;
+
+ dbg_assert (left);
+ dbg_assert (right);
+
+ sta_left = PARENT_OF (cp_sta_t, node, left);
+ sta_right = PARENT_OF (cp_sta_t, node, right);
+
+ if (sta_left->tei_lease_rtc < sta_right->tei_lease_rtc)
+ return true;
+ else
+ return false;
+}
+
+
+/**
+ * initialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_cco_action_init (cp_t *ctx)
+{
+ uint i;
+ dbg_assert (ctx);
+
+ for (i = 0; i < CP_CCO_ACTION_TEI_FLAGS_ROW; i++)
+ ctx->cco_action.tei_flags[i] = 0;
+
+ // Initialise the set.
+ set_init (&ctx->cco_action.tei_lease_expiration,
+ cp_cco_action_tei_lease_less);
+}
+
+/**
+ * Uninitialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_cco_action_uninit (cp_t *ctx)
+{
+ set_node_t *set_node;
+ cp_sta_t *sta;
+ dbg_assert (ctx);
+
+ // If the set is empty, there is nothing to do.
+ if (set_empty (&ctx->cco_action.tei_lease_expiration))
+ return;
+
+ set_node = set_begin (&ctx->cco_action.tei_lease_expiration);
+
+ if (set_node)
+ sta = PARENT_OF (cp_sta_t, node, set_node);
+
+ while ((set_node = set_next (&ctx->cco_action.tei_lease_expiration,
+ &sta->node)))
+ {
+ set_remove (&ctx->cco_action.tei_lease_expiration, &sta->node);
+ blk_release (sta);
+
+ if (set_node)
+ sta = PARENT_OF (cp_sta_t, node, set_node);
+ }
+
+ set_remove (&ctx->cco_action.tei_lease_expiration, &sta->node);
+ blk_release (sta);
+}
+
+/**
+ * Change the SNID.
+ * \param ctx the module context.
+ *
+ * It shall request the SNIDs in use from the station manager to choose
+ * one randomly in the available SNIDs
+ */
+void
+cp_cco_action_snid_change (cp_t *ctx)
+{
+ u16 flags;
+ u16 table [16];
+ uint nb_elem;
+ uint i;
+ lib_rnd_t random;
+ dbg_assert (ctx);
+
+ lib_rnd_init (&random, mac_ntb());
+
+ // Get the present flags.
+ flags = ~cp_sta_mgr_get_present_snids (ctx);
+
+ // fill the table.
+ for (i = 0, nb_elem = 0; i < 16; i++)
+ {
+ if ((flags >> i) & true)
+ {
+ table[nb_elem] = i + 1;
+ nb_elem ++;
+ }
+ }
+
+
+ // Chose the new SNID.
+ i = lib_rnd32 (&random) % nb_elem;
+
+ // Provide the SNID to the beacon module.
+ cp_beacon_change_snid (ctx, table[i]);
+}
+
+/**
+ * perform garbage actions of CCo's responsibility.
+ * \param ctx the module context.
+ */
+void
+cp_cco_action_garbage (cp_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+/**
+ * generate a new NEK value.
+ * \param ctx the module context.
+ * \param sl security level
+ *
+ * NEK shall be used no more than 1 hour, so must be changed after 1
+ * hour for that purpose, NEK expiration date is checked at every occurrence
+ * of the global garbage collector timer and if current NEK expiration
+ * date reached, a new NEK value shall be generated by calling this function
+ */
+void
+cp_cco_action_gen_nek (cp_t *ctx, u8 sl);
+
+/**
+ * treat various interesting info for a CCo (or, may be, even a STA) from
+ * within a received beacon.
+ * \param ctx the module context.
+ * \param beacon received beacon
+ *
+ * treat other infos from within the beacon (useful infos for the CCo
+ * or STA)
+ */
+void
+cp_cco_action_manage_rx_beacon (cp_t *ctx, cp_beacon_desc_t * beacon);
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ *
+ * 1) if CC_ASSOC.REQ ReqType field value is "join", call create_tei_lease()
+ * to create a default TEI lease (select a TEI value and set 15 minutes
+ * of lease date by default, Table 11-212) 2) else if CC_ASSOC.REQ ReqType
+ * field value is "renew", update (renew) the TEI lease (lease = 15
+ * minutes if STA still not authenticated, 48 Hours if STA is authenticated
+ * ? Table 11-212) 3) prepare CM_ASSOC.CNF MME to be sent back to the
+ * STA that sent the assoc request 4) send CM_ASSOC.CNF MME back to the
+ * STA that sent the assoc request 5) if the CM_ASSOC.CNF was a positive
+ * confirmation, put a STA_JOINED event in the FSM
+ */
+void
+cp_cco_action_manage_sta_assoc (cp_t *ctx, cp_mme_rx_t * assoc_req);
+
+/**
+ * manage authentication of a station.
+ * \param ctx the module context.
+ * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
+ *
+ * 1) prepare CM_SET_KEY.REQ MME to be sent back to the STA that sent
+ * the auth (get key) request 2) encrypt and encapsulate the CM_SET_KEY.REQ
+ * MME into a CM_ENCRYPTED_PAYLOAD.IND MME 3) send CM_ENCRYPTED_PAYLOAD.IND(CM_SET_KEY.REQ)
+ * back to the STA that sent the auth (get key) request
+ */
+void
+cp_cco_action_manage_sta_auth (cp_t *ctx, cp_mme_rx_t * get_key_req);
+
+/**
+ * manage explicit leave request of a station.
+ * \param ctx the module context.
+ * \param leave_req The MME leave req message.
+ *
+ * Remove the station from the station manager
+ */
+void
+cp_cco_action_manage_sta_leave (cp_t *ctx, cp_mme_rx_t * leave_req);
+
diff --git a/cesar/cp2/cco/action/test/Makefile b/cesar/cp2/cco/action/test/Makefile
index e2a50f08d0..b8cbe50d38 100644
--- a/cesar/cp2/cco/action/test/Makefile
+++ b/cesar/cp2/cco/action/test/Makefile
@@ -1,5 +1,10 @@
-BASE = ../../..
+BASE = ../../../..
-HOST_PROGRAMS =
+ECOS = y
+
+TARGET_PROGRAMS = action
+
+action_SOURCES = action-test.c
+action_MODULES = lib cp2/cco/action mac/common
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp2/cco/action/test/doc/cco_action.txt b/cesar/cp2/cco/action/test/doc/cco_action.txt
index 5ad1f7883a..9626ef8a15 100644
--- a/cesar/cp2/cco/action/test/doc/cco_action.txt
+++ b/cesar/cp2/cco/action/test/doc/cco_action.txt
@@ -52,7 +52,7 @@ Garbage
The garbage function will call the tei_lease_check function to expire the expired TEI lease in the station of the AVLN.
-normally the clock use for the TEI lease is the eCos time, so it is very
+Normally the clock use for the TEI lease is the eCos time, so it is very
difficult to modify this timer.
For that a thread shall be added to the test to use the cyg_thread_delay
@@ -137,6 +137,30 @@ Environment
Result
The CCo shall send a answer CM_GET_KEY.CNF with the following data.
+
* Result = 0 (guaranteed)
* key = 2 (NEK)
* NID = 0
+
+STA leaving
+-----------
+
+Station is known
+~~~~~~~~~~~~~~~~
+
+Environment
+ Some station have been added and are associated and authenticated.
+ One of those stations sends a CC_LEAVE.REQ.
+
+Result
+ The station is removed from the station manager.
+ The CCo answers with a CC_LEAVE.IND.
+
+Station is not known
+~~~~~~~~~~~~~~~~~~~~
+
+Environment
+ A CC_LEAVE.REQ is received from a unknown station.
+
+Result
+ The CC_LEAVE.REQ is ignored.
diff --git a/cesar/cp2/cco/action/test/ecos.ecc.sh b/cesar/cp2/cco/action/test/ecos.ecc.sh
new file mode 100644
index 0000000000..8253d98c9a
--- /dev/null
+++ b/cesar/cp2/cco/action/test/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<EOF
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/cp2/cco/action/test/src/action-test.c b/cesar/cp2/cco/action/test/src/action-test.c
new file mode 100755
index 0000000000..e2bf046412
--- /dev/null
+++ b/cesar/cp2/cco/action/test/src/action-test.c
@@ -0,0 +1,321 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/action-test.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "lib/test.h"
+
+#include "mac/common/ntb.h"
+
+#include "cp2/cp.h"
+
+#include "cp2/cco/action/cco_action.h"
+#include "cp2/cco/action/inc/cco_action.h"
+
+
+#include "cp2/inc/context.h"
+
+// Snid return by the override of the sta_mgr_get_present_snids
+u16 snids;
+
+// The value provided to the module beacon.
+u16 snid_compute;
+
+/**
+ * Verify TEI lease computing function.
+ * \param test the test object.
+ *
+ * Test 1:
+ * Initialise the TEI flags to the value 0x0124 in the first word.
+ * The TEI return shall be 2.
+ *
+ * Test 2:
+ * Initialise the TEI flags first word to 0xFFFFFFFE.
+ * The second one with 0xFFFFEFFF
+ * The TEI returned shall be 45.
+ *
+ * Test 3:
+ * Initialise the TEI flags first word to 0xFFFFFFFE.
+ * Initialise the TEI flags second word to 0xFFFFFFFF.
+ * Initialise the TEI flags ... word to 0xFFFFFFFF.
+ * Initialise the TEI flags eights word to 0x7FFFFFFF.
+ * The TEI returned shall be 0.
+ */
+void
+test_case_tei_lease_create (test_t test)
+{
+ cp_cco_action_t action;
+ uint tei;
+
+ test_case_begin (test, "TEI Lease create");
+
+ action.tei_flags[0] = 0x0124;
+
+ tei = cp_cco_action_tei_compute (&action);
+
+ test_begin (test, "Test 1")
+ {
+ test_fail_if (tei != 2, "TEI shall be 2");
+ test_fail_if ((action.tei_flags[0] & 0x2) != 2,
+ "TEI bit flag shall be setted");
+ }
+ test_end;
+
+ action.tei_flags[0] = 0xFFFFFFFE;
+ action.tei_flags[1] = 0xFFFFEFFF;
+
+ tei = cp_cco_action_tei_compute (&action);
+
+ test_begin (test, "Test 2")
+ {
+ test_fail_if (tei != 45, "TEI shall be 57");
+ test_fail_if ((action.tei_flags[1] & 0xC) != 12,
+ "TEI bit flag shall be setted");
+ }
+ test_end;
+
+ action.tei_flags[0] = 0xFFFFFFFE;
+ action.tei_flags[1] = 0xFFFFFFFF;
+ action.tei_flags[2] = 0xFFFFFFFF;
+ action.tei_flags[3] = 0xFFFFFFFF;
+ action.tei_flags[4] = 0xFFFFFFFF;
+ action.tei_flags[5] = 0xFFFFFFFF;
+ action.tei_flags[6] = 0xFFFFFFFF;
+ action.tei_flags[7] = 0x7FFFFFFF;
+
+ tei = cp_cco_action_tei_compute (&action);
+
+ test_begin (test, "Test 3")
+ {
+ test_fail_if (tei != 0, "TEI shall be 0");
+ test_fail_if (action.tei_flags[7] != 0x7FFFFFFF,
+ "TEI bit flag shall be setted");
+ }
+ test_end;
+
+}
+
+/**
+ * Verify TEI release function.
+ * \param test the test object.
+ *
+ * Test 1:
+ * Initialise the TEI flags to the value 0x0126 in the first word.
+ * The TEI return shall be 2
+ *
+ * Test 2:
+ * Initialise the TEI flags first word to 0xFFFFFFFE.
+ * The second one with 0xFFFFFFFF
+ * The TEI returned shall be 45.
+ */
+void
+test_case_tei_release (test_t test)
+{
+ cp_cco_action_t action;
+ uint tei;
+
+ test_case_begin (test, "TEI Lease release");
+
+ action.tei_flags[0] = 0x0126;
+
+ //Release TEI 2.
+ cp_cco_action_tei_release (&action, 2);
+
+ // Get TEI.
+ tei = cp_cco_action_tei_compute (&action);
+
+ test_begin (test, "Test 1")
+ {
+ test_fail_if (tei != 2, "TEI shall be 2");
+ test_fail_if ((action.tei_flags[0] & 0x2) != 2,
+ "TEI bit flag shall be setted");
+ }
+ test_end;
+
+ action.tei_flags[0] = 0xFFFFFFFE;
+ action.tei_flags[1] = 0xFFFFFFFF;
+
+ cp_cco_action_tei_release (&action, 45);
+ tei = cp_cco_action_tei_compute (&action);
+
+ test_begin (test, "Test 2")
+ {
+ test_fail_if (tei != 45, "TEI shall be 57");
+ test_fail_if ((action.tei_flags[1] & 0xC) != 12,
+ "TEI bit flag shall be setted");
+ }
+ test_end;
+}
+
+/** Test the initialisation of the cco_action module.
+ * \param test the test object.
+ *
+ * The initialise procedure shall only initialise the set for the expiration
+ * process.
+ * At the end of this test the set shall be empty.
+ */
+void
+test_case_cco_action_init (test_t test)
+{
+ cp_t cp;
+
+ test_case_begin (test, "Initialise the module.");
+
+ cp_cco_action_init (&cp);
+
+ test_begin (test, "Verify")
+ {
+ test_fail_if (set_empty(&cp.cco_action.tei_lease_expiration) != true,
+ "Tei lease set shall be empty");
+ }
+ test_end;
+}
+
+/** Test the uninitialisation of the cco_action module.
+ * \param test the test object.
+ *
+ * The initialise procedure shall only initialise the set for the expiration
+ * process.
+ * At the end of this test the set shall be empty.
+ */
+void
+test_case_cco_action_uninit (test_t test)
+{
+ cp_t cp;
+ cp_sta_t *sta;
+
+ test_case_begin (test, "Uninitialise the module.");
+
+ cp_cco_action_init (&cp);
+
+ sta = blk_alloc ();
+ set_node_init (&sta->node);
+ set_insert (&cp.cco_action.tei_lease_expiration, &sta->node);
+
+ test_begin (test, "Verify the environment")
+ {
+ test_fail_if (set_empty(&cp.cco_action.tei_lease_expiration) != false,
+ "Tei lease set shall not be empty");
+ }
+ test_end;
+
+ cp_cco_action_uninit (&cp);
+
+ test_begin (test, "Verify the uninit")
+ {
+ test_fail_if (set_empty (&cp.cco_action.tei_lease_expiration) != true,
+ "Tei lease set shall be empty");
+ }
+ test_end;
+}
+
+/** Change SNID.
+ * \param test the test object.
+ *
+ * Test the procedure to modify the SNID at the beginning of the AVLN, and
+ * simulating an AVLN SNID collision.
+ *
+ * Test 1: Choosing SNID at the beginning.
+ * This shall choose randomly a value of SNID. The random generator is
+ * initialised with the mac_ntb date.
+ *
+ * Environment:
+ * The phy_date override in the test shall always return the same value
+ * in order to verify the SNID chosen.
+ *
+ * The all range of SNID values shall be available. The flags returned
+ * by the override of the get_snids function from the sta manager shall
+ * return 0x0.
+ *
+ * Test 2: Choosing SNID after collision.
+ *
+ * This shall choose randomly a value of SNID between the following ones,
+ * 1, 5, 7, 10, 13. So the flag returned by the get_snids function from
+ * the sta manager shall be not(0x1251) so 0xEDAE.
+ *
+ * Once this is done the value of the new SNID shall be provide to the beacon
+ * module using change_snid function.
+ */
+void
+test_case_change_snid (test_t test)
+{
+ cp_t cp;
+ uint phy;
+ mac_config_t mac_config;
+
+ test_case_begin (test, "change SNID test 1");
+
+ mac_ntb_init ((phy_t *) phy, &mac_config);
+ cp_cco_action_init (&cp);
+ snids = 0;
+
+ cp_cco_action_snid_change (&cp);
+
+ test_begin (test, "Verify SNID chosen")
+ {
+ test_fail_if (snid_compute != 4, "Wrong snid");
+ }
+ test_end;
+
+ test_case_begin (test, "change SNID test 2");
+
+ cp_cco_action_init (&cp);
+ snids = 0xEDAE;
+
+ cp_cco_action_snid_change (&cp);
+
+ test_begin (test, "Verify SNID chosen")
+ {
+ test_fail_if (snid_compute != 7, "Wrong snid");
+ }
+ test_end;
+}
+
+
+int
+main (void)
+{
+ test_t test;
+
+ test_init (test, 0, NULL);
+
+ test_case_tei_lease_create (test);
+ test_case_tei_release (test);
+ test_case_cco_action_init (test);
+ test_case_cco_action_uninit (test);
+ test_case_change_snid (test);
+
+ test_case_begin (test, "Memory leaks");
+
+ test_begin (test, "Memory leaks verification")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+void
+cp_beacon_change_snid (cp_t *ctx, u16 snid)
+{
+ snid_compute = snid;
+}
+
+u16
+cp_sta_mgr_get_present_snids (cp_t *ctx)
+{
+ return snids;
+}