aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-01-01 16:42:12 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-01 19:51:50 +0100
commit89c159c87348c0280dbc99f002a87f64d137646b (patch)
tree072190e60cc77556ab746bb65033f6eb34d42316
parent022c45a26345a54880e48e3bc30adc60643270e1 (diff)
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.
-rw-r--r--src/diag_msg.c50
-rw-r--r--src/protocol/protocol.h47
2 files changed, 65 insertions, 32 deletions
diff --git a/src/diag_msg.c b/src/diag_msg.c
index 661d1d1..348cf2a 100644
--- a/src/diag_msg.c
+++ b/src/diag_msg.c
@@ -93,12 +93,12 @@ static void diag_rx_ext_msg_f(struct diag_instance *di, struct msgb *msgb)
}
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]);
file = fmt + strlen(fmt) + 1;
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));
switch (num_args) {
case 0:
@@ -126,8 +126,54 @@ static void diag_rx_ext_msg_f(struct diag_instance *di, struct msgb *msgb)
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[] = {
{ 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)
diff --git a/src/protocol/protocol.h b/src/protocol/protocol.h
index 53b9670..083c004 100644
--- a/src/protocol/protocol.h
+++ b/src/protocol/protocol.h
@@ -23,14 +23,17 @@ struct msgb;
* Extended Message Service (DIAG_EXT_MSG_F)
***********************************************************************/
-struct ext_log_msg {
- /* msg_hdr_type equivalent */
- uint8_t type;
- uint8_t ts_type; /* timestamp tyoe */
- uint8_t num_args; /* number of arguments */
- uint8_t drop_cnt; /* dropped messages */
- uint64_t timestamp; /* More 32 bit but dm-commands.h */
+/* message header */
+struct diag_msg_hdr {
+ uint8_t cmd_code;
+ uint8_t ts_type;
+ uint8_t num_args;
+ uint8_t drop_cnt;
+ uint64_t timestamp;
+} __attribute__((packed));
+struct ext_log_msg {
+ struct diag_msg_hdr hdr;
/* msg_desc_type */
uint16_t line_nr;
uint16_t subsys_id;
@@ -39,31 +42,15 @@ struct ext_log_msg {
int32_t params[0]; /* three params */
} __attribute__((packed));
+struct qsr_ext_msg_terse {
+ struct diag_msg_hdr hdr;
-/* message header */
-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 line_nr;
uint16_t subsys_id;
- uint16_t subsys_mask;
-} __attribute__((packed));
-
-/* 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));
-
+ uint32_t subsys_mask;
+ uint32_t hash;
+ int32_t params[0];
+};
/***********************************************************************
* Log Service (IAG_LOG_F)