summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburet2008-02-26 16:37:03 +0000
committerburet2008-02-26 16:37:03 +0000
commit522a5222031861c75b8f0173abe75e4e11282510 (patch)
treeaf72dc30c601b7760d1775e61278c1e5bb4f8457
parentc8e4abdf8db02e25b91450f3fa71f98c93fa56ec (diff)
Maximus V2: Update station configuration according to new CP interface functions (still functions TBD).
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1469 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cp/station/maximus/src/maximus_cp_station.c81
-rw-r--r--maximus/python/maximus/station/sta.py52
-rw-r--r--maximus/python/test/test_station.py46
3 files changed, 127 insertions, 52 deletions
diff --git a/cp/station/maximus/src/maximus_cp_station.c b/cp/station/maximus/src/maximus_cp_station.c
index c32c21fc83..b5ee164907 100644
--- a/cp/station/maximus/src/maximus_cp_station.c
+++ b/cp/station/maximus/src/maximus_cp_station.c
@@ -56,7 +56,6 @@ int maximus_set_mac_address (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_
mac_address_t mac_address;
const unsigned short int mac_address_length = 6;
memset(mac_address, '\0', mac_address_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_mac_address");
@@ -110,7 +109,7 @@ int maximus_set_mac_address (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_
else
{
/* do other tasks ... */
- //process_drv_set_mac_address((void *)mme);
+ process_drv_set_mac_address((void *)mme);
}
/* now make the return parameter list */
@@ -122,7 +121,6 @@ int maximus_set_mac_address (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_
int maximus_set_cco_preference (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
cco_preference_t cco_preference = false;
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_cco_preference");
@@ -166,7 +164,7 @@ int maximus_set_cco_preference (fcall_ctx_t *fcall, fcall_param_t **param, sci_m
else
{
/* do other tasks ... */
- //process_drv_set_cco_preference((void *)&mme);
+ process_drv_set_cco_preference((void *)&mme);
}
/* now make the return parameter list */
@@ -178,7 +176,6 @@ int maximus_set_cco_preference (fcall_ctx_t *fcall, fcall_param_t **param, sci_m
int maximus_set_was_cco (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
was_cco_t was_cco = false;
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_was_cco");
@@ -222,7 +219,7 @@ int maximus_set_was_cco (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **
else
{
/* do other tasks ... */
- //process_drv_set_was_cco((void *)&mme);
+ process_drv_set_was_cco((void *)&mme);
}
/* now make the return parameter list */
@@ -236,7 +233,6 @@ int maximus_set_npw (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
npw_t npw;
const unsigned short int npw_length = 65;
memset(npw, '\0', npw_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_npw");
@@ -280,7 +276,7 @@ int maximus_set_npw (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
else
{
/* do other tasks ... */
- //process_drv_set_npw((void *)&mme);
+ process_drv_set_npw((void *)&mme);
}
/* now make the return parameter list */
@@ -294,7 +290,6 @@ int maximus_set_dpw (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
dpw_t dpw;
const unsigned short int dpw_length = 65;
memset(dpw, '\0', dpw_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_dpw");
@@ -338,7 +333,7 @@ int maximus_set_dpw (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
else
{
/* do other tasks ... */
- //process_drv_set_dpw_req((void *)&mme);
+ process_drv_set_dpw_req((void *)&mme);
}
/* now make the return parameter list */
@@ -352,7 +347,6 @@ int maximus_set_m_sta_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
m_sta_hfid_t m_sta_hfid;
const unsigned short int m_sta_hfid_length = 65;
memset(m_sta_hfid, '\0', m_sta_hfid_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_m_sta_hfid");
@@ -396,7 +390,7 @@ int maximus_set_m_sta_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
else
{
/* do other tasks ... */
- //process_drv_set_m_sta_hfid((void *)&mme);
+ process_drv_set_m_sta_hfid((void *)&mme);
}
/* now make the return parameter list */
@@ -410,7 +404,6 @@ int maximus_set_u_sta_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
u_sta_hfid_t u_sta_hfid;
const unsigned short int u_sta_hfid_length = 65;
memset(u_sta_hfid, '\0', u_sta_hfid_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_u_sta_hfid");
@@ -454,7 +447,7 @@ int maximus_set_u_sta_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
else
{
/* do other tasks ... */
- //process_drv_set_u_sta_hfid((void *)&mme);
+ process_drv_set_u_sta_hfid((void *)&mme);
}
/* now make the return parameter list */
@@ -468,7 +461,6 @@ int maximus_set_avln_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
avln_hfid_t avln_hfid;
const unsigned short int avln_hfid_length = 65;
memset(avln_hfid, '\0', avln_hfid_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_avln_hfid");
@@ -512,7 +504,7 @@ int maximus_set_avln_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
else
{
/* do other tasks ... */
- //process_drv_set_avln_hfid((void *)&mme);
+ process_drv_set_avln_hfid((void *)&mme);
}
/* now make the return parameter list */
@@ -524,7 +516,6 @@ int maximus_set_avln_hfid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t
int maximus_set_sl (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
sl_t sl = '\0';
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_sl");
@@ -568,7 +559,7 @@ int maximus_set_sl (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
else
{
/* do other tasks ... */
- //process_drv_set_sl((void *)&mme);
+ process_drv_set_sl((void *)&mme);
}
/* now make the return parameter list */
@@ -582,7 +573,6 @@ int maximus_set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t *
tonemask_t tonemask;
const unsigned short int tonemask_length = (PHY_CARRIER_NB + 7) / 8;
memset(tonemask, '\0', tonemask_length);
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_tonemask");
@@ -626,7 +616,7 @@ int maximus_set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t *
else
{
/* do other tasks ... */
- //process_drv_set_tonemask((void *)&mme);
+ process_drv_set_tonemask((void *)&mme);
}
/* now make the return parameter list */
@@ -638,7 +628,6 @@ int maximus_set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t *
int maximus_set_snid (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
snid_t snid = '\0';
- //static char mme[ETH_PACKET_MAX_SIZE];
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_set_snid");
@@ -678,8 +667,29 @@ int maximus_mac_start (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **ms
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_mac_start");
- /* do other tasks ... */
- cp_station_mac_start();
+ /* get parameters content */
+
+ if (-1 == fcall_param_bind(*param, *msg, "mme", ETH_PACKET_MAX_SIZE, &mme))
+ {
+ if (ENOENT != errno)
+ {
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_FCALL,
+ "%s: errno = %d", __FUNCTION__, errno);
+ }
+ else
+ {
+ // reset errno
+ errno = 0;
+
+ /* do other tasks ... */
+ cp_station_mac_start();
+ }
+ }
+ else
+ {
+ /* do other tasks ... */
+ process_drv_start_mac_req((void *)mme);
+ }
/* now make the return parameter list */
fcall_param_reset(*param);
@@ -692,8 +702,29 @@ int maximus_mac_stop (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_FCALL,
"=> maximus_mac_stop");
- /* do other tasks ... */
- //cp_station_mac_stop();
+ /* get parameters content */
+
+ if (-1 == fcall_param_bind(*param, *msg, "mme", ETH_PACKET_MAX_SIZE, &mme))
+ {
+ if (ENOENT != errno)
+ {
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_FCALL,
+ "%s: errno = %d", __FUNCTION__, errno);
+ }
+ else
+ {
+ // reset errno
+ errno = 0;
+
+ /* do other tasks ... */
+ //cp_station_mac_stop();
+ }
+ }
+ else
+ {
+ /* do other tasks ... */
+ //process_drv_stop_mac_req((void *)mme);
+ }
/* now make the return parameter list */
fcall_param_reset(*param);
diff --git a/maximus/python/maximus/station/sta.py b/maximus/python/maximus/station/sta.py
index e70239c815..491e656fc0 100644
--- a/maximus/python/maximus/station/sta.py
+++ b/maximus/python/maximus/station/sta.py
@@ -111,7 +111,10 @@ class STA:
def __start(self):
"""Send the MAC_START message to the station.
"""
- if self.get_config_mode() is CONFIG_MODES[0]: # 'MME'
+ if self.get_config_mode() is CONFIG_MODES[2]: # 'fcall_cp_station'
+ self.__get_maximus().create_fcall("maximus_mac_start") \
+ .send(self.get())
+ else: # we need to build an MME
# Computes MM Header
if self.get_mac_address() is not None:
@@ -120,18 +123,28 @@ class STA:
osa = DEFAULT_MAC_ADDRESS
mmheader = MMHeader(ODA=DEFAULT_MAC_ADDRESS, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_START + MME_TYPES['REQ'])
- # Create the MME and wait for the response
- rsp = MME(MMHeader=mmheader).sendnrecv(maximus=self.__get_maximus(), station=self.get(), filter=mme_filter)
- self.__check_cnf(rsp, DRV_STA_START)
-
- else: # 'fcall_cp_station' or 'fcall_process_drv'
- self.__get_maximus().create_fcall("maximus_mac_start") \
- .send(self.get())
+ # Create the MME
+ mme = MME(MMHeader=mmheader)
+
+ if self.get_config_mode() is CONFIG_MODES[1]: # 'fcall_process_drv'
+ self.__get_maximus().create_fcall("maximus_mac_start") \
+ .add_param("mme", mme.get()) \
+ .send(self.get())
+ else: # 'MME'
+ # Allocate an MME buffer
+ alloc_mme_buffer(maximus=self.__get_maximus(), station=self.get())
+
+ # Send the MME and wait for the response
+ rsp = mme.sendnrecv(maximus=self.__get_maximus(), station=self.get(), filter=mme_filter)
+ self.__check_cnf(rsp, DRV_STA_START)
def stop(self):
"""Send the MAC_STOP message to the station.
"""
- if self.get_config_mode() is CONFIG_MODES[0]: # 'MME'
+ if self.get_config_mode() is CONFIG_MODES[2]: # 'fcall_cp_station'
+ self.__get_maximus().create_fcall("maximus_mac_stop") \
+ .send(self.get())
+ else: # we need to build an MME
# Computes MM Header
if self.get_mac_address() is not None:
@@ -140,13 +153,20 @@ class STA:
osa = DEFAULT_MAC_ADDRESS
mmheader = MMHeader(ODA=DEFAULT_MAC_ADDRESS, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_STOP + MME_TYPES['REQ'])
- # Create the MME and wait for the response
- rsp = MME(MMHeader=mmheader).sendnrecv(maximus=self.__get_maximus(), station=self.get(), filter=mme_filter)
- self.__check_cnf(rsp, DRV_STA_STOP)
-
- else: # 'fcall_cp_station' or 'fcall_process_drv'
- self.__get_maximus().create_fcall("maximus_mac_stop") \
- .send(self.get())
+ # Create the MME
+ mme = MME(MMHeader=mmheader)
+
+ if self.get_config_mode() is CONFIG_MODES[1]: # 'fcall_process_drv'
+ self.__get_maximus().create_fcall("maximus_mac_stop") \
+ .add_param("mme", mme.get()) \
+ .send(self.get())
+ else: # 'MME'
+ # Allocate an MME buffer
+ alloc_mme_buffer(maximus=self.__get_maximus(), station=self.get())
+
+ # Send the MME and wait for the response
+ rsp = mme.sendnrecv(maximus=self.__get_maximus(), station=self.get(), filter=mme_filter)
+ self.__check_cnf(rsp, DRV_STA_STOP)
def set_name(self, name):
"""Set the name.
diff --git a/maximus/python/test/test_station.py b/maximus/python/test/test_station.py
index 0b788c3228..9b8e93f616 100644
--- a/maximus/python/test/test_station.py
+++ b/maximus/python/test/test_station.py
@@ -40,21 +40,34 @@ sta3.debug()
m.create_fcall("uninit_ether").send(sta3.get())
sta3.remove()
-conf = Config(cco_preference=True)
-sta4 = STA(m, name="my_sta", config=conf)
+conf4 = Config(cco_preference=True)
+sta4 = STA(m, name="my_sta", config=conf4)
station_nb += 1
sta4.debug()
m.create_fcall("uninit_ether").send(sta4.get())
sta4.remove()
-conf = Config(was_cco=True, npw="network_password", sl=2)
-sta5 = STA(m, name="This is the name of my station", config=conf)
+conf5 = Config(was_cco=True, npw="network_password", sl=2)
+sta5 = STA(m, name="This is the name of my station", config=conf5)
station_nb += 1
sta5.debug()
m.create_fcall("uninit_ether").send(sta5.get())
sta5.remove()
-sta6 = STA(m, debug=True, name="sta0", config_mode='fcall_cp_station', config=Config(mac_address='12:34:56:78:9A:BC'))
+conf = Config()
+conf.mac_address = '12:34:56:78:9A:BC'
+conf.cco_preference = True
+conf.was_cco = False
+conf.npw = "a Python string of length from 8 to 64 octets"
+conf.dpw = "a Python string of length from 0 to 64 octets"
+conf.m_sta_hfid = "a Python string of length from 0 to 64 octets"
+conf.u_sta_hfid = "a Python string of length from 0 to 64 octets"
+conf.avln_hfid = "a Python string of length from 0 to 64 octets"
+conf.sl = 2
+conf.tonemask = (85,139,167,214,225,282,302,409,419,569,591,736,748,856,882,1015,1027,1143,1535)
+conf.snid = 15
+
+sta6 = STA(m, debug=True, name="sta6", config_mode='fcall_cp_station', config=conf)
m.create_fcall("uninit_ether").send(sta6.get())
sta6.remove()
@@ -66,6 +79,14 @@ except TypeError:
m.create_fcall("uninit_ether").send(sta7.get())
sta7.remove()
+sta8 = STA(m, name="sta8", config_mode='fcall_process_drv', config=conf)
+m.create_fcall("uninit_ether").send(sta8.get())
+sta8.remove()
+
+sta9 = STA(m, name="sta9", config_mode='MME', config=conf)
+m.create_fcall("uninit_ether").send(sta9.get())
+sta9.remove()
+
# Test with the maximum number of stations,
# which is limited by the maximum number of open file descriptors (1024)
station_max_nb = (1024 + (file_desc_nb - 1)) / file_desc_nb - station_nb * file_desc_nb
@@ -103,6 +124,9 @@ class TestSTAFunctions(unittest.TestCase):
m.create_fcall("uninit_ether").send(self.station.get())
self.station.remove()
+ def test_stop(self):
+ self.station.stop()
+
def test_set_name(self):
name = "Name of my station"
self.station.set_name(name)
@@ -119,12 +143,12 @@ class TestSTAFunctions(unittest.TestCase):
self.assertEqual(self.station.get_config_mode(), config_mode)
def test_set_config(self):
- conf = Config()
- conf.mac_address = (0x11, 0x22, 0x33, 0x44, 0x55, 0x66)
- conf.cco_preference = True
- self.station.set_config(conf)
- self.assertEqual(self.station.get_config().mac_address, conf.mac_address)
- self.assertEqual(self.station.get_config().cco_preference, conf.cco_preference)
+ test_conf = Config()
+ test_conf.mac_address = (0x11, 0x22, 0x33, 0x44, 0x55, 0x66)
+ test_conf.cco_preference = True
+ self.station.set_config(test_conf)
+ self.assertEqual(self.station.get_config().mac_address, test_conf.mac_address)
+ self.assertEqual(self.station.get_config().cco_preference, test_conf.cco_preference)
def test_set_mac_address(self):
mac_address = (0x41, 0x42, 0x43, 0x44, 0x45, 0x46)