/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <locale.h>
#include <fcntl.h>
#include <libgen.h>
static int cfg_changed;
static char *progname;
static ncall_node_t *getnodelist(int, int *, int *);
static void
{
#ifdef DEBUG
progname);
#endif
#ifdef DEBUG
gettext(" -c set or print ncall configuration\n"));
#endif
}
static void
{
return;
}
sizeof (hostid)) {
exit(1);
}
gettext("%s: unable to access the configuration: %s\n"),
exit(1);
}
gettext("%s: unable to lock the configuration: %s\n"),
exit(1);
}
}
static void
ncall_cfg_close(void)
{
gettext("%s: unable to update the configuration: %s\n"),
exit(1);
}
}
/*
* Get config from dscfg.
*/
static int
{
int rc;
if (rc == 1) {
ret = 0;
}
}
return (ret);
}
static void
ncall_print(void)
{
clnodeid = cfg_issuncluster();
} else if (rc < 0) {
"nodeid: %d\n"), progname, 0);
} else {
progname);
/* deliberately not i18n'd - "nodeid" is a keyword */
}
}
static void
{
/* remove old config */
gettext("%s: unable to update the configuration: "
exit(1);
}
}
gettext("%s: unable to update configuration: "
"data too long\n"), progname);
exit(1);
}
gettext("%s: unable to update the configuration: %s\n"),
exit(1);
}
cfg_changed = 1;
/* deliberately not i18n'd - "nodeid" is a keyword */
}
#ifdef lint
int
#else
int
#endif
{
int nsize;
int i;
int up;
(void) textdomain("ncalladm");
opterr = 0;
#ifdef DEBUG
"cip:"
#endif
"deh")) != -1) {
switch (opt) {
case 'c':
cflag = 1;
break;
case 'd':
dflag = 1;
break;
case 'e':
eflag = 1;
break;
case 'h':
usage(0);
break;
case 'i':
iflag = 1;
break;
case 'p':
pflag = 1;
break;
default:
progname);
usage(1);
break;
}
}
usage(1);
}
if (!cflag ||
usage(1);
}
}
gettext("%s: multiple options are not supported\n"),
progname);
usage(1);
}
if (!cflag) {
if (fd < 0) {
gettext("%s: unable to open %s: %s\n"),
exit(1);
}
}
if (dflag) {
/* ioctl stop into kernel */
gettext("%s: unable to disable ncall: %s\n"),
exit(1);
}
} else if (eflag) {
clnodeid = cfg_issuncluster();
cfnodeid = 0;
/* get node info */
sizeof (nodeinfo.nc_nodename));
if (rc < 0) {
gettext("%s: unable to determine hostname: %s\n"),
exit(1);
}
/*
* check that the nodeids from the cf file and
* cluster match.
*/
gettext("%s: nodeid from configuration "
"(%d) != cluster nodeid (%d)\n"),
exit(1);
}
}
if (rc == 0) {
} else if (clnodeid > 0) {
} else {
}
/* ioctl node info into kernel and start ncall */
if (rc < 0) {
gettext("%s: unable to enable ncall: %s\n"),
exit(1);
}
}
gettext("%s: unable to get node info\n"),
progname);
exit(1);
}
}
if (iflag) {
char *mname;
char *pnodestr;
nodes[0].nc_nodename);
/*
* determine which slot is the mirror node.
*/
if (mnode != -1) {
for (i = 1; i < nsize; i++) {
break;
}
}
}
mnode = -1;
}
/*
* See if we need to translate the node strings.
*/
if (nsize > 1) {
for (i = 1; i < nsize; i++) {
/*
* Don't print the mirror twice.
*/
nodes[i].nc_nodename,
}
}
}
}
if (pflag) {
gettext("%s: hostname '%s' is too long\n"),
exit(1);
}
up = 0;
} else {
/* not self, so ask kernel */
/* strlen(ping) checked above */
}
/* model the ping messages on ping(1m) */
if (up < 0) {
gettext("%s: unable to ping host '%s': %s\n"),
exit(1);
} else if (up > 0) {
} else {
exit(1);
}
}
}
if (cflag) {
ncall_print();
return (0);
}
gettext("%s: nodeid \"%s\" is not an "
exit(1);
}
clnodeid = cfg_issuncluster();
gettext("%s: nodeid from command line "
"(%d) != cluster nodeid (%d)\n"),
exit(1);
}
}
if (!cflag) {
}
return (0);
}
/*
* return a pointer to a list of currently configured
* nodes.
* Return the number of nodes via the nodesizep pointer.
* Return the mirror nodeid via the mirrorp pointer.
* Return NULL on errors.
*/
static ncall_node_t *
{
int maxsize;
int cnt;
int mirror;
int nonet;
/*
* Get this host info and mirror nodeid.
*/
if (mirror < 0) {
return (NULL);
}
/*
* See if we need to allocate the buffer.
*/
nonet = 0;
if (maxsize < 1) {
maxsize = 1;
nonet = 1;
}
if (nodelist) {
if (nonet == 0) {
/*
* fetch the node data.
*/
if (cnt > 0) {
} else {
*nodesizep = 0;
}
} else {
*nodesizep = 1;
/*
* Although we know the mirror nodeid, there
* is no point in returning it as we have
* no information about any other hosts.
*/
*mirrorp = -1;
}
}
return (noderet);
}