diff --git a/include/toksvc/toksvc.h b/include/toksvc/toksvc.h index 236cad7..894d496 100644 --- a/include/toksvc/toksvc.h +++ b/include/toksvc/toksvc.h @@ -58,6 +58,8 @@ extern "C" { #define TOKS_DRIVER_ACTION_NTOKENS_GET 0X1000000 #define TOKS_DRIVER_ACTION_NTOKENS_SET 0X2000000 +#define TOKS_DRIVER_ACTION_LOGLEVEL_GET 0X4000000 +#define TOKS_DRIVER_ACTION_LOGLEVEL_SET 0X8000000 #define TOKS_DRIVER_ACTION_SVCINFO_GET 0X10000000 #define TOKS_DRIVER_ACTION_SVCINFO_LOG 0X20000000 @@ -102,12 +104,18 @@ extern "C" { #define TOKS_IOCTL_IDX_GET_SERVICE_INFO 2 #define TOKS_IOCTL_IDX_LOG_SERVICE_INFO 3 +#define TOKS_IOCTL_IDX_GET_LOG_LEVEL 6 +#define TOKS_IOCTL_IDX_SET_LOG_LEVEL 7 + #define TOKS_IOCTL_GET_TOKEN_COUNT TOKS_IOCTL_GET(TOKS_IOCTL_IDX_GET_TOKEN_COUNT) #define TOKS_IOCTL_SET_TOKEN_COUNT TOKS_IOCTL_SET(TOKS_IOCTL_IDX_SET_TOKEN_COUNT) #define TOKS_IOCTL_GET_SERVICE_INFO TOKS_IOCTL_GET(TOKS_IOCTL_IDX_GET_SERVICE_INFO) #define TOKS_IOCTL_LOG_SERVICE_INFO TOKS_IOCTL_SET(TOKS_IOCTL_IDX_LOG_SERVICE_INFO) +#define TOKS_IOCTL_GET_LOG_LEVEL TOKS_IOCTL_GET(TOKS_IOCTL_IDX_GET_LOG_LEVEL) +#define TOKS_IOCTL_SET_LOG_LEVEL TOKS_IOCTL_SET(TOKS_IOCTL_IDX_SET_LOG_LEVEL) + enum toks_custom_error { TOKS_ERR_FLOW_ERROR, TOKS_ERR_FLEE_ERROR, diff --git a/src/daemon/toks_daemon_ioctl.c b/src/daemon/toks_daemon_ioctl.c index ef7157b..7e49bdc 100644 --- a/src/daemon/toks_daemon_ioctl.c +++ b/src/daemon/toks_daemon_ioctl.c @@ -41,6 +41,31 @@ static int32_t toks_daemon_ioctl_set_token_count(struct toks_daemon_ctx * dctx) return toks_daemon_release(dctx); } +static int32_t toks_daemon_ioctl_get_log_level(struct toks_daemon_ctx * dctx) +{ + nt_tty_port_msg * msg = &dctx->reply; + msg->ttyinfo.exarg = (void *)(intptr_t)dctx->driver_ctx->cctx->loglevel; + return NT_STATUS_SUCCESS; +} + +static int32_t toks_daemon_ioctl_set_log_level(struct toks_daemon_ctx * dctx) +{ + nt_tty_port_msg * msg; + int loglevel; + + msg = &dctx->reply; + loglevel = (int)(intptr_t)msg->ttyinfo.exarg; + + if ((loglevel < 0) || (loglevel > 9)) + return NT_STATUS_INVALID_PARAMETER; + + toks_set_driver_log_level(dctx->driver_ctx,loglevel); + + toks_log_service_info(dctx); + + return NT_STATUS_SUCCESS; +} + static int32_t toks_daemon_ioctl_get_service_info(struct toks_daemon_ctx * dctx) { nt_tty_port_msg * msg = &dctx->reply; @@ -107,6 +132,12 @@ int32_t __stdcall toks_daemon_ioctl(struct toks_daemon_ctx * dctx) case TOKS_IOCTL_LOG_SERVICE_INFO: return toks_daemon_ioctl_log_service_info(dctx); + case TOKS_IOCTL_GET_LOG_LEVEL: + return toks_daemon_ioctl_get_log_level(dctx); + + case TOKS_IOCTL_SET_LOG_LEVEL: + return toks_daemon_ioctl_set_log_level(dctx); + default: return NT_STATUS_NOT_IMPLEMENTED; } diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index 1dbe4ac..2503eca 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -289,6 +289,13 @@ static inline int toks_get_driver_atokens(const struct toks_driver_ctx * dctx) return ictx->atokens; } +static inline void toks_set_driver_log_level(const struct toks_driver_ctx * dctx, int loglevel) +{ + struct toks_driver_ctx_impl * ictx; + ictx = toks_get_driver_ictx(dctx); + ictx->cctx.loglevel = loglevel; +} + static inline int toks_get_driver_tokpid(const struct toks_driver_ctx * dctx) { struct toks_driver_ctx_impl * ictx;