libdlvnic.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 <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <libintl.h>
#include <net/if_types.h>
#include <libdladm_impl.h>
#include <libdllink.h>
#include <libdlvnic.h>
/*
* VNIC administration library.
*/
/* Limits on buffer size for VNIC_IOC_INFO request */
/* configuration database entry */
typedef struct dladm_vnic_attr_db {
typedef struct dladm_vnic_modify_attr {
int vm_mac_len;
/*
* Send a create command to the VNIC driver.
*/
static dladm_status_t
{
int rc;
if (rc < 0)
return (dladm_errno2status(errno));
return (DLADM_STATUS_OK);
}
/*
* Send a modify command to the VNIC driver.
*/
static dladm_status_t
{
int rc;
int fd;
ioc.vm_modify_mask = 0;
return (dladm_errno2status(errno));
if (rc < 0)
return (dladm_errno2status(errno));
return (DLADM_STATUS_OK);
}
/*
* Get the configuration information of the given VNIC.
*/
{
/* for now, only temporary creations are supported */
if (flags & DLADM_OPT_PERSIST)
return (dladm_errno2status(ENOTSUP));
return (dladm_errno2status(errno));
return (dladm_errno2status(ENOMEM));
}
if (rc != 0) {
goto bail;
}
bail:
return (status);
}
/*
* Remove a VNIC from the kernel.
*/
static dladm_status_t
{
int rc;
if (rc < 0)
return (dladm_errno2status(errno));
return (DLADM_STATUS_OK);
}
/*
* Convert between MAC address types and their string representations.
*/
typedef struct dladm_vnic_addr_type_s {
char *va_str;
static dladm_vnic_addr_type_t addr_types[] = {
{"fixed", VNIC_MAC_ADDR_TYPE_FIXED},
};
/*
* Return DLADM_STATUS_OK if a matching type was found,
* DLADM_STATUS_BADARG otherwise
*/
{
int i;
for (i = 0; i < NADDR_TYPES; i++) {
type = &addr_types[i];
return (DLADM_STATUS_OK);
}
}
return (DLADM_STATUS_BADARG);
}
/*
* Create a new VNIC. Update the configuration file and bring it up.
*/
{
int i, fd;
/*
* Sanity test arguments.
*/
if (flags & DLADM_OPT_PERSIST)
return (dladm_errno2status(ENOTSUP));
if (mac_len > MAXMACADDRLEN)
return (DLADM_STATUS_INVALIDMACADDRLEN);
for (i = 0; i < NADDR_TYPES; i++) {
break;
}
if (i == NADDR_TYPES)
return (DLADM_STATUS_INVALIDMACADDRTYPE);
NULL, 0)) != DLADM_STATUS_OK) {
return (status);
}
if (class == DATALINK_CLASS_VNIC)
return (DLADM_STATUS_BADARG);
name = "vnic";
}
return (status);
}
goto done;
}
done:
if (status != DLADM_STATUS_OK) {
(void) dladm_destroy_datalink_id(vnic_id,
flags & ~DLADM_OPT_PREFIX);
} else {
*vnic_id_out = vnic_id;
}
return (status);
}
/*
* Modify the properties of a VNIC.
*/
{
/* for now, only temporary creations are supported */
if (flags & DLADM_OPT_PERSIST)
return (dladm_errno2status(ENOTSUP));
if (modify_mask & DLADM_VNIC_MODIFY_ADDR) {
}
/* update the properties of the existing VNIC */
}
/*
* Delete a VNIC.
*/
{
int fd;
/* for now, only temporary deletes are supported */
if (flags & DLADM_OPT_PERSIST)
return (dladm_errno2status(ENOTSUP));
return (dladm_errno2status(errno));
if (status != DLADM_STATUS_OK)
return (status);
return (status);
}