xref: /illumos-gate/usr/src/lib/libipmp/common/ipmp_mpathd.h (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
22  * Use is subject to license terms.
23  *
24  * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
25  */
26 
27 #ifndef	_IPMP_MPATHD_H
28 #define	_IPMP_MPATHD_H
29 
30 /*
31  * Definitions for the messaging protocol between in.mpathd and libipmp.
32  * This interface is project-private to the IPMP subsystem.
33  */
34 
35 #include <sys/types.h>
36 #include <sys/socket.h>		/* needed for <net/if.h> */
37 #include <net/if.h>		/* needed for LIFNAMSIZ */
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #define	MPATHD_PORT	5999
44 #define	MPATHD_PATH	"/lib/inet/in.mpathd"
45 
46 /*
47  * Supported commands.
48  */
49 enum {
50 	MI_PING		= 0,	/* ping in.mpathd */
51 	MI_OFFLINE	= 1,	/* offline the interface */
52 	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
53 	MI_QUERY	= 3,	/* query ipmp-related information */
54 	MI_NCMD			/* total number of commands */
55 };
56 
57 /*
58  * Types of information which can be requested and received (except for
59  * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received).
60  */
61 typedef enum {
62 	IPMP_GROUPLIST	= 1,
63 	IPMP_GROUPINFO	= 2,
64 	IPMP_GROUPCNT	= 3,
65 	IPMP_IFINFO	= 4,
66 	IPMP_IFLIST	= 5,
67 	IPMP_IFCNT	= 6,
68 	IPMP_ADDRLIST	= 7,
69 	IPMP_ADDRINFO	= 8,
70 	IPMP_ADDRCNT	= 9,
71 	IPMP_SNAP	= 10
72 } ipmp_infotype_t;
73 
74 /*
75  * Daemon ping request.
76  */
77 typedef struct mi_ping {
78 	uint32_t	mip_command;
79 } mi_ping_t;
80 
81 /*
82  * Interface offline request; `mio_ifname' is the interface to offline;
83  * `mio_min_redundancy' is the minimum amount of usable interfaces after
84  * offline that must exist for the operation to succeed.
85  */
86 typedef struct mi_offline {
87 	uint32_t	mio_command;
88 	char		mio_ifname[LIFNAMSIZ];
89 	uint32_t	mio_min_redundancy;
90 } mi_offline_t;
91 
92 /*
93  * Interface undo-offline request; `miu_uname' is the interface to
94  * undo-offline.
95  */
96 typedef struct mi_undo_offline {
97 	uint32_t	miu_command;
98 	char		miu_ifname[LIFNAMSIZ];
99 } mi_undo_offline_t;
100 
101 /*
102  * Retrieve IPMP-related information: `miq_inforeq' is the type of information
103  * being request (see above for the list of types).  If the request type is
104  * IPMP_GROUPINFO, then `miq_grname' indicates the group.  If the request type
105  * is IPMP_IFINFO, then `miq_ifname' indicates the interface.  If the request
106  * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr'
107  * indicates the address.
108  */
109 typedef struct mi_query {
110 	uint32_t	miq_command;
111 	ipmp_infotype_t	miq_inforeq;
112 	union {
113 		char	miqu_ifname[LIFNAMSIZ];
114 		char	miqu_grname[LIFGRNAMSIZ];
115 	} miq_infodata;
116 	struct sockaddr_storage	miq_addr;
117 } mi_query_t;
118 #define	miq_ifname	miq_infodata.miqu_ifname
119 #define	miq_grname	miq_infodata.miqu_grname
120 
121 /*
122  * Union of all commands. Can be used to estimate the maximum buffer size
123  * requirement for receiving any command.
124  */
125 union mi_commands {
126 	uint32_t		mi_command;
127 	mi_ping_t		mi_pcmd;
128 	mi_offline_t		mi_ocmd;
129 	mi_undo_offline_t	mi_ucmd;
130 	mi_query_t		mi_qcmd;
131 };
132 
133 /*
134  * Result structure returned by in.mpathd.
135  */
136 typedef struct mi_result {
137 	uint32_t me_sys_error;			/* System error (errno.h) */
138 	uint32_t me_mpathd_error;		/* Mpathd error */
139 } mi_result_t;
140 
141 #define	IPMP_REQTIMEOUT	5			/* seconds */
142 
143 extern int ipmp_connect(int *);
144 extern int ipmp_read(int, void *, size_t, const struct timeval *);
145 extern int ipmp_write(int, const void *, size_t);
146 extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
147 extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
148     const struct timeval *);
149 
150 #ifdef	__cplusplus
151 }
152 #endif
153 
154 #endif	/* _IPMP_MPATHD_H */
155