/*
* 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.
*/
/*
* supporting modules.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wait.h>
#include <time.h>
#include <thread.h>
#include <signal.h>
#include <ctype.h>
#include <langinfo.h>
#include <libintl.h>
#include <syslog.h>
#include "vntsd.h"
#include "chars.h"
/* vntsd_write_line() - write a line to TCP client */
int
{
int rv;
if (rv == VNTSD_SUCCESS) {
}
return (rv);
}
/* vntsd_write_lines() write one or more lines to client. */
int
{
char *buf;
char *line;
char *endofline;
return (VNTSD_ERR_NO_MEM);
}
*endofline = '\0';
}
else
}
return (VNTSD_SUCCESS);
}
/* vntsd_get_yes_no() - read in a "y" or "n" */
int
{
char c;
int rv;
/* create [y/n] prompt */
for (; ; ) {
!= VNTSD_SUCCESS) {
return (rv);
}
return (rv);
}
!= VNTSD_SUCCESS) {
return (rv);
}
/* echo */
return (rv);
}
VNTSD_EOL_LEN)) != VNTSD_SUCCESS) {
return (rv);
}
c = tolower(c);
if (c == *nl_langinfo(YESSTR)) {
return (VNTSD_SUCCESS);
}
if (c == *nl_langinfo(NOSTR)) {
return (VNTSD_SUCCESS);
}
gettext("Invalid response. Try again.")))
!= VNTSD_SUCCESS) {
return (rv);
}
}
/*NOTREACHED*/
return (0);
}
/* vntsd_open_vcc() - open a vcc port */
int
{
int drvfd;
int sz;
char *path;
return (-1);
}
for (; ; ) {
!= VNTSD_SUCCESS) {
break;
}
} else {
break;
}
}
if (drvfd < 0) {
return (-1);
}
return (drvfd);
}
/* vntsd_cons_by_consno() - match a console structure to cons no */
{
return (B_FALSE);
}
}
/* vntsd_write_client() write to telnet client */
int
{
int rv;
/* write to client */
/* client has output, reset timer */
return (rv);
}
/* vntsd_write_fd() write to tcp socket file descriptor */
int
{
int n;
while (sz > 0) {
if (n < 0) {
return (VNTSD_STATUS_INTR);
}
return (VNTSD_STATUS_CLIENT_QUIT);
}
if (n == 0) {
return (VNTSD_STATUS_CLIENT_QUIT);
}
sz -= n;
}
return (VNTSD_SUCCESS);
}
/*
* vntsd_read_char() - read a char from TCP Clienti. Returns:
* VNTSD_SUCCESS, VNTSD_STATUS_CLIENT_QUIT or VNTSD_STATUS_INTR
*/
int
{
int n;
int rv;
/* attach to timer */
return (rv);
}
/* detach from timer */
return (rv);
}
if (n == 1) {
return (VNTSD_SUCCESS);
}
if (n == 0) {
return (VNTSD_STATUS_CLIENT_QUIT);
}
/*
* read error or wake up by signal, either console is being removed or
* timeout occurs.
*/
return (VNTSD_STATUS_INTR);
}
/* any other error, we close client */
return (VNTSD_STATUS_CLIENT_QUIT);
}
/*
* vntsd_read_data() - handle special commands
* such as telnet, daemon and ctrl cmds. Returns:
* from vntsd_read_char:
* VNTSD_STATUS_CLIENT_QUIT
* VNTSD_STATUS_INTR
* from vnts_process_daemon_cmd:
* VNTSD_STATUS_RESELECT_CONS
* VNTSD_STATUS_MOV_CONS_FORWARD
* VNTSD_STATUS_MOV_CONS_BACKWARD
* VNTSD_STATUS_ACQURE_WRITER
* VNTSD_STATUS_CONTINUE
* from vntsd_telnet_cmd
* VNTSD_STATUS_CONTINUE
*/
int
{
int rv;
for (; ; ) {
return (rv);
}
/* daemon cmd? */
if (rv == VNTSD_SUCCESS) {
/* telnet cmd? */
}
if (rv == VNTSD_STATUS_CONTINUE) {
/*
* either a daemon cmd or a telnet cmd
* was processed.
*/
continue;
}
return (rv);
}
/*NOTREACHED*/
return (0);
}
/* vntsd_read_line() - read a line from TCP client */
int
{
char c;
int rv;
int out_sz = 0;
for (; ; ) {
return (rv);
}
if (c == BS) {
/* back */
return (rv);
}
c = ' ';
return (rv);
}
buf--;
out_sz--;
continue;
}
/* echo */
return (rv);
}
*buf++ = c;
out_sz++;
if (c == CR) {
/* end of line */
return (VNTSD_SUCCESS);
}
return (VNTSD_SUCCESS);
}
}
/*NOTREACHED*/
return (0);
}
/* free a client */
void
{
}
}
/* check if a vcc console port still ok */
{
int rv;
/* construct current configuration */
/* call vcc to verify */
if (rv != VNTSD_SUCCESS) {
return (B_FALSE);
}
/* port is gone */
return (B_FALSE);
}
/* port is ok */
return (B_TRUE);
}
/* add to total if a console is alive */
static boolean_t
{
int rv;
if (rv == VNTSD_STATUS_CONTINUE) {
(*num_cons)++;
}
return (B_FALSE);
}
/* total alive consoles in a group */
int
{
&num_cons);
return (num_cons);
}
/* vntsd_log() log function for errors */
void
{
int critical = 0;
switch (status) {
case VNTSD_SUCCESS:
status_msg = "STATUS_OK";
break;
case VNTSD_STATUS_CONTINUE:
status_msg = "CONTINUE";
break;
case VNTSD_STATUS_EXIT_SIG:
critical = 1;
status_msg = "KILL SIGNAL RECV";
break;
case VNTSD_STATUS_SIG:
status_msg = "SIG RECV";
break;
status_msg = "Warining NO HOST NAME";
break;
case VNTSD_STATUS_CLIENT_QUIT:
status_msg = "CLIENT CLOSED GROUP CONNECTION";
break;
status_msg = "CLIENT RESELECTS CONSOLE";
break;
case VNTSD_STATUS_VCC_IO_ERR:
status_msg = "CONSOLE WAS DELETED";
break;
status_msg = "MOVE CONSOLE FORWARD";
break;
status_msg = "MOVE CONSOLE BACKWARD";
break;
status_msg = "FORCE CONSOLE WRITE";
break;
case VNTSD_STATUS_INTR:
status_msg = "RECV SIGNAL";
break;
status_msg = "DELETING CONSOLE";
break;
case VNTSD_STATUS_NO_CONS:
status_msg = "All console(s) in the group have been deleted.";
break;
critical = 1;
status_msg = "VNTSD_STATUS_AUTH_ENABLED";
break;
case VNTSD_ERR_NO_MEM:
critical = 1;
status_msg = "NO MEMORY";
break;
case VNTSD_ERR_NO_DRV:
critical = 1;
status_msg = "NO VCC DRIVER";
break;
case VNTSD_ERR_WRITE_CLIENT:
status_msg = "WRITE CLIENT ERR";
break;
case VNTSD_ERR_EL_NOT_FOUND:
critical = 1;
status_msg = "ELEMENT_NOT_FOUND";
break;
case VNTSD_ERR_VCC_CTRL_DATA:
critical = 1;
status_msg = "VCC CTRL DATA ERROR";
break;
case VNTSD_ERR_VCC_POLL:
critical = 1;
status_msg = "VCC POLL ERROR";
break;
case VNTSD_ERR_VCC_IOCTL:
critical = 1;
status_msg = "VCC IOCTL ERROR";
break;
case VNTSD_ERR_VCC_GRP_NAME:
critical = 1;
status_msg = "VCC GROUP NAME ERROR";
break;
critical = 1;
status_msg = "FAIL TO CREATE LISTEN THREAD";
break;
case VNTSD_ERR_CREATE_WR_THR:
critical = 1;
status_msg = "FAIL TO CREATE WRITE THREAD";
break;
critical = 1;
status_msg = "FAIL TO ADD A CONSOLE";
break;
case VNTSD_ERR_LISTEN_SOCKET:
critical = 1;
status_msg = "LISTEN SOCKET ERROR";
break;
case VNTSD_ERR_LISTEN_OPTS:
critical = 1;
status_msg = "SET SOCKET OPTIONS ERROR";
break;
case VNTSD_ERR_LISTEN_BIND:
critical = 1;
status_msg = "BIND SOCKET ERROR";
break;
case VNTSD_STATUS_ACCEPT_ERR:
critical = 1;
status_msg = "LISTEN ACCEPT ERROR";
break;
critical = 1;
status_msg = "CREATE CONSOLE THREAD ERROR ";
break;
case VNTSD_ERR_SIG:
critical = 1;
status_msg = "RECV UNKNOWN SIG";
break;
case VNTSD_ERR_UNKNOWN_CMD:
critical = 1;
status_msg = "RECV UNKNOWN COMMAND";
break;
case VNTSD_ERR_CLIENT_TIMEOUT:
status_msg = "CLOSE CLIENT BECAUSE TIMEOUT";
break;
default:
status_msg = "Unknown status recv";
break;
}
if (critical) {
}
#ifdef DEBUG
#endif
}