aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-01-01 19:48:10 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-01 19:51:50 +0100
commitddd6a0d249ff35739c8a7635becf87f54d000565 (patch)
treea1df8d8818d59173dcf45d7eb4c9a9bd106d9523
parent89c159c87348c0280dbc99f002a87f64d137646b (diff)
diag_cmd: Print error messages for bad {command, length, parameter}
-rw-r--r--src/diag_cmd.c9
-rw-r--r--src/diag_dpl.c2
-rw-r--r--src/diag_io.c1
-rw-r--r--src/protocol/protocol.h2
4 files changed, 12 insertions, 2 deletions
diff --git a/src/diag_cmd.c b/src/diag_cmd.c
index e540670..a1b814d 100644
--- a/src/diag_cmd.c
+++ b/src/diag_cmd.c
@@ -52,6 +52,15 @@ int diag_process_msg(struct diag_instance *di, struct msgb *msg)
diag_log_handle(di, msg);
msgb_free(msg);
return 1;
+ case DIAG_BAD_CMD_F:
+ fprintf(stderr, "BAD COMMAND: %s\n", msgb_hexdump(msg));
+ return 0;
+ case DIAG_BAD_PARM_F:
+ fprintf(stderr, "BAD PARAMETER: %s\n", msgb_hexdump(msg));
+ return 0;
+ case DIAG_BAD_LEN_F:
+ fprintf(stderr, "BAD LENGTH: %s\n", msgb_hexdump(msg));
+ return 0;
default:
if (cmd_handlers[cmd]) {
(cmd_handlers[cmd])(di, msg);
diff --git a/src/diag_dpl.c b/src/diag_dpl.c
index 31bcff6..a906d25 100644
--- a/src/diag_dpl.c
+++ b/src/diag_dpl.c
@@ -65,7 +65,7 @@ int diag_dpl_get_if_desc(struct diag_instance *di, uint8_t iface_id)
gidr = (struct dpl_get_if_desc_req *) msgb_put(msg, sizeof(*gidr));
gidr->iface_id = iface_id;
diag_push_subsys_hdr(msg, DIAG_SUBSYS_PS_DATA_LOGGING,
- DIAG_DPL_GET_SUPPORTED_IFACES);
+ DIAG_DPL_GET_IFACE_DESC);
rx = diag_transceive_msg(di, msg);
/* FIXME */
msgb_free(rx);
diff --git a/src/diag_io.c b/src/diag_io.c
index 3589678..59bedab 100644
--- a/src/diag_io.c
+++ b/src/diag_io.c
@@ -98,6 +98,7 @@ struct msgb *diag_read_msg(struct diag_instance *di)
}
msg = di->rx.msg;
+ memset(&hdlc_decode, 0, sizeof(hdlc_decode));
hdlc_decode.dest_ptr = msg->tail;
hdlc_decode.dest_size = msgb_tailroom(msg);
hdlc_decode.src_ptr = buf;
diff --git a/src/protocol/protocol.h b/src/protocol/protocol.h
index 083c004..69f9dca 100644
--- a/src/protocol/protocol.h
+++ b/src/protocol/protocol.h
@@ -80,7 +80,7 @@ struct log_hdr {
struct diagpkt_subsys_hdr {
uint8_t command; /* DIAG_SUBSYS_CMD_F */
uint8_t subsys_id;
- uint8_t subsys_cmd_code;
+ uint16_t subsys_cmd_code;
} __attribute__((packed));
int diag_push_subsys_hdr(struct msgb *msg, uint8_t subsys, uint8_t code);