xref: /titanic_51/usr/src/lib/libdladm/common/libdllink.h (revision 6cefaae1e90a413ba01560575bb3998e1a3df40e)
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 _LIBDLLINK_H
27 #define	_LIBDLLINK_H
28 
29 /*
30  * This file includes structures, macros and routines used by general
31  * link administration (i.e. not limited to one specific type of link).
32  */
33 
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <libdladm.h>
37 #include <kstat.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 typedef struct dladm_attr {
44 	uint_t		da_max_sdu;
45 } dladm_attr_t;
46 
47 typedef struct dladm_phys_attr {
48 	char		dp_dev[MAXLINKNAMELEN];
49 	/*
50 	 * Whether this physical link supports vanity naming (links with media
51 	 * types not supported by GLDv3 don't have vanity naming support).
52 	 */
53 	boolean_t	dp_novanity;
54 } dladm_phys_attr_t;
55 
56 typedef enum {
57 	DLADM_PROP_VAL_CURRENT = 1,
58 	DLADM_PROP_VAL_DEFAULT,
59 	DLADM_PROP_VAL_PERM,
60 	DLADM_PROP_VAL_MODIFIABLE,
61 	DLADM_PROP_VAL_PERSISTENT
62 } dladm_prop_type_t;
63 
64 /*
65  * Maximum size of secobj value. Note that it should not be greater than
66  * DLD_SECOBJ_VAL_MAX.
67  */
68 #define	DLADM_SECOBJ_VAL_MAX	256
69 
70 /*
71  * Maximum size of secobj name. Note that it should not be greater than
72  * DLD_SECOBJ_NAME_MAX.
73  */
74 #define	DLADM_SECOBJ_NAME_MAX	32
75 
76 #define	DLADM_MAX_PROP_VALCNT	32
77 /*
78  * Size of prop_val buffer passed to pd_get function must be at
79  * least DLADM_PROP_VAL_MAX
80  */
81 #define	DLADM_PROP_VAL_MAX	128
82 
83 #define		DLADM_SECOBJ_CLASS_WEP	0
84 #define		DLADM_SECOBJ_CLASS_WPA	1
85 typedef int	dladm_secobj_class_t;
86 
87 typedef int (dladm_walkcb_t)(const char *, void *);
88 
89 extern dladm_status_t	dladm_walk(dladm_walkcb_t *, void *, datalink_class_t,
90 			    datalink_media_t, uint32_t);
91 extern dladm_status_t	dladm_mac_walk(dladm_walkcb_t *, void *);
92 extern dladm_status_t	dladm_info(datalink_id_t, dladm_attr_t *);
93 extern dladm_status_t	dladm_setzid(const char *, char *);
94 
95 extern dladm_status_t	dladm_rename_link(const char *, const char *);
96 
97 extern dladm_status_t	dladm_set_linkprop(datalink_id_t, const char *,
98 			    char **, uint_t, uint_t);
99 extern dladm_status_t	dladm_get_linkprop(datalink_id_t, dladm_prop_type_t,
100 			    const char *, char **, uint_t *);
101 extern dladm_status_t	dladm_walk_linkprop(datalink_id_t, void *,
102 			    int (*)(datalink_id_t, const char *, void *));
103 
104 extern dladm_status_t	dladm_set_secobj(const char *, dladm_secobj_class_t,
105 			    uint8_t *, uint_t, uint_t);
106 extern dladm_status_t	dladm_get_secobj(const char *, dladm_secobj_class_t *,
107 			    uint8_t *, uint_t *, uint_t);
108 extern dladm_status_t	dladm_unset_secobj(const char *, uint_t);
109 extern dladm_status_t	dladm_walk_secobj(void *,
110 			    boolean_t (*)(void *, const char *), uint_t);
111 
112 extern const char	*dladm_linkstate2str(link_state_t, char *);
113 extern const char	*dladm_linkduplex2str(link_duplex_t, char *);
114 extern const char	*dladm_secobjclass2str(dladm_secobj_class_t, char *);
115 extern dladm_status_t	dladm_str2secobjclass(const char *,
116 			    dladm_secobj_class_t *);
117 
118 extern dladm_status_t	dladm_init_linkprop(datalink_id_t, boolean_t);
119 extern dladm_status_t	dladm_init_secobj(void);
120 
121 extern dladm_status_t	dladm_create_datalink_id(const char *, datalink_class_t,
122 			    uint_t, uint32_t, datalink_id_t *);
123 extern dladm_status_t	dladm_destroy_datalink_id(datalink_id_t, uint32_t);
124 extern dladm_status_t	dladm_remap_datalink_id(datalink_id_t, const char *);
125 extern dladm_status_t	dladm_up_datalink_id(datalink_id_t);
126 extern dladm_status_t	dladm_name2info(const char *, datalink_id_t *,
127 			    uint32_t *, datalink_class_t *, uint32_t *);
128 extern dladm_status_t	dladm_datalink_id2info(datalink_id_t, uint32_t *,
129 			    datalink_class_t *, uint32_t *, char *, size_t);
130 extern dladm_status_t	dladm_walk_datalink_id(int (*)(datalink_id_t, void *),
131 			    void *, datalink_class_t, datalink_media_t,
132 			    uint32_t);
133 extern dladm_status_t	dladm_create_conf(const char *, datalink_id_t,
134 			    datalink_class_t, uint32_t, dladm_conf_t *);
135 extern dladm_status_t	dladm_read_conf(datalink_id_t, dladm_conf_t *);
136 extern dladm_status_t	dladm_write_conf(dladm_conf_t);
137 extern dladm_status_t	dladm_remove_conf(datalink_id_t);
138 extern void		dladm_destroy_conf(dladm_conf_t);
139 extern dladm_status_t	dladm_get_conf_field(dladm_conf_t, const char *,
140 			    void *, size_t);
141 extern dladm_status_t	dladm_set_conf_field(dladm_conf_t, const char *,
142 			    dladm_datatype_t, const void *);
143 extern dladm_status_t	dladm_unset_conf_field(dladm_conf_t, const char *);
144 
145 extern dladm_status_t	dladm_dev2linkid(const char *, datalink_id_t *);
146 extern dladm_status_t	dladm_linkid2legacyname(datalink_id_t, char *, size_t);
147 extern dladm_status_t	dladm_phys_delete(datalink_id_t);
148 
149 extern dladm_status_t	dladm_phys_info(datalink_id_t, dladm_phys_attr_t *,
150 			    uint32_t);
151 extern dladm_status_t	dladm_get_single_mac_stat(datalink_id_t, const char *,
152     uint8_t, void *);
153 extern int		dladm_kstat_value(kstat_t *, const char *, uint8_t,
154     void *);
155 extern dladm_status_t	dladm_parselink(const char *, char *, uint_t *);
156 
157 #ifdef	__cplusplus
158 }
159 #endif
160 
161 #endif	/* _LIBDLLINK_H */
162