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]
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
38 * Returns the current attributes of the specified VLAN.
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
)) !=
51 dvap
->dv_vid
= vnic
->va_vid
;
52 dvap
->dv_linkid
= vnic
->va_link_id
;
53 dvap
->dv_force
= vnic
->va_force
;
58 * Create a VLAN on given link.
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.
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
));
80 dladm_vlan_up(dladm_handle_t handle
, datalink_id_t linkid
)
82 return (dladm_vnic_up(handle
, linkid
, DLADM_OPT_VLAN
));