xref: /onnv-gate/usr/src/lib/libipmp/common/ipmp_mpathd.h (revision 8485:633e5b5eb268)
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_MPATHD_H
260Sstevel@tonic-gate #define	_IPMP_MPATHD_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Definitions for the messaging protocol between in.mpathd and libipmp.
30*8485SPeter.Memishian@Sun.COM  * This interface is project-private to the IPMP subsystem.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <sys/socket.h>		/* needed for <net/if.h> */
350Sstevel@tonic-gate #include <net/if.h>		/* needed for LIFNAMSIZ */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	MPATHD_PORT	5999
42*8485SPeter.Memishian@Sun.COM #define	MPATHD_PATH	"/lib/inet/in.mpathd"
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Supported commands.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate enum {
48*8485SPeter.Memishian@Sun.COM 	MI_PING		= 0,	/* ping in.mpathd */
490Sstevel@tonic-gate 	MI_OFFLINE	= 1,	/* offline the interface */
500Sstevel@tonic-gate 	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
51*8485SPeter.Memishian@Sun.COM 	MI_QUERY	= 3,	/* query ipmp-related information */
520Sstevel@tonic-gate 	MI_NCMD			/* total number of commands */
530Sstevel@tonic-gate };
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * Types of information which can be requested and received (except for
57*8485SPeter.Memishian@Sun.COM  * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received).
580Sstevel@tonic-gate  */
590Sstevel@tonic-gate typedef enum {
600Sstevel@tonic-gate 	IPMP_GROUPLIST	= 1,
610Sstevel@tonic-gate 	IPMP_GROUPINFO	= 2,
620Sstevel@tonic-gate 	IPMP_IFINFO	= 3,
630Sstevel@tonic-gate 	IPMP_IFLIST	= 4,
64*8485SPeter.Memishian@Sun.COM 	IPMP_SNAP	= 5,
65*8485SPeter.Memishian@Sun.COM 	IPMP_ADDRLIST	= 6,
66*8485SPeter.Memishian@Sun.COM 	IPMP_ADDRINFO	= 7
670Sstevel@tonic-gate } ipmp_infotype_t;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /*
70*8485SPeter.Memishian@Sun.COM  * Daemon ping request.
71*8485SPeter.Memishian@Sun.COM  */
72*8485SPeter.Memishian@Sun.COM typedef struct mi_ping {
73*8485SPeter.Memishian@Sun.COM 	uint32_t	mip_command;
74*8485SPeter.Memishian@Sun.COM } mi_ping_t;
75*8485SPeter.Memishian@Sun.COM 
76*8485SPeter.Memishian@Sun.COM /*
770Sstevel@tonic-gate  * Interface offline request; `mio_ifname' is the interface to offline;
780Sstevel@tonic-gate  * `mio_min_redundancy' is the minimum amount of usable interfaces after
790Sstevel@tonic-gate  * offline that must exist for the operation to succeed.
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate typedef struct mi_offline {
820Sstevel@tonic-gate 	uint32_t 	mio_command;
830Sstevel@tonic-gate 	char		mio_ifname[LIFNAMSIZ];
840Sstevel@tonic-gate 	uint32_t	mio_min_redundancy;
850Sstevel@tonic-gate } mi_offline_t;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate /*
880Sstevel@tonic-gate  * Interface undo-offline request; `miu_uname' is the interface to
890Sstevel@tonic-gate  * undo-offline.
900Sstevel@tonic-gate  */
910Sstevel@tonic-gate typedef struct mi_undo_offline {
920Sstevel@tonic-gate 	uint32_t	miu_command;
930Sstevel@tonic-gate 	char		miu_ifname[LIFNAMSIZ];
940Sstevel@tonic-gate } mi_undo_offline_t;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
970Sstevel@tonic-gate  * Retrieve IPMP-related information: `miq_inforeq' is the type of information
98*8485SPeter.Memishian@Sun.COM  * being request (see above for the list of types).  If the request type is
99*8485SPeter.Memishian@Sun.COM  * IPMP_GROUPINFO, then `miq_grname' indicates the group.  If the request type
100*8485SPeter.Memishian@Sun.COM  * is IPMP_IFINFO, then `miq_ifname' indicates the interface.  If the request
101*8485SPeter.Memishian@Sun.COM  * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr'
102*8485SPeter.Memishian@Sun.COM  * indicates the address.
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate typedef struct mi_query {
1050Sstevel@tonic-gate 	uint32_t	miq_command;
1060Sstevel@tonic-gate 	ipmp_infotype_t	miq_inforeq;
1070Sstevel@tonic-gate 	union {
1080Sstevel@tonic-gate 		char	miqu_ifname[LIFNAMSIZ];
1090Sstevel@tonic-gate 		char	miqu_grname[LIFGRNAMSIZ];
1100Sstevel@tonic-gate 	} miq_infodata;
111*8485SPeter.Memishian@Sun.COM 	struct sockaddr_storage	miq_addr;
1120Sstevel@tonic-gate } mi_query_t;
1130Sstevel@tonic-gate #define	miq_ifname	miq_infodata.miqu_ifname
1140Sstevel@tonic-gate #define	miq_grname	miq_infodata.miqu_grname
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate  * Union of all commands. Can be used to estimate the maximum buffer size
1180Sstevel@tonic-gate  * requirement for receiving any command.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate union mi_commands {
121*8485SPeter.Memishian@Sun.COM 	uint32_t		mi_command;
122*8485SPeter.Memishian@Sun.COM 	mi_ping_t		mi_pcmd;
1230Sstevel@tonic-gate 	mi_offline_t		mi_ocmd;
1240Sstevel@tonic-gate 	mi_undo_offline_t	mi_ucmd;
1250Sstevel@tonic-gate 	mi_query_t		mi_qcmd;
1260Sstevel@tonic-gate };
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
1290Sstevel@tonic-gate  * Result structure returned by in.mpathd.
1300Sstevel@tonic-gate  */
1310Sstevel@tonic-gate typedef struct mi_result {
1320Sstevel@tonic-gate 	uint32_t me_sys_error;			/* System error (errno.h) */
1330Sstevel@tonic-gate 	uint32_t me_mpathd_error;		/* Mpathd error */
1340Sstevel@tonic-gate } mi_result_t;
1350Sstevel@tonic-gate 
136*8485SPeter.Memishian@Sun.COM #define	IPMP_REQTIMEOUT	5			/* seconds */
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate extern int ipmp_connect(int *);
1390Sstevel@tonic-gate extern int ipmp_read(int, void *, size_t, const struct timeval *);
1400Sstevel@tonic-gate extern int ipmp_write(int, const void *, size_t);
1410Sstevel@tonic-gate extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
1420Sstevel@tonic-gate extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
1430Sstevel@tonic-gate     const struct timeval *);
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #ifdef	__cplusplus
1460Sstevel@tonic-gate }
1470Sstevel@tonic-gate #endif
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate #endif	/* _IPMP_MPATHD_H */
150