10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*8485SPeter.Memishian@Sun.COM * Common Development and Distribution License (the "License"). 6*8485SPeter.Memishian@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 20*8485SPeter.Memishian@Sun.COM * 21*8485SPeter.Memishian@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 220Sstevel@tonic-gate * Use is subject to license terms. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _IPMP_QUERY_H 260Sstevel@tonic-gate #define _IPMP_QUERY_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/socket.h> /* needed by <net/if.h> */ 300Sstevel@tonic-gate #include <net/if.h> /* for LIF*NAMSIZ */ 310Sstevel@tonic-gate #include <ipmp.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate /* 340Sstevel@tonic-gate * IPMP query interfaces. 350Sstevel@tonic-gate * 360Sstevel@tonic-gate * These interfaces may only be used within ON or after signing a contract 37*8485SPeter.Memishian@Sun.COM * with ON. For documentation, refer to PSARC/2002/615 and PSARC/2007/272. 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 45*8485SPeter.Memishian@Sun.COM * Assorted enumerations used in the data types described below. 46*8485SPeter.Memishian@Sun.COM */ 47*8485SPeter.Memishian@Sun.COM typedef enum ipmp_if_probestate { 48*8485SPeter.Memishian@Sun.COM IPMP_PROBE_OK, /* probes detect no problems */ 49*8485SPeter.Memishian@Sun.COM IPMP_PROBE_FAILED, /* probes detect failure */ 50*8485SPeter.Memishian@Sun.COM IPMP_PROBE_UNKNOWN, /* probe detection unavailable */ 51*8485SPeter.Memishian@Sun.COM IPMP_PROBE_DISABLED /* probe detection disabled */ 52*8485SPeter.Memishian@Sun.COM } ipmp_if_probestate_t; 53*8485SPeter.Memishian@Sun.COM 54*8485SPeter.Memishian@Sun.COM typedef enum ipmp_if_linkstate { 55*8485SPeter.Memishian@Sun.COM IPMP_LINK_UP, /* link detects up */ 56*8485SPeter.Memishian@Sun.COM IPMP_LINK_DOWN, /* link detects down */ 57*8485SPeter.Memishian@Sun.COM IPMP_LINK_UNKNOWN /* link detection unavailable */ 58*8485SPeter.Memishian@Sun.COM } ipmp_if_linkstate_t; 59*8485SPeter.Memishian@Sun.COM 60*8485SPeter.Memishian@Sun.COM typedef enum ipmp_if_flags { 61*8485SPeter.Memishian@Sun.COM IPMP_IFFLAG_INACTIVE = 0x1, 62*8485SPeter.Memishian@Sun.COM IPMP_IFFLAG_HWADDRDUP = 0x2, 63*8485SPeter.Memishian@Sun.COM IPMP_IFFLAG_ACTIVE = 0x4, 64*8485SPeter.Memishian@Sun.COM IPMP_IFFLAG_DOWN = 0x8 65*8485SPeter.Memishian@Sun.COM } ipmp_if_flags_t; 66*8485SPeter.Memishian@Sun.COM 67*8485SPeter.Memishian@Sun.COM typedef enum ipmp_addr_state { 68*8485SPeter.Memishian@Sun.COM IPMP_ADDR_UP, /* address is up */ 69*8485SPeter.Memishian@Sun.COM IPMP_ADDR_DOWN /* address is down */ 70*8485SPeter.Memishian@Sun.COM } ipmp_addr_state_t; 71*8485SPeter.Memishian@Sun.COM 72*8485SPeter.Memishian@Sun.COM typedef enum ipmp_if_targmode { 73*8485SPeter.Memishian@Sun.COM IPMP_TARG_DISABLED, /* use of targets is disabled */ 74*8485SPeter.Memishian@Sun.COM IPMP_TARG_ROUTES, /* route-learned targets */ 75*8485SPeter.Memishian@Sun.COM IPMP_TARG_MULTICAST /* multicast-learned targets */ 76*8485SPeter.Memishian@Sun.COM } ipmp_if_targmode_t; 77*8485SPeter.Memishian@Sun.COM 78*8485SPeter.Memishian@Sun.COM #define IPMP_LIST_SIZE(listtype, elsize, nel) \ 79*8485SPeter.Memishian@Sun.COM ((sizeof (ipmp_ ## listtype ## _t) - (elsize)) + ((nel) * (elsize))) 80*8485SPeter.Memishian@Sun.COM 81*8485SPeter.Memishian@Sun.COM /* 820Sstevel@tonic-gate * Data type describing a list of IPMP groups. 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate typedef struct ipmp_grouplist { 850Sstevel@tonic-gate uint64_t gl_sig; 860Sstevel@tonic-gate unsigned int gl_ngroup; 870Sstevel@tonic-gate char gl_groups[1][LIFGRNAMSIZ]; 880Sstevel@tonic-gate } ipmp_grouplist_t; 890Sstevel@tonic-gate 90*8485SPeter.Memishian@Sun.COM #define IPMP_GROUPLIST_SIZE(ngr) \ 91*8485SPeter.Memishian@Sun.COM IPMP_LIST_SIZE(grouplist, LIFGRNAMSIZ, ngr) 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * Data type describing a list of interfaces. 950Sstevel@tonic-gate */ 960Sstevel@tonic-gate typedef struct ipmp_iflist { 970Sstevel@tonic-gate unsigned int il_nif; 980Sstevel@tonic-gate char il_ifs[1][LIFNAMSIZ]; 990Sstevel@tonic-gate } ipmp_iflist_t; 1000Sstevel@tonic-gate 101*8485SPeter.Memishian@Sun.COM #define IPMP_IFLIST_SIZE(nif) \ 102*8485SPeter.Memishian@Sun.COM IPMP_LIST_SIZE(iflist, LIFNAMSIZ, nif) 103*8485SPeter.Memishian@Sun.COM 104*8485SPeter.Memishian@Sun.COM /* 105*8485SPeter.Memishian@Sun.COM * Data type describing a list of addresses. 106*8485SPeter.Memishian@Sun.COM */ 107*8485SPeter.Memishian@Sun.COM typedef struct ipmp_addrlist { 108*8485SPeter.Memishian@Sun.COM unsigned int al_naddr; 109*8485SPeter.Memishian@Sun.COM struct sockaddr_storage al_addrs[1]; 110*8485SPeter.Memishian@Sun.COM } ipmp_addrlist_t; 111*8485SPeter.Memishian@Sun.COM 112*8485SPeter.Memishian@Sun.COM #define IPMP_ADDRLIST_SIZE(naddr) \ 113*8485SPeter.Memishian@Sun.COM IPMP_LIST_SIZE(addrlist, sizeof (struct sockaddr_storage), naddr) 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 1160Sstevel@tonic-gate * Data type describing the state of an IPMP group. 1170Sstevel@tonic-gate */ 1180Sstevel@tonic-gate typedef struct ipmp_groupinfo { 1190Sstevel@tonic-gate char gr_name[LIFGRNAMSIZ]; 1200Sstevel@tonic-gate uint64_t gr_sig; 1210Sstevel@tonic-gate ipmp_group_state_t gr_state; 1220Sstevel@tonic-gate ipmp_iflist_t *gr_iflistp; 123*8485SPeter.Memishian@Sun.COM ipmp_addrlist_t *gr_adlistp; 124*8485SPeter.Memishian@Sun.COM char gr_ifname[LIFNAMSIZ]; 125*8485SPeter.Memishian@Sun.COM char gr_m4ifname[LIFNAMSIZ]; 126*8485SPeter.Memishian@Sun.COM char gr_m6ifname[LIFNAMSIZ]; 127*8485SPeter.Memishian@Sun.COM char gr_bcifname[LIFNAMSIZ]; 128*8485SPeter.Memishian@Sun.COM unsigned int gr_fdt; 1290Sstevel@tonic-gate } ipmp_groupinfo_t; 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 132*8485SPeter.Memishian@Sun.COM * Data type describing IPMP target information for a particular interface. 133*8485SPeter.Memishian@Sun.COM */ 134*8485SPeter.Memishian@Sun.COM typedef struct ipmp_targinfo { 135*8485SPeter.Memishian@Sun.COM char it_name[LIFNAMSIZ]; 136*8485SPeter.Memishian@Sun.COM struct sockaddr_storage it_testaddr; 137*8485SPeter.Memishian@Sun.COM ipmp_if_targmode_t it_targmode; 138*8485SPeter.Memishian@Sun.COM ipmp_addrlist_t *it_targlistp; 139*8485SPeter.Memishian@Sun.COM } ipmp_targinfo_t; 140*8485SPeter.Memishian@Sun.COM 141*8485SPeter.Memishian@Sun.COM /* 1420Sstevel@tonic-gate * Data type describing the IPMP-related state of an interface. 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate typedef struct ipmp_ifinfo { 145*8485SPeter.Memishian@Sun.COM char if_name[LIFNAMSIZ]; 146*8485SPeter.Memishian@Sun.COM char if_group[LIFGRNAMSIZ]; 147*8485SPeter.Memishian@Sun.COM ipmp_if_state_t if_state; 148*8485SPeter.Memishian@Sun.COM ipmp_if_type_t if_type; 149*8485SPeter.Memishian@Sun.COM ipmp_if_linkstate_t if_linkstate; 150*8485SPeter.Memishian@Sun.COM ipmp_if_probestate_t if_probestate; 151*8485SPeter.Memishian@Sun.COM ipmp_if_flags_t if_flags; 152*8485SPeter.Memishian@Sun.COM ipmp_targinfo_t if_targinfo4; 153*8485SPeter.Memishian@Sun.COM ipmp_targinfo_t if_targinfo6; 1540Sstevel@tonic-gate } ipmp_ifinfo_t; 1550Sstevel@tonic-gate 156*8485SPeter.Memishian@Sun.COM /* 157*8485SPeter.Memishian@Sun.COM * Data type describing an IPMP data address. 158*8485SPeter.Memishian@Sun.COM */ 159*8485SPeter.Memishian@Sun.COM typedef struct ipmp_addrinfo { 160*8485SPeter.Memishian@Sun.COM struct sockaddr_storage ad_addr; 161*8485SPeter.Memishian@Sun.COM ipmp_addr_state_t ad_state; 162*8485SPeter.Memishian@Sun.COM char ad_group[LIFGRNAMSIZ]; 163*8485SPeter.Memishian@Sun.COM char ad_binding[LIFNAMSIZ]; 164*8485SPeter.Memishian@Sun.COM } ipmp_addrinfo_t; 165*8485SPeter.Memishian@Sun.COM 1660Sstevel@tonic-gate typedef enum { 1670Sstevel@tonic-gate IPMP_QCONTEXT_LIVE, 1680Sstevel@tonic-gate IPMP_QCONTEXT_SNAP 1690Sstevel@tonic-gate } ipmp_qcontext_t; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate extern int ipmp_setqcontext(ipmp_handle_t, ipmp_qcontext_t); 1720Sstevel@tonic-gate extern int ipmp_getgrouplist(ipmp_handle_t, ipmp_grouplist_t **); 1730Sstevel@tonic-gate extern void ipmp_freegrouplist(ipmp_grouplist_t *); 1740Sstevel@tonic-gate extern int ipmp_getgroupinfo(ipmp_handle_t, const char *, ipmp_groupinfo_t **); 1750Sstevel@tonic-gate extern void ipmp_freegroupinfo(ipmp_groupinfo_t *); 1760Sstevel@tonic-gate extern int ipmp_getifinfo(ipmp_handle_t, const char *, ipmp_ifinfo_t **); 1770Sstevel@tonic-gate extern void ipmp_freeifinfo(ipmp_ifinfo_t *); 178*8485SPeter.Memishian@Sun.COM extern int ipmp_getaddrinfo(ipmp_handle_t, const char *, 179*8485SPeter.Memishian@Sun.COM struct sockaddr_storage *, ipmp_addrinfo_t **); 180*8485SPeter.Memishian@Sun.COM extern void ipmp_freeaddrinfo(ipmp_addrinfo_t *); 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate #ifdef __cplusplus 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate #endif 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate #endif /* _IPMP_QUERY_H */ 187