1*c18ec02fSPetter Reinholdtsen /*
2*c18ec02fSPetter Reinholdtsen * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3*c18ec02fSPetter Reinholdtsen *
4*c18ec02fSPetter Reinholdtsen * Redistribution and use in source and binary forms, with or without
5*c18ec02fSPetter Reinholdtsen * modification, are permitted provided that the following conditions
6*c18ec02fSPetter Reinholdtsen * are met:
7*c18ec02fSPetter Reinholdtsen *
8*c18ec02fSPetter Reinholdtsen * Redistribution of source code must retain the above copyright
9*c18ec02fSPetter Reinholdtsen * notice, this list of conditions and the following disclaimer.
10*c18ec02fSPetter Reinholdtsen *
11*c18ec02fSPetter Reinholdtsen * Redistribution in binary form must reproduce the above copyright
12*c18ec02fSPetter Reinholdtsen * notice, this list of conditions and the following disclaimer in the
13*c18ec02fSPetter Reinholdtsen * documentation and/or other materials provided with the distribution.
14*c18ec02fSPetter Reinholdtsen *
15*c18ec02fSPetter Reinholdtsen * Neither the name of Sun Microsystems, Inc. or the names of
16*c18ec02fSPetter Reinholdtsen * contributors may be used to endorse or promote products derived
17*c18ec02fSPetter Reinholdtsen * from this software without specific prior written permission.
18*c18ec02fSPetter Reinholdtsen *
19*c18ec02fSPetter Reinholdtsen * This software is provided "AS IS," without a warranty of any kind.
20*c18ec02fSPetter Reinholdtsen * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21*c18ec02fSPetter Reinholdtsen * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22*c18ec02fSPetter Reinholdtsen * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23*c18ec02fSPetter Reinholdtsen * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
24*c18ec02fSPetter Reinholdtsen * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25*c18ec02fSPetter Reinholdtsen * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
26*c18ec02fSPetter Reinholdtsen * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27*c18ec02fSPetter Reinholdtsen * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28*c18ec02fSPetter Reinholdtsen * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29*c18ec02fSPetter Reinholdtsen * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30*c18ec02fSPetter Reinholdtsen * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31*c18ec02fSPetter Reinholdtsen */
32*c18ec02fSPetter Reinholdtsen
33*c18ec02fSPetter Reinholdtsen #include "lanplus.h"
34*c18ec02fSPetter Reinholdtsen #include "lanplus_dump.h"
35*c18ec02fSPetter Reinholdtsen
36*c18ec02fSPetter Reinholdtsen extern const struct valstr ipmi_rakp_return_codes[];
37*c18ec02fSPetter Reinholdtsen extern const struct valstr ipmi_priv_levels[];
38*c18ec02fSPetter Reinholdtsen extern const struct valstr ipmi_auth_algorithms[];
39*c18ec02fSPetter Reinholdtsen extern const struct valstr ipmi_integrity_algorithms[];
40*c18ec02fSPetter Reinholdtsen extern const struct valstr ipmi_encryption_algorithms[];
41*c18ec02fSPetter Reinholdtsen
42*c18ec02fSPetter Reinholdtsen #define DUMP_PREFIX_INCOMING "<<"
43*c18ec02fSPetter Reinholdtsen
lanplus_dump_open_session_response(const struct ipmi_rs * rsp)44*c18ec02fSPetter Reinholdtsen void lanplus_dump_open_session_response(const struct ipmi_rs * rsp)
45*c18ec02fSPetter Reinholdtsen {
46*c18ec02fSPetter Reinholdtsen if (verbose < 2)
47*c18ec02fSPetter Reinholdtsen return;
48*c18ec02fSPetter Reinholdtsen
49*c18ec02fSPetter Reinholdtsen printf("%sOPEN SESSION RESPONSE\n", DUMP_PREFIX_INCOMING);
50*c18ec02fSPetter Reinholdtsen
51*c18ec02fSPetter Reinholdtsen printf("%s Message tag : 0x%02x\n",
52*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
53*c18ec02fSPetter Reinholdtsen rsp->payload.open_session_response.message_tag);
54*c18ec02fSPetter Reinholdtsen printf("%s RMCP+ status : %s\n",
55*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
56*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.open_session_response.rakp_return_code,
57*c18ec02fSPetter Reinholdtsen ipmi_rakp_return_codes));
58*c18ec02fSPetter Reinholdtsen printf("%s Maximum privilege level : %s\n",
59*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
60*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.open_session_response.max_priv_level,
61*c18ec02fSPetter Reinholdtsen ipmi_priv_levels));
62*c18ec02fSPetter Reinholdtsen printf("%s Console Session ID : 0x%08lx\n",
63*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
64*c18ec02fSPetter Reinholdtsen (long)rsp->payload.open_session_response.console_id);
65*c18ec02fSPetter Reinholdtsen
66*c18ec02fSPetter Reinholdtsen /* only tag, status, privlvl, and console id are returned if error */
67*c18ec02fSPetter Reinholdtsen if (rsp->payload.open_session_response.rakp_return_code !=
68*c18ec02fSPetter Reinholdtsen IPMI_RAKP_STATUS_NO_ERRORS)
69*c18ec02fSPetter Reinholdtsen return;
70*c18ec02fSPetter Reinholdtsen
71*c18ec02fSPetter Reinholdtsen printf("%s BMC Session ID : 0x%08lx\n",
72*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
73*c18ec02fSPetter Reinholdtsen (long)rsp->payload.open_session_response.bmc_id);
74*c18ec02fSPetter Reinholdtsen printf("%s Negotiated authenticatin algorithm : %s\n",
75*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
76*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.open_session_response.auth_alg,
77*c18ec02fSPetter Reinholdtsen ipmi_auth_algorithms));
78*c18ec02fSPetter Reinholdtsen printf("%s Negotiated integrity algorithm : %s\n",
79*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
80*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.open_session_response.integrity_alg,
81*c18ec02fSPetter Reinholdtsen ipmi_integrity_algorithms));
82*c18ec02fSPetter Reinholdtsen printf("%s Negotiated encryption algorithm : %s\n",
83*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
84*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.open_session_response.crypt_alg,
85*c18ec02fSPetter Reinholdtsen ipmi_encryption_algorithms));
86*c18ec02fSPetter Reinholdtsen printf("\n");
87*c18ec02fSPetter Reinholdtsen }
88*c18ec02fSPetter Reinholdtsen
89*c18ec02fSPetter Reinholdtsen
90*c18ec02fSPetter Reinholdtsen
lanplus_dump_rakp2_message(const struct ipmi_rs * rsp,uint8_t auth_alg)91*c18ec02fSPetter Reinholdtsen void lanplus_dump_rakp2_message(const struct ipmi_rs * rsp, uint8_t auth_alg)
92*c18ec02fSPetter Reinholdtsen {
93*c18ec02fSPetter Reinholdtsen int i;
94*c18ec02fSPetter Reinholdtsen
95*c18ec02fSPetter Reinholdtsen if (verbose < 2)
96*c18ec02fSPetter Reinholdtsen return;
97*c18ec02fSPetter Reinholdtsen
98*c18ec02fSPetter Reinholdtsen printf("%sRAKP 2 MESSAGE\n", DUMP_PREFIX_INCOMING);
99*c18ec02fSPetter Reinholdtsen
100*c18ec02fSPetter Reinholdtsen printf("%s Message tag : 0x%02x\n",
101*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
102*c18ec02fSPetter Reinholdtsen rsp->payload.rakp2_message.message_tag);
103*c18ec02fSPetter Reinholdtsen
104*c18ec02fSPetter Reinholdtsen printf("%s RMCP+ status : %s\n",
105*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
106*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.rakp2_message.rakp_return_code,
107*c18ec02fSPetter Reinholdtsen ipmi_rakp_return_codes));
108*c18ec02fSPetter Reinholdtsen
109*c18ec02fSPetter Reinholdtsen printf("%s Console Session ID : 0x%08lx\n",
110*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
111*c18ec02fSPetter Reinholdtsen (long)rsp->payload.rakp2_message.console_id);
112*c18ec02fSPetter Reinholdtsen
113*c18ec02fSPetter Reinholdtsen printf("%s BMC random number : 0x", DUMP_PREFIX_INCOMING);
114*c18ec02fSPetter Reinholdtsen for (i = 0; i < 16; ++i)
115*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp2_message.bmc_rand[i]);
116*c18ec02fSPetter Reinholdtsen printf("\n");
117*c18ec02fSPetter Reinholdtsen
118*c18ec02fSPetter Reinholdtsen printf("%s BMC GUID : 0x", DUMP_PREFIX_INCOMING);
119*c18ec02fSPetter Reinholdtsen for (i = 0; i < 16; ++i)
120*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp2_message.bmc_guid[i]);
121*c18ec02fSPetter Reinholdtsen printf("\n");
122*c18ec02fSPetter Reinholdtsen
123*c18ec02fSPetter Reinholdtsen switch(auth_alg)
124*c18ec02fSPetter Reinholdtsen {
125*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_NONE:
126*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code : none\n", DUMP_PREFIX_INCOMING);
127*c18ec02fSPetter Reinholdtsen break;
128*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_HMAC_SHA1:
129*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code [sha1] : 0x", DUMP_PREFIX_INCOMING);
130*c18ec02fSPetter Reinholdtsen for (i = 0; i < 20; ++i)
131*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp2_message.key_exchange_auth_code[i]);
132*c18ec02fSPetter Reinholdtsen printf("\n");
133*c18ec02fSPetter Reinholdtsen break;
134*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_HMAC_MD5:
135*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code [md5] : 0x", DUMP_PREFIX_INCOMING);
136*c18ec02fSPetter Reinholdtsen for (i = 0; i < 16; ++i)
137*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp2_message.key_exchange_auth_code[i]);
138*c18ec02fSPetter Reinholdtsen printf("\n");
139*c18ec02fSPetter Reinholdtsen break;
140*c18ec02fSPetter Reinholdtsen default:
141*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code : invalid", DUMP_PREFIX_INCOMING);
142*c18ec02fSPetter Reinholdtsen }
143*c18ec02fSPetter Reinholdtsen printf("\n");
144*c18ec02fSPetter Reinholdtsen }
145*c18ec02fSPetter Reinholdtsen
146*c18ec02fSPetter Reinholdtsen
147*c18ec02fSPetter Reinholdtsen
lanplus_dump_rakp4_message(const struct ipmi_rs * rsp,uint8_t auth_alg)148*c18ec02fSPetter Reinholdtsen void lanplus_dump_rakp4_message(const struct ipmi_rs * rsp, uint8_t auth_alg)
149*c18ec02fSPetter Reinholdtsen {
150*c18ec02fSPetter Reinholdtsen int i;
151*c18ec02fSPetter Reinholdtsen
152*c18ec02fSPetter Reinholdtsen if (verbose < 2)
153*c18ec02fSPetter Reinholdtsen return;
154*c18ec02fSPetter Reinholdtsen
155*c18ec02fSPetter Reinholdtsen printf("%sRAKP 4 MESSAGE\n", DUMP_PREFIX_INCOMING);
156*c18ec02fSPetter Reinholdtsen
157*c18ec02fSPetter Reinholdtsen printf("%s Message tag : 0x%02x\n",
158*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
159*c18ec02fSPetter Reinholdtsen rsp->payload.rakp4_message.message_tag);
160*c18ec02fSPetter Reinholdtsen
161*c18ec02fSPetter Reinholdtsen printf("%s RMCP+ status : %s\n",
162*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
163*c18ec02fSPetter Reinholdtsen val2str(rsp->payload.rakp4_message.rakp_return_code,
164*c18ec02fSPetter Reinholdtsen ipmi_rakp_return_codes));
165*c18ec02fSPetter Reinholdtsen
166*c18ec02fSPetter Reinholdtsen printf("%s Console Session ID : 0x%08lx\n",
167*c18ec02fSPetter Reinholdtsen DUMP_PREFIX_INCOMING,
168*c18ec02fSPetter Reinholdtsen (long)rsp->payload.rakp4_message.console_id);
169*c18ec02fSPetter Reinholdtsen
170*c18ec02fSPetter Reinholdtsen switch(auth_alg)
171*c18ec02fSPetter Reinholdtsen {
172*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_NONE:
173*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code : none\n", DUMP_PREFIX_INCOMING);
174*c18ec02fSPetter Reinholdtsen break;
175*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_HMAC_SHA1:
176*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code [sha1] : 0x", DUMP_PREFIX_INCOMING);
177*c18ec02fSPetter Reinholdtsen for (i = 0; i < 12; ++i)
178*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp4_message.integrity_check_value[i]);
179*c18ec02fSPetter Reinholdtsen printf("\n");
180*c18ec02fSPetter Reinholdtsen break;
181*c18ec02fSPetter Reinholdtsen case IPMI_AUTH_RAKP_HMAC_MD5:
182*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code [md5] : 0x", DUMP_PREFIX_INCOMING);
183*c18ec02fSPetter Reinholdtsen for (i = 0; i < 12; ++i)
184*c18ec02fSPetter Reinholdtsen printf("%02x", rsp->payload.rakp4_message.integrity_check_value[i]);
185*c18ec02fSPetter Reinholdtsen printf("\n");
186*c18ec02fSPetter Reinholdtsen break;
187*c18ec02fSPetter Reinholdtsen default:
188*c18ec02fSPetter Reinholdtsen printf("%s Key exchange auth code : invalid", DUMP_PREFIX_INCOMING);
189*c18ec02fSPetter Reinholdtsen }
190*c18ec02fSPetter Reinholdtsen printf("\n");
191*c18ec02fSPetter Reinholdtsen }
192*c18ec02fSPetter Reinholdtsen
193