Blob Blame History Raw
/*********************************************************/
/*  toksvc: a framework-native token broker service      */
/*  Copyright (C) 2020  Z. Gilboa                        */
/*  Released under GPLv2 and GPLv3; see COPYING.TOKSVC.  */
/*********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/ntapi.h>
#include <ntapi/nt_termios.h>

#include "toksvc_daemon_impl.h"
#include "toksvc_driver_impl.h"

static int32_t toks_daemon_ioctl_get_token_count(struct toks_daemon_ctx * dctx)
{
	nt_tty_port_msg * msg = &dctx->reply;
	msg->ttyinfo.exarg = (void *)(intptr_t)toks_get_driver_ntokens(dctx->driver_ctx);
	return NT_STATUS_SUCCESS;
}

int32_t __stdcall toks_daemon_ioctl(struct toks_daemon_ctx * dctx)
{
	nt_tty_port_msg * msg;
	uint32_t          ctlcode;

	msg     = &dctx->reply;
	ctlcode = msg->ttyinfo.opdata;

	switch (ctlcode) {
		case TOKS_IOCTL_GET_TOKEN_COUNT:
			return toks_daemon_ioctl_get_token_count(dctx);

		default:
			return NT_STATUS_NOT_IMPLEMENTED;
	}
}