summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/cell.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/cell.c')
-rw-r--r--fw/fe310/eos/cell.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fw/fe310/eos/cell.c b/fw/fe310/eos/cell.c
index 4b4fcc0..452fb47 100644
--- a/fw/fe310/eos/cell.c
+++ b/fw/fe310/eos/cell.c
@@ -11,14 +11,17 @@
static eos_evt_handler_t evt_handler[EOS_CELL_MAX_MTYPE];
static void cell_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+ unsigned char mtype;
+ unsigned char idx;
+
if ((buffer == NULL) || (len < 1)) {
eos_net_bad_handler(type, buffer, len);
return;
}
- unsigned char mtype = buffer[0];
- unsigned char idx = (mtype & EOS_CELL_MTYPE_MASK) >> 4;
- if (idx < EOS_CELL_MAX_MTYPE) {
+ mtype = buffer[0];
+ idx = (mtype & EOS_CELL_MTYPE_MASK) >> 4;
+ if ((idx < EOS_CELL_MAX_MTYPE) && evt_handler[idx]) {
evt_handler[idx](mtype & ~EOS_CELL_MTYPE_MASK, buffer, len);
} else {
eos_net_bad_handler(type, buffer, len);
@@ -34,7 +37,7 @@ void eos_cell_init(void) {
int i;
for (i=0; i<EOS_CELL_MAX_MTYPE; i++) {
- evt_handler[i] = eos_net_bad_handler;
+ evt_handler[i] = NULL;
}
eos_net_set_handler(EOS_NET_MTYPE_CELL, cell_handle_evt);
eos_cell_set_handler(EOS_CELL_MTYPE_READY, cell_handle_rdy);
@@ -43,6 +46,5 @@ void eos_cell_init(void) {
void eos_cell_set_handler(unsigned char mtype, eos_evt_handler_t handler) {
unsigned char idx = (mtype & EOS_CELL_MTYPE_MASK) >> 4;
- if (handler == NULL) handler = eos_net_bad_handler;
if (idx < EOS_CELL_MAX_MTYPE) evt_handler[idx] = handler;
}