summaryrefslogtreecommitdiff
path: root/mac/sar/test/maximus_test/src/Maximus_sar.cpp
diff options
context:
space:
mode:
authorlaranjeiro2007-09-17 13:36:12 +0000
committerlaranjeiro2007-09-17 13:36:12 +0000
commita436bd1c95574cf5f93ff04880ca561c91e5099b (patch)
tree570a9f387651040bcfcb0708ad6e4b7537b02c33 /mac/sar/test/maximus_test/src/Maximus_sar.cpp
parent3e4a2e23e1ee516b784fc81a4010c8908fb50d1c (diff)
Sar Maximus test with two functions :
- one shoot. - multiple shoots. i.e. does not work correctly yet see #27 git-svn-id: svn+ssh://pessac/svn/cesar/trunk@712 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'mac/sar/test/maximus_test/src/Maximus_sar.cpp')
-rw-r--r--mac/sar/test/maximus_test/src/Maximus_sar.cpp141
1 files changed, 128 insertions, 13 deletions
diff --git a/mac/sar/test/maximus_test/src/Maximus_sar.cpp b/mac/sar/test/maximus_test/src/Maximus_sar.cpp
index 8d425dccf9..12283dfb9e 100644
--- a/mac/sar/test/maximus_test/src/Maximus_sar.cpp
+++ b/mac/sar/test/maximus_test/src/Maximus_sar.cpp
@@ -34,6 +34,8 @@
#include <iostream> // for 'cout', 'cerr' and 'clog'
using namespace std;
+#include "mac/sar/test/maximus_test/inc/blk_t.h"
+
#define debug_info true
typedef void (station_cb_t) (Msg &msg);
@@ -104,9 +106,16 @@ bool reassembly (Sta *station, station_cb_t sta_cb, unsigned char lid,
*/
int one_shoot (int argc, char *argv[]);
-unsigned char blk[5][1024];
-unsigned int blk_header[5];
-unsigned int nb_data_received;
+/**
+ * Launch the test on multiple shoot mode.
+ *
+ * \param argc the quantity of arguments provided
+ * \param argv the char array containing the arguments
+ * \param iter the quantity of iteration the multiple shoot should do.
+ *
+ * \return the end value
+ */
+int multiple_shoot (int argc, char *argv[], int iter);
bool station1_rsp;
bool station2_rsp;
@@ -114,9 +123,16 @@ bool test_fail;
Maximus maximus;
+blk_t *blk_head;
+blk_t *blk_tail;
+
int main (int argc, char *argv[])
{
- return one_shoot(argc, argv);
+ blk_head = NULL;
+ blk_tail = NULL;
+
+ //return one_shoot(argc, argv);
+ return multiple_shoot (argc, argv, 2);
}
/**
@@ -183,6 +199,80 @@ int one_shoot (int argc, char *argv[])
}
/**
+ * Launch the test on multiple shoot mode.
+ *
+ * \param argc the quantity of arguments provided
+ * \param argv the char array containing the arguments
+ * \param iter the quantity of iteration the multiple shoot should do.
+ *
+ * \return the end value
+ */
+int multiple_shoot (int argc, char *argv[], int iter)
+{
+ unsigned char lid;
+ unsigned char tei;
+ bool bcast;
+ unsigned char mf_type;
+ unsigned char packet;
+ bool logs;
+
+ test_fail = false;
+ station1_rsp = false;
+ station2_rsp = false;
+
+ maximus.init (argc, argv);
+
+ Sta station1 = maximus.create_sta ();
+ station1.debug();
+ Sta station2 = maximus.create_sta ();
+ //station2.debug ();
+
+ // activate the sta 1 logs
+ Msg fc = maximus.create_fc ("activate_logs");
+ logs = true;
+ fc.add_param ("debug", sizeof(unsigned char), (unsigned char *) &logs);
+ fc.send (station2);
+ //fc.send (station1);
+
+ while (iter)
+ {
+ iter --;
+ station1_rsp = false;
+ station2_rsp = false;
+
+ printf ("ITER : %d\n", iter);
+
+ lid = 1;
+ tei = 2;
+ bcast = true;
+ mf_type = 2;
+ packet = 0;
+ segmentation (&station1, station1_cb, lid, tei, bcast, mf_type,
+ packet);
+
+ while (!station1_rsp)
+ {
+ maximus.process ();
+ }
+
+ if (test_fail)
+ return 0;
+
+ tei = 1;
+ reassembly (&station2, station2_cb, lid, tei, bcast, mf_type, packet);
+
+ while (!station2_rsp)
+ {
+ maximus.process ();
+ }
+
+ maximus.wait (10000);
+ }
+
+ return 0;
+}
+
+/**
* The station 1 callback
*
* \param msg the message
@@ -206,9 +296,22 @@ void station1_cb (Msg &msg)
}
else
{
- nb_data_received = msg.bind_param<unsigned int> ("qte");
+ if (blk_head == NULL)
+ {
+ blk_head = new blk_t();
+ blk_tail = blk_head;
+ }
+ else
+ {
+ blk_tail->next = new blk_t ();
+ blk_tail = blk_tail->next;
+ }
+
+ blk_tail->next = NULL;
- for (val = 0; val < nb_data_received; val++)
+ blk_tail->qte = msg.bind_param<unsigned int> ("qte");
+
+ for (val = 0; val < blk_tail->qte; val++)
{
sprintf (value, "%d", val);
@@ -219,12 +322,12 @@ void station1_cb (Msg &msg)
if (msg_return != NULL)
{
- memcpy (blk[val], buffer, 512);
+ memcpy (blk_tail->pbs[val], buffer, 512);
}
strcpy (id, "pbh");
strcat (id, value);
- blk_header[val] = msg.bind_param<unsigned int> (id);
+ blk_tail->header[val] = msg.bind_param<unsigned int> (id);
}
}
@@ -305,6 +408,17 @@ bool reassembly (Sta *station, station_cb_t sta_cb, unsigned char lid,
char value[3];
char id[5];
unsigned int i;
+ blk_t *blk;
+
+ if (blk_head)
+ {
+ blk = blk_head;
+ blk_head = blk_head->next;
+ }
+ else
+ {
+ return false;
+ }
//create the function call
Msg fc_sta = maximus.create_fc ("reassembly");
@@ -314,27 +428,28 @@ bool reassembly (Sta *station, station_cb_t sta_cb, unsigned char lid,
fc_sta.add_param ("tei", sizeof(unsigned char), &tei);
fc_sta.add_param ("bcast", sizeof(unsigned char), (unsigned char*) &bcast);
fc_sta.add_param ("packet", sizeof(unsigned char), &packet);
- fc_sta.add_param ("qte", sizeof(unsigned int),
- (unsigned char*) &nb_data_received);
+ fc_sta.add_param ("qte", sizeof(unsigned int), (unsigned char*) &blk->qte);
- for (i = 0; i < nb_data_received; i++)
+ for (i = 0; i < blk->qte; i++)
{
sprintf (value, "%d", i);
strcpy (id, "pb");
strcat (id, value);
fc_sta.add_param (id, 1024 * sizeof(unsigned char),
- (unsigned char*) blk[i]);
+ (unsigned char*) blk->pbs[i]);
strcpy (id, "pbh");
strcat (id, value);
fc_sta.add_param (id, sizeof(unsigned int),
- (unsigned char*) &blk_header[i]);
+ (unsigned char*) &blk->header[i]);
}
fc_sta.set_cb (sta_cb);
fc_sta.send (*station);
+ free (blk);
+
return true;
}