6659 nvlist_free(NULL) is a no-op
[illumos-gate.git] / usr / src / lib / libdladm / common / libdladm_impl.h
blob13169285e398bbd4cf1f59d52b6ba4d383d2ba67
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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
25 #ifndef _LIBDLADM_IMPL_H
26 #define _LIBDLADM_IMPL_H
28 #include <sys/types.h>
29 #include <sys/mac.h>
30 #include <sys/mac_flow.h>
31 #include <libdladm.h>
32 #include <stdio.h>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 #define MAXLINELEN 1024
39 #define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0)
40 #define V4_PART_OF_V6(v6) ((v6)._S6_un._S6_u32[3])
43 * The handle contains file descriptors to DLD_CONTROL_DEV and
44 * DLMGMT_DOOR. Rather than opening the file descriptor each time
45 * it is required, the handle is opened by consumers of libdladm
46 * (e.g., dladm) and then passed to libdladm.
48 struct dladm_handle {
49 int dld_fd; /* file descriptor to DLD_CONTROL_DEV */
50 int door_fd; /* file descriptor to DLMGMT_DOOR */
53 /* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */
54 extern dladm_status_t dladm_door_fd(dladm_handle_t, int *);
56 extern dladm_status_t dladm_errno2status(int);
57 extern dladm_status_t i_dladm_rw_db(dladm_handle_t, const char *, mode_t,
58 dladm_status_t (*)(dladm_handle_t, void *, FILE *,
59 FILE *), void *, boolean_t);
60 extern dladm_status_t dladm_get_state(dladm_handle_t, datalink_id_t,
61 link_state_t *);
62 extern void dladm_find_setbits32(uint32_t, uint32_t *, uint32_t *);
63 extern dladm_status_t dladm_parse_args(char *, dladm_arg_list_t **,
64 boolean_t);
65 extern void dladm_free_args(dladm_arg_list_t *);
68 * Link attributes persisted by dlmgmtd.
71 * Set for VLANs only
73 #define FVLANID "vid" /* uint64_t */
74 #define FLINKOVER "linkover" /* uint64_t */
77 * Set for AGGRs only
79 #define FKEY "key" /* uint64_t */
80 #define FNPORTS "nports" /* uint64_t */
81 #define FPORTS "portnames" /* string */
82 #define FPOLICY "policy" /* uint64_t */
83 #define FFIXMACADDR "fix_macaddr" /* boolean_t */
84 #define FFORCE "force" /* boolean_t */
85 #define FLACPMODE "lacp_mode" /* uint64_t */
86 #define FLACPTIMER "lacp_timer" /* uint64_t */
89 * Set for VNICs only
91 #define FMADDRTYPE "maddrtype" /* uint64_t */
92 #define FMADDRLEN "maddrlen" /* uint64_t */
93 #define FMADDRSLOT "maddrslot" /* uint64_t */
94 #define FMADDRPREFIXLEN "maddrpreflen" /* uint64_t */
95 #define FVRID "vrid" /* uint64_t */
96 #define FVRAF "vraf" /* uint64_t */
99 * Set for simlinks only
101 #define FSIMNETTYPE "simnettype" /* uint64_t */
102 #define FSIMNETPEER "simnetpeer" /* uint64_t */
105 * Set for IB partitions only
107 #define FPORTPKEY "pkey" /* uint64_t */
110 * Common fields
112 #define FMACADDR "macaddr" /* string */
115 * List of all the above attributes.
117 #define DLADM_ATTR_NAMES FVLANID, FLINKOVER, \
118 FKEY, FNPORTS, FPORTS, FPOLICY, \
119 FFIXMACADDR, FFORCE, FLACPMODE, FLACPTIMER, \
120 FMADDRTYPE, FMADDRLEN, FMADDRSLOT, \
121 FMADDRPREFIXLEN, FVRID, FVRAF, \
122 FMACADDR, FSIMNETTYPE, FSIMNETPEER
125 * Data structures used for implementing temporary properties
128 typedef struct val_desc {
129 char *vd_name;
130 uintptr_t vd_val;
131 } val_desc_t;
133 #define VALCNT(vals) (sizeof ((vals)) / sizeof (val_desc_t))
135 extern dladm_status_t dladm_link_proplist_extract(dladm_handle_t,
136 dladm_arg_list_t *, mac_resource_props_t *,
137 uint_t);
139 extern dladm_status_t dladm_flow_proplist_extract(dladm_arg_list_t *,
140 mac_resource_props_t *);
143 * The prop extract() callback.
145 * rp_extract extracts the kernel structure from the val_desc_t created
146 * by the pd_check function.
148 typedef dladm_status_t rp_extractf_t(val_desc_t *, uint_t, void *);
149 extern rp_extractf_t extract_maxbw, extract_priority,
150 extract_cpus, extract_protection,
151 extract_allowedips, extract_allowedcids,
152 extract_rxrings, extract_txrings, extract_pool;
154 typedef struct resource_prop_s {
156 * resource property name
158 char *rp_name;
161 * callback to extract kernel structure
163 rp_extractf_t *rp_extract;
164 } resource_prop_t;
167 * Set for bridged links only
169 #define FBRIDGE "bridge" /* string */
171 #ifdef __cplusplus
173 #endif
175 #endif /* _LIBDLADM_IMPL_H */