ipmp_query.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* IPMP query interfaces (PSARC/2002/615).
*/
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "ipmp_impl.h"
#include "ipmp_mpathd.h"
#include "ipmp_query_impl.h"
static int ipmp_querydone(ipmp_state_t *, int);
/*
* Using `statep', send a query request for `type' to in.mpathd, and if
* necessary wait until at least `endtp' for a response. Returns an IPMP
* error code. If successful, the caller may then read additional query
* information through ipmp_readinfo(), and must eventually call
* ipmp_querydone() to complete the query operation. Only one query may be
* outstanding on a given `statep' at a time.
*/
static int
{
int retval;
switch (type) {
case IPMP_GROUPINFO:
break;
case IPMP_IFINFO:
break;
case IPMP_GROUPLIST:
case IPMP_SNAP:
break;
default:
assert(0);
}
return (IPMP_FAILURE);
if (retval != IPMP_SUCCESS)
return (retval);
if (retval != IPMP_SUCCESS)
if (retval != IPMP_SUCCESS)
return (IPMP_SUCCESS);
}
/*
* Using `statep', read a query response of type `infotype' into a dynamically
* allocated buffer pointed to by `*infop', before the current time becomes
* `endtp'. Returns an IPMP error code.
*/
static int
{
int retval;
if (retval != IPMP_SUCCESS)
return (retval);
return (IPMP_EPROTO);
}
return (IPMP_SUCCESS);
}
/*
* Complete the query operation started in ipmp_sendquery(). The interface is
* designed to be easy to use in the `return' statement of a function, and
* thus returns the passed in `retval' and preserves `errno'.
*/
static int
{
return (retval);
}
/*
* Using `handle', get the group list and store the results in a dynamically
* allocated buffer pointed to by `*grlistpp'. Returns an IPMP error code.
*/
int
{
int retval;
}
if (retval != IPMP_SUCCESS)
return (retval);
}
/*
* Free the group list pointed to by `grlistp'.
*/
void
{
}
/*
* Using `handle', get the group information associated with group `name' and
* store the results in a dynamically allocated buffer pointed to by
* `*grinfopp'. Returns an IPMP error code.
*/
int
{
int retval;
return (IPMP_EUNKGROUP);
}
if (retval != IPMP_SUCCESS)
return (retval);
if (retval != IPMP_SUCCESS)
if (retval != IPMP_SUCCESS)
else
}
/*
* Free the group information pointed to by `grinfop'.
*/
void
{
}
/*
* Using `handle', get the interface information associated with interface
* `name' and store the results in a dynamically allocated buffer pointed to
* by `*ifinfopp'. Returns an IPMP error code.
*/
int
{
int retval;
return (IPMP_EUNKIF);
}
if (retval != IPMP_SUCCESS)
return (retval);
}
/*
* Free the interface information pointed to by `ifinfop'.
*/
void
{
}
/*
* Check if `buf' has a NUL byte in its first `bufsize' bytes.
*/
static boolean_t
{
while (bufsize-- > 0) {
return (B_TRUE);
}
return (B_FALSE);
}
/*
* Check that the TLV triplet named by `type', `len' and `value' is correctly
* formed.
*/
static boolean_t
{
unsigned int i;
switch (type) {
case IPMP_IFLIST:
if (len < IPMP_IFLIST_MINSIZE ||
return (B_FALSE);
return (B_FALSE);
break;
case IPMP_IFINFO:
if (len != sizeof (ipmp_ifinfo_t))
return (B_FALSE);
return (B_FALSE);
break;
case IPMP_GROUPLIST:
if (len < IPMP_GROUPLIST_MINSIZE ||
return (B_FALSE);
return (B_FALSE);
break;
case IPMP_GROUPINFO:
if (len != sizeof (ipmp_groupinfo_t))
return (B_FALSE);
return (B_FALSE);
break;
case IPMP_SNAP:
if (len != sizeof (ipmp_snap_t))
return (B_FALSE);
break;
default:
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Create a group list with signature `sig' containing `ngroup' groups named
* by `groups'. Returns a pointer to the new group list on success, or NULL
* on failure.
*/
char (*groups)[LIFGRNAMSIZ])
{
unsigned int i;
return (NULL);
for (i = 0; i < ngroup; i++)
return (grlistp);
}
/*
* Clone the group list named by `grlistp'. Returns a pointer to the clone on
* success, or NULL on failure.
*/
{
}
/*
* Create an interface information structure for interface `name' and
* associate `group', `state' and `type' with it. Returns a pointer to the
* interface information on success, or NULL on failure.
*/
{
return (NULL);
return (ifinfop);
}
/*
* Clone the interface information named by `ifinfop'. Returns a pointer to
* the clone on success, or NULL on failure.
*/
{
}
/*
* Create a group named `name' with signature `sig', in state `state', and
* with the `nif' interfaces named by `ifs' as members. Returns a pointer
* to the new group on success, or NULL on failure.
*/
{
unsigned int i;
return (NULL);
return (NULL);
}
for (i = 0; i < nif; i++)
return (grinfop);
}
/*
* Clone the group information named by `grinfop'. Returns a pointer to
* the clone on success, or NULL on failure.
*/
{
}
/*
* Set the query context associated with `handle' to `qcontext', which must be
* either IPMP_QCONTEXT_LIVE or IPMP_QCONTEXT_SNAP. Upon success, any
* previous snapshot associated with `handle' is discarded. Returns an IPMP
* error code.
*/
int
{
int retval;
switch (qcontext) {
case IPMP_QCONTEXT_LIVE:
break;
case IPMP_QCONTEXT_SNAP:
if (retval != IPMP_SUCCESS)
return (retval);
break;
default:
return (IPMP_EINVAL);
}
return (IPMP_SUCCESS);
}
/*
* Create an empty snapshot. Returns a pointer to the snapshot on success,
* or NULL on failure.
*/
ipmp_snap_create(void)
{
return (NULL);
return (snap);
}
/*
* Free all of the resources associated with snapshot `snap'.
*/
void
{
}
}
}
/*
* Add the group information in `grinfop' to the snapshot named by `snap'.
* Returns an IPMP error code.
*/
int
{
/*
* If the information for this group is already in the snapshot,
* in.mpathd is broken.
*/
return (IPMP_EPROTO);
return (IPMP_ENOMEM);
return (IPMP_SUCCESS);
}
/*
* Add the interface information in `ifinfop' to the snapshot named by `snap'.
* Returns an IPMP error code.
*/
int
{
/*
* If the information for this interface is already in the snapshot,
* in.mpathd is broken.
*/
return (IPMP_EPROTO);
return (IPMP_ENOMEM);
return (IPMP_SUCCESS);
}
/*
* Retrieve the information for the group `name' in snapshot `snap'.
* Returns a pointer to the group information on success, or NULL on failure.
*/
static ipmp_groupinfo_t *
{
break;
}
}
/*
* Retrieve the information for the interface `name' in snapshot `snap'.
* Returns a pointer to the interface information on success, or NULL on
* failure.
*/
static ipmp_ifinfo_t *
{
break;
}
}
/*
* Using `statep', take a snapshot of the IPMP subsystem and if successful
* return it in a dynamically allocated snapshot pointed to by `*snapp'.
* Returns an IPMP error code.
*/
static int
{
int retval;
void *infop;
snap = ipmp_snap_create();
return (IPMP_ENOMEM);
if (retval != IPMP_SUCCESS) {
return (retval);
}
if (retval != IPMP_SUCCESS) {
}
/*
* Using the information in the passed `osnap' snapshot, build up our
* own snapshot. If we receive more than one grouplist, or more than
* the expected number of interfaces or groups, then bail out. Note
* that there's only so much we can do to check that the information
* sent by in.mpathd makes sense. We know there will always be at
* least one TLV (IPMP_GROUPLIST).
*/
do {
if (retval != IPMP_SUCCESS)
goto fail;
goto fail;
}
switch (type) {
case IPMP_GROUPLIST:
break;
}
break;
case IPMP_IFINFO:
break;
}
break;
case IPMP_GROUPINFO:
break;
}
/*
* An IPMP_IFLIST TLV always follows the
* IPMP_GROUPINFO TLV; read it in.
*/
if (retval != IPMP_SUCCESS)
break;
if (retval != IPMP_SUCCESS)
break;
default:
break;
}
fail:
if (retval != IPMP_SUCCESS) {
}
}