1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #include <libdlvlan.h> 27 #include <libdlvnic.h> 28 #include <libvrrpadm.h> 29 30 /* 31 * VLAN Administration Library. 32 * 33 * This library is used by administration tools such as dladm(8) to 34 * configure VLANs. 35 */ 36 37 /* 38 * Returns the current attributes of the specified VLAN. 39 */ 40 dladm_status_t 41 dladm_vlan_info(dladm_handle_t handle, datalink_id_t vlanid, 42 dladm_vlan_attr_t *dvap, uint32_t flags) 43 { 44 dladm_status_t status; 45 dladm_vnic_attr_t attr, *vnic = &attr; 46 47 if ((status = dladm_vnic_info(handle, vlanid, vnic, flags)) != 48 DLADM_STATUS_OK) 49 return (status); 50 51 dvap->dv_vid = vnic->va_vid; 52 dvap->dv_linkid = vnic->va_link_id; 53 dvap->dv_force = vnic->va_force; 54 return (status); 55 } 56 57 /* 58 * Create a VLAN on given link. 59 */ 60 dladm_status_t 61 dladm_vlan_create(dladm_handle_t handle, const char *vlan, datalink_id_t linkid, 62 uint16_t vid, dladm_arg_list_t *proplist, uint32_t flags, 63 datalink_id_t *vlan_id_out) 64 { 65 return (dladm_vnic_create(handle, vlan, linkid, 66 VNIC_MAC_ADDR_TYPE_PRIMARY, NULL, 0, NULL, 0, vid, VRRP_VRID_NONE, 67 AF_UNSPEC, vlan_id_out, proplist, NULL, flags | DLADM_OPT_VLAN)); 68 } 69 70 /* 71 * Delete a given VLAN. 72 */ 73 dladm_status_t 74 dladm_vlan_delete(dladm_handle_t handle, datalink_id_t vlanid, uint32_t flags) 75 { 76 return (dladm_vnic_delete(handle, vlanid, flags | DLADM_OPT_VLAN)); 77 } 78 79 dladm_status_t 80 dladm_vlan_up(dladm_handle_t handle, datalink_id_t linkid) 81 { 82 return (dladm_vnic_up(handle, linkid, DLADM_OPT_VLAN)); 83 } 84