xref: /titanic_52/usr/src/lib/libipmp/common/ipmp_mpathd.h (revision c2580b931007758eab8cb5ae8726ebe1588e259b)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1999-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_IPMP_MPATHD_H
28 #define	_IPMP_MPATHD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Definitions for the messaging protocol between in.mpathd and libipmp.
34  * This interface is loosely documented in PSARC/2000/306.
35  *
36  * PLEASE NOTE: Although this interface is officially consolidation-private,
37  * we will be reclassifying it as project-private in the future, and
38  * transitioning any existing consumers to use higher-level libipmp routines.
39  *
40  * Put another way: treat this as if it was project-private!
41  */
42 
43 #include <sys/types.h>
44 #include <sys/socket.h>		/* needed for <net/if.h> */
45 #include <net/if.h>		/* needed for LIFNAMSIZ */
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 #define	MPATHD_PORT	5999
52 #define	MPATHD_PATH	"/usr/lib/inet/in.mpathd"
53 
54 /*
55  * Supported commands.
56  */
57 enum {
58 	MI_PING		= 0,	/* sanity test */
59 	MI_OFFLINE	= 1,	/* offline the interface */
60 	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
61 	MI_SETOINDEX	= 3,	/* set original interface index */
62 	MI_QUERY	= 4,	/* query ipmp-related information */
63 	MI_NCMD			/* total number of commands */
64 };
65 
66 /*
67  * Types of information which can be requested and received (except for
68  * IPMP_IFLIST, which can only be received).
69  */
70 typedef enum {
71 	IPMP_GROUPLIST	= 1,
72 	IPMP_GROUPINFO	= 2,
73 	IPMP_IFINFO	= 3,
74 	IPMP_IFLIST	= 4,
75 	IPMP_SNAP	= 5
76 } ipmp_infotype_t;
77 
78 /*
79  * Interface offline request; `mio_ifname' is the interface to offline;
80  * `mio_min_redundancy' is the minimum amount of usable interfaces after
81  * offline that must exist for the operation to succeed.
82  */
83 typedef struct mi_offline {
84 	uint32_t 	mio_command;
85 	char		mio_ifname[LIFNAMSIZ];
86 	char		mio_move_to_if[LIFNAMSIZ]; /* currently unused */
87 	uint32_t	mio_min_redundancy;
88 } mi_offline_t;
89 
90 /*
91  * Interface undo-offline request; `miu_uname' is the interface to
92  * undo-offline.
93  */
94 typedef struct mi_undo_offline {
95 	uint32_t	miu_command;
96 	char		miu_ifname[LIFNAMSIZ];
97 } mi_undo_offline_t;
98 
99 /*
100  * Set original interface index request: `mis_lifname' is the name of the
101  * logical interface that is having its index reset; `mis_new_pifname' is the
102  * name of the interface whose index will be associated with `mis_lifname';
103  * `mis_iftype' is the interface type.
104  */
105 typedef struct mi_setoindex {
106 	uint32_t	mis_command;
107 	char		mis_lifname[LIFNAMSIZ];
108 	char		mis_new_pifname[LIFNAMSIZ];
109 	uint32_t	mis_iftype;
110 } mi_setoindex_t;
111 
112 /*
113  * Retrieve IPMP-related information: `miq_inforeq' is the type of information
114  * being request (see above for the list of types).  If the request is for
115  * either IPMP_GROUPINFO or IPMP_IFINFO, then either `miq_grname' or
116  * `miq_ifname' should be set (respectively) to indicate the name of the
117  * group or interface to retrieve the information for.
118  */
119 typedef struct mi_query {
120 	uint32_t	miq_command;
121 	ipmp_infotype_t	miq_inforeq;
122 	union {
123 		char	miqu_ifname[LIFNAMSIZ];
124 		char	miqu_grname[LIFGRNAMSIZ];
125 	} miq_infodata;
126 } mi_query_t;
127 #define	miq_ifname	miq_infodata.miqu_ifname
128 #define	miq_grname	miq_infodata.miqu_grname
129 
130 /*
131  * Union of all commands. Can be used to estimate the maximum buffer size
132  * requirement for receiving any command.
133  */
134 union mi_commands {
135 	uint32_t mi_command;
136 	mi_offline_t		mi_ocmd;
137 	mi_undo_offline_t	mi_ucmd;
138 	mi_setoindex_t 		mi_scmd;
139 	mi_query_t		mi_qcmd;
140 };
141 
142 /*
143  * Result structure returned by in.mpathd.
144  */
145 typedef struct mi_result {
146 	uint32_t me_sys_error;			/* System error (errno.h) */
147 	uint32_t me_mpathd_error;		/* Mpathd error */
148 } mi_result_t;
149 
150 /*
151  * Legacy values for me_mpathd_error; the daemon now returns the IPMP
152  * error codes defined in <ipmp.h>, which are compatible with these error
153  * codes.  These will be removed in the future.
154  */
155 enum {
156 	MPATHD_SUCCESS		= 0,	/* operation succeeded */
157 	MPATHD_SYS_ERROR	= 1,	/* check me_sys_error for the errno */
158 	MPATHD_MIN_RED_ERROR	= 2,	/* minimum redundancy not met */
159 	MPATHD_FAILBACK_DISABLED = 3,	/* failback administratively disabled */
160 	MPATHD_FAILBACK_PARTIAL = 4	/* unable to completely failback */
161 };
162 
163 extern int ipmp_connect(int *);
164 extern int ipmp_read(int, void *, size_t, const struct timeval *);
165 extern int ipmp_write(int, const void *, size_t);
166 extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
167 extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
168     const struct timeval *);
169 
170 #ifdef	__cplusplus
171 }
172 #endif
173 
174 #endif	/* _IPMP_MPATHD_H */
175