cmd.c revision 8e6a2a040587479821d1e682a28bcef7e75f19a6
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The contents of this file are subject to the terms of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Common Development and Distribution License (the "License").
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You may not use this file except in compliance with the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * When distributing Covered Code, include this CDDL HEADER in each
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If applicable, add the following below this CDDL HEADER, with the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * fields enclosed by brackets "[]" replaced with your own identifying
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * information: Portions Copyright [yyyy] [name of copyright owner]
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#pragma ident "%Z%%M% %I% %E% SMI"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Vntsd handles two types of special commands, one is telnet
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * commands and another is vntsd special commands.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * telnet commands supported are:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Vntsd special commands are:
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Send break (~#)
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Exit (~.)
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Force write access (~w)
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Console next (~n)
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Console previous (~p)
8e6a2a040587479821d1e682a28bcef7e75f19a6lm * Help (~?)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* structure for daemon special cmd */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* genbrk() - send a break to vcc driver */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo D1(stderr, "t@%d genbrk fd=%d sockfd %d\n", thr_self(),
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* reader */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* writer */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * console_forward() - cycle client to the next console
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * in the group queue.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * console_backward() - cycle client to the previous
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * console in the group queue.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* acquire_write() - acquire write access to a console. */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* client is a writer */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* message to client */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_write_client(clientp, vntsd_eol, VNTSD_EOL_LEN))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * TRANSLATION_NOTE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The following string should be formatted to fit on multiple lines
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * assuming a line width of at most 78 characters. There must be no
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * trailing newline.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "has write permission\nto this console and forcibly removing "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "him/her will terminate\nany current write action and all work "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* get client yes no */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* client change mind no need to acquire write access */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* client_exit() - disconnect client from the console. */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* table for daemon commands */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send a break to vcc */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* acquire write access */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* connect to next console in queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* connect to previous console in queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* help must be next to last */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* table terminator */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* daemon_cmd_help() - print help. */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * TRANSLATION_NOTE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * VNTSD is the name of the VNTS daemon and should not be translated.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_write_line(clientp, gettext("VNTSD commands"))) !=
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_write_line(clientp, buf)) != VNTSD_SUCCESS) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* exit from daemon command */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* vntsd_process_daemon_cmd() - special commands */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovntsd_process_daemon_cmd(vntsd_client_t *clientp, char c)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* not a daemon command */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (clientp->status & VNTSD_CLIENT_DISABLE_DAEMON_CMD) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* no reentry to process_daemon_cmd */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo D3(stderr, "t@%d process_daemon_cmd %d %d \n", thr_self(),
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* read in command */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_read_char(clientp, &c)) != VNTSD_SUCCESS) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (p->e_char == c) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* found match */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* no match, print out the help */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* vntsd_set_telnet_options() - change telnet client to character mode. */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* set client telnet options */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t buf[] = {IAC, DONT, LINEMODE, IAC, WILL, SUPRESS, IAC, WILL,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo IAC, DONT, STATUS, IAC, DONT, FC, IAC, DONT, TM, IAC, DONT, ENV,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* vntsd_telnet_cmd() process telnet commands */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* not telnet cmd */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_read_char(clientp, &cmd)) != VNTSD_SUCCESS) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = vntsd_read_char(clientp, &c)) != VNTSD_SUCCESS) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo switch ((uint8_t)c) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo switch ((uint8_t)c) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send break to vcc */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * vntsd_ctrl_cmd() - control keys
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * read and write suspend are supported.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* not a supported control command */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (c == START) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send resume read */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send resume write */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (c == STOP) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send suspend read */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* send suspend write */