libdlvlan.c revision 2
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <libdlvlan.h>
2N/A#include <libdlvnic.h>
2N/A#include <libvrrpadm.h>
2N/A
2N/A/*
2N/A * VLAN Administration Library.
2N/A *
2N/A * This library is used by administration tools such as dladm(1M) to
2N/A * configure VLANs.
2N/A */
2N/A
2N/A/*
2N/A * Returns the current attributes of the specified VLAN.
2N/A */
2N/Adladm_status_t
2N/Adladm_vlan_info(dladm_handle_t handle, datalink_id_t vlanid,
2N/A dladm_vlan_attr_t *dvap, uint32_t flags)
2N/A{
2N/A dladm_status_t status;
2N/A dladm_vnic_attr_t attr, *vnic = &attr;
2N/A
2N/A if ((status = dladm_vnic_info(handle, vlanid, vnic, flags)) !=
2N/A DLADM_STATUS_OK)
2N/A return (status);
2N/A
2N/A dvap->dv_vid = vnic->va_vid;
2N/A dvap->dv_linkid = vnic->va_link_id;
2N/A dvap->dv_force = vnic->va_force;
2N/A return (status);
2N/A}
2N/A
2N/A/*
2N/A * Create a VLAN on given link.
2N/A */
2N/Adladm_status_t
2N/Adladm_vlan_create(dladm_handle_t handle, const char *vlan, datalink_id_t linkid,
2N/A uint16_t vid, dladm_arg_list_t *proplist, uint32_t flags,
2N/A datalink_id_t *vlan_id_out)
2N/A{
2N/A return (dladm_vnic_create(handle, vlan, linkid, -1,
2N/A VNIC_MAC_ADDR_TYPE_PRIMARY, NULL, 0, NULL, NULL, 0, 0, vid,
2N/A VRRP_VRID_NONE, AF_UNSPEC, vlan_id_out, proplist,
2N/A flags | DLADM_OPT_VLAN));
2N/A}
2N/A
2N/Adladm_status_t
2N/Adladm_vlan_modify(dladm_handle_t handle, datalink_id_t linkid,
2N/A datalink_id_t lower_linkid, uint16_t vid, dladm_arg_list_t *proplist,
2N/A uint32_t flags)
2N/A{
2N/A return (dladm_vnic_modify(handle, linkid, lower_linkid, -1,
2N/A VNIC_MAC_ADDR_TYPE_UNKNOWN, NULL, 0, NULL, NULL, 0, 0, vid,
2N/A VRRP_VRID_NONE, AF_UNSPEC, proplist, flags | DLADM_OPT_VLAN));
2N/A}
2N/A
2N/A/*
2N/A * Delete a given VLAN.
2N/A */
2N/Adladm_status_t
2N/Adladm_vlan_delete(dladm_handle_t handle, datalink_id_t vlanid, uint32_t flags)
2N/A{
2N/A return (dladm_vnic_delete(handle, vlanid, flags | DLADM_OPT_VLAN));
2N/A}
2N/A
2N/Adladm_status_t
2N/Adladm_vlan_up(dladm_handle_t handle, datalink_id_t linkid)
2N/A{
2N/A return (dladm_vnic_up(handle, linkid, DLADM_OPT_VLAN));
2N/A}
2N/A
2N/A/*
2N/A * Bring down one VLAN or all active VLANs. Persistent configuration and
2N/A * linkid mapping in dlmgmtd is not changed. Downed VLAN(s) can be brought up
2N/A * with dladm_vlan_up().
2N/A */
2N/Adladm_status_t
2N/Adladm_vlan_down(dladm_handle_t handle, datalink_id_t linkid)
2N/A{
2N/A return (dladm_vnic_down(handle, linkid, DLADM_OPT_VLAN));
2N/A}