17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5e11c3f44Smeem  * Common Development and Distribution License (the "License").
6e11c3f44Smeem  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
20e11c3f44Smeem  *
21e11c3f44Smeem  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
23*80d556f9SHans Rosenfeld  *
24*80d556f9SHans Rosenfeld  * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_IPMP_MPATHD_H
287c478bd9Sstevel@tonic-gate #define	_IPMP_MPATHD_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * Definitions for the messaging protocol between in.mpathd and libipmp.
32e11c3f44Smeem  * This interface is project-private to the IPMP subsystem.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <sys/socket.h>		/* needed for <net/if.h> */
377c478bd9Sstevel@tonic-gate #include <net/if.h>		/* needed for LIFNAMSIZ */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	MPATHD_PORT	5999
44e11c3f44Smeem #define	MPATHD_PATH	"/lib/inet/in.mpathd"
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Supported commands.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate enum {
50e11c3f44Smeem 	MI_PING		= 0,	/* ping in.mpathd */
517c478bd9Sstevel@tonic-gate 	MI_OFFLINE	= 1,	/* offline the interface */
527c478bd9Sstevel@tonic-gate 	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
53e11c3f44Smeem 	MI_QUERY	= 3,	/* query ipmp-related information */
547c478bd9Sstevel@tonic-gate 	MI_NCMD			/* total number of commands */
557c478bd9Sstevel@tonic-gate };
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Types of information which can be requested and received (except for
59e11c3f44Smeem  * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received).
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate typedef enum {
627c478bd9Sstevel@tonic-gate 	IPMP_GROUPLIST	= 1,
637c478bd9Sstevel@tonic-gate 	IPMP_GROUPINFO	= 2,
64*80d556f9SHans Rosenfeld 	IPMP_GROUPCNT	= 3,
65*80d556f9SHans Rosenfeld 	IPMP_IFINFO	= 4,
66*80d556f9SHans Rosenfeld 	IPMP_IFLIST	= 5,
67*80d556f9SHans Rosenfeld 	IPMP_IFCNT	= 6,
68*80d556f9SHans Rosenfeld 	IPMP_ADDRLIST	= 7,
69*80d556f9SHans Rosenfeld 	IPMP_ADDRINFO	= 8,
70*80d556f9SHans Rosenfeld 	IPMP_ADDRCNT	= 9,
71*80d556f9SHans Rosenfeld 	IPMP_SNAP	= 10
727c478bd9Sstevel@tonic-gate } ipmp_infotype_t;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
75e11c3f44Smeem  * Daemon ping request.
76e11c3f44Smeem  */
77e11c3f44Smeem typedef struct mi_ping {
78e11c3f44Smeem 	uint32_t	mip_command;
79e11c3f44Smeem } mi_ping_t;
80e11c3f44Smeem 
81e11c3f44Smeem /*
827c478bd9Sstevel@tonic-gate  * Interface offline request; `mio_ifname' is the interface to offline;
837c478bd9Sstevel@tonic-gate  * `mio_min_redundancy' is the minimum amount of usable interfaces after
847c478bd9Sstevel@tonic-gate  * offline that must exist for the operation to succeed.
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate typedef struct mi_offline {
877c478bd9Sstevel@tonic-gate 	uint32_t	mio_command;
887c478bd9Sstevel@tonic-gate 	char		mio_ifname[LIFNAMSIZ];
897c478bd9Sstevel@tonic-gate 	uint32_t	mio_min_redundancy;
907c478bd9Sstevel@tonic-gate } mi_offline_t;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Interface undo-offline request; `miu_uname' is the interface to
947c478bd9Sstevel@tonic-gate  * undo-offline.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate typedef struct mi_undo_offline {
977c478bd9Sstevel@tonic-gate 	uint32_t	miu_command;
987c478bd9Sstevel@tonic-gate 	char		miu_ifname[LIFNAMSIZ];
997c478bd9Sstevel@tonic-gate } mi_undo_offline_t;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * Retrieve IPMP-related information: `miq_inforeq' is the type of information
103e11c3f44Smeem  * being request (see above for the list of types).  If the request type is
104e11c3f44Smeem  * IPMP_GROUPINFO, then `miq_grname' indicates the group.  If the request type
105e11c3f44Smeem  * is IPMP_IFINFO, then `miq_ifname' indicates the interface.  If the request
106e11c3f44Smeem  * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr'
107e11c3f44Smeem  * indicates the address.
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate typedef struct mi_query {
1107c478bd9Sstevel@tonic-gate 	uint32_t	miq_command;
1117c478bd9Sstevel@tonic-gate 	ipmp_infotype_t	miq_inforeq;
1127c478bd9Sstevel@tonic-gate 	union {
1137c478bd9Sstevel@tonic-gate 		char	miqu_ifname[LIFNAMSIZ];
1147c478bd9Sstevel@tonic-gate 		char	miqu_grname[LIFGRNAMSIZ];
1157c478bd9Sstevel@tonic-gate 	} miq_infodata;
116e11c3f44Smeem 	struct sockaddr_storage	miq_addr;
1177c478bd9Sstevel@tonic-gate } mi_query_t;
1187c478bd9Sstevel@tonic-gate #define	miq_ifname	miq_infodata.miqu_ifname
1197c478bd9Sstevel@tonic-gate #define	miq_grname	miq_infodata.miqu_grname
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Union of all commands. Can be used to estimate the maximum buffer size
1237c478bd9Sstevel@tonic-gate  * requirement for receiving any command.
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate union mi_commands {
1267c478bd9Sstevel@tonic-gate 	uint32_t		mi_command;
127e11c3f44Smeem 	mi_ping_t		mi_pcmd;
1287c478bd9Sstevel@tonic-gate 	mi_offline_t		mi_ocmd;
1297c478bd9Sstevel@tonic-gate 	mi_undo_offline_t	mi_ucmd;
1307c478bd9Sstevel@tonic-gate 	mi_query_t		mi_qcmd;
1317c478bd9Sstevel@tonic-gate };
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * Result structure returned by in.mpathd.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate typedef struct mi_result {
1377c478bd9Sstevel@tonic-gate 	uint32_t me_sys_error;			/* System error (errno.h) */
1387c478bd9Sstevel@tonic-gate 	uint32_t me_mpathd_error;		/* Mpathd error */
1397c478bd9Sstevel@tonic-gate } mi_result_t;
1407c478bd9Sstevel@tonic-gate 
141e11c3f44Smeem #define	IPMP_REQTIMEOUT	5			/* seconds */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate extern int ipmp_connect(int *);
1447c478bd9Sstevel@tonic-gate extern int ipmp_read(int, void *, size_t, const struct timeval *);
1457c478bd9Sstevel@tonic-gate extern int ipmp_write(int, const void *, size_t);
1467c478bd9Sstevel@tonic-gate extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
1477c478bd9Sstevel@tonic-gate extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
1487c478bd9Sstevel@tonic-gate     const struct timeval *);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate #endif
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #endif	/* _IPMP_MPATHD_H */
155