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
40
#include <ipmitool/ipmi.h>
41
#include <ipmitool/ipmi_oem.h>
42
#include <ipmitool/ipmi_constants.h>
44
#include <sys/types.h>
45
#include <arpa/inet.h>
46
#include <sys/socket.h>
47
#include <netinet/in.h>
50
* An enumeration that describes every possible session state for
51
* an IPMIv2 / RMCP+ session.
53
enum LANPLUS_SESSION_STATE {
54
LANPLUS_STATE_PRESESSION = 0,
55
LANPLUS_STATE_OPEN_SESSION_SENT,
56
LANPLUS_STATE_OPEN_SESSION_RECEIEVED,
57
LANPLUS_STATE_RAKP_1_SENT,
58
LANPLUS_STATE_RAKP_2_RECEIVED,
59
LANPLUS_STATE_RAKP_3_SENT,
61
LANPLUS_STATE_CLOSE_SENT,
65
#define IPMI_AUTHCODE_BUFFER_SIZE 20
66
#define IPMI_SIK_BUFFER_SIZE 20
67
#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
72
uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
73
uint8_t challenge[16];
76
#define IPMI_AUTHSTATUS_PER_MSG_DISABLED 0x10
77
#define IPMI_AUTHSTATUS_PER_USER_DISABLED 0x08
78
#define IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED 0x04
79
#define IPMI_AUTHSTATUS_NULL_USERS_ENABLED 0x02
80
#define IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED 0x01
84
uint8_t cipher_suite_id;
94
struct sockaddr_in addr;
98
* This struct holds state data specific to IMPI v2 / RMCP+ sessions
101
enum LANPLUS_SESSION_STATE session_state;
103
/* These are the algorithms agreed upon for the session */
104
uint8_t requested_auth_alg;
105
uint8_t requested_integrity_alg;
106
uint8_t requested_crypt_alg;
108
uint8_t integrity_alg;
110
uint8_t max_priv_level;
116
* Values required for RAKP mesages
119
/* Random number generated byt the console */
120
uint8_t console_rand[16];
121
/* Random number generated by the BMC */
122
uint8_t bmc_rand[16];
124
uint8_t bmc_guid[16];
125
uint8_t requested_role; /* As sent in the RAKP 1 message */
126
uint8_t rakp2_return_code;
128
uint8_t sik[IPMI_SIK_BUFFER_SIZE]; /* Session integrity key */
129
uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */
130
uint8_t k1[20]; /* Used for Integrity checking? */
131
uint8_t k2[20]; /* First 16 bytes used for AES */
136
* This data is specific to the Serial Over Lan session
139
uint16_t max_inbound_payload_size;
140
uint16_t max_outbound_payload_size;
142
uint8_t sequence_number;
144
/* This data describes the last SOL packet */
145
uint8_t last_received_sequence_number;
146
uint8_t last_received_byte_count;
147
void (*sol_input_handler)(struct ipmi_rs * rsp);
158
struct ipmi_session * session;
159
struct ipmi_oem_handle * oem;
161
uint32_t target_addr;
163
int (*setup)(struct ipmi_intf * intf);
164
int (*open)(struct ipmi_intf * intf);
165
void (*close)(struct ipmi_intf * intf);
166
struct ipmi_rs *(*sendrecv)(struct ipmi_intf * intf, struct ipmi_rq * req);
167
int (*sendrsp)(struct ipmi_intf * intf, struct ipmi_rs * rsp);
168
struct ipmi_rs *(*recv_sol)(struct ipmi_intf * intf);
169
struct ipmi_rs *(*send_sol)(struct ipmi_intf * intf, struct ipmi_v2_payload * payload);
170
int (*keepalive)(struct ipmi_intf * intf);
173
struct ipmi_intf * ipmi_intf_load(char * name);
174
void ipmi_intf_print(void);
176
void ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname);
177
void ipmi_intf_session_set_username(struct ipmi_intf * intf, char * username);
178
void ipmi_intf_session_set_password(struct ipmi_intf * intf, char * password);
179
void ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t privlvl);
180
void ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id);
181
void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
182
void ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype);
183
void ipmi_cleanup(struct ipmi_intf * intf);
185
#endif /* IPMI_INTF_H */