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