summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburet2008-04-29 16:41:35 +0000
committerburet2008-04-29 16:41:35 +0000
commita58e2e03a4d4e5f442007e4b4ce909ca273ae6ab (patch)
tree726ecee1f44049016e0dd1e0c8ca8ee3541ab855
parentc801f6570f4f51ecf84c4e615cf029753a051827 (diff)
Fcall proto: continue development and unit tests of interface fcall module.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1932 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/host/sci/cesar/inc/context.h2
-rw-r--r--cesar/host/sci/cesar/inc/sci.h5
-rw-r--r--cesar/host/sci/cesar/src/sci.c4
-rw-r--r--cesar/host/sci/cesar/test/src/test_sci_cesar.c10
-rw-r--r--cesar/interface/fcall/inc/context.h15
-rw-r--r--cesar/interface/fcall/inc/interface_fcall.h5
-rw-r--r--cesar/interface/fcall/interface_fcall.h6
-rw-r--r--cesar/interface/fcall/src/interface_fcall.c130
-rw-r--r--cesar/interface/fcall/test/src/test_interface_fcall.c142
-rw-r--r--cesar/interface/interface.h4
-rw-r--r--cesar/interface/interface_module.h3
11 files changed, 199 insertions, 127 deletions
diff --git a/cesar/host/sci/cesar/inc/context.h b/cesar/host/sci/cesar/inc/context.h
index fd0e9e13b0..8c0101e299 100644
--- a/cesar/host/sci/cesar/inc/context.h
+++ b/cesar/host/sci/cesar/inc/context.h
@@ -29,7 +29,7 @@ struct sci_callback
/** send callback structure */
struct send_callback
{
- void (*function)(void *ctx, u8 *mme, uint length);
+ void (*function)(void *ctx, struct sci_msg *msg);
void *data;
};
diff --git a/cesar/host/sci/cesar/inc/sci.h b/cesar/host/sci/cesar/inc/sci.h
index 31e1bc1f02..8fb9847f78 100644
--- a/cesar/host/sci/cesar/inc/sci.h
+++ b/cesar/host/sci/cesar/inc/sci.h
@@ -19,6 +19,9 @@
* \todo
*/
+#undef SCI_MSG_MAX_SIZE
+#define SCI_MSG_MAX_SIZE 1513
+
/**
* register a send callback function to send a message
* \param sci current sci context
@@ -28,7 +31,7 @@
*/
int sci_register_send_callback(
sci_ctx_t *sci,
- void(*function)(void *data, u8 *mme, uint length),
+ void(*function)(void *data, struct sci_msg *msg),
void *data);
/**
diff --git a/cesar/host/sci/cesar/src/sci.c b/cesar/host/sci/cesar/src/sci.c
index 49888a9fab..f495ee2efd 100644
--- a/cesar/host/sci/cesar/src/sci.c
+++ b/cesar/host/sci/cesar/src/sci.c
@@ -134,7 +134,7 @@ int sci_send(sci_ctx_t *sci, sci_msg_t *msg)
if(sci->send_cb.function != NULL)
{
- (*sci->send_cb.function)(sci->send_cb.data, msg->data_begin, msg->length);
+ (*sci->send_cb.function)(sci->send_cb.data, msg);
}
return msg->length;
@@ -162,7 +162,7 @@ int sci_recv(sci_ctx_t *sci)
*/
int sci_register_send_callback(
sci_ctx_t *sci,
- void(*function)(void *data, u8 *mme, uint length),
+ void(*function)(void *data, struct sci_msg *msg),
void *data)
{
DBG_ASSERT(sci);
diff --git a/cesar/host/sci/cesar/test/src/test_sci_cesar.c b/cesar/host/sci/cesar/test/src/test_sci_cesar.c
index db8c820af0..085c9d1893 100644
--- a/cesar/host/sci/cesar/test/src/test_sci_cesar.c
+++ b/cesar/host/sci/cesar/test/src/test_sci_cesar.c
@@ -38,15 +38,15 @@ static int _sci_callback(sci_msg_t *msg, void *data)
return 0;
}
-static void _send_callback(void *ctx, u8 *mme, uint length)
+static void _send_callback(void *ctx, sci_msg_t *msg)
{
dbg_assert_print((NULL == ctx)
- && (NULL != mme)
- && (strlen(TEST_DATA_STR) == length)
- && (0 == memcmp(mme, TEST_DATA_STR, length)),
+ && (NULL != msg)
+ && (strlen(TEST_DATA_STR) == msg->length)
+ && (0 == memcmp(msg->data_begin, TEST_DATA_STR, msg->length)),
"registered send function: expected len = %d - len = %d",
strlen(TEST_DATA_STR),
- length);
+ msg->length);
}
void sci_init_test_case(test_t t)
diff --git a/cesar/interface/fcall/inc/context.h b/cesar/interface/fcall/inc/context.h
index 7d5656a503..4b510ded03 100644
--- a/cesar/interface/fcall/inc/context.h
+++ b/cesar/interface/fcall/inc/context.h
@@ -13,18 +13,19 @@
* \ingroup interface/fcall
*
*/
-#include "interface/forward.h"
-#include "host/sci/sci.h"
+#include "host/fcall/fcall.h"
+#include "lib/bitstream.h"
-typedef u8* (*interface_buffer_work_get_cb_t) (interface_t *ctx);
-typedef void (*interface_fcall_send_message_cb_t) (void *user_data, u8 *message, uint length);
+typedef void (*interface_fcall_send_message_cb_t) (void *user_data, uint *message, uint length);
typedef struct interface_fcall_t
{
- sci_ctx_t *sci_ctx; /** pointer to the SCI context */
- interface_buffer_work_get_cb_t buffer_cb; /** get buffer function */
- interface_fcall_send_message_cb_t send_cb; /** callback function to call when the interface fcall module needs to send a message */
+ fcall_ctx_t *fcall_ctx; /** pointer to fcall context */
+ interface_fcall_send_message_cb_t send_cb; /** callback function to call when interface fcall module needs to send a message */
void *user_data; /** data to provide on callback function */
+ bitstream_t bitstream_ctx; /** bitstream context */
+ mac_t oda; /** ODA of the received MME */
+ mac_t osa; /** OSA of the received MME */
} interface_fcall_t;
#endif /* interface_fcall_inc_context_h */
diff --git a/cesar/interface/fcall/inc/interface_fcall.h b/cesar/interface/fcall/inc/interface_fcall.h
index 958773acdb..dc1961f344 100644
--- a/cesar/interface/fcall/inc/interface_fcall.h
+++ b/cesar/interface/fcall/inc/interface_fcall.h
@@ -14,6 +14,9 @@
*
*/
+#define INTERFACE_FCALL_OFFSET 20 /* mme header without vlan tag (19) + sub-module type (1) */
+#define INTERFACE_FCALL_MMTYPE 0xABCD // TBD
+
/**
* request the interface module to send a MME
* \param data pointer to the interface fcall context
@@ -21,6 +24,6 @@
* \param length the MME length
*/
void
-interface_fcall_mme_send (void *data, u8 *mme, uint length);
+interface_fcall_mme_send (void *data, sci_msg_t *msg);
#endif /* interface_fcall_inc_interface_fcall_h */
diff --git a/cesar/interface/fcall/interface_fcall.h b/cesar/interface/fcall/interface_fcall.h
index 5afdd997b3..1533de6c91 100644
--- a/cesar/interface/fcall/interface_fcall.h
+++ b/cesar/interface/fcall/interface_fcall.h
@@ -21,8 +21,7 @@
* \param user_data the data to provide on callback function
*/
interface_fcall_t*
-interface_fcall_init (interface_buffer_work_get_cb_t buffer_cb,
- interface_fcall_send_message_cb_t send_cb,
+interface_fcall_init (interface_fcall_send_message_cb_t send_cb,
void *user_data);
/**
@@ -37,8 +36,9 @@ interface_fcall_uninit (interface_fcall_t *ctx);
* \param data pointer to the interface fcall context
* \param mme the MME buffer
* \param length the MME length
+ * \param buffer an empty allocated buffer for fcall response
*/
void
-interface_fcall_mme_recv (void *data, u8 *mme, uint length);
+interface_fcall_mme_recv (void *data, u8 *mme, uint length, u8 *buffer);
#endif /* interface_fcall_interface_fcall_h */
diff --git a/cesar/interface/fcall/src/interface_fcall.c b/cesar/interface/fcall/src/interface_fcall.c
index 622e2421a9..d34697fb40 100644
--- a/cesar/interface/fcall/src/interface_fcall.c
+++ b/cesar/interface/fcall/src/interface_fcall.c
@@ -17,7 +17,12 @@
#include "lib/dbg.h"
#include "interface/fcall/inc/context.h"
#include "interface/fcall/inc/interface_fcall.h"
+#include "interface/interface_module.h" // for 'INTERFACE_MODULE_FCALL'
#include "common/defs/ethernet.h" // for 'ETH_PACKET_MIN_SIZE' and 'ETH_PACKET_MAX_SIZE'
+#include "common/defs/homeplugAV.h" // for 'HPAV_MTYPE_MME' and 'HPAV_MMV'
+#include "hal/hle/defs.h"
+#include "lib/read_word.h"
+#include "lib/utils.h"
#include <errno.h>
/**
@@ -26,19 +31,16 @@
* \param user_data the data to provide on callback function
*/
interface_fcall_t*
-interface_fcall_init (interface_buffer_work_get_cb_t buffer_cb,
- interface_fcall_send_message_cb_t send_cb,
+interface_fcall_init (interface_fcall_send_message_cb_t send_cb,
void *user_data)
{
static interface_fcall_t ctx;
- sci_ctx_t sci_ctx;
- station_ctx_t station_ctx;
+ static sci_ctx_t sci_ctx;
+ static fcall_ctx_t fcall_ctx;
- dbg_assert_ptr(buffer_cb);
dbg_assert_ptr(send_cb);
dbg_assert_ptr(user_data);
- if ((NULL == buffer_cb)
- || (NULL == send_cb)
+ if ((NULL == send_cb)
|| (NULL == user_data))
{
errno = EINVAL;
@@ -46,16 +48,22 @@ interface_fcall_init (interface_buffer_work_get_cb_t buffer_cb,
}
memset(&ctx, '\0', sizeof(interface_fcall_t));
- ctx.buffer_cb = buffer_cb;
+ ctx.fcall_ctx = &fcall_ctx;
ctx.send_cb = send_cb;
ctx.user_data = user_data;
- if (sci_init(&sci_ctx, &station_ctx) < 0)
+ if (sci_init(&sci_ctx, NULL) < 0)
{
+ dbg_assert_print(false, "sci init failed with errno = %d", errno);
return NULL;
}
- ctx.sci_ctx = &sci_ctx;
if (sci_register_send_callback(&sci_ctx, &interface_fcall_mme_send, (void*)&ctx) < 0)
{
+ dbg_assert_print(false, "sci register send callback failed with errno = %d", errno);
+ return NULL;
+ }
+ if (fcall_init(&fcall_ctx, &sci_ctx) < 0)
+ {
+ dbg_assert_print(false, "fcall init failed with errno = %d", errno);
return NULL;
}
@@ -84,39 +92,56 @@ interface_fcall_uninit (interface_fcall_t *ctx)
* \param ctx the interface fcall context
* \param mme the MME buffer
* \param length the MME length
+ * \param buffer an empty allocated buffer for fcall response
*/
void
-interface_fcall_mme_recv (void *data, u8 *mme, uint length)
+interface_fcall_mme_recv (void *data, u8 *mme, uint length, u8 *buffer)
{
- unsigned char *sci_buffer = NULL; /** the receive buffer */
- sci_msg_t msg;
interface_fcall_t *ctx = NULL;
+ sci_msg_t msg;
+ uint payload_length = 0;
dbg_assert_ptr(data);
dbg_assert_ptr(mme);
+ dbg_assert((ETH_PACKET_MIN_SIZE <= length) && (ETH_PACKET_MAX_SIZE >= length));
+ dbg_assert_ptr(buffer);
if ( (NULL == data)
- || (NULL == mme) )
+ || (NULL == mme)
+ || (ETH_PACKET_MIN_SIZE > length)
+ || (ETH_PACKET_MAX_SIZE < length)
+ || (NULL == buffer) )
{
errno = EINVAL;
return;
}
ctx = (interface_fcall_t*)data;
- if (NULL != ctx->buffer_cb)
+
+ /** Read ODA and OSA. */
+ bitstream_init (&ctx->bitstream_ctx, mme, length, BITSTREAM_READ);
+ bitstream_access (&ctx->bitstream_ctx, &ctx->oda, 48);
+ bitstream_access (&ctx->bitstream_ctx, &ctx->osa, 48);
+ bitstream_finalise (&ctx->bitstream_ctx);
+
+ /** Read payload length. */
+ payload_length = read_u16_from_word (mme + INTERFACE_FCALL_OFFSET);
+
+ if (sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE) < 0)
{
- sci_buffer = (*ctx->buffer_cb)((interface_t*)ctx->user_data);
- if (NULL == sci_buffer)
- {
- // wait and retry
- return;
- }
+ dbg_assert_print(false, "sci msg init failed with errno = %d", errno);
+ return;
}
- if (sci_msg_init(&msg, sci_buffer, SCI_MSG_MAX_SIZE) < 0)
+ if ((int)payload_length != sci_msg_push(&msg, payload_length))
{
+ dbg_assert_print(false, "sci msg push failed with errno = %d", errno);
return;
}
- if (sci_recv_msg(ctx->sci_ctx, &msg) < 0)
+ memcpy(msg.data_begin, mme + INTERFACE_FCALL_OFFSET + sizeof(u16), payload_length);
+ dbg_assert_ptr(ctx->fcall_ctx);
+ if ( (NULL != ctx->fcall_ctx)
+ && (sci_recv_msg(ctx->fcall_ctx->sci, &msg) < 0) )
{
+ dbg_assert_print(false, "sci recv msg failed with errno = %d", errno);
return;
}
}
@@ -128,24 +153,71 @@ interface_fcall_mme_recv (void *data, u8 *mme, uint length)
* \param length the MME length
*/
void
-interface_fcall_mme_send (void *data, u8 *mme, uint length)
+interface_fcall_mme_send (void *data, sci_msg_t *msg)
{
interface_fcall_t *ctx;
+ uint field;
+ uint word[2];
dbg_assert_ptr(data);
- dbg_assert_ptr(mme);
+ dbg_assert_ptr(msg);
if ((NULL == data)
- || (NULL == mme))
+ || (NULL == msg))
{
errno = EINVAL;
return;
}
ctx = (interface_fcall_t*)data;
- if (NULL != ctx->send_cb)
+
+ if (INTERFACE_FCALL_OFFSET + sizeof(u16) != sci_msg_push(msg, INTERFACE_FCALL_OFFSET + sizeof(u16)))
{
- (*ctx->send_cb)(ctx->user_data, mme, length);
+ dbg_assert_print(false, "sci msg push failed with errno = %d", errno);
+ return;
}
- return;
+ // Fill the MME Header.
+ bitstream_init (&ctx->bitstream_ctx, msg->data_begin, INTERFACE_FCALL_OFFSET + sizeof(u16), BITSTREAM_WRITE);
+
+ /* Inserting the ODA and the OSA. */
+ bitstream_access (&ctx->bitstream_ctx, &ctx->osa, 48);
+ bitstream_access (&ctx->bitstream_ctx, &ctx->oda, 48);
+
+ /* Inserting the MTYPE. */
+ field = htons(HPAV_MTYPE_MME);
+ bitstream_access (&ctx->bitstream_ctx, &field, 16);
+
+ /* Inserting the MMV. */
+ field = HPAV_MMV;
+ bitstream_access (&ctx->bitstream_ctx, &field, 8);
+
+ /* Inserting the MMTYPE. */
+ field = INTERFACE_FCALL_MMTYPE;
+ bitstream_access (&ctx->bitstream_ctx, &field, 16);
+
+ /* Inserting the FMI. */
+ field = 0;
+ bitstream_access (&ctx->bitstream_ctx, &field, 16);
+
+ /* Inserting the module type. */
+ field = INTERFACE_MODULE_FCALL;
+ bitstream_access (&ctx->bitstream_ctx, &field, 8);
+
+ /* Inserting the payload length. */
+ bitstream_access (&ctx->bitstream_ctx, &msg->length - INTERFACE_FCALL_OFFSET - sizeof(u16), 16);
+
+ bitstream_finalise (&ctx->bitstream_ctx);
+
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_INTERFACE),
+ (MSG_LENGTH, 1),
+ (PARAM_INTERFACE_TYPE, INTERFACE_MODULE_FCALL),
+ (PARAM_INTERFACE_LENGTH, msg->length));
+ word[1] = (uint)msg->data_begin;
+
+ /** Request the interface to send the message to the linux driver. */
+ dbg_assert_ptr(ctx->send_cb);
+ if (NULL != ctx->send_cb)
+ {
+ (*ctx->send_cb)(ctx->user_data, word, 2);
+ }
}
diff --git a/cesar/interface/fcall/test/src/test_interface_fcall.c b/cesar/interface/fcall/test/src/test_interface_fcall.c
index 83e1418618..3745a2b516 100644
--- a/cesar/interface/fcall/test/src/test_interface_fcall.c
+++ b/cesar/interface/fcall/test/src/test_interface_fcall.c
@@ -12,8 +12,7 @@
*/
#include "common/std.h"
#include "lib/test.h"
-#include "host/sci/sci.h"
-#include "host/station/station.h"
+#include "host/fcall/fcall.h"
#include "interface/fcall/interface_fcall.h"
#include "interface/fcall/inc/interface_fcall.h"
#include "interface/forward.h"
@@ -23,18 +22,24 @@
u32 maximus_pending_isrs;
interface_fcall_t *ctx;
+char test[] = "test";
-u8*
-interface_buffer_work_get_cb (interface_t *ctx)
+void
+interface_fcall_send_message_cb (void *user_data, uint *message, uint length)
{
- static u8 buffer[SCI_MSG_MAX_SIZE];
- return buffer;
+ u8 *data;
+ dbg_assert_ptr(user_data);
+ dbg_assert_ptr(message);
+ dbg_assert(2 == length);
+ data = (u8*)(*(message + 1));
+ dbg_assert_print((0 == memcmp(data + INTERFACE_FCALL_OFFSET + sizeof(u16) + sizeof(struct fcall_msg_hdr), test, strlen(test) + 1)),
+ "registered send function");
+ return;
}
-void
-interface_fcall_send_message_cb (void *user_data, u8 *message, uint length)
+int host_fcall_test (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
- return;
+ return 0;
}
void
@@ -44,27 +49,12 @@ interface_fcall_init_test_case(test_t t)
test_case_begin(t, "init");
- test_begin(t, "NULL buffer cb")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless(
- (NULL == interface_fcall_init(NULL, &interface_fcall_send_message_cb, (void*)&user_data))
- );
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("init with NULL buffer cb\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- } test_end;
-
test_begin(t, "NULL send cb")
{
dbg_fatal_try_begin
{
test_fail_unless(
- (NULL == interface_fcall_init(&interface_buffer_work_get_cb, NULL, (void*)&user_data))
+ (NULL == interface_fcall_init(NULL, (void*)&user_data))
);
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -79,7 +69,7 @@ interface_fcall_init_test_case(test_t t)
dbg_fatal_try_begin
{
test_fail_unless(
- (NULL == interface_fcall_init(&interface_buffer_work_get_cb, &interface_fcall_send_message_cb, NULL))
+ (NULL == interface_fcall_init(&interface_fcall_send_message_cb, NULL))
);
}
dbg_fatal_try_catch (const char *fatal_message)
@@ -91,17 +81,14 @@ interface_fcall_init_test_case(test_t t)
test_begin(t, "check init")
{
- ctx = interface_fcall_init(&interface_buffer_work_get_cb, &interface_fcall_send_message_cb, (void*)&user_data);
-/*
+ ctx = interface_fcall_init(&interface_fcall_send_message_cb, (void*)&user_data);
test_fail_unless(
(NULL != ctx)
&& (EINVAL != errno)
- && (ctx->buffer_cb = &interface_buffer_work_get_cb)
+ && (ctx->fcall_ctx != NULL)
&& (ctx->send_cb == &interface_fcall_send_message_cb)
&& (ctx->user_data == &user_data)
- && (ctx->sci_ctx != NULL)
);
-*/
} test_end;
}
@@ -109,7 +96,11 @@ void
interface_fcall_mme_recv_test_case(test_t t)
{
u8 mme[ETH_PACKET_MAX_SIZE];
- uint length = ETH_PACKET_MAX_SIZE;
+ u8 buffer[SCI_MSG_MAX_SIZE];
+ struct fcall_msg_hdr fcall_hdr;
+ uint length = ETH_PACKET_MIN_SIZE;
+ memset(mme, '\0', ETH_PACKET_MAX_SIZE);
+ memset(buffer, '\0', SCI_MSG_MAX_SIZE);
test_case_begin(t, "mme recv");
@@ -117,7 +108,7 @@ interface_fcall_mme_recv_test_case(test_t t)
{
dbg_fatal_try_begin
{
- interface_fcall_mme_recv (NULL, mme, length);
+ interface_fcall_mme_recv (NULL, mme, length, buffer);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -130,7 +121,7 @@ interface_fcall_mme_recv_test_case(test_t t)
{
dbg_fatal_try_begin
{
- interface_fcall_mme_recv (ctx, NULL, length);
+ interface_fcall_mme_recv (ctx, NULL, length, buffer);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -143,7 +134,7 @@ interface_fcall_mme_recv_test_case(test_t t)
{
dbg_fatal_try_begin
{
- interface_fcall_mme_recv (ctx, mme, 1);
+ interface_fcall_mme_recv (ctx, mme, 1, buffer);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -156,7 +147,7 @@ interface_fcall_mme_recv_test_case(test_t t)
{
dbg_fatal_try_begin
{
- interface_fcall_mme_recv (ctx, mme, length + 1);
+ interface_fcall_mme_recv (ctx, mme, ETH_PACKET_MAX_SIZE + 1, buffer);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -165,22 +156,41 @@ interface_fcall_mme_recv_test_case(test_t t)
dbg_fatal_try_end;
} test_end;
+ test_begin(t, "NULL buffer")
+ {
+ dbg_fatal_try_begin
+ {
+ interface_fcall_mme_recv (ctx, mme, length, NULL);
+ }
+ dbg_fatal_try_catch (const char *fatal_message)
+ {
+ printf("mme recv with NULL buffer\n%s\n", fatal_message);
+ }
+ dbg_fatal_try_end;
+ } test_end;
+
test_begin(t, "check mme recv")
{
-/*
- interface_fcall_mme_recv (ctx, mme, length);
+ u16 payload_length = sizeof(fcall_hdr) + strlen(test) + 1;
+ fcall_register(ctx->fcall_ctx, test, (void*)&host_fcall_test, NULL);
+ memset(&fcall_hdr, '\0', sizeof(fcall_hdr));
+ fcall_hdr.version = FUNCTION_CALL_VERSION;
+ fcall_hdr.type = FUNCTION_CALL_TYPE_REQ;
+ memcpy((char*)mme + INTERFACE_FCALL_OFFSET, &payload_length, sizeof(u16));
+ memcpy((char*)mme + INTERFACE_FCALL_OFFSET + sizeof(u16), &fcall_hdr, sizeof(fcall_hdr));
+ strcpy((char*)mme + INTERFACE_FCALL_OFFSET + sizeof(u16) + sizeof(fcall_hdr), test);
+ interface_fcall_mme_recv (ctx, mme, length, buffer);
test_fail_unless(
(errno != EINVAL)
);
-*/
} test_end;
}
void
interface_fcall_mme_send_test_case(test_t t)
{
- u8 mme[ETH_PACKET_MAX_SIZE];
- uint length = ETH_PACKET_MAX_SIZE;
+ sci_msg_t msg;
+ u8 buffer[SCI_MSG_MAX_SIZE];
test_case_begin(t, "mme send");
@@ -188,7 +198,7 @@ interface_fcall_mme_send_test_case(test_t t)
{
dbg_fatal_try_begin
{
- interface_fcall_mme_send (NULL, mme, length);
+ interface_fcall_mme_send (NULL, &msg);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -197,53 +207,35 @@ interface_fcall_mme_send_test_case(test_t t)
dbg_fatal_try_end;
} test_end;
- test_begin(t, "NULL mme")
- {
- dbg_fatal_try_begin
- {
- interface_fcall_mme_send (ctx, NULL, length);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("mme send with NULL mme\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- } test_end;
-
- test_begin(t, "length < ETH_PACKET_MIN_SIZE")
- {
- dbg_fatal_try_begin
- {
- interface_fcall_mme_send (ctx, mme, 1);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("mme send with length < ETH_PACKET_MIN_SIZE\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- } test_end;
-
- test_begin(t, "length > ETH_PACKET_MAX_SIZE")
+ test_begin(t, "NULL msg")
{
dbg_fatal_try_begin
{
- interface_fcall_mme_send (ctx, mme, length + 1);
+ interface_fcall_mme_send (ctx, NULL);
}
dbg_fatal_try_catch (const char *fatal_message)
{
- printf("mme send with length > ETH_PACKET_MAX_SIZE\n%s\n", fatal_message);
+ printf("mme send with NULL msg\n%s\n", fatal_message);
}
dbg_fatal_try_end;
} test_end;
test_begin(t, "check mme send")
{
-/*
- interface_fcall_mme_send (ctx, mme, length);
+ test_fail_unless(
+ sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE) >= 0
+ );
+ test_fail_unless(
+ sci_msg_push(&msg, strlen(test) + 1) >= 0
+ );
+ strcpy((char*)msg.data_begin, test);
+ test_fail_unless(
+ sci_msg_push(&msg, sizeof(struct fcall_msg_hdr)) >= 0
+ );
+ interface_fcall_mme_send (ctx, &msg);
test_fail_unless(
(errno != EINVAL)
);
-*/
} test_end;
}
@@ -267,12 +259,10 @@ interface_fcall_uninit_test_case(test_t t)
test_begin(t, "check uninit")
{
-/*
interface_fcall_uninit(ctx);
test_fail_unless(
(errno != EINVAL)
);
-*/
} test_end;
}
diff --git a/cesar/interface/interface.h b/cesar/interface/interface.h
index 2a2b1e5656..05d846bee2 100644
--- a/cesar/interface/interface.h
+++ b/cesar/interface/interface.h
@@ -23,7 +23,9 @@
#include "interface/interface_module.h"
#include "interface/forward.h"
-#define INTERFACE_BUFFER_LIST_NUM_SLOTS 2
+/** Allocate 2 buffers for sniffer sub-module
+ * and 1 buffer for fcall sub-module. */
+#define INTERFACE_BUFFER_LIST_NUM_SLOTS 3
/**
* Function to call when the interface receives a new MME.
diff --git a/cesar/interface/interface_module.h b/cesar/interface/interface_module.h
index 3a606fa317..829a35c0f9 100644
--- a/cesar/interface/interface_module.h
+++ b/cesar/interface/interface_module.h
@@ -17,7 +17,8 @@
enum interface_modules_t
{
INTERFACE_MODULE_INTERFACE,
- INTERFACE_MODULE_SNIFFER
+ INTERFACE_MODULE_SNIFFER,
+ INTERFACE_MODULE_FCALL
};
#endif /* interface_interface_module_h */