summaryrefslogtreecommitdiff
path: root/cesar/hal/hle/maximus
diff options
context:
space:
mode:
authorburet2008-05-13 16:36:50 +0000
committerburet2008-05-13 16:36:50 +0000
commite1a84b804369eae8920641b171f4909337ccfacb (patch)
treee0e6e4f617072263f8c551c49b9ecada29f0ef4e /cesar/hal/hle/maximus
parent5f0381c4a5e3d5bd119090c8ef5cdd99eb79d373 (diff)
Maximus: remove module params from IPMBox messages of type INTERFACE.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1976 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/hal/hle/maximus')
-rw-r--r--cesar/hal/hle/maximus/inc/maximus_ether.h10
-rw-r--r--cesar/hal/hle/maximus/src/maximus_ether.c21
-rw-r--r--cesar/hal/hle/maximus/src/maximus_ipmbox.c37
-rw-r--r--cesar/hal/hle/maximus/test/src/test_maximus_ether.c68
-rw-r--r--cesar/hal/hle/maximus/test/src/test_maximus_ipmbox.c24
5 files changed, 26 insertions, 134 deletions
diff --git a/cesar/hal/hle/maximus/inc/maximus_ether.h b/cesar/hal/hle/maximus/inc/maximus_ether.h
index a8ddcec861..007ede58d6 100644
--- a/cesar/hal/hle/maximus/inc/maximus_ether.h
+++ b/cesar/hal/hle/maximus/inc/maximus_ether.h
@@ -22,12 +22,11 @@
* \param ctx current ipmbox context
* \param msg pointer to sci message to fill header
* \param type type of message (DATA, MME, DATA_BUFFER_ADD, MME_BUFFER_ADD, BUFFER_RELEASED, or SNIFFER)
- * \param sniffer_type type of sniffed packet (MME or BEACON)
- * \param flags indicates sniffed packet encryption and way
+ * \param flags not used
* \return 0 if ok, -1 if it fails with errno =
* - EINVAL if ctx or msg are NULL, or if arguments are out-of-range
*/
-int maximus_ether_fill_hdr(ipmbox_t *ctx, sci_msg_t *msg, u8 type, u8 sniffer_type, u8 flags);
+int maximus_ether_fill_hdr(ipmbox_t *ctx, sci_msg_t *msg, u8 type, u8 flags);
/**
* Process ether message received by the sci layer.
@@ -56,14 +55,13 @@ int maximus_ether_recv_buffer_add (ipmbox_t *ctx, sci_msg_t *msg);
* Send an Ether SCI message of type DATA, MME, BUFFER_RELEASED, or SNIFFER to Maximus.
* \param ctx ipmbox current context
* \param type type of message (DATA, MME, BUFFER_RELEASED, or SNIFFER)
- * \param sniffer_type type of sniffed packet (MME or BEACON)
- * \param flags indicates sniffed packet encryption and way
+ * \param flags not used
* \param data_length sci message data length to send
* \param data pointer to sci message data to send
* \return 0 if ok, -1 if it fails with errno =
* - EINVAL if ctx or data are null, or if data length equals 0
* if 'sci_send()' fails, it sets errno
*/
-int maximus_ether_send (ipmbox_t *ctx, u8 type, u8 sniffer_type, u8 flags, uint data_length, u32 *data);
+int maximus_ether_send (ipmbox_t *ctx, u8 type, u8 flags, uint data_length, u32 *data);
#endif /* hal_phy_maximus_inc_maximus_ether_h */
diff --git a/cesar/hal/hle/maximus/src/maximus_ether.c b/cesar/hal/hle/maximus/src/maximus_ether.c
index 6fe8063c7c..77955ed2e9 100644
--- a/cesar/hal/hle/maximus/src/maximus_ether.c
+++ b/cesar/hal/hle/maximus/src/maximus_ether.c
@@ -40,25 +40,22 @@ maximus_ether_recv_function maximus_ether_function_array[ETHERNET_TYPE_NB] = { &
* \param ctx current ipmbox context
* \param msg pointer to sci message to fill header
* \param type type of message (DATA, MME, DATA_BUFFER_ADD, MME_BUFFER_ADD, INTERFACE_BUFFER_ADD, BUFFER_RELEASED, or SNIFFER)
- * \param sniffer_type type of sniffed packet (MME or BEACON)
- * \param flags indicates sniffed packet encryption and way
+ * \param flags not used
* \return 0 if ok, -1 if it fails with errno =
* - EINVAL if ctx or msg are NULL, or if arguments are out-of-range
*/
int
-maximus_ether_fill_hdr(ipmbox_t *ctx, sci_msg_t *msg, u8 type, u8 sniffer_type, u8 flags)
+maximus_ether_fill_hdr(ipmbox_t *ctx, sci_msg_t *msg, u8 type, u8 flags)
{
int ret = -1;
dbg_assert_ptr(ctx);
dbg_assert_ptr(msg);
dbg_assert((ETHERNET_TYPE_NB > type) && (ETHERNET_TYPE_NONE < type));
- dbg_assert((SNIFFER_BEACON == sniffer_type) || (SNIFFER_MME == sniffer_type));
dbg_assert(ETHERNET_FLAG_MAX >= flags);
if ((NULL == ctx)
|| (NULL == msg)
|| ((ETHERNET_TYPE_NB <= type) || (ETHERNET_TYPE_NONE >= type))
- || ((SNIFFER_BEACON != sniffer_type) && (SNIFFER_MME != sniffer_type))
|| (ETHERNET_FLAG_MAX < flags))
{
errno = EINVAL;
@@ -80,7 +77,6 @@ maximus_ether_fill_hdr(ipmbox_t *ctx, sci_msg_t *msg, u8 type, u8 sniffer_type,
msg->hdr.ether = (ether_msg_hdr_t*)msg->data_begin;
msg->hdr.ether->version = ETHERNET_VERSION;
msg->hdr.ether->type = type;
- msg->hdr.ether->sniffer_type = sniffer_type;
msg->hdr.ether->flags = flags;
msg->hdr.ether->reserved = 0;
@@ -136,13 +132,9 @@ maximus_ether_recv (sci_msg_t *msg, void *ipmbox)
dbg_assert_ptr(msg->hdr.ether);
dbg_assert(ETHERNET_TYPE_NB > msg->hdr.ether->type);
- dbg_assert((SNIFFER_BEACON == msg->hdr.ether->sniffer_type)
- || (SNIFFER_MME == msg->hdr.ether->sniffer_type));
dbg_assert(ETHERNET_FLAG_MAX >= msg->hdr.ether->flags);
if ((NULL == msg->hdr.ether)
|| (ETHERNET_TYPE_NB <= msg->hdr.ether->type)
- || ((SNIFFER_BEACON != msg->hdr.ether->sniffer_type)
- && (SNIFFER_MME != msg->hdr.ether->sniffer_type))
|| (ETHERNET_FLAG_MAX < msg->hdr.ether->flags))
{
errno = EPROTO;
@@ -378,8 +370,7 @@ maximus_ether_recv_buffer_add (ipmbox_t *ctx, sci_msg_t *msg)
* Send an Ether SCI message of type DATA, MME, BUFFER_RELEASED, or SNIFFER to Maximus.
* \param ctx ipmbox current context
* \param type type of message (DATA, MME, BUFFER_RELEASED, or SNIFFER)
- * \param sniffer_type type of sniffed packet (MME or BEACON)
- * \param flags indicates sniffed packet encryption and way
+ * \param flags not used
* \param data_length sci message data length to send
* \param data pointer to sci message data to send
* \return 0 if ok, -1 if it fails with errno =
@@ -387,7 +378,7 @@ maximus_ether_recv_buffer_add (ipmbox_t *ctx, sci_msg_t *msg)
* if 'sci_send()' fails, it sets errno
*/
int
-maximus_ether_send (ipmbox_t *ctx, u8 type, u8 sniffer_type, u8 flags, uint data_length, u32 *data)
+maximus_ether_send (ipmbox_t *ctx, u8 type, u8 flags, uint data_length, u32 *data)
{
int ret = -1;
@@ -397,7 +388,6 @@ maximus_ether_send (ipmbox_t *ctx, u8 type, u8 sniffer_type, u8 flags, uint data
&& (ETHERNET_TYPE_DATA_BUFFER_ADD != type)
&& (ETHERNET_TYPE_MME_BUFFER_ADD != type)
&& (ETHERNET_TYPE_INTERFACE_BUFFER_ADD != type));
- dbg_assert((SNIFFER_BEACON == sniffer_type) || (SNIFFER_MME == sniffer_type));
dbg_assert(ETHERNET_FLAG_MAX >= flags);
dbg_assert(0 != data_length);
dbg_assert_ptr(data);
@@ -407,7 +397,6 @@ maximus_ether_send (ipmbox_t *ctx, u8 type, u8 sniffer_type, u8 flags, uint data
|| (ETHERNET_TYPE_DATA_BUFFER_ADD == type)
|| (ETHERNET_TYPE_MME_BUFFER_ADD == type)
|| (ETHERNET_TYPE_INTERFACE_BUFFER_ADD == type)
- || ((SNIFFER_BEACON != sniffer_type) && (SNIFFER_MME != sniffer_type))
|| (ETHERNET_FLAG_MAX < flags)
|| (0 == data_length)
|| (NULL == data) )
@@ -443,7 +432,7 @@ maximus_ether_send (ipmbox_t *ctx, u8 type, u8 sniffer_type, u8 flags, uint data
memcpy(msg.data_begin, data, data_length);
// fill ether and sci header
- if ( (0 != maximus_ether_fill_hdr(ctx, &msg, type, sniffer_type, flags))
+ if ( (0 != maximus_ether_fill_hdr(ctx, &msg, type, flags))
|| (0 != sci_fill_hdr(my_station.sci, &msg, SCI_MSG_TYPE_ETHERNET, 0 /* flags */)) )
{
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_ETHER,
diff --git a/cesar/hal/hle/maximus/src/maximus_ipmbox.c b/cesar/hal/hle/maximus/src/maximus_ipmbox.c
index 6e1117e630..7faf845c2a 100644
--- a/cesar/hal/hle/maximus/src/maximus_ipmbox.c
+++ b/cesar/hal/hle/maximus/src/maximus_ipmbox.c
@@ -188,11 +188,10 @@ ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
{
dbg_assert_ptr(ctx);
dbg_assert_ptr(first_msg);
- dbg_assert((2 <= length) && (3 >= length));
+ dbg_assert(2 == length);
if ((NULL == ctx)
|| (NULL == first_msg)
- || (2 > length)
- || (3 < length))
+ || (2 != length))
{
errno = EINVAL;
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_ETHER,
@@ -202,12 +201,9 @@ ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
{
ipmbox_msg_hdr_t hdr = *(ipmbox_msg_hdr_t *)first_msg;
dbg_assert(HLE_MSG_TYPE_NB > hdr.type);
- dbg_assert(((HLE_MSG_TYPE_INTERFACE != hdr.type) && (2 == length))
- || (HLE_MSG_TYPE_INTERFACE == hdr.type));
- dbg_assert(length - 1 == hdr.length);
+ dbg_assert(1 == hdr.length);
if ((HLE_MSG_TYPE_NB <= hdr.type)
- || ((HLE_MSG_TYPE_INTERFACE != hdr.type) && (2 != length))
- || (length - 1 != hdr.length))
+ || (1 != hdr.length))
{
errno = EINVAL;
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_ETHER,
@@ -220,7 +216,6 @@ ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
{
// to send message
u8 type = ETHERNET_TYPE_NONE;
- u8 sniffer_type = 0;
u8 flags = ETHERNET_FLAG_NONE;
uint data_length = 0;
u32 data = 0;
@@ -267,32 +262,12 @@ ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
// get data length (11 bits): length of data into buffer
data_length = (uint)((hdr.param & 0x7FF00) >> 8);
- if (3 == length) // get module param (32 bits)
- {
- u32 module_param = *(first_msg + data_index);
- data_index++;
-
- // get way (1 bit): Tx or Rx
- // 0: Tx
- // 1: Rx
- // get encryption (1 bit): encrypted or not
- // 0: false
- // 1: true
- flags = (u8)(module_param & 0x00000003);
-
- // get data type (3 bits): Beacon or MME type
- // 0: Beacon type
- // 1: MME type
- // 2-7: unused
- sniffer_type = (u8)((module_param & 0x0000001C) >> 2);
- }
-
// get buffer pointer (32 bits): pointer to buffer
data = *(first_msg + data_index);
}
// send DATA, MME or SNIFFER (sniffed Beacon or MME) to Maximus
- if (0 != maximus_ether_send(ctx, type, sniffer_type, flags, data_length, (u32 *)data))
+ if (0 != maximus_ether_send(ctx, type, flags, data_length, (u32 *)data))
{
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_ETHER,
"%s: errno = %d", __FUNCTION__, errno);
@@ -329,7 +304,7 @@ ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
free(current_buffer);
// send BUFFER RELEASED to Maximus
- if (0 != maximus_ether_send(ctx, ETHERNET_TYPE_BUFFER_RELEASED, 0 /* sniffer_type */, ETHERNET_FLAG_NONE, sizeof(u32), &id))
+ if (0 != maximus_ether_send(ctx, ETHERNET_TYPE_BUFFER_RELEASED, ETHERNET_FLAG_NONE, sizeof(u32), &id))
{
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_ETHER,
"%s: errno = %d", __FUNCTION__, errno);
diff --git a/cesar/hal/hle/maximus/test/src/test_maximus_ether.c b/cesar/hal/hle/maximus/test/src/test_maximus_ether.c
index 9cd0777ea4..afed3e35cd 100644
--- a/cesar/hal/hle/maximus/test/src/test_maximus_ether.c
+++ b/cesar/hal/hle/maximus/test/src/test_maximus_ether.c
@@ -41,7 +41,6 @@ void maximus_ether_fill_hdr_test_case(test_t t)
sci_msg_t msg;
unsigned char buffer[SCI_MSG_MAX_SIZE];
uint8_t type = ETHERNET_TYPE_DATA;
- uint8_t sniffer_type = 0;
uint8_t flags = ETHERNET_FLAG_NONE;
test_begin(t, "sci init")
@@ -54,11 +53,10 @@ void maximus_ether_fill_hdr_test_case(test_t t)
test_begin(t, "fill hdr")
{
- test_fail_unless ((0 == maximus_ether_fill_hdr(ctx, &msg, type, sniffer_type, flags))
+ test_fail_unless ((0 == maximus_ether_fill_hdr(ctx, &msg, type, flags))
&& (EINVAL != errno)
&& (ETHERNET_VERSION == msg.hdr.ether->version)
&& (type == msg.hdr.ether->type)
- && (sniffer_type == msg.hdr.ether->sniffer_type)
&& (flags == msg.hdr.ether->flags)
&& (0 == msg.hdr.ether->reserved));
} test_end;
@@ -69,7 +67,7 @@ void maximus_ether_fill_hdr_test_case(test_t t)
dbg_fatal_try_begin
{
- test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type, sniffer_type, flags))
+ test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type, flags))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -85,35 +83,13 @@ void maximus_ether_fill_hdr_test_case(test_t t)
type = ETHERNET_TYPE_DATA;
} test_end;
- test_begin(t, "fill hdr with incorrect sniffer type")
- {
- sniffer_type = 2;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type, sniffer_type, flags))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("fill hdr with incorrect sniffer type\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- // reset sniffer type to correct value
- sniffer_type = 0;
- } test_end;
-
test_begin(t, "fill hdr with incorrect flags")
{
flags = ETHERNET_FLAG_MAX + 1;
dbg_fatal_try_begin
{
- test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type, sniffer_type, flags))
+ test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type, flags))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -201,7 +177,6 @@ void maximus_ether_recv_test_case(test_t t)
// set ether header values
ether_hdr.version = ETHERNET_VERSION;
ether_hdr.type = ETHERNET_TYPE_NONE;
- ether_hdr.sniffer_type = 0;
ether_hdr.flags = ETHERNET_FLAG_NONE;
ether_hdr.reserved = 0;
@@ -296,7 +271,6 @@ void maximus_ether_recv_test_case(test_t t)
test_fail_unless ((ether_hdr.version == msg.hdr.ether->version)
&& (ether_hdr.type == msg.hdr.ether->type)
- && (ether_hdr.sniffer_type == msg.hdr.ether->sniffer_type)
&& (ether_hdr.flags == msg.hdr.ether->flags)
&& (ether_hdr.reserved == msg.hdr.ether->reserved));
@@ -535,7 +509,6 @@ void maximus_ether_send_test_case(test_t t)
{
// ether type
u8 type = ETHERNET_TYPE_DATA;
- u8 sniffer_type = 0;
u8 flags = ETHERNET_FLAG_NONE;
// data
@@ -548,35 +521,13 @@ void maximus_ether_send_test_case(test_t t)
printf("send\n");
test_case_begin(t, "send");
- test_begin(t, "send incorrect sniffer type")
- {
- sniffer_type = 2;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send(ctx, type, sniffer_type, flags, data_length, (u32 *)data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("send incorrect sniffer type\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- // set sniffer type to correct value
- sniffer_type = 1;
- } test_end;
-
test_begin(t, "send incorrect flags")
{
flags = ETHERNET_FLAG_MAX + 1;
dbg_fatal_try_begin
{
- test_fail_unless ((0 > (maximus_ether_send(ctx, type, sniffer_type, flags, data_length, (u32 *)data)))
+ test_fail_unless ((0 > (maximus_ether_send(ctx, type, flags, data_length, (u32 *)data)))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -589,14 +540,14 @@ void maximus_ether_send_test_case(test_t t)
errno = 0;
// set flags to correct value
- flags = ETHERNET_FLAG_ENCRYPTED;
+ flags = ETHERNET_FLAG_MAX;
} test_end;
test_begin(t, "send incorrect data length")
{
dbg_fatal_try_begin
{
- test_fail_unless ((0 > (maximus_ether_send(ctx, type, sniffer_type, flags, 0, (u32 *)data)))
+ test_fail_unless ((0 > (maximus_ether_send(ctx, type, flags, 0, (u32 *)data)))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -613,7 +564,7 @@ void maximus_ether_send_test_case(test_t t)
{
dbg_fatal_try_begin
{
- test_fail_unless ((0 > (maximus_ether_send(ctx, type, sniffer_type, flags, data_length, NULL)))
+ test_fail_unless ((0 > (maximus_ether_send(ctx, type, flags, data_length, NULL)))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -637,7 +588,7 @@ void maximus_ether_send_test_case(test_t t)
{
dbg_fatal_try_begin
{
- test_fail_unless ((0 > (maximus_ether_send(ctx, type, sniffer_type, flags, data_length, (u32 *)data)))
+ test_fail_unless ((0 > (maximus_ether_send(ctx, type, flags, data_length, (u32 *)data)))
&& (EINVAL == errno));
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -684,7 +635,7 @@ void maximus_ether_send_test_case(test_t t)
test_begin(t, "send ether")
{
- test_fail_unless ((0 == maximus_ether_send(ctx, type, sniffer_type, flags, data_length, (u32 *)data))
+ test_fail_unless ((0 == maximus_ether_send(ctx, type, flags, data_length, (u32 *)data))
&& (EINVAL != errno));
} test_end;
@@ -713,7 +664,6 @@ void maximus_ether_send_test_case(test_t t)
// check ether header
test_fail_unless ((type == ether_hdr->type)
- && (sniffer_type == ether_hdr->sniffer_type)
&& (flags == ether_hdr->flags));
// read the remaining part of message
diff --git a/cesar/hal/hle/maximus/test/src/test_maximus_ipmbox.c b/cesar/hal/hle/maximus/test/src/test_maximus_ipmbox.c
index 53bd42ab25..0fb58ada0f 100644
--- a/cesar/hal/hle/maximus/test/src/test_maximus_ipmbox.c
+++ b/cesar/hal/hle/maximus/test/src/test_maximus_ipmbox.c
@@ -158,7 +158,6 @@ void ipmbox_tx_test_case(test_t t)
if ((HLE_MSG_TYPE_DATA == hdr.type) || (HLE_MSG_TYPE_INTERFACE == hdr.type))
{
int i;
- int msg_index = 1; // init message index
maximus_hle_buffer_t *second_buffer = (maximus_hle_buffer_t *)malloc(sizeof(maximus_hle_buffer_t));
second_buffer->next = NULL;
second_buffer->id = 32;
@@ -177,33 +176,17 @@ void ipmbox_tx_test_case(test_t t)
}
else // (HLE_MSG_TYPE_INTERFACE == hdr.type)
{
- u32 module_param = 0; // init module param
-
- // set length
- length = 3;
-
// set hdr length
- hdr.length = 2;
+ hdr.length = 1;
// set hdr param
hdr.param = frame_length << 8; // data length
hdr.param |= 1; // module type
-
- // set module param
- module_param = 1 << 2; // data type
- module_param |= 1 << 1; // encryption
- module_param |= 1; // way
-
- // set mailbox
- mailbox[msg_index] = module_param; // set module param
-
- // update message index
- msg_index++;
}
// set mailbox
memcpy(&mailbox[0], &hdr, sizeof(ipmbox_msg_hdr_t)); // set first msg
- mailbox[msg_index] = (u32)second_buffer->data; // set data
+ mailbox[1] = (u32)second_buffer->data; // set data
test_begin(t, "tx data or interface")
{
@@ -284,7 +267,6 @@ void ipmbox_tx_test_case(test_t t)
// check ether header
test_fail_unless ((ETHERNET_TYPE_DATA == ether_hdr->type)
- && (0 == ether_hdr->sniffer_type)
&& (ETHERNET_FLAG_NONE == ether_hdr->flags));
// read the remaining part of message
@@ -340,7 +322,6 @@ void ipmbox_tx_test_case(test_t t)
// check ether header
test_fail_unless ((ETHERNET_TYPE_SNIFFER == ether_hdr->type)
- && (1 == ether_hdr->sniffer_type)
&& (ETHERNET_FLAG_MAX == ether_hdr->flags));
// read the remaining part of message
@@ -379,7 +360,6 @@ void ipmbox_tx_test_case(test_t t)
// check ether header
test_fail_unless ((ETHERNET_TYPE_BUFFER_RELEASED == ether_hdr->type)
- && (0 == ether_hdr->sniffer_type)
&& (ETHERNET_FLAG_NONE == ether_hdr->flags));
// read the remaining part of message