6659 nvlist_free(NULL) is a no-op
[illumos-gate.git] / usr / src / lib / libdladm / common / libdlvlan.c
blob943728dc03c96239be25b502509374ed64b4cee2
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <libdlvlan.h>
27 #include <libdlvnic.h>
28 #include <libvrrpadm.h>
31 * VLAN Administration Library.
33 * This library is used by administration tools such as dladm(1M) to
34 * configure VLANs.
38 * Returns the current attributes of the specified VLAN.
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)
44 dladm_status_t status;
45 dladm_vnic_attr_t attr, *vnic = &attr;
47 if ((status = dladm_vnic_info(handle, vlanid, vnic, flags)) !=
48 DLADM_STATUS_OK)
49 return (status);
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);
58 * Create a VLAN on given link.
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)
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, flags | DLADM_OPT_VLAN));
71 * Delete a given VLAN.
73 dladm_status_t
74 dladm_vlan_delete(dladm_handle_t handle, datalink_id_t vlanid, uint32_t flags)
76 return (dladm_vnic_delete(handle, vlanid, flags | DLADM_OPT_VLAN));
79 dladm_status_t
80 dladm_vlan_up(dladm_handle_t handle, datalink_id_t linkid)
82 return (dladm_vnic_up(handle, linkid, DLADM_OPT_VLAN));