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.
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.
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]
21 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
22 * Use is subject to license terms.
26 * IPMP administrative interfaces (see PSARC/2007/272).
34 #include <sys/types.h>
36 #include "ipmp_impl.h"
37 #include "ipmp_mpathd.h"
38 #include "ipmp_admin.h"
41 ipmp_command(ipmp_handle_t handle
, const void *req
, uint_t reqsize
)
43 ipmp_state_t
*statep
= (ipmp_state_t
*)handle
;
49 if (gettimeofday(&end
, NULL
) == -1)
50 return (IPMP_FAILURE
);
51 end
.tv_sec
+= IPMP_REQTIMEOUT
;
53 assert(statep
->st_fd
== -1);
54 retval
= ipmp_connect(&statep
->st_fd
);
55 if (retval
!= IPMP_SUCCESS
)
58 retval
= ipmp_write(statep
->st_fd
, req
, reqsize
);
59 if (retval
!= IPMP_SUCCESS
)
62 retval
= ipmp_read(statep
->st_fd
, &result
, sizeof (result
), &end
);
63 if (retval
!= IPMP_SUCCESS
)
66 errno
= result
.me_sys_error
;
67 retval
= result
.me_mpathd_error
;
70 (void) close(statep
->st_fd
);
77 ipmp_offline(ipmp_handle_t handle
, const char *ifname
, uint_t minred
)
81 mio
.mio_command
= MI_OFFLINE
;
82 mio
.mio_min_redundancy
= minred
;
83 (void) strlcpy(mio
.mio_ifname
, ifname
, LIFNAMSIZ
);
84 return (ipmp_command(handle
, &mio
, sizeof (mio
)));
88 ipmp_undo_offline(ipmp_handle_t handle
, const char *ifname
)
90 mi_undo_offline_t miu
;
92 miu
.miu_command
= MI_UNDO_OFFLINE
;
93 (void) strlcpy(miu
.miu_ifname
, ifname
, LIFNAMSIZ
);
94 return (ipmp_command(handle
, &miu
, sizeof (miu
)));
98 ipmp_ping_daemon(ipmp_handle_t handle
)
102 mip
.mip_command
= MI_PING
;
103 return (ipmp_command(handle
, &mip
, sizeof (mip
)));