~ubuntu-branches/ubuntu/maverick/ipmitool/maverick

« back to all changes in this revision

Viewing changes to include/ipmitool/ipmi_intf.h

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2005-04-07 01:18:44 UTC
  • Revision ID: james.westby@ubuntu.com-20050407011844-a1b206z5iefiu5vi
Tags: upstream-1.8.1
ImportĀ upstreamĀ versionĀ 1.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2003 Sun Microsystems, Inc.  All Rights Reserved.
 
3
 * 
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 
 
8
 * Redistribution of source code must retain the above copyright
 
9
 * notice, this list of conditions and the following disclaimer.
 
10
 * 
 
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.
 
14
 * 
 
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.
 
18
 * 
 
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.
 
31
 * 
 
32
 * You acknowledge that this software is not designed or intended for use
 
33
 * in the design, construction, operation or maintenance of any nuclear
 
34
 * facility.
 
35
 */
 
36
 
 
37
#ifndef IPMI_INTF_H
 
38
#define IPMI_INTF_H
 
39
 
 
40
#include <ipmitool/ipmi.h>
 
41
#include <ipmitool/ipmi_oem.h>
 
42
#include <ipmitool/ipmi_constants.h>
 
43
 
 
44
#include <sys/types.h>
 
45
#include <arpa/inet.h>
 
46
#include <sys/socket.h>
 
47
#include <netinet/in.h>
 
48
 
 
49
/*
 
50
 * An enumeration that describes every possible session state for
 
51
 * an IPMIv2 / RMCP+ session.
 
52
 */
 
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,
 
60
        LANPLUS_STATE_ACTIVE,
 
61
        LANPLUS_STATE_CLOSE_SENT,
 
62
};
 
63
 
 
64
 
 
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 */
 
68
 
 
69
struct ipmi_session {
 
70
        uint8_t hostname[64];
 
71
        uint8_t username[16];
 
72
        uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
 
73
        uint8_t challenge[16];
 
74
        uint8_t authtype;
 
75
        uint8_t authtype_set;
 
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
 
81
        uint8_t authstatus;
 
82
        uint8_t authextra;
 
83
        uint8_t privlvl;
 
84
        uint8_t cipher_suite_id;
 
85
        int password;
 
86
        int port;
 
87
        int active;
 
88
 
 
89
        uint32_t session_id;
 
90
        uint32_t in_seq;
 
91
        uint32_t out_seq;
 
92
        uint32_t timeout;
 
93
 
 
94
        struct sockaddr_in addr;
 
95
        socklen_t addrlen;
 
96
 
 
97
        /*
 
98
         * This struct holds state data specific to IMPI v2 / RMCP+ sessions
 
99
         */
 
100
        struct {
 
101
                enum LANPLUS_SESSION_STATE session_state;
 
102
 
 
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;
 
107
                uint8_t auth_alg;
 
108
                uint8_t integrity_alg;
 
109
                uint8_t crypt_alg;
 
110
                uint8_t max_priv_level;
 
111
 
 
112
                uint32_t console_id;
 
113
                uint32_t bmc_id;
 
114
 
 
115
                /*
 
116
                 * Values required for RAKP mesages
 
117
                 */
 
118
 
 
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];
 
123
 
 
124
                uint8_t bmc_guid[16];
 
125
                uint8_t requested_role;   /* As sent in the RAKP 1 message */
 
126
                uint8_t rakp2_return_code;
 
127
 
 
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  */
 
132
        } v2_data;
 
133
 
 
134
 
 
135
        /*
 
136
         * This data is specific to the Serial Over Lan session
 
137
         */
 
138
        struct {
 
139
                uint16_t max_inbound_payload_size;
 
140
                uint16_t max_outbound_payload_size;
 
141
                uint16_t port;
 
142
                uint8_t sequence_number;
 
143
 
 
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);
 
148
        } sol_data;
 
149
};
 
150
 
 
151
struct ipmi_intf {
 
152
        char name[16];
 
153
        char desc[128];
 
154
        int fd;
 
155
        int opened;
 
156
        int abort;
 
157
 
 
158
        struct ipmi_session * session;
 
159
        struct ipmi_oem_handle * oem;
 
160
        uint32_t my_addr;
 
161
        uint32_t target_addr;
 
162
 
 
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);
 
171
};
 
172
 
 
173
struct ipmi_intf * ipmi_intf_load(char * name);
 
174
void ipmi_intf_print(void);
 
175
 
 
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);
 
184
 
 
185
#endif /* IPMI_INTF_H */