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 2003 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 /*
32 *
33 * MODULE: dapl_get_handle_type.c
34 *
35 * PURPOSE: Interface Adapter management
36 * Description: Interfaces in this file are completely described in
37 * the DAPL 1.1 API, Chapter 6, section 2
38 *
39 */
40
41 #include "dapl.h"
42
43 /*
44 * dapl_get_handle_type
45 *
46 * DAPL Requirements Version xxx, 6.2.2.6
47 *
48 * Gets the handle type for the given dat_handle
49 *
50 * Input:
51 * dat_handle
52 *
53 * Output:
54 * handle_type
55 *
56 * Returns:
57 * DAT_SUCCESS
58 * DAT_INVALID_PARAMETER
59 */
60 DAT_RETURN
dapl_get_handle_type(IN DAT_HANDLE dat_handle,OUT DAT_HANDLE_TYPE * handle_type)61 dapl_get_handle_type(
62 IN DAT_HANDLE dat_handle,
63 OUT DAT_HANDLE_TYPE *handle_type)
64 {
65 DAT_RETURN dat_status;
66 DAPL_HEADER *header;
67
68 dat_status = DAT_SUCCESS;
69
70 header = (DAPL_HEADER *)dat_handle;
71 if (((header) == NULL) ||
72 ((unsigned long)(header) & 3) ||
73 (header->magic != DAPL_MAGIC_IA &&
74 header->magic != DAPL_MAGIC_EVD &&
75 header->magic != DAPL_MAGIC_EP &&
76 header->magic != DAPL_MAGIC_LMR &&
77 header->magic != DAPL_MAGIC_RMR &&
78 header->magic != DAPL_MAGIC_PZ &&
79 header->magic != DAPL_MAGIC_PSP &&
80 header->magic != DAPL_MAGIC_RSP &&
81 header->magic != DAPL_MAGIC_CR)) {
82 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
83 goto bail;
84 }
85 *handle_type = header->handle_type;
86
87 bail:
88 return (dat_status);
89 }
90