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 /* 225895Syz147064 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 235895Syz147064 * Use is subject to license terms. 245895Syz147064 */ 255895Syz147064 265895Syz147064 #include <libdlvlan.h> 278275SEric Cheng #include <libdlvnic.h> 285895Syz147064 295895Syz147064 /* 305895Syz147064 * VLAN Administration Library. 315895Syz147064 * 325895Syz147064 * This library is used by administration tools such as dladm(1M) to 335895Syz147064 * configure VLANs. 345895Syz147064 */ 355895Syz147064 365895Syz147064 /* 375895Syz147064 * Returns the current attributes of the specified VLAN. 385895Syz147064 */ 395895Syz147064 dladm_status_t 40*8453SAnurag.Maskey@Sun.COM dladm_vlan_info(dladm_handle_t handle, datalink_id_t vlanid, 41*8453SAnurag.Maskey@Sun.COM dladm_vlan_attr_t *dvap, uint32_t flags) 425895Syz147064 { 438275SEric Cheng dladm_status_t status; 448275SEric Cheng dladm_vnic_attr_t attr, *vnic = &attr; 455895Syz147064 46*8453SAnurag.Maskey@Sun.COM if ((status = dladm_vnic_info(handle, vlanid, vnic, flags)) != 478275SEric Cheng DLADM_STATUS_OK) 485895Syz147064 return (status); 495895Syz147064 508275SEric Cheng dvap->dv_vid = vnic->va_vid; 518275SEric Cheng dvap->dv_linkid = vnic->va_link_id; 528275SEric Cheng dvap->dv_force = vnic->va_force; 535895Syz147064 return (status); 545895Syz147064 } 555895Syz147064 565895Syz147064 /* 575895Syz147064 * Create a VLAN on given link. 585895Syz147064 */ 595895Syz147064 dladm_status_t 60*8453SAnurag.Maskey@Sun.COM dladm_vlan_create(dladm_handle_t handle, const char *vlan, datalink_id_t linkid, 61*8453SAnurag.Maskey@Sun.COM uint16_t vid, dladm_arg_list_t *proplist, uint32_t flags, 62*8453SAnurag.Maskey@Sun.COM datalink_id_t *vlan_id_out) 635895Syz147064 { 64*8453SAnurag.Maskey@Sun.COM return (dladm_vnic_create(handle, vlan, linkid, 65*8453SAnurag.Maskey@Sun.COM VNIC_MAC_ADDR_TYPE_PRIMARY, NULL, 0, NULL, 0, vid, vlan_id_out, 66*8453SAnurag.Maskey@Sun.COM proplist, flags | DLADM_OPT_VLAN)); 675895Syz147064 } 685895Syz147064 695895Syz147064 /* 705895Syz147064 * Delete a given VLAN. 715895Syz147064 */ 725895Syz147064 dladm_status_t 73*8453SAnurag.Maskey@Sun.COM dladm_vlan_delete(dladm_handle_t handle, datalink_id_t vlanid, uint32_t flags) 745895Syz147064 { 75*8453SAnurag.Maskey@Sun.COM return (dladm_vnic_delete(handle, vlanid, flags | DLADM_OPT_VLAN)); 765895Syz147064 } 775895Syz147064 785895Syz147064 dladm_status_t 79*8453SAnurag.Maskey@Sun.COM dladm_vlan_up(dladm_handle_t handle, datalink_id_t linkid) 805895Syz147064 { 81*8453SAnurag.Maskey@Sun.COM return (dladm_vnic_up(handle, linkid, DLADM_OPT_VLAN)); 825895Syz147064 } 83