add printing of DIAG_QSR_EXT_MSG_TERSE_F

Those are QSHRINK type messages where the format-string is not contained
in the message itself but would have to be provided from an external
source and looked up by a hash.
This commit is contained in:
Harald Welte 2017-01-01 16:42:12 +01:00
parent 022c45a263
commit 89c159c873
2 changed files with 65 additions and 32 deletions

View File

@ -93,12 +93,12 @@ static void diag_rx_ext_msg_f(struct diag_instance *di, struct msgb *msgb)
} }
msg = (struct ext_log_msg *) data; msg = (struct ext_log_msg *) data;
num_args = msg->num_args; num_args = msg->hdr.num_args;
fmt = (const char *) msg->params + num_args*sizeof(msg->params[0]); fmt = (const char *) msg->params + num_args*sizeof(msg->params[0]);
file = fmt + strlen(fmt) + 1; file = fmt + strlen(fmt) + 1;
printf("MSG(%u|%u|%s:%u): ", osmo_load16le(&msg->subsys_id), printf("MSG(%u|%u|%s:%u): ", osmo_load16le(&msg->subsys_id),
diag_ts_to_epoch(osmo_load64le(&msg->timestamp)), diag_ts_to_epoch(osmo_load64le(&msg->hdr.timestamp)),
file, osmo_load16le(&msg->line_nr)); file, osmo_load16le(&msg->line_nr));
switch (num_args) { switch (num_args) {
case 0: case 0:
@ -126,8 +126,54 @@ static void diag_rx_ext_msg_f(struct diag_instance *di, struct msgb *msgb)
fputc('\n', stdout); fputc('\n', stdout);
} }
static void diag_rx_ext_msg_terse_f(struct diag_instance *di, struct msgb *msgb)
{
const uint8_t *data = msgb_data(msgb);
const size_t len = msgb_length(msgb);
const struct qsr_ext_msg_terse *msg;
unsigned int num_args;
if (len < sizeof(struct qsr_ext_msg_terse)) {
printf("too short ext_log_msg.\n");
return;
}
msg = (struct qsr_ext_msg_terse *) data;
num_args = msg->hdr.num_args;
printf("MSG_QS(%u|%u|%08x:%u): ", osmo_load16le(&msg->subsys_id),
diag_ts_to_epoch(osmo_load64le(&msg->hdr.timestamp)),
osmo_load32le(&msg->hash), osmo_load16le(&msg->line_nr));
switch (num_args) {
case 0:
fputs("", stdout);
break;
case 1:
printf("%08x", osmo_load32le(&msg->params[0]));
break;
case 2:
printf("%08x %08x", osmo_load32le(&msg->params[0]),
osmo_load32le(&msg->params[1]));
break;
case 3:
printf("%08x %08x %08x", osmo_load32le(&msg->params[0]),
osmo_load32le(&msg->params[1]),
osmo_load32le(&msg->params[2]));
break;
case 4:
printf("%08x %08x %08x %08x", osmo_load32le(&msg->params[0]),
osmo_load32le(&msg->params[1]),
osmo_load32le(&msg->params[2]),
osmo_load32le(&msg->params[3]));
break;
}
fputc('\n', stdout);
}
struct diag_cmd_dispatch_tbl cmd_tbl[] = { struct diag_cmd_dispatch_tbl cmd_tbl[] = {
{ DIAG_EXT_MSG_F, diag_rx_ext_msg_f }, { DIAG_EXT_MSG_F, diag_rx_ext_msg_f },
{ DIAG_QSR_EXT_MSG_TERSE_F, diag_rx_ext_msg_terse_f },
}; };
static __attribute__((constructor)) void on_dso_load_msg(void) static __attribute__((constructor)) void on_dso_load_msg(void)

View File

@ -23,14 +23,17 @@ struct msgb;
* Extended Message Service (DIAG_EXT_MSG_F) * Extended Message Service (DIAG_EXT_MSG_F)
***********************************************************************/ ***********************************************************************/
struct ext_log_msg { /* message header */
/* msg_hdr_type equivalent */ struct diag_msg_hdr {
uint8_t type; uint8_t cmd_code;
uint8_t ts_type; /* timestamp tyoe */ uint8_t ts_type;
uint8_t num_args; /* number of arguments */ uint8_t num_args;
uint8_t drop_cnt; /* dropped messages */ uint8_t drop_cnt;
uint64_t timestamp; /* More 32 bit but dm-commands.h */ uint64_t timestamp;
} __attribute__((packed));
struct ext_log_msg {
struct diag_msg_hdr hdr;
/* msg_desc_type */ /* msg_desc_type */
uint16_t line_nr; uint16_t line_nr;
uint16_t subsys_id; uint16_t subsys_id;
@ -39,31 +42,15 @@ struct ext_log_msg {
int32_t params[0]; /* three params */ int32_t params[0]; /* three params */
} __attribute__((packed)); } __attribute__((packed));
struct qsr_ext_msg_terse {
struct diag_msg_hdr hdr;
/* message header */ uint16_t line_nr;
struct diag_msg_hdr {
uint8_t cmd_code;
uint8_t timestamp_type;
uint8_t num_args;
uint8_t drop_count;
uint64_t ts;
} __attribute__((packed));
/* message descriptor */
struct diag_msg_desc {
uint16_t line;
uint16_t subsys_id; uint16_t subsys_id;
uint16_t subsys_mask; uint32_t subsys_mask;
} __attribute__((packed)); uint32_t hash;
int32_t params[0];
/* message header for DIAG_EXT_MSG_F */ };
struct diag_msg_ext {
struct diag_msg_hdr hdr;
struct diag_msg_desc desc;
uint32_t args[0]; /* see hdr.num_args */
/* followed by null-terminated strings */
} __attribute__((packed));
/*********************************************************************** /***********************************************************************
* Log Service (IAG_LOG_F) * Log Service (IAG_LOG_F)