17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5e11c3f4meem * Common Development and Distribution License (the "License").
6e11c3f4meem * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
20e11c3f4meem *
21e11c3f4meem * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
227c478bdstevel@tonic-gate * Use is subject to license terms.
237c478bdstevel@tonic-gate */
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate#ifndef _IPMP_QUERY_H
267c478bdstevel@tonic-gate#define	_IPMP_QUERY_H
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#include <sys/types.h>
297c478bdstevel@tonic-gate#include <sys/socket.h>			/* needed by <net/if.h> */
307c478bdstevel@tonic-gate#include <net/if.h>			/* for LIF*NAMSIZ */
317c478bdstevel@tonic-gate#include <ipmp.h>
327c478bdstevel@tonic-gate
337c478bdstevel@tonic-gate/*
347c478bdstevel@tonic-gate * IPMP query interfaces.
357c478bdstevel@tonic-gate *
367c478bdstevel@tonic-gate * These interfaces may only be used within ON or after signing a contract
37e11c3f4meem * with ON.  For documentation, refer to PSARC/2002/615 and PSARC/2007/272.
387c478bdstevel@tonic-gate */
397c478bdstevel@tonic-gate
407c478bdstevel@tonic-gate#ifdef __cplusplus
417c478bdstevel@tonic-gateextern "C" {
427c478bdstevel@tonic-gate#endif
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate/*
45e11c3f4meem * Assorted enumerations used in the data types described below.
46e11c3f4meem */
47e11c3f4meemtypedef enum ipmp_if_probestate {
48e11c3f4meem	IPMP_PROBE_OK,		/* probes detect no problems */
49e11c3f4meem	IPMP_PROBE_FAILED,	/* probes detect failure */
50e11c3f4meem	IPMP_PROBE_UNKNOWN,	/* probe detection unavailable */
51e11c3f4meem	IPMP_PROBE_DISABLED	/* probe detection disabled */
52e11c3f4meem} ipmp_if_probestate_t;
53e11c3f4meem
54e11c3f4meemtypedef enum ipmp_if_linkstate {
55e11c3f4meem	IPMP_LINK_UP,		/* link detects up */
56e11c3f4meem	IPMP_LINK_DOWN,		/* link detects down */
57e11c3f4meem	IPMP_LINK_UNKNOWN	/* link detection unavailable */
58e11c3f4meem} ipmp_if_linkstate_t;
59e11c3f4meem
60e11c3f4meemtypedef enum ipmp_if_flags {
61e11c3f4meem	IPMP_IFFLAG_INACTIVE	= 0x1,
62e11c3f4meem	IPMP_IFFLAG_HWADDRDUP	= 0x2,
63e11c3f4meem	IPMP_IFFLAG_ACTIVE 	= 0x4,
64e11c3f4meem	IPMP_IFFLAG_DOWN	= 0x8
65e11c3f4meem} ipmp_if_flags_t;
66e11c3f4meem
67e11c3f4meemtypedef enum ipmp_addr_state {
68e11c3f4meem	IPMP_ADDR_UP,		/* address is up */
69e11c3f4meem	IPMP_ADDR_DOWN		/* address is down */
70e11c3f4meem} ipmp_addr_state_t;
71e11c3f4meem
72e11c3f4meemtypedef enum ipmp_if_targmode {
73e11c3f4meem	IPMP_TARG_DISABLED,	/* use of targets is disabled */
74e11c3f4meem	IPMP_TARG_ROUTES,	/* route-learned targets */
75e11c3f4meem	IPMP_TARG_MULTICAST	/* multicast-learned targets */
76e11c3f4meem} ipmp_if_targmode_t;
77e11c3f4meem
78e11c3f4meem#define	IPMP_LIST_SIZE(listtype, elsize, nel) \
79e11c3f4meem	((sizeof (ipmp_ ## listtype ## _t) - (elsize)) + ((nel) * (elsize)))
80e11c3f4meem
81e11c3f4meem/*
827c478bdstevel@tonic-gate * Data type describing a list of IPMP groups.
837c478bdstevel@tonic-gate */
847c478bdstevel@tonic-gatetypedef struct ipmp_grouplist {
857c478bdstevel@tonic-gate	uint64_t	gl_sig;
867c478bdstevel@tonic-gate	unsigned int	gl_ngroup;
877c478bdstevel@tonic-gate	char		gl_groups[1][LIFGRNAMSIZ];
887c478bdstevel@tonic-gate} ipmp_grouplist_t;
897c478bdstevel@tonic-gate
90e11c3f4meem#define	IPMP_GROUPLIST_SIZE(ngr)	\
91e11c3f4meem	IPMP_LIST_SIZE(grouplist, LIFGRNAMSIZ, ngr)
927c478bdstevel@tonic-gate
937c478bdstevel@tonic-gate/*
947c478bdstevel@tonic-gate * Data type describing a list of interfaces.
957c478bdstevel@tonic-gate */
967c478bdstevel@tonic-gatetypedef struct ipmp_iflist {
977c478bdstevel@tonic-gate	unsigned int	il_nif;
987c478bdstevel@tonic-gate	char		il_ifs[1][LIFNAMSIZ];
997c478bdstevel@tonic-gate} ipmp_iflist_t;
1007c478bdstevel@tonic-gate
101e11c3f4meem#define	IPMP_IFLIST_SIZE(nif)		\
102e11c3f4meem	IPMP_LIST_SIZE(iflist, LIFNAMSIZ, nif)
103e11c3f4meem
104e11c3f4meem/*
105e11c3f4meem * Data type describing a list of addresses.
106e11c3f4meem */
107e11c3f4meemtypedef struct ipmp_addrlist {
108e11c3f4meem	unsigned int		al_naddr;
109e11c3f4meem	struct sockaddr_storage al_addrs[1];
110e11c3f4meem} ipmp_addrlist_t;
111e11c3f4meem
112e11c3f4meem#define	IPMP_ADDRLIST_SIZE(naddr)	\
113e11c3f4meem	IPMP_LIST_SIZE(addrlist, sizeof (struct sockaddr_storage), naddr)
1147c478bdstevel@tonic-gate
1157c478bdstevel@tonic-gate/*
1167c478bdstevel@tonic-gate * Data type describing the state of an IPMP group.
1177c478bdstevel@tonic-gate */
1187c478bdstevel@tonic-gatetypedef struct ipmp_groupinfo {
1197c478bdstevel@tonic-gate	char			gr_name[LIFGRNAMSIZ];
1207c478bdstevel@tonic-gate	uint64_t		gr_sig;
1217c478bdstevel@tonic-gate	ipmp_group_state_t	gr_state;
1227c478bdstevel@tonic-gate	ipmp_iflist_t		*gr_iflistp;
123e11c3f4meem	ipmp_addrlist_t		*gr_adlistp;
124e11c3f4meem	char			gr_ifname[LIFNAMSIZ];
125e11c3f4meem	char			gr_m4ifname[LIFNAMSIZ];
126e11c3f4meem	char			gr_m6ifname[LIFNAMSIZ];
127e11c3f4meem	char			gr_bcifname[LIFNAMSIZ];
128e11c3f4meem	unsigned int		gr_fdt;
1297c478bdstevel@tonic-gate} ipmp_groupinfo_t;
1307c478bdstevel@tonic-gate
1317c478bdstevel@tonic-gate/*
132e11c3f4meem * Data type describing IPMP target information for a particular interface.
133e11c3f4meem */
134e11c3f4meemtypedef struct ipmp_targinfo {
135e11c3f4meem	char			it_name[LIFNAMSIZ];
136e11c3f4meem	struct sockaddr_storage	it_testaddr;
137e11c3f4meem	ipmp_if_targmode_t	it_targmode;
138e11c3f4meem	ipmp_addrlist_t		*it_targlistp;
139e11c3f4meem} ipmp_targinfo_t;
140e11c3f4meem
141e11c3f4meem/*
1427c478bdstevel@tonic-gate * Data type describing the IPMP-related state of an interface.
1437c478bdstevel@tonic-gate */
1447c478bdstevel@tonic-gatetypedef struct ipmp_ifinfo {
145e11c3f4meem	char			if_name[LIFNAMSIZ];
146e11c3f4meem	char			if_group[LIFGRNAMSIZ];
147e11c3f4meem	ipmp_if_state_t		if_state;
148e11c3f4meem	ipmp_if_type_t		if_type;
149e11c3f4meem	ipmp_if_linkstate_t	if_linkstate;
150e11c3f4meem	ipmp_if_probestate_t	if_probestate;
151e11c3f4meem	ipmp_if_flags_t		if_flags;
152e11c3f4meem	ipmp_targinfo_t		if_targinfo4;
153e11c3f4meem	ipmp_targinfo_t		if_targinfo6;
1547c478bdstevel@tonic-gate} ipmp_ifinfo_t;
1557c478bdstevel@tonic-gate
156e11c3f4meem/*
157e11c3f4meem * Data type describing an IPMP data address.
158e11c3f4meem */
159e11c3f4meemtypedef struct ipmp_addrinfo {
160e11c3f4meem	struct sockaddr_storage	ad_addr;
161e11c3f4meem	ipmp_addr_state_t	ad_state;
162e11c3f4meem	char			ad_group[LIFGRNAMSIZ];
163e11c3f4meem	char			ad_binding[LIFNAMSIZ];
164e11c3f4meem} ipmp_addrinfo_t;
165e11c3f4meem
1667c478bdstevel@tonic-gatetypedef enum {
1677c478bdstevel@tonic-gate	IPMP_QCONTEXT_LIVE,
1687c478bdstevel@tonic-gate	IPMP_QCONTEXT_SNAP
1697c478bdstevel@tonic-gate} ipmp_qcontext_t;
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gateextern int  ipmp_setqcontext(ipmp_handle_t, ipmp_qcontext_t);
1727c478bdstevel@tonic-gateextern int  ipmp_getgrouplist(ipmp_handle_t, ipmp_grouplist_t **);
1737c478bdstevel@tonic-gateextern void ipmp_freegrouplist(ipmp_grouplist_t *);
1747c478bdstevel@tonic-gateextern int  ipmp_getgroupinfo(ipmp_handle_t, const char *, ipmp_groupinfo_t **);
1757c478bdstevel@tonic-gateextern void ipmp_freegroupinfo(ipmp_groupinfo_t *);
1767c478bdstevel@tonic-gateextern int  ipmp_getifinfo(ipmp_handle_t, const char *, ipmp_ifinfo_t **);
1777c478bdstevel@tonic-gateextern void ipmp_freeifinfo(ipmp_ifinfo_t *);
178e11c3f4meemextern int  ipmp_getaddrinfo(ipmp_handle_t, const char *,
179e11c3f4meem    struct sockaddr_storage *, ipmp_addrinfo_t **);
180e11c3f4meemextern void ipmp_freeaddrinfo(ipmp_addrinfo_t *);
1817c478bdstevel@tonic-gate
1827c478bdstevel@tonic-gate#ifdef __cplusplus
1837c478bdstevel@tonic-gate}
1847c478bdstevel@tonic-gate#endif
1857c478bdstevel@tonic-gate
1867c478bdstevel@tonic-gate#endif /* _IPMP_QUERY_H */
187