vna.c revision da14cebe459d3275048785f25bd869cb09b5307f
/*
* 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.
*/
/*
* This utility constitutes a private interface - it will be removed
* in a future release of Solaris. Neither users nor other software
* components can depend on the actions or existence of the utility.
*/
#include <stdio.h>
#include <string.h>
#include <sys/ethernet.h>
#include <libdllink.h>
#include <libdlvnic.h>
#include <libdlpi.h>
typedef struct vnic_attr {
char *name;
} vnic_attr_t;
/*ARGSUSED*/
static int
{
char vnic[MAXLINKNAMELEN];
char link[MAXLINKNAMELEN];
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
sizeof (vnic)) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
sizeof (link)) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
static void
v_list(void)
{
}
static int
{
char linkname[MAXLINKNAMELEN];
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
return (DLADM_WALK_CONTINUE);
attr.va_mac_len) != 0) {
return (DLADM_WALK_CONTINUE);
}
/* Names must match. */
sizeof (linkname)) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_TERMINATE);
}
/*
* Broadcasst a loopback ethernet packet via "link"
*/
static int
v_broadcast(char *link)
{
int rval;
struct ether_header eh;
return (-1);
}
dlpi_close(dh);
return (-1);
}
dlpi_close(dh);
return (-1);
}
if (dlinfo.di_bcastaddrlen == 0) {
"no broadcast address for link: %s\n", link);
dlpi_close(dh);
return (-1);
}
if (rval != DLPI_SUCCESS) {
dlpi_close(dh);
return (-1);
}
dlpi_close(dh);
return (0);
}
/*
* Print out the link name of the VNIC.
*/
static int
{
struct ether_addr *ea;
char vnic[MAXLINKNAMELEN];
char buf[DLADM_STRSIZE];
return (-1);
}
return (-1);
}
/*
* If a VNIC already exists over the specified link
* with this MAC address and name, use it.
*/
/*
* None found, so create.
*/
if (status != DLADM_STATUS_OK) {
return (-1);
}
} else {
}
sizeof (vnic))) != DLADM_STATUS_OK) {
return (-1);
}
/*
* Before we hand this newly created vnic over to caller, we want to
* broadcast its MAC address to make sure that the <MAC,port> mapping
* in the switch is correct.
*/
if (created)
(void) v_broadcast(vnic);
return (0);
}
/*
* v_remove() takes VNIC link name as the argument.
*/
static int
{
char buf[DLADM_STRSIZE];
return (-1);
}
if (status != DLADM_STATUS_OK) {
return (-1);
}
return (0);
}
int
{
switch (argc) {
case 1:
/* List operation. */
v_list();
return (0);
/* NOTREACHED */
case 2:
/* Remove operation. */
/* NOTREACHED */
case 3:
case 4:
/* Add operation. */
/* NOTREACHED */
default:
"must have 0, 1, 2 or 3.\n");
return (-1);
/* NOTREACHED */
}
/* NOTREACHED */
}