/*
* 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.
* Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <stddef.h>
#include <assert.h>
#include <errno.h>
#include <ofmt.h>
#include <libilb.h>
#include "ilbadm.h"
};
};
typedef struct sg_export_arg {
typedef struct arg_struct {
int flags;
char *o_str;
} list_arg_t;
typedef struct sg_srv_o_struct {
char *sgname;
};
};
extern char *optarg;
static boolean_t
{
return (B_TRUE);
}
static boolean_t
{
return (B_TRUE);
}
static boolean_t
{
int port;
if (port == 0)
*buf = '\0';
else
} else {
if (port == 0)
*buf = '\0';
else
}
return (B_TRUE);
}
static boolean_t
{
return (B_TRUE);
}
{
return (ILBADM_OK);
}
/*
* This function is always called via ilb_walk_servergroups()
* and so must return libilb errors.
* That's why we need to retain currently unused "h" argument
*/
/* ARGSUSED */
static ilb_status_t
void *arg)
{
int oflags = 0;
ofp = sgfields_v6;
else
ofp = sgfields_v4;
oflags |= OFMT_PARSABLE;
if (oerr != OFMT_SUCCESS) {
char e[80];
return (ILB_STATUS_GENERIC);
}
}
return (ILB_STATUS_OK);
}
if (h_minport == 0)
*port_str = '\0';
else
return (ILB_STATUS_OK);
}
{
if (sg->sgd_srvcount == 0) {
}
}
/* ARGSUSED */
{
int c;
switch ((char)c) {
break;
break;
" for %c"), (char)optopt);
rc = ILBADM_LIBERR;
goto out;
/* not reached */
break;
}
}
exit(1);
}
" names for -o"));
exit(1);
}
if (rclib != ILB_STATUS_OK)
goto out;
(void*)&larg);
if (rclib != ILB_STATUS_OK)
rc = ILBADM_LIBERR;
} else {
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
break;
}
}
}
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
if (rclib != ILB_STATUS_OK) {
/*
* The show function returns ILB_STATUS_GENERIC after printing
* out an error message. So we don't need to print it again.
*/
if (rclib != ILB_STATUS_GENERIC)
rc = ILBADM_LIBERR;
}
return (rc);
}
{
if (s != NULL) {
}
return (s);
}
static ilbadm_status_t
{
int count;
return (rc);
}
static ilbadm_status_t
{
int count;
return (rc);
}
static ilbadm_status_t
int flags)
{
return (ILBADM_LIBERR);
srv);
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
/* if we created the SG, we bail out */
if (cmd == cmd_create_sg)
return (rc);
}
} else {
srv);
/* if we fail, we tell user and continue */
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
gettext("cannot remove %s from %s: %s"),
ilb_errstr(rclib));
}
}
/*
* list_next returns NULL instead of cycling back to head
* so we don't have to check for list_head explicitly.
*/
};
return (rc);
}
static void
{
return;
}
static void
{
free(s);
}
{
int c;
int flags = 0;
switch ((char)c) {
case 's':
break;
case ':':
" %c"), (char)optopt);
rc = ILBADM_LIBERR;
break;
case '?':
default:
/* not reached */
break;
}
goto out;
}
" to 'create-servergroup' subcommand"
" description in ilbadm(1M)"));
rc = ILBADM_LIBERR;
goto out;
}
ILB_SGNAME_SZ - 1);
rc = ILBADM_LIBERR;
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
if (rclib != ILB_STATUS_OK)
goto out;
/* we create a servergroup with all servers enabled */
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
}
return (rc);
}
{
int c;
int flags = 0;
switch ((char)c) {
case 's':
break;
case ':':
" %c"), (char)optopt);
rc = ILBADM_LIBERR;
break;
case '?':
/* not reached */
break;
}
goto out;
}
" to 'add-server' subcommand description in ilbadm(1M)"));
rc = ILBADM_LIBERR;
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
/* A server is added enabled */
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
return (rc);
}
/* ARGSUSED */
static ilbadm_status_t
{
int i;
if (argc < 2) {
" (server specification)"));
rc = ILBADM_LIBERR;
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
/* enable-server and disable-server only accepts serverids */
if (argv[i][0] != ILB_SRVID_PREFIX) {
goto out;
}
/* to do: check length */
switch (cmd) {
case cmd_enable_server:
break;
case cmd_disable_server:
break;
}
/* if we can't find a given server ID, just plough on */
if (rclib == ILB_STATUS_ENOENT) {
rc = ILBADM_LIBERR;
continue;
}
if (rclib != ILB_STATUS_OK)
break;
}
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
}
return (rc);
}
{
}
{
}
/* ARGSUSED */
{
int c;
switch ((char)c) {
case 's':
break;
case ':':
" %c"), (char)optopt);
rc = ILBADM_LIBERR;
break;
case '?':
/* not reached */
break;
}
goto out;
}
/* we need servergroup name and at least one serverID to remove */
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
return (rc);
}
{
char *sgname;
if (argc != 2) {
" delete-servergroup groupname"));
rc = ILBADM_LIBERR;
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
}
return (rc);
}
static int
{
if (srv->sd_minport != 0) {
int inc;
/* to do: if service name was given, print that, not number */
else
return (-1);
}
return (len);
}
/*
* this is called by ilb_walk_servers(), therefore we return ilb_status_t
* not ilbadm_status, and retain an unused function argument
*/
/* ARGSUSED */
void *arg)
{
return (ILB_STATUS_OK);
return (ILB_STATUS_OK);
}
{
if (sg->sgd_srvcount == 0)
return (ILB_STATUS_OK);
if (rc != ILB_STATUS_OK)
goto out;
out:
return (rc);
}
{
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
}
return (rc);
}