15895Syz147064 /*
25895Syz147064 * CDDL HEADER START
35895Syz147064 *
45895Syz147064 * The contents of this file are subject to the terms of the
55895Syz147064 * Common Development and Distribution License (the "License").
65895Syz147064 * You may not use this file except in compliance with the License.
75895Syz147064 *
85895Syz147064 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95895Syz147064 * or http://www.opensolaris.org/os/licensing.
105895Syz147064 * See the License for the specific language governing permissions
115895Syz147064 * and limitations under the License.
125895Syz147064 *
135895Syz147064 * When distributing Covered Code, include this CDDL HEADER in each
145895Syz147064 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155895Syz147064 * If applicable, add the following below this CDDL HEADER, with the
165895Syz147064 * fields enclosed by brackets "[]" replaced with your own identifying
175895Syz147064 * information: Portions Copyright [yyyy] [name of copyright owner]
185895Syz147064 *
195895Syz147064 * CDDL HEADER END
205895Syz147064 */
215895Syz147064 /*
22*11076SCathy.Zhou@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
235895Syz147064 * Use is subject to license terms.
245895Syz147064 */
255895Syz147064
265895Syz147064 #include <libdlvlan.h>
278275SEric Cheng #include <libdlvnic.h>
28*11076SCathy.Zhou@Sun.COM #include <libvrrpadm.h>
295895Syz147064
305895Syz147064 /*
315895Syz147064 * VLAN Administration Library.
325895Syz147064 *
335895Syz147064 * This library is used by administration tools such as dladm(1M) to
345895Syz147064 * configure VLANs.
355895Syz147064 */
365895Syz147064
375895Syz147064 /*
385895Syz147064 * Returns the current attributes of the specified VLAN.
395895Syz147064 */
405895Syz147064 dladm_status_t
dladm_vlan_info(dladm_handle_t handle,datalink_id_t vlanid,dladm_vlan_attr_t * dvap,uint32_t flags)418453SAnurag.Maskey@Sun.COM dladm_vlan_info(dladm_handle_t handle, datalink_id_t vlanid,
428453SAnurag.Maskey@Sun.COM dladm_vlan_attr_t *dvap, uint32_t flags)
435895Syz147064 {
448275SEric Cheng dladm_status_t status;
458275SEric Cheng dladm_vnic_attr_t attr, *vnic = &attr;
465895Syz147064
478453SAnurag.Maskey@Sun.COM if ((status = dladm_vnic_info(handle, vlanid, vnic, flags)) !=
488275SEric Cheng DLADM_STATUS_OK)
495895Syz147064 return (status);
505895Syz147064
518275SEric Cheng dvap->dv_vid = vnic->va_vid;
528275SEric Cheng dvap->dv_linkid = vnic->va_link_id;
538275SEric Cheng dvap->dv_force = vnic->va_force;
545895Syz147064 return (status);
555895Syz147064 }
565895Syz147064
575895Syz147064 /*
585895Syz147064 * Create a VLAN on given link.
595895Syz147064 */
605895Syz147064 dladm_status_t
dladm_vlan_create(dladm_handle_t handle,const char * vlan,datalink_id_t linkid,uint16_t vid,dladm_arg_list_t * proplist,uint32_t flags,datalink_id_t * vlan_id_out)618453SAnurag.Maskey@Sun.COM dladm_vlan_create(dladm_handle_t handle, const char *vlan, datalink_id_t linkid,
628453SAnurag.Maskey@Sun.COM uint16_t vid, dladm_arg_list_t *proplist, uint32_t flags,
638453SAnurag.Maskey@Sun.COM datalink_id_t *vlan_id_out)
645895Syz147064 {
658453SAnurag.Maskey@Sun.COM return (dladm_vnic_create(handle, vlan, linkid,
66*11076SCathy.Zhou@Sun.COM VNIC_MAC_ADDR_TYPE_PRIMARY, NULL, 0, NULL, 0, vid, VRRP_VRID_NONE,
67*11076SCathy.Zhou@Sun.COM AF_UNSPEC, vlan_id_out, proplist, flags | DLADM_OPT_VLAN));
685895Syz147064 }
695895Syz147064
705895Syz147064 /*
715895Syz147064 * Delete a given VLAN.
725895Syz147064 */
735895Syz147064 dladm_status_t
dladm_vlan_delete(dladm_handle_t handle,datalink_id_t vlanid,uint32_t flags)748453SAnurag.Maskey@Sun.COM dladm_vlan_delete(dladm_handle_t handle, datalink_id_t vlanid, uint32_t flags)
755895Syz147064 {
768453SAnurag.Maskey@Sun.COM return (dladm_vnic_delete(handle, vlanid, flags | DLADM_OPT_VLAN));
775895Syz147064 }
785895Syz147064
795895Syz147064 dladm_status_t
dladm_vlan_up(dladm_handle_t handle,datalink_id_t linkid)808453SAnurag.Maskey@Sun.COM dladm_vlan_up(dladm_handle_t handle, datalink_id_t linkid)
815895Syz147064 {
828453SAnurag.Maskey@Sun.COM return (dladm_vnic_up(handle, linkid, DLADM_OPT_VLAN));
835895Syz147064 }
84