/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Vntsd handles two types of special commands, one is telnet
* commands and another is vntsd special commands.
* telnet commands supported are:
* WILL
* WONT
* DO
* DONT
* TEL_ECHO
* SUPRESS
* LINEMODE
* BRK
* AYT
* HT
* NOP
*
* Vntsd special commands are:
* Send break (~#)
* Send alternate break (~^B)
* Exit (~.)
* Force write access (~w)
* Console next (~n)
* Console previous (~p)
* Help (~?)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <thread.h>
#include <ctype.h>
#include <libintl.h>
#include <syslog.h>
#include "vntsd.h"
#include "chars.h"
/* structure for daemon special cmd */
typedef struct {
} esctable_t;
/* genbrk() - send a break to vcc driver */
static int
{
/* reader */
return (vntsd_write_line(clientp,
}
/* writer */
return (VNTSD_ERR_VCC_IOCTL);
}
return (VNTSD_STATUS_CONTINUE);
}
/* genaltbrk() - handle the alternate break sequence */
static int
{
/* reader */
return (vntsd_write_line(clientp,
}
/*
* Unlike the genbrk() function we will just forward the break sequence
* on to vcc and subsequently the underlying console driver. This will
* involve sending the characters '~' and CNTRL('B').
*/
return (VNTSD_STATUS_CONTINUE);
else
return (VNTSD_STATUS_VCC_IO_ERR);
}
/*
* console_forward() - cycle client to the next console
* in the group queue.
*/
static int
{
/* forward when there are mutiple consoles in the group */
return (VNTSD_STATUS_MOV_CONS_FORWARD);
return (VNTSD_STATUS_CONTINUE);
}
/*
* console_backward() - cycle client to the previous
* console in the group queue.
*/
static int
{
/* backward when there are mutiple consoles in the group */
return (VNTSD_STATUS_MOV_CONS_BACKWARD);
return (VNTSD_STATUS_CONTINUE);
}
/* acquire_write() - acquire write access to a console. */
static int
{
int rv;
/* client is a writer */
gettext("You have write permission"))) !=
return (rv);
}
return (VNTSD_STATUS_CONTINUE);
}
/* message to client */
!= VNTSD_SUCCESS) {
return (rv);
}
/*
* TRANSLATION_NOTE
* The following string should be formatted to fit on multiple lines
* assuming a line width of at most 78 characters. There must be no
* trailing newline.
*/
gettext("Warning: another user currently "
"has write permission\nto this console and forcibly removing "
"will be lost."))) != VNTSD_SUCCESS) {
return (rv);
}
/* get client yes no */
VNTSD_EOL_LEN)) != VNTSD_SUCCESS) {
return (rv);
}
gettext("Would you like to continue?"),
&yes_no)) != VNTSD_SUCCESS) {
return (rv);
}
/* client change mind no need to acquire write access */
return (VNTSD_STATUS_CONTINUE);
}
return (VNTSD_STATUS_ACQUIRE_WRITER);
}
/* client_exit() - disconnect client from the console. */
static int
client_exit(void)
{
return (VNTSD_STATUS_RESELECT_CONS);
}
/* table for daemon commands */
/* send a break to vcc */
/* alternate break sequence */
/* exit */
/* acquire write access */
/* connect to next console in queue */
/* connect to previous console in queue */
/* help must be next to last */
/* table terminator */
{0, 0, 0}
};
void
vntsd_init_esctable_msgs(void)
{
esctable_t *p;
}
}
/* daemon_cmd_help() - print help. */
static int
{
esctable_t *p;
int rv;
VNTSD_EOL_LEN)) != VNTSD_SUCCESS) {
return (rv);
}
/*
* TRANSLATION_NOTE
* VNTSD is the name of the VNTS daemon and should not be translated.
*/
return (rv);
}
p->e_help);
} else {
}
return (rv);
}
}
return (VNTSD_STATUS_CONTINUE);
}
/* exit from daemon command */
static int
{
return (rv);
}
/*
* vntsd_process_daemon_cmd() - special commands
* "<RET>~" vntsd daemon commands
* "<RET>~~" enter '~' character
*/
int
{
esctable_t *p;
int rv;
char prev_char;
/* not a daemon command */
return (VNTSD_SUCCESS);
}
return (VNTSD_STATUS_CONTINUE);
}
/* no reentry to process_daemon_cmd */
/* read in command */
}
if (c == VNTSD_DAEMON_CMD) {
/*
* received another '~'
* a user types '~~' to get '~'
*/
return (VNTSD_SUCCESS);
}
if (p->e_char == c) {
/* found match */
}
}
/* no match, print out the help */
p--;
}
/* vntsd_set_telnet_options() - change telnet client to character mode. */
int
{
/* set client telnet options */
}
/* vntsd_telnet_cmd() process telnet commands */
int
{
char cmd;
/* not telnet cmd */
return (VNTSD_SUCCESS);
}
return (rv);
}
return (rv);
}
}
case WILL:
switch ((uint8_t)c) {
case TEL_ECHO:
case SUPRESS:
case LINEMODE:
break;
default:
break;
}
break;
case WONT:
switch ((uint8_t)c) {
case TEL_ECHO:
case SUPRESS:
case LINEMODE:
default:
break;
}
break;
case DO:
case DONT:
buf[2] = c;
break;
case BRK:
/* send break to vcc */
break;
case IP:
break;
case AYT: {
sizeof (aytresp) - 1);
break;
}
case HT:
case NOP:
return (VNTSD_STATUS_CONTINUE);
default:
break;
}
if (rv == VNTSD_SUCCESS) {
return (VNTSD_STATUS_CONTINUE);
} else {
return (rv);
}
}
/*
* vntsd_ctrl_cmd() - control keys
* read and write suspend are supported.
*/
int
{
int cmd;
/* not a supported control command */
return (VNTSD_SUCCESS);
}
if (c == START) {
/* send resume read */
cmd = 1;
return (VNTSD_STATUS_VCC_IO_ERR);
}
}
if (c == STOP) {
/* send suspend read */
cmd = 0;
return (VNTSD_STATUS_VCC_IO_ERR);
}
}
return (VNTSD_STATUS_CONTINUE);
}