2
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
8
* Redistribution of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
11
* Redistribution in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* Neither the name of Sun Microsystems, Inc. or the names of
16
* contributors may be used to endorse or promote products derived
17
* from this software without specific prior written permission.
19
* This software is provided "AS IS," without a warranty of any kind.
20
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
24
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
26
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32
* You acknowledge that this software is not designed or intended for use
33
* in the design, construction, operation or maintenance of any nuclear
42
#include <ipmitool/ipmi_intf.h>
43
#include <ipmitool/ipmi.h>
44
#include <ipmitool/ipmi_sdr.h>
45
#include <ipmitool/log.h>
48
extern struct ipmi_intf ipmi_open_intf;
51
extern struct ipmi_intf ipmi_imb_intf;
53
#ifdef IPMI_INTF_LIPMI
54
extern struct ipmi_intf ipmi_lipmi_intf;
57
extern struct ipmi_intf ipmi_bmc_intf;
60
extern struct ipmi_intf ipmi_lan_intf;
62
#ifdef IPMI_INTF_LANPLUS
63
extern struct ipmi_intf ipmi_lanplus_intf;
66
struct ipmi_intf * ipmi_intf_table[] = {
73
#ifdef IPMI_INTF_LIPMI
82
#ifdef IPMI_INTF_LANPLUS
88
/* ipmi_intf_print - Print list of interfaces
90
* no meaningful return code
92
void ipmi_intf_print(void)
94
struct ipmi_intf ** intf;
97
lprintf(LOG_NOTICE, "Interfaces:");
99
for (intf = ipmi_intf_table; intf && *intf; intf++) {
100
lprintf(LOG_NOTICE, "\t%-12s %s %s",
101
(*intf)->name, (*intf)->desc,
102
def ? "[default]" : "");
105
lprintf(LOG_NOTICE, "");
108
/* ipmi_intf_load - Load an interface from the interface table above
109
* If no interface name is given return first entry
111
* @name: interface name to try and load
113
* returns pointer to inteface structure if found
114
* returns NULL on error
116
struct ipmi_intf * ipmi_intf_load(char * name)
118
struct ipmi_intf ** intf;
119
struct ipmi_intf * i;
122
i = ipmi_intf_table[0];
123
if (i->setup != NULL && (i->setup(i) < 0)) {
124
lprintf(LOG_ERR, "Unable to setup "
125
"interface %s", name);
131
for (intf = ipmi_intf_table;
132
((intf != NULL) && (*intf != NULL));
135
if (strncmp(name, i->name, strlen(name)) == 0) {
136
if (i->setup != NULL && (i->setup(i) < 0)) {
137
lprintf(LOG_ERR, "Unable to setup "
138
"interface %s", name);
149
ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname)
151
if (intf->session == NULL)
154
memset(intf->session->hostname, 0, 16);
156
if (hostname != NULL) {
157
memcpy(intf->session->hostname, hostname,
158
__min(strlen(hostname), 64));
163
ipmi_intf_session_set_username(struct ipmi_intf * intf, char * username)
165
if (intf->session == NULL)
168
memset(intf->session->username, 0, 16);
170
if (username == NULL)
173
memcpy(intf->session->username, username, __min(strlen(username), 16));
177
ipmi_intf_session_set_password(struct ipmi_intf * intf, char * password)
179
if (intf->session == NULL)
182
memset(intf->session->authcode, 0, IPMI_AUTHCODE_BUFFER_SIZE);
184
if (password == NULL) {
185
intf->session->password = 0;
189
intf->session->password = 1;
190
memcpy(intf->session->authcode, password,
191
__min(strlen(password), IPMI_AUTHCODE_BUFFER_SIZE));
195
ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t level)
197
if (intf->session == NULL)
200
intf->session->privlvl = level;
204
ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id)
206
if (intf->session == NULL)
209
intf->session->cipher_suite_id = cipher_suite_id;
213
ipmi_intf_session_set_port(struct ipmi_intf * intf, int port)
215
if (intf->session == NULL)
218
intf->session->port = port;
222
ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype)
224
if (intf->session == NULL)
227
intf->session->authtype_set = authtype;
231
ipmi_cleanup(struct ipmi_intf * intf)
233
ipmi_sdr_list_empty(intf);