vntsdvcc.c revision 7636cb21f250f0485ca6052ffadc80ace93e6358
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Configuration and setup interface to vcc driver.
* At intialization time, vntsd opens vcc ctrl port and read initial
* configuratioa. It manages console groups, creates the listen thread,
* dynamically adds and removes virtual console within a group.
*/
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wait.h>
#include <time.h>
#include <synch.h>
#include <thread.h>
#include <signal.h>
#include "vntsd.h"
/* signal all clients that console has been deleted */
{
return (B_FALSE);
}
/* free console structure */
static void
{
}
/*
* all clients connected to a console must disconnect before
* removing a console.
*/
static void
{
/* wait for all clients disconnect from the console */
/* signal client to disconnect the console */
/* wait for clients to disconnect */
}
}
/* search for a group whose console is being deleted */
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/* search for a console that is being deleted */
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/* delete a console */
void
{
for (; ; ) {
/* get the group contains deleted console */
/* no more group has console deleted */
return;
}
for (; ; ) {
/* get the console to be deleted */
/* no more cons to delete */
break;
}
/* remove console from the group */
/* clean up the console */
/* delete group? */
/* no more console delete it */
groupp);
/* clean up the group */
break;
}
}
}
}
/* clean up a group */
void
{
/* prevent from reentry */
/* signal that the listen thread is exiting */
}
return;
}
/* walk through no cons client queue */
}
/* listen thread is exiting */
return;
}
/* signal listen thread to exit */
/* wait listen thread to exit */
}
/* free group */
}
/* allocate and initialize console structure */
static vntsd_cons_t *
{
int rv;
/* allocate console */
return (NULL);
}
/* intialize console */
/* join the group */
return (NULL);
}
return (consp);
}
/* compare tcp with group->tcp */
static boolean_t
{
}
/* allocate and initialize group */
static vntsd_group_t *
{
/* allocate group */
return (NULL);
}
/* initialize group */
if (group_name != NULL) {
}
groupp->group_name);
return (groupp);
}
/*
* Initialize a console, if console is associated with with a
* new group, intialize the group.
*/
static int
{
int rv;
*new_groupp = NULL;
/* match group by tcp port */
/* group with same tcp port found */
/* conflict group name */
"group name is different from existing group");
return (VNTSD_ERR_VCC_CTRL_DATA);
}
} else {
/* new group */
return (VNTSD_ERR_NO_MEM);
}
/* queue group to vntsdp */
if (rv != VNTSD_SUCCESS) {
return (rv);
}
*new_groupp = groupp;
}
/* intialize console */
/* no memory */
if (new_groupp != NULL) {
/* clean up new group */
}
return (VNTSD_ERR_NO_MEM);
}
return (VNTSD_SUCCESS);
}
/* create listen thread */
static boolean_t
{
char err_msg[VNTSD_LINE_LEN];
int rv;
!= 0) {
"Can not create listen thread for"
/* clean up group queue */
}
return (rv != 0);
}
/* delete a console if the console exists in the vntsd */
static void
{
/* group exists? */
(void *)&(tcp_port));
/* no such group */
return;
}
/* group exists, if console exists? */
/* no such console */
return;
}
/* console exists - delete console */
}
/* add a console */
static void
{
int rv;
char err_msg[VNTSD_LINE_LEN];
"do_add_cons():Can not add console=%d", cons_no);
/* get console configuration from vcc */
!= VNTSD_SUCCESS) {
return;
}
/* clean up the console if console was deleted and added again */
/* initialize console */
/* no memory to add this new console */
return;
}
/* new group */
/* create listen thread for this console */
if (create_listen_thread(groupp)) {
}
}
}
/* daemon wake up */
void
{
/* reason to wake up */
return;
}
case VCC_CONS_ADDED:
break;
case VCC_CONS_MISS_ADDED:
/* an added port was deleted before vntsd can process it */
return;
default:
break;
}
}
/* initial console configuration */
void
{
int i;
int num_cons;
/* num of consoles */
num_cons = 0;
return;
}
if (num_cons == 0) {
return;
}
/* allocate memory for all consoles */
return;
}
/* get console table */
"for console table\n");
return;
}
/* intialize groups and consoles */
for (i = 0; i < num_cons; i++) {
!= VNTSD_SUCCESS) {
}
}
/* create listen thread for each group */
for (; ; ) {
break;
}
}
}