libdlmgmt.c revision d62bc4badc1c1f1549c961cfb8b420e650e1272b
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <door.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
#include <libdladm.h>
#include <libdladm_impl.h>
#include <libdllink.h>
#include <libdlmgmt.h>
/*
* Table of data type sizes indexed by dladm_datatype_t.
*/
static size_t dladm_datatype_size[] = {
0, /* DLADM_TYPE_STR, use strnlen() */
sizeof (boolean_t), /* DLADM_TYPE_BOOLEAN */
sizeof (uint64_t) /* DLADM_TYPE_UINT64 */
};
static dladm_status_t
{
int fd;
return (dladm_errno2status(errno));
if (status != DLADM_STATUS_OK)
return (status);
/*
* The size of the input rbuf is not big enough so that
* the door allocate the rbuf itself. In this case, simply
* think something wrong with the door call.
*/
return (DLADM_STATUS_TOOSMALL);
}
return (DLADM_STATUS_FAILED);
else
return (status);
}
/*
* Allocate a new linkid with the given name. Return the new linkid.
*/
{
return (DLADM_STATUS_BADARG);
}
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Destroy the given link ID.
*/
{
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Remap a given link ID to a new name.
*/
{
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Make a given link ID active.
*/
{
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Create a new link with the given name. Return the new link's handle
*/
{
return (DLADM_STATUS_BADARG);
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* An active physical link reported by the dlmgmtd daemon might not be active
* anymore as this link might be removed during system shutdown. Check its
* real status by calling dladm_phys_info().
*/
{
if (status == DLADM_STATUS_NOTFOUND) {
/*
* No active status, this link was removed. Update its status
* in the daemon and delete all active linkprops.
*/
(*flagsp) &= ~DLMGMT_ACTIVE;
}
return (status);
}
/*
* Walk each entry in the data link configuration repository and
* call fn on the linkid and arg.
*/
{
return (DLADM_STATUS_BADARG);
do {
if (status != DLADM_STATUS_OK) {
/*
* done with walking
*/
break;
}
break;
}
/*
* An active physical link reported by the dlmgmtd
* daemon might not be active anymore. Check its
* real status.
*/
continue;
}
continue;
}
break;
} while (linkid != DATALINK_INVALID_LINKID);
return (status);
}
/*
* Get the link properties structure for the given link.
*/
{
return (DLADM_STATUS_BADARG);
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Commit the given link to the data link configuration repository so
* that it will persist across reboots.
*/
{
if (conf == DLADM_INVALID_CONF)
return (DLADM_STATUS_BADARG);
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Given a link ID and a key, get the matching information from
* data link configuration repository.
*/
{
return (DLADM_STATUS_BADARG);
}
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK)
goto done;
done:
return (status);
}
/*
* Get the link ID that is associated with the given name.
*/
{
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
/*
* An active physical link reported by the dlmgmtd daemon
* might not be active anymore. Check and set its real status.
*/
if (status != DLADM_STATUS_OK)
return (status);
}
DLADM_OPT_PERSIST : 0;
}
return (DLADM_STATUS_OK);
}
/*
* Get the link name that is associated with the given id.
*/
{
return (DLADM_STATUS_BADARG);
}
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_TOOSMALL);
}
/*
* An active physical link reported by the dlmgmtd daemon
* might not be active anymore. Check and set its real status.
*/
if (status != DLADM_STATUS_OK)
return (status);
}
DLADM_OPT_ACTIVE : 0;
DLADM_OPT_PERSIST : 0;
}
return (DLADM_STATUS_OK);
}
/*
* Set the given attr with the given attrval for the given link.
*/
{
return (DLADM_STATUS_BADARG);
if (type == DLADM_TYPE_STR)
else
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK)
goto done;
done:
return (status);
}
/*
* Unset the given attr the given link.
*/
{
return (DLADM_STATUS_BADARG);
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Remove the given link ID and its entry from the data link configuration
* repository.
*/
{
&rsize);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
}
/*
* Free the contents of the link structure.
*/
void
{
if (conf == DLADM_INVALID_CONF)
return;
&rsize);
}