diag_cmd: Print error messages for bad {command, length, parameter}

This commit is contained in:
Harald Welte 2017-01-01 19:48:10 +01:00
parent 89c159c873
commit ddd6a0d249
4 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);