xref: /titanic_51/usr/src/lib/libipmp/common/ipmp_query.h (revision c10c16dec587a0662068f6e2991c29ed3a9db943)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
22  * Use is subject to license terms.
23  */
24 
25 #ifndef _IPMP_QUERY_H
26 #define	_IPMP_QUERY_H
27 
28 #include <sys/types.h>
29 #include <sys/socket.h>			/* needed by <net/if.h> */
30 #include <net/if.h>			/* for LIF*NAMSIZ */
31 #include <ipmp.h>
32 
33 /*
34  * IPMP query interfaces.
35  *
36  * These interfaces may only be used within ON or after signing a contract
37  * with ON.  For documentation, refer to PSARC/2002/615 and PSARC/2007/272.
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Assorted enumerations used in the data types described below.
46  */
47 typedef enum ipmp_if_probestate {
48 	IPMP_PROBE_OK,		/* probes detect no problems */
49 	IPMP_PROBE_FAILED,	/* probes detect failure */
50 	IPMP_PROBE_UNKNOWN,	/* probe detection unavailable */
51 	IPMP_PROBE_DISABLED	/* probe detection disabled */
52 } ipmp_if_probestate_t;
53 
54 typedef enum ipmp_if_linkstate {
55 	IPMP_LINK_UP,		/* link detects up */
56 	IPMP_LINK_DOWN,		/* link detects down */
57 	IPMP_LINK_UNKNOWN	/* link detection unavailable */
58 } ipmp_if_linkstate_t;
59 
60 typedef enum ipmp_if_flags {
61 	IPMP_IFFLAG_INACTIVE	= 0x1,
62 	IPMP_IFFLAG_HWADDRDUP	= 0x2,
63 	IPMP_IFFLAG_ACTIVE 	= 0x4,
64 	IPMP_IFFLAG_DOWN	= 0x8
65 } ipmp_if_flags_t;
66 
67 typedef enum ipmp_addr_state {
68 	IPMP_ADDR_UP,		/* address is up */
69 	IPMP_ADDR_DOWN		/* address is down */
70 } ipmp_addr_state_t;
71 
72 typedef enum ipmp_if_targmode {
73 	IPMP_TARG_DISABLED,	/* use of targets is disabled */
74 	IPMP_TARG_ROUTES,	/* route-learned targets */
75 	IPMP_TARG_MULTICAST	/* multicast-learned targets */
76 } ipmp_if_targmode_t;
77 
78 #define	IPMP_LIST_SIZE(listtype, elsize, nel) \
79 	((sizeof (ipmp_ ## listtype ## _t) - (elsize)) + ((nel) * (elsize)))
80 
81 /*
82  * Data type describing a list of IPMP groups.
83  */
84 typedef struct ipmp_grouplist {
85 	uint64_t	gl_sig;
86 	unsigned int	gl_ngroup;
87 	char		gl_groups[1][LIFGRNAMSIZ];
88 } ipmp_grouplist_t;
89 
90 #define	IPMP_GROUPLIST_SIZE(ngr)	\
91 	IPMP_LIST_SIZE(grouplist, LIFGRNAMSIZ, ngr)
92 
93 /*
94  * Data type describing a list of interfaces.
95  */
96 typedef struct ipmp_iflist {
97 	unsigned int	il_nif;
98 	char		il_ifs[1][LIFNAMSIZ];
99 } ipmp_iflist_t;
100 
101 #define	IPMP_IFLIST_SIZE(nif)		\
102 	IPMP_LIST_SIZE(iflist, LIFNAMSIZ, nif)
103 
104 /*
105  * Data type describing a list of addresses.
106  */
107 typedef struct ipmp_addrlist {
108 	unsigned int		al_naddr;
109 	struct sockaddr_storage al_addrs[1];
110 } ipmp_addrlist_t;
111 
112 #define	IPMP_ADDRLIST_SIZE(naddr)	\
113 	IPMP_LIST_SIZE(addrlist, sizeof (struct sockaddr_storage), naddr)
114 
115 /*
116  * Data type describing the state of an IPMP group.
117  */
118 typedef struct ipmp_groupinfo {
119 	char			gr_name[LIFGRNAMSIZ];
120 	uint64_t		gr_sig;
121 	ipmp_group_state_t	gr_state;
122 	ipmp_iflist_t		*gr_iflistp;
123 	ipmp_addrlist_t		*gr_adlistp;
124 	char			gr_ifname[LIFNAMSIZ];
125 	char			gr_m4ifname[LIFNAMSIZ];
126 	char			gr_m6ifname[LIFNAMSIZ];
127 	char			gr_bcifname[LIFNAMSIZ];
128 	unsigned int		gr_fdt;
129 } ipmp_groupinfo_t;
130 
131 /*
132  * Data type describing IPMP target information for a particular interface.
133  */
134 typedef struct ipmp_targinfo {
135 	char			it_name[LIFNAMSIZ];
136 	struct sockaddr_storage	it_testaddr;
137 	ipmp_if_targmode_t	it_targmode;
138 	ipmp_addrlist_t		*it_targlistp;
139 } ipmp_targinfo_t;
140 
141 /*
142  * Data type describing the IPMP-related state of an interface.
143  */
144 typedef struct ipmp_ifinfo {
145 	char			if_name[LIFNAMSIZ];
146 	char			if_group[LIFGRNAMSIZ];
147 	ipmp_if_state_t		if_state;
148 	ipmp_if_type_t		if_type;
149 	ipmp_if_linkstate_t	if_linkstate;
150 	ipmp_if_probestate_t	if_probestate;
151 	ipmp_if_flags_t		if_flags;
152 	ipmp_targinfo_t		if_targinfo4;
153 	ipmp_targinfo_t		if_targinfo6;
154 } ipmp_ifinfo_t;
155 
156 /*
157  * Data type describing an IPMP data address.
158  */
159 typedef struct ipmp_addrinfo {
160 	struct sockaddr_storage	ad_addr;
161 	ipmp_addr_state_t	ad_state;
162 	char			ad_group[LIFGRNAMSIZ];
163 	char			ad_binding[LIFNAMSIZ];
164 } ipmp_addrinfo_t;
165 
166 typedef enum {
167 	IPMP_QCONTEXT_LIVE,
168 	IPMP_QCONTEXT_SNAP
169 } ipmp_qcontext_t;
170 
171 extern int  ipmp_setqcontext(ipmp_handle_t, ipmp_qcontext_t);
172 extern int  ipmp_getgrouplist(ipmp_handle_t, ipmp_grouplist_t **);
173 extern void ipmp_freegrouplist(ipmp_grouplist_t *);
174 extern int  ipmp_getgroupinfo(ipmp_handle_t, const char *, ipmp_groupinfo_t **);
175 extern void ipmp_freegroupinfo(ipmp_groupinfo_t *);
176 extern int  ipmp_getifinfo(ipmp_handle_t, const char *, ipmp_ifinfo_t **);
177 extern void ipmp_freeifinfo(ipmp_ifinfo_t *);
178 extern int  ipmp_getaddrinfo(ipmp_handle_t, const char *,
179     struct sockaddr_storage *, ipmp_addrinfo_t **);
180 extern void ipmp_freeaddrinfo(ipmp_addrinfo_t *);
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* _IPMP_QUERY_H */
187