summaryrefslogtreecommitdiff
path: root/usr/src/lib/libipmp/common/ipmp_mpathd.h
blob: 7df3b4fd92eea3602eccbd200a5eb90e20646316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_IPMP_MPATHD_H
#define	_IPMP_MPATHD_H

/*
 * Definitions for the messaging protocol between in.mpathd and libipmp.
 * This interface is project-private to the IPMP subsystem.
 */

#include <sys/types.h>
#include <sys/socket.h>		/* needed for <net/if.h> */
#include <net/if.h>		/* needed for LIFNAMSIZ */

#ifdef	__cplusplus
extern "C" {
#endif

#define	MPATHD_PORT	5999
#define	MPATHD_PATH	"/lib/inet/in.mpathd"

/*
 * Supported commands.
 */
enum {
	MI_PING		= 0,	/* ping in.mpathd */
	MI_OFFLINE	= 1,	/* offline the interface */
	MI_UNDO_OFFLINE	= 2,	/* undo the offline */
	MI_QUERY	= 3,	/* query ipmp-related information */
	MI_NCMD			/* total number of commands */
};

/*
 * Types of information which can be requested and received (except for
 * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received).
 */
typedef enum {
	IPMP_GROUPLIST	= 1,
	IPMP_GROUPINFO	= 2,
	IPMP_IFINFO	= 3,
	IPMP_IFLIST	= 4,
	IPMP_SNAP	= 5,
	IPMP_ADDRLIST	= 6,
	IPMP_ADDRINFO	= 7
} ipmp_infotype_t;

/*
 * Daemon ping request.
 */
typedef struct mi_ping {
	uint32_t	mip_command;
} mi_ping_t;

/*
 * Interface offline request; `mio_ifname' is the interface to offline;
 * `mio_min_redundancy' is the minimum amount of usable interfaces after
 * offline that must exist for the operation to succeed.
 */
typedef struct mi_offline {
	uint32_t 	mio_command;
	char		mio_ifname[LIFNAMSIZ];
	uint32_t	mio_min_redundancy;
} mi_offline_t;

/*
 * Interface undo-offline request; `miu_uname' is the interface to
 * undo-offline.
 */
typedef struct mi_undo_offline {
	uint32_t	miu_command;
	char		miu_ifname[LIFNAMSIZ];
} mi_undo_offline_t;

/*
 * Retrieve IPMP-related information: `miq_inforeq' is the type of information
 * being request (see above for the list of types).  If the request type is
 * IPMP_GROUPINFO, then `miq_grname' indicates the group.  If the request type
 * is IPMP_IFINFO, then `miq_ifname' indicates the interface.  If the request
 * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr'
 * indicates the address.
 */
typedef struct mi_query {
	uint32_t	miq_command;
	ipmp_infotype_t	miq_inforeq;
	union {
		char	miqu_ifname[LIFNAMSIZ];
		char	miqu_grname[LIFGRNAMSIZ];
	} miq_infodata;
	struct sockaddr_storage	miq_addr;
} mi_query_t;
#define	miq_ifname	miq_infodata.miqu_ifname
#define	miq_grname	miq_infodata.miqu_grname

/*
 * Union of all commands. Can be used to estimate the maximum buffer size
 * requirement for receiving any command.
 */
union mi_commands {
	uint32_t		mi_command;
	mi_ping_t		mi_pcmd;
	mi_offline_t		mi_ocmd;
	mi_undo_offline_t	mi_ucmd;
	mi_query_t		mi_qcmd;
};

/*
 * Result structure returned by in.mpathd.
 */
typedef struct mi_result {
	uint32_t me_sys_error;			/* System error (errno.h) */
	uint32_t me_mpathd_error;		/* Mpathd error */
} mi_result_t;

#define	IPMP_REQTIMEOUT	5			/* seconds */

extern int ipmp_connect(int *);
extern int ipmp_read(int, void *, size_t, const struct timeval *);
extern int ipmp_write(int, const void *, size_t);
extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *);
extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **,
    const struct timeval *);

#ifdef	__cplusplus
}
#endif

#endif	/* _IPMP_MPATHD_H */