xref: /illumos-gate/usr/src/lib/libipmp/common/ipmp_mpathd.h (revision 1f6352c601b7f3c744b4684ff673c813927da24c)
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 
25 #ifndef	_IPMP_MPATHD_H
26 #define	_IPMP_MPATHD_H
27 
28 /*
29  * Definitions for the messaging protocol between in.mpathd and libipmp.
30  * This interface is project-private to the IPMP subsystem.
31  */
32 
33 #include <sys/types.h>
34 #include <sys/socket.h>		/* needed for <net/if.h> */
35 #include <net/if.h>		/* needed for LIFNAMSIZ */
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #define	MPATHD_PORT	5999
42 #define	MPATHD_PATH	"/lib/inet/in.mpathd"
43 
44 /*
45  * Supported commands.
46  */
47 enum {
48 	MI_PING		= 0,	/* ping in.mpathd */
49 	MI_OFFLINE	= 1,	/* offline the interface */
50 	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
51 	MI_QUERY	= 3,	/* query ipmp-related information */
52 	MI_NCMD			/* total number of commands */
53 };
54 
55 /*
56  * Types of information which can be requested and received (except for
57  * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received).
58  */
59 typedef enum {
60 	IPMP_GROUPLIST	= 1,
61 	IPMP_GROUPINFO	= 2,
62 	IPMP_IFINFO	= 3,
63 	IPMP_IFLIST	= 4,
64 	IPMP_SNAP	= 5,
65 	IPMP_ADDRLIST	= 6,
66 	IPMP_ADDRINFO	= 7
67 } ipmp_infotype_t;
68 
69 /*
70  * Daemon ping request.
71  */
72 typedef struct mi_ping {
73 	uint32_t	mip_command;
74 } mi_ping_t;
75 
76 /*
77  * Interface offline request; `mio_ifname' is the interface to offline;
78  * `mio_min_redundancy' is the minimum amount of usable interfaces after
79  * offline that must exist for the operation to succeed.
80  */
81 typedef struct mi_offline {
82 	uint32_t 	mio_command;
83 	char		mio_ifname[LIFNAMSIZ];
84 	uint32_t	mio_min_redundancy;
85 } mi_offline_t;
86 
87 /*
88  * Interface undo-offline request; `miu_uname' is the interface to
89  * undo-offline.
90  */
91 typedef struct mi_undo_offline {
92 	uint32_t	miu_command;
93 	char		miu_ifname[LIFNAMSIZ];
94 } mi_undo_offline_t;
95 
96 /*
97  * Retrieve IPMP-related information: `miq_inforeq' is the type of information
98  * being request (see above for the list of types).  If the request type is
99  * IPMP_GROUPINFO, then `miq_grname' indicates the group.  If the request type
100  * is IPMP_IFINFO, then `miq_ifname' indicates the interface.  If the request
101  * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr'
102  * indicates the address.
103  */
104 typedef struct mi_query {
105 	uint32_t	miq_command;
106 	ipmp_infotype_t	miq_inforeq;
107 	union {
108 		char	miqu_ifname[LIFNAMSIZ];
109 		char	miqu_grname[LIFGRNAMSIZ];
110 	} miq_infodata;
111 	struct sockaddr_storage	miq_addr;
112 } mi_query_t;
113 #define	miq_ifname	miq_infodata.miqu_ifname
114 #define	miq_grname	miq_infodata.miqu_grname
115 
116 /*
117  * Union of all commands. Can be used to estimate the maximum buffer size
118  * requirement for receiving any command.
119  */
120 union mi_commands {
121 	uint32_t		mi_command;
122 	mi_ping_t		mi_pcmd;
123 	mi_offline_t		mi_ocmd;
124 	mi_undo_offline_t	mi_ucmd;
125 	mi_query_t		mi_qcmd;
126 };
127 
128 /*
129  * Result structure returned by in.mpathd.
130  */
131 typedef struct mi_result {
132 	uint32_t me_sys_error;			/* System error (errno.h) */
133 	uint32_t me_mpathd_error;		/* Mpathd error */
134 } mi_result_t;
135 
136 #define	IPMP_REQTIMEOUT	5			/* seconds */
137 
138 extern int ipmp_connect(int *);
139 extern int ipmp_read(int, void *, size_t, const struct timeval *);
140 extern int ipmp_write(int, const void *, size_t);
141 extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
142 extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
143     const struct timeval *);
144 
145 #ifdef	__cplusplus
146 }
147 #endif
148 
149 #endif	/* _IPMP_MPATHD_H */
150