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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <libipmi.h>
27 #include <string.h>
28
29 #include "ipmi_impl.h"
30
31 ipmi_handle_t *
32 ipmi_open(int *errp, char **msg, uint_t xport_type, nvlist_t *params)
33 {
34 ipmi_handle_t *ihp;
35 static char errmsg[48];
36
37 if (msg)
38 *msg = NULL;
39
40 if ((ihp = calloc(sizeof (ipmi_handle_t), 1)) == NULL) {
41 *errp = EIPMI_NOMEM;
42 if (msg)
43 *msg = "memory allocation failure";
44 return (NULL);
45 }
46
47 switch (xport_type) {
48 case IPMI_TRANSPORT_BMC:
49 ihp->ih_transport = &ipmi_transport_bmc;
50 break;
51 case IPMI_TRANSPORT_LAN:
52 ihp->ih_transport = &ipmi_transport_lan;
53 break;
54 default:
55 *msg = "invalid transport type specified";
56 return (NULL);
57 }
58
59 ihp->ih_retries = 3;
60
|
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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright (c) 2018, Joyent, Inc.
26 */
27
28 #include <libipmi.h>
29 #include <string.h>
30
31 #include "ipmi_impl.h"
32
33 ipmi_handle_t *
34 ipmi_open(int *errp, char **msg, uint_t xport_type, nvlist_t *params)
35 {
36 ipmi_handle_t *ihp;
37 static char errmsg[48];
38
39 if (msg)
40 *msg = NULL;
41
42 if ((ihp = calloc(1, sizeof (ipmi_handle_t))) == NULL) {
43 *errp = EIPMI_NOMEM;
44 if (msg)
45 *msg = "memory allocation failure";
46 return (NULL);
47 }
48
49 switch (xport_type) {
50 case IPMI_TRANSPORT_BMC:
51 ihp->ih_transport = &ipmi_transport_bmc;
52 break;
53 case IPMI_TRANSPORT_LAN:
54 ihp->ih_transport = &ipmi_transport_lan;
55 break;
56 default:
57 *msg = "invalid transport type specified";
58 return (NULL);
59 }
60
61 ihp->ih_retries = 3;
62
|