xref: /illumos-gate/usr/src/lib/libdladm/common/libdladm.h (revision 5f41bf46ca5230bc3ee6b7d6a714a3a16a390261)
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_H
27 #define	_LIBDLADM_H
28 
29 #include <sys/dls.h>
30 #include <sys/dlpi.h>
31 
32 /*
33  * This file includes structures, macros and common routines shared by all
34  * data-link administration, and routines which do not directly administrate
35  * links. For example, dladm_status2str().
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	LINKID_STR_WIDTH	10
43 #define	DLADM_STRSIZE		256
44 
45 /*
46  * option flags taken by the libdladm functions
47  *
48  *  - DLADM_OPT_ACTIVE:
49  *    The function requests to bringup some configuration that only take
50  *    effect on active system (not persistent).
51  *
52  *  - DLADM_OPT_PERSIST:
53  *    The function requests to persist some configuration.
54  *
55  *  - DLADM_OPT_CREATE:
56  *    Today, only used by dladm_set_secobj() - requests to create a secobj.
57  *
58  *  - DLADM_OPT_FORCE:
59  *    The function requests to execute a specific operation forcefully.
60  *
61  *  - DLADM_OPT_PREFIX:
62  *    The function requests to generate a link name using the specified prefix.
63  */
64 #define	DLADM_OPT_ACTIVE	0x00000001
65 #define	DLADM_OPT_PERSIST	0x00000002
66 #define	DLADM_OPT_CREATE	0x00000004
67 #define	DLADM_OPT_FORCE		0x00000008
68 #define	DLADM_OPT_PREFIX	0x00000010
69 
70 #define	DLADM_WALK_TERMINATE	0
71 #define	DLADM_WALK_CONTINUE	-1
72 
73 typedef enum {
74 	DLADM_STATUS_OK = 0,
75 	DLADM_STATUS_BADARG,
76 	DLADM_STATUS_FAILED,
77 	DLADM_STATUS_TOOSMALL,
78 	DLADM_STATUS_NOTSUP,
79 	DLADM_STATUS_NOTFOUND,
80 	DLADM_STATUS_BADVAL,
81 	DLADM_STATUS_NOMEM,
82 	DLADM_STATUS_EXIST,
83 	DLADM_STATUS_LINKINVAL,
84 	DLADM_STATUS_PROPRDONLY,
85 	DLADM_STATUS_BADVALCNT,
86 	DLADM_STATUS_DBNOTFOUND,
87 	DLADM_STATUS_DENIED,
88 	DLADM_STATUS_IOERR,
89 	DLADM_STATUS_TEMPONLY,
90 	DLADM_STATUS_TIMEDOUT,
91 	DLADM_STATUS_ISCONN,
92 	DLADM_STATUS_NOTCONN,
93 	DLADM_STATUS_REPOSITORYINVAL,
94 	DLADM_STATUS_MACADDRINVAL,
95 	DLADM_STATUS_KEYINVAL,
96 	DLADM_STATUS_INVALIDMACADDRLEN,
97 	DLADM_STATUS_INVALIDMACADDRTYPE,
98 	DLADM_STATUS_LINKBUSY,
99 	DLADM_STATUS_VIDINVAL,
100 	DLADM_STATUS_NONOTIF,
101 	DLADM_STATUS_TRYAGAIN,
102 	DLADM_STATUS_NOTDEFINED
103 } dladm_status_t;
104 
105 typedef enum {
106 	DLADM_TYPE_STR,
107 	DLADM_TYPE_BOOLEAN,
108 	DLADM_TYPE_UINT64
109 } dladm_datatype_t;
110 
111 typedef int dladm_conf_t;
112 #define	DLADM_INVALID_CONF	0
113 
114 extern const char	*dladm_status2str(dladm_status_t, char *);
115 extern dladm_status_t	dladm_set_rootdir(const char *);
116 extern const char	*dladm_class2str(datalink_class_t, char *);
117 extern const char	*dladm_media2str(uint32_t, char *);
118 extern boolean_t	dladm_valid_linkname(const char *);
119 
120 #ifdef	__cplusplus
121 }
122 #endif
123 
124 #endif	/* _LIBDLADM_H */
125