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 
33 #ifndef IPMI_CHANNEL_H
34 #define IPMI_CHANNEL_H
35 
36 #if HAVE_CONFIG_H
37 # include <config.h>
38 #endif
39 #include <ipmitool/ipmi.h>
40 
41 
42 #define IPMI_GET_CHANNEL_AUTH_CAP      0x38
43 #define IPMI_SET_CHANNEL_ACCESS        0x40
44 #define IPMI_GET_CHANNEL_ACCESS        0x41
45 #define IPMI_GET_CHANNEL_INFO          0x42
46 #define IPMI_SET_USER_ACCESS           0x43
47 #define IPMI_GET_USER_ACCESS           0x44
48 #define IPMI_SET_USER_NAME             0x45
49 #define IPMI_GET_USER_NAME             0x46
50 #define IPMI_SET_USER_PASSWORD         0x47
51 #define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54
52 
53 /* These are for channel_info_t.session_support */
54 #define IPMI_CHANNEL_SESSION_LESS 0x00
55 #define IPMI_CHANNEL_SESSION_SINGLE 0x40
56 #define IPMI_CHANNEL_SESSION_MULTI 0x80
57 #define IPMI_CHANNEL_SESSION_BASED 0xC0
58 
59 /* (22.24) Get Channel Info */
60 struct channel_info_t {
61 	uint8_t channel;
62 	uint8_t medium;
63 	uint8_t protocol;
64 	uint8_t session_support;
65 	uint8_t active_sessions;
66 	uint8_t vendor_id[3];
67 	uint8_t aux_info[2];
68 };
69 
70 /* (22.23) Get Channel Access */
71 struct channel_access_t {
72 	uint8_t access_mode;
73 	uint8_t alerting;
74 	uint8_t channel;
75 	uint8_t per_message_auth;
76 	uint8_t privilege_limit;
77 	uint8_t user_level_auth;
78 };
79 
80 /*
81  * The Get Authentication Capabilities response structure
82  * From table 22-15 of the IPMI v2.0 spec
83  */
84 #ifdef HAVE_PRAGMA_PACK
85 #pragma pack(1)
86 #endif
87 struct get_channel_auth_cap_rsp {
88 	uint8_t channel_number;
89 #if WORDS_BIGENDIAN
90 	uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */
91 	uint8_t __reserved1        : 1;
92 	uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */
93 #else
94 	uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */
95 	uint8_t __reserved1        : 1;
96 	uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */
97 #endif
98 #if WORDS_BIGENDIAN
99 	uint8_t __reserved2        : 2;
100 	uint8_t kg_status          : 1; /* two-key login status */
101 	uint8_t per_message_auth   : 1; /* per-message authentication status */
102 	uint8_t user_level_auth    : 1; /* user-level authentication status */
103 	uint8_t non_null_usernames : 1; /* one or more non-null users exist */
104 	uint8_t null_usernames     : 1; /* one or more null usernames non-null pwds */
105 	uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */
106 #else
107 	uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */
108 	uint8_t null_usernames     : 1; /* one or more null usernames non-null pwds */
109 	uint8_t non_null_usernames : 1; /* one or more non-null users exist */
110 	uint8_t user_level_auth    : 1; /* user-level authentication status */
111 	uint8_t per_message_auth   : 1; /* per-message authentication status */
112 	uint8_t kg_status          : 1; /* two-key login status */
113 	uint8_t __reserved2        : 2;
114 #endif
115 #if WORDS_BIGENDIAN
116 	uint8_t __reserved3        : 6;
117 	uint8_t ipmiv20_support    : 1; /* channel supports IPMI v2.0 connections */
118 	uint8_t ipmiv15_support    : 1; /* channel supports IPMI v1.5 connections */
119 #else
120 	uint8_t ipmiv15_support    : 1; /* channel supports IPMI v1.5 connections */
121 	uint8_t ipmiv20_support    : 1; /* channel supports IPMI v2.0 connections */
122 	uint8_t __reserved3        : 6;
123 #endif
124 	uint8_t oem_id[3];    /* IANA enterprise number for auth type */
125 	uint8_t oem_aux_data; /* Additional OEM specific data for oem auths */
126 } ATTRIBUTE_PACKING;
127 #ifdef HAVE_PRAGMA_PACK
128 #pragma pack(0)
129 #endif
130 
131 int _ipmi_get_channel_access(struct ipmi_intf *intf,
132 		struct channel_access_t *channel_access,
133 		uint8_t get_volatile_settings);
134 int _ipmi_set_channel_access(struct ipmi_intf *intf,
135 		struct channel_access_t channel_access, uint8_t access_option,
136 		uint8_t privilege_option);
137 
138 uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel);
139 uint8_t ipmi_current_channel_medium(struct ipmi_intf * intf);
140 int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv);
141 int ipmi_get_channel_auth_cap(struct ipmi_intf * intf, uint8_t channel, uint8_t priv);
142 int ipmi_get_channel_info(struct ipmi_intf * intf, uint8_t channel);
143 
144 #endif /*IPMI_CHANNEL_H*/
145