#ifndef _IPMP_QUERY_H
#define _IPMP_QUERY_H
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <ipmp.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum ipmp_if_probestate {
IPMP_PROBE_OK,
IPMP_PROBE_FAILED,
IPMP_PROBE_UNKNOWN,
IPMP_PROBE_DISABLED
} ipmp_if_probestate_t;
typedef enum ipmp_if_linkstate {
IPMP_LINK_UP,
IPMP_LINK_DOWN,
IPMP_LINK_UNKNOWN
} ipmp_if_linkstate_t;
typedef enum ipmp_if_flags {
IPMP_IFFLAG_INACTIVE = 0x1,
IPMP_IFFLAG_HWADDRDUP = 0x2,
IPMP_IFFLAG_ACTIVE = 0x4,
IPMP_IFFLAG_DOWN = 0x8
} ipmp_if_flags_t;
typedef enum ipmp_addr_state {
IPMP_ADDR_UP,
IPMP_ADDR_DOWN
} ipmp_addr_state_t;
typedef enum ipmp_if_targmode {
IPMP_TARG_DISABLED,
IPMP_TARG_ROUTES,
IPMP_TARG_MULTICAST
} ipmp_if_targmode_t;
#define IPMP_LIST_SIZE(listtype, elsize, nel) \
((sizeof (ipmp_ ## listtype ## _t) - (elsize)) + ((nel) * (elsize)))
typedef struct ipmp_grouplist {
uint64_t gl_sig;
unsigned int gl_ngroup;
uint32_t gl_pad;
char gl_groups[1][LIFGRNAMSIZ];
} ipmp_grouplist_t;
#define IPMP_GROUPLIST_SIZE(ngr) \
IPMP_LIST_SIZE(grouplist, LIFGRNAMSIZ, ngr)
typedef struct ipmp_iflist {
unsigned int il_nif;
char il_ifs[1][LIFNAMSIZ];
} ipmp_iflist_t;
#define IPMP_IFLIST_SIZE(nif) \
IPMP_LIST_SIZE(iflist, LIFNAMSIZ, nif)
typedef struct ipmp_addrlist {
unsigned int al_naddr;
uint32_t al_pad;
struct sockaddr_storage al_addrs[1];
} ipmp_addrlist_t;
#define IPMP_ADDRLIST_SIZE(naddr) \
IPMP_LIST_SIZE(addrlist, sizeof (struct sockaddr_storage), naddr)
typedef struct ipmp_groupinfo {
char gr_name[LIFGRNAMSIZ];
uint64_t gr_sig;
ipmp_group_state_t gr_state;
ipmp_iflist_t *gr_iflistp;
ipmp_addrlist_t *gr_adlistp;
char gr_ifname[LIFNAMSIZ];
char gr_m4ifname[LIFNAMSIZ];
char gr_m6ifname[LIFNAMSIZ];
char gr_bcifname[LIFNAMSIZ];
unsigned int gr_fdt;
} ipmp_groupinfo_t;
typedef struct ipmp_groupinfo_xfer {
char grx_name[LIFGRNAMSIZ];
uint64_t grx_sig;
ipmp_group_state_t grx_state;
char grx_ifname[LIFNAMSIZ];
char grx_m4ifname[LIFNAMSIZ];
char grx_m6ifname[LIFNAMSIZ];
char grx_bcifname[LIFNAMSIZ];
unsigned int grx_fdt;
} ipmp_groupinfo_xfer_t;
typedef struct ipmp_targinfo {
char it_name[LIFNAMSIZ];
struct sockaddr_storage it_testaddr;
ipmp_if_targmode_t it_targmode;
ipmp_addrlist_t *it_targlistp;
} ipmp_targinfo_t;
typedef struct ipmp_targinfo_xfer {
char itx_name[LIFNAMSIZ];
struct sockaddr_storage itx_testaddr;
ipmp_if_targmode_t itx_targmode;
uint32_t itx_pad;
} ipmp_targinfo_xfer_t;
typedef struct ipmp_ifinfo {
char if_name[LIFNAMSIZ];
char if_group[LIFGRNAMSIZ];
ipmp_if_state_t if_state;
ipmp_if_type_t if_type;
ipmp_if_linkstate_t if_linkstate;
ipmp_if_probestate_t if_probestate;
ipmp_if_flags_t if_flags;
ipmp_targinfo_t if_targinfo4;
ipmp_targinfo_t if_targinfo6;
} ipmp_ifinfo_t;
typedef struct ipmp_ifinfo_xfer {
char ifx_name[LIFNAMSIZ];
char ifx_group[LIFGRNAMSIZ];
ipmp_if_state_t ifx_state;
ipmp_if_type_t ifx_type;
ipmp_if_linkstate_t ifx_linkstate;
ipmp_if_probestate_t ifx_probestate;
ipmp_if_flags_t ifx_flags;
uint32_t ifx_pad;
ipmp_targinfo_xfer_t ifx_targinfo4;
ipmp_targinfo_xfer_t ifx_targinfo6;
} ipmp_ifinfo_xfer_t;
typedef struct ipmp_addrinfo {
struct sockaddr_storage ad_addr;
ipmp_addr_state_t ad_state;
char ad_group[LIFGRNAMSIZ];
char ad_binding[LIFNAMSIZ];
uint32_t ad_pad;
} ipmp_addrinfo_t;
typedef enum {
IPMP_QCONTEXT_LIVE,
IPMP_QCONTEXT_SNAP
} ipmp_qcontext_t;
extern int ipmp_setqcontext(ipmp_handle_t, ipmp_qcontext_t);
extern int ipmp_getgrouplist(ipmp_handle_t, ipmp_grouplist_t **);
extern void ipmp_freegrouplist(ipmp_grouplist_t *);
extern int ipmp_getgroupinfo(ipmp_handle_t, const char *, ipmp_groupinfo_t **);
extern void ipmp_freegroupinfo(ipmp_groupinfo_t *);
extern int ipmp_getifinfo(ipmp_handle_t, const char *, ipmp_ifinfo_t **);
extern void ipmp_freeifinfo(ipmp_ifinfo_t *);
extern int ipmp_getaddrinfo(ipmp_handle_t, const char *,
struct sockaddr_storage *, ipmp_addrinfo_t **);
extern void ipmp_freeaddrinfo(ipmp_addrinfo_t *);
#ifdef __cplusplus
}
#endif
#endif