xref: /illumos-gate/usr/src/lib/libdladm/common/libdladm_impl.h (revision a7e661a2db6ff10cd43a089e7f4dcbd0cfd609f1)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLADM_IMPL_H
27 #define	_LIBDLADM_IMPL_H
28 
29 #include <libdladm.h>
30 #include <stdio.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	MAXLINELEN		1024
37 #define	BUFLEN(lim, ptr)	(((lim) > (ptr)) ? ((lim) - (ptr)) : 0)
38 
39 extern dladm_status_t	dladm_errno2status(int);
40 extern dladm_status_t   i_dladm_rw_db(const char *, mode_t,
41 			    dladm_status_t (*)(void *, FILE *, FILE *),
42 			    void *, boolean_t);
43 extern dladm_status_t	i_dladm_get_state(datalink_id_t, link_state_t *);
44 
45 extern const char	*dladm_pri2str(mac_priority_level_t, char *);
46 extern dladm_status_t	dladm_str2pri(char *, mac_priority_level_t *);
47 extern dladm_status_t	dladm_parse_args(char *, dladm_arg_list_t **,
48 			    boolean_t);
49 extern void		dladm_free_args(dladm_arg_list_t *);
50 
51 /*
52  * Link attributes persisted by dlmgmtd.
53  */
54 /*
55  * Set for VLANs only
56  */
57 #define	FVLANID		"vid"		/* uint64_t */
58 #define	FLINKOVER	"linkover"	/* uint64_t */
59 
60 /*
61  * Set for AGGRs only
62  */
63 #define	FKEY		"key"		/* uint64_t */
64 #define	FNPORTS		"nports"	/* uint64_t */
65 #define	FPORTS		"portnames"	/* string */
66 #define	FPOLICY		"policy"	/* uint64_t */
67 #define	FFIXMACADDR	"fix_macaddr"	/* boolean_t */
68 #define	FFORCE		"force"		/* boolean_t */
69 #define	FLACPMODE	"lacp_mode"	/* uint64_t */
70 #define	FLACPTIMER	"lacp_timer"	/* uint64_t */
71 
72 /*
73  * Set for VNICs only
74  */
75 #define	FMADDRTYPE	"maddrtype"	/* uint64_t */
76 #define	FMADDRLEN	"maddrlen"	/* uint64_t */
77 #define	FMADDRSLOT	"maddrslot"	/* uint64_t */
78 #define	FMADDRPREFIXLEN	"maddrpreflen"	/* uint64_t */
79 #define	FHWRINGS	"hwrings"	/* boolean_t */
80 
81 /*
82  * Common fields
83  */
84 #define	FMACADDR	"macaddr"	/* string */
85 
86 /*
87  * Data structures used for implementing temporary properties
88  */
89 
90 typedef struct val_desc {
91 	char		*vd_name;
92 	uintptr_t	vd_val;
93 } val_desc_t;
94 
95 #define	VALCNT(vals)	(sizeof ((vals)) / sizeof (val_desc_t))
96 
97 extern dladm_status_t	dladm_link_proplist_extract(dladm_arg_list_t *,
98 			    mac_resource_props_t *);
99 
100 extern dladm_status_t	dladm_flow_proplist_extract(dladm_arg_list_t *,
101 			    mac_resource_props_t *);
102 
103 /*
104  * The prop extract() callback.
105  *
106  * rp_extract extracts the kernel structure from the val_desc_t created
107  * by the pd_check function.
108  */
109 typedef	dladm_status_t	rp_extractf_t(val_desc_t *propval, void *arg,
110 				uint_t cnt);
111 extern rp_extractf_t	do_extract_maxbw, do_extract_priority,
112 			do_extract_cpus;
113 
114 typedef struct resource_prop_s {
115 	/*
116 	 * resource property name
117 	 */
118 	char		*rp_name;
119 
120 	/*
121 	 * callback to extract kernel structure
122 	 */
123 	rp_extractf_t	*rp_extract;
124 } resource_prop_t;
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif	/* _LIBDLADM_IMPL_H */
131