summaryrefslogtreecommitdiff
path: root/cesar/maximus/stationtest/src/test_station.c
diff options
context:
space:
mode:
authorburet2009-09-09 10:05:38 +0000
committerburet2009-09-09 10:05:38 +0000
commit4f43bb83b11c64948014aa9bd8d029cf5c0e6057 (patch)
tree87c92e922f2f5b4fd0a4ad349fd8dd3c4aa0a4fe /cesar/maximus/stationtest/src/test_station.c
parentbd2cd053e6a48dbf890eeb7d6ec3a0643a93f2ad (diff)
[maximus] update station test (DRV MME and tonemask)
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5467 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/maximus/stationtest/src/test_station.c')
-rw-r--r--cesar/maximus/stationtest/src/test_station.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/cesar/maximus/stationtest/src/test_station.c b/cesar/maximus/stationtest/src/test_station.c
index 8d519079d9..9f15f1812c 100644
--- a/cesar/maximus/stationtest/src/test_station.c
+++ b/cesar/maximus/stationtest/src/test_station.c
@@ -12,12 +12,32 @@
*/
#include "common/std.h"
+#include "common/defs/homeplugAV.h"
#include "host/station/station.h" // for 'station_ctx_t'
#include "hal/hle/ipmbox.h"
#include "hal/hle/defs.h" // for 'HLE_MSG_TYPE_...' and 'ipmbox_msg_hdr_t'
#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 <cyg/infra/diag.h>
+#include <stdio.h>
+
+#define RESULT_SUCCESS 0x00
+#define CM_SET_KEY_REQ_MMTYPE 0x6008
+
+/* DRV_STA_....CNF MMENTRY only contains 1 byte: Result */
+#define DRV_STA_CNF_LEN (HPAV_MME_HEADER + 1)
+
+/* CM_SET_KEY.CNF MMENTRY contains:
+ - 1 byte: Result
+ - 4 bytes: My Nonce
+ - 4 bytes: Your Nonce
+ - 1 byte: PID
+ - 2 bytes: PRN
+ - 1 byte: PMN
+ - 1 byte: CCo Capability
+ => 14 bytes in total */
+#define CM_SET_KEY_CNF_LEN (HPAV_MME_HEADER + 14)
extern station_ctx_t my_station;
ipmbox_t *ctx;
@@ -34,18 +54,37 @@ void ipmbox_rx_cb (void *user_data, u32 *first_msg, uint length)
/* When receiving an Ether SCI message of type MME REQ from Maximus,
* send the answer (an Ether SCI message of type MME CNF). */
+ // REQ data length
uint data_length = (uint)(hdr->param >> 1);
+
+ // REQ data
memcpy(ctx->first_buffer->next->data, (u32 *)ctx->rx.mailbox[1], data_length);
- char *data = (char *)ctx->first_buffer->next->data;
- *(data + 15) = *(data + 15) + 1; // REQ => CNF
- *(data + 19) = 0x01; // Success
- memset(data + 20, '\0', data_length - 20);
+
+ // CNF data
+ char *cnf_data = (char *)ctx->first_buffer->next->data;
+ *(cnf_data + HPAV_MMTYPE_OFFSET) = *(cnf_data + HPAV_MMTYPE_OFFSET) + 1; // REQ => CNF
+ *(cnf_data + HPAV_MME_HEADER) = RESULT_SUCCESS;
+
+ // CNF data length
+ uint cnf_data_length = 0;
+ u16 mmtype = (u16)(*(cnf_data + HPAV_MMTYPE_OFFSET + 1) << 8)\
+ | (u16)(*(cnf_data + HPAV_MMTYPE_OFFSET));
+ if (CM_SET_KEY_REQ_MMTYPE == mmtype)
+ {
+ cnf_data_length = CM_SET_KEY_CNF_LEN;
+ }
+ else /* mmtype = DRV_STA_....REQ */
+ {
+ cnf_data_length = DRV_STA_CNF_LEN;
+ }
// Release allocated buffer
hdr->type = HLE_MSG_TYPE_SEND_DONE;
ipmbox_tx (ctx, ctx->rx.mailbox, 2);
+ // Tx
hdr->type = HLE_MSG_TYPE_DATA;
+ hdr->param = cnf_data_length << 8;
hdr->param |= 0x001;
ctx->rx.mailbox[1] = (u32)ctx->first_buffer->next->data;
ipmbox_tx (ctx, ctx->rx.mailbox, ctx->rx.length);