From 295f6bfd92a33d2887e5e88396ff03a393d5e5b7 Mon Sep 17 00:00:00 2001 From: midipix Date: Jun 11 2020 08:54:09 +0000 Subject: logging: toks_log_lpc_request(): output the lpc message type. --- diff --git a/src/log/toks_log_lpc_request.c b/src/log/toks_log_lpc_request.c index 380a029..adf4219 100644 --- a/src/log/toks_log_lpc_request.c +++ b/src/log/toks_log_lpc_request.c @@ -12,6 +12,42 @@ #include "toksvc_daemon_impl.h" #include "toksvc_log_impl.h" +static const char toks_error_str[] = "#ERROR"; + +static const char * toks_lpc_msg_str[] = { + [NT_LPC_NEW_MESSAGE] = "NT_LPC_NEW_MESSAGE", + [NT_LPC_REQUEST] = "NT_LPC_REQUEST", + [NT_LPC_REPLY] = "NT_LPC_REPLY", + [NT_LPC_DATAGRAM] = "NT_LPC_DATAGRAM", + [NT_LPC_LOST_REPLY] = "NT_LPC_LOST_REPLY", + [NT_LPC_PORT_CLOSED] = "NT_LPC_PORT_CLOSED", + [NT_LPC_CLIENT_DIED] = "NT_LPC_CLIENT_DIED", + [NT_LPC_EXCEPTION] = "NT_LPC_EXCEPTION", + [NT_LPC_DEBUG_EVENT] = "NT_LPC_DEBUG_EVENT", + [NT_LPC_ERROR_EVENT] = "NT_LPC_ERROR_EVENT", + [NT_LPC_CONNECTION_REQUEST] = "NT_LPC_CONNECTION_REQUEST", +}; + +static const char * toks_alpc_msg_str[] = { + [NT_ALPC_REQUEST ^ 0x2000] = "NT_ALPC_REQUEST", + [NT_ALPC_CONNECTION_REQUEST ^ 0x2000] = "NT_ALPC_CONNECTION_REQUEST", +}; + +static const char * toks_lpc_msg_type_desc(unsigned msgtype) +{ + if (msgtype <= NT_LPC_CONNECTION_REQUEST) + return toks_lpc_msg_str[msgtype]; + + else if (msgtype == NT_ALPC_REQUEST) + return toks_alpc_msg_str[msgtype ^ 0x2000]; + + else if (msgtype == NT_ALPC_CONNECTION_REQUEST) + return toks_alpc_msg_str[msgtype ^ 0x2000]; + + else + return toks_error_str; +} + void toks_log_lpc_request( struct toks_daemon_ctx * dctx, const nt_tty_port_msg * msg) @@ -32,15 +68,16 @@ void toks_log_lpc_request( toks_log_header( drvctx, TOKS_LOG_ENTRY_SERVER_INFO, - "LPC request from %s (syspid %d, systid %d), " + "LPC message from %s (syspid %d, systid %d), " "data_size=%u, msg_size=%u, " - "msg_type=%u, msg_id=%u\n", + "msg_type=%u (%s), msg_id=%u\n", toks_log_basename(path), cid.process_id, cid.thread_id, msg->header.data_size, msg->header.msg_size, msg->header.msg_type, + toks_lpc_msg_type_desc(msg->header.msg_type), msg->header.msg_id); if (cid.process_id)