summaryrefslogtreecommitdiff
path: root/maximus/stationtest/src/test_ether.c
diff options
context:
space:
mode:
Diffstat (limited to 'maximus/stationtest/src/test_ether.c')
-rw-r--r--maximus/stationtest/src/test_ether.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/maximus/stationtest/src/test_ether.c b/maximus/stationtest/src/test_ether.c
index 3e2539afc2..83a8452774 100644
--- a/maximus/stationtest/src/test_ether.c
+++ b/maximus/stationtest/src/test_ether.c
@@ -21,6 +21,7 @@
#include "hal/hle/maximus/inc/maximus_ipmbox_ctx.h" // for 'ipmbox_t'
#include "hal/hle/maximus/inc/maximus_interrupts.h" // for 'HAL_HLE_INTERRUPT_IPMBOX'
#include "maximus/common/types/ethernet_types.h" // for 'ETHERNET_TYPE_...'
+#include <stdlib.h> // for 'malloc()'
extern station_ctx_t my_station;
ipmbox_t * ctx;
@@ -57,21 +58,35 @@ void ipmbox_rx_cb (void *user_data, u32 *first_msg, uint length)
}
else if (HLE_MSG_TYPE_BUFFER_ADD == hdr->type)
{
- /* When receiving an Ether SCI message of type DATA_BUFFER_ADD or MME_BUFFER_ADD from Maximus,
- * answer by sending an Ether SCI message of type SNIFFER. */
-
- uint data_length = 64;
- char data[data_length];
- memset(data, '\0', data_length);
- strcpy(data, "This is a sniffed packet coming from the station");
-
hdr->type = HLE_MSG_TYPE_SEND_DONE;
ipmbox_tx (ctx, ctx->rx.mailbox, 2); // do nothing
- hdr->type = HLE_MSG_TYPE_INTERFACE_SNIFFER;
- hdr->param = (data_length << 5) | 0x7;
- ctx->rx.mailbox[1] = (u32)data;
- ipmbox_tx (ctx, ctx->rx.mailbox, 2);
+ if (2 == hdr->param)
+ {
+ /* When receiving an Ether SCI message of type INTERFACE_BUFFER_ADD from Maximus,
+ * answer by sending an Ether SCI message of type SNIFFER,
+ * with an Ether SCI message of type BUFFER_RELEASED. */
+
+ uint data_length = 64;
+ char * p_data = malloc(data_length);
+ memset(p_data, '\0', data_length);
+ strcpy(p_data, "This is a sniffed packet coming from the station");
+
+ maximus_hle_buffer_t *p_buffer = (maximus_hle_buffer_t *)malloc(sizeof(maximus_hle_buffer_t));
+ u32 id = ctx->last_buffer->id;
+ ctx->last_buffer->next = p_buffer;
+ ctx->last_buffer = p_buffer;
+ ctx->last_buffer->next = NULL;
+ ctx->last_buffer->id = id;
+ ctx->last_buffer->data = (u32 *)p_data;
+
+ hdr->type = HLE_MSG_TYPE_INTERFACE;
+ hdr->length = 2;
+ hdr->param = (data_length << 8) & 0x7FF00;
+ ctx->rx.mailbox[1] = 0x00000007;
+ ctx->rx.mailbox[2] = (u32)p_data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, 3);
+ }
}
return;
@@ -89,7 +104,7 @@ int init_ether (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void
ctx->warning_assert = true;
// Activate ipmbox interruptions
- ipmbox_activate(ctx, true);
+ ipmbox_activate (ctx, true);
/* now make the return parameter list */
fcall_param_reset(*param);