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 
22 /*
23  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 /*
32  *
33  * MODULE: dapl_rmr_query.c
34  *
35  * PURPOSE: Memory management
36  * Description: Interfaces in this file are completely described in
37  *		the DAPL 1.1 API, Chapter 6, section 6
38  *
39  */
40 
41 #include "dapl.h"
42 
43 /*
44  * dapl_rmr_query
45  *
46  * DAPL Requirements Version xxx, 6.6.4.3
47  *
48  * Provide the RMR arguments.
49  *
50  * Input:
51  * 	rmr_handle
52  * 	rmr_args_mask
53  *
54  * Output:
55  * 	rmr_args
56  *
57  * Returns:
58  * 	DAT_SUCCESS
59  *      DAT_INVALID_HANDLE
60  * 	DAT_INVALID_PARAMETER
61  */
62 DAT_RETURN
dapl_rmr_query(IN DAT_RMR_HANDLE rmr_handle,IN DAT_RMR_PARAM_MASK rmr_param_mask,IN DAT_RMR_PARAM * rmr_param)63 dapl_rmr_query(IN DAT_RMR_HANDLE rmr_handle,
64 	IN DAT_RMR_PARAM_MASK rmr_param_mask,
65 	IN DAT_RMR_PARAM *rmr_param)
66 {
67 	DAPL_RMR *rmr;
68 	DAT_RETURN dat_status;
69 
70 	dat_status = DAT_SUCCESS;
71 
72 	if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
73 		dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
74 		    DAT_INVALID_HANDLE_RMR);
75 		goto bail;
76 	}
77 	if (NULL == rmr_param) {
78 		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
79 		goto bail;
80 	}
81 
82 	rmr = (DAPL_RMR *)rmr_handle;
83 
84 	/* If the RMR is unbound, there is no LMR triplet associated with   */
85 	/* this RMR.  If the consumer requests this field, return an error. */
86 	if ((rmr_param_mask & DAT_RMR_FIELD_LMR_TRIPLET) &&
87 	    (NULL == rmr->lmr)) {
88 		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER,
89 		    DAT_INVALID_ARG2);
90 		goto bail;
91 	}
92 
93 	(void) dapl_os_memcpy(rmr_param, &rmr->param, sizeof (DAT_RMR_PARAM));
94 
95 bail:
96 	return (dat_status);
97 }
98