ipmi_lan.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * LAN transport-specific data 2N/A * Calculate and returns IPMI checksum 2N/A * Checksum algorithm is described in Section 13.8 2N/A * d: buffer to check 2N/A * s: position in buffer to start checksum from 2N/A for (; s > 0; s--, d++)
2N/A * The first read may return ECONNREFUSED because the rmcp ping 2N/A * packet--sent to UDP port 623--will be processed by both the 2N/A * The problem with this is that the ECONNREFUSED takes 2N/A * priority over any other received datagram; that means that 2N/A * the Connection Refused shows up _before_ the response packet, 2N/A * regardless of the order they were sent out. (unless the 2N/A * response is read before the connection refused is returned) 2N/A * See section 13.2.4 2N/A * parse response RMCP "pong" packet 2N/A * return -1 if ping response not received 2N/A * returns 0 if IPMI is NOT supported 2N/A * returns 1 if IPMI is supported 2N/A /*LINTED: E_BAD_PTR_CAST_ALIGN*/ 2N/A * Build and send RMCP presence ping message 2N/A /* parse response headers */ 2N/A /* ping response packet */ 2N/A /* handled by rest of function */ 2N/A /* Invalid RMCP class */ 2N/A /* shift response data to start of array */ 2N/A * IPMI LAN Request Message Format 2N/A * +---------------------+ 2N/A * | rmcp_hdr_t | 4 bytes 2N/A * +---------------------+ 2N/A * | v15_session_hdr_t | 9 bytes 2N/A * +---------------------+ 2N/A * | [authcode] | 16 bytes (if AUTHTYPE != none) 2N/A * +---------------------+ 2N/A * | msg length | 1 byte 2N/A * +---------------------+ 2N/A * | ipmi_msg_hdr_t | 6 bytes 2N/A * +---------------------+ 2N/A * | [msg data] | variable 2N/A * +---------------------+ 2N/A * | msg data checksum | 1 byte 2N/A * +---------------------+ 2N/A /* ipmi_errno set */ 2N/A /* IPMI session header */ 2N/A /* hardcode passwd authentication */ 2N/A /* IPMI session authcode */ 2N/A /* message length */ 2N/A /* IPMI message header */ 2N/A /* message data checksum */ 2N/A * IPMI Get Session Challenge Command 2N/A * Copies the returned session ID and 16-byte challenge string to the supplied 2N/A * IPMI Activate Session Command 2N/A /* setup initial outbound sequence number */ 2N/A * returns privilege level or -1 on error 2N/A * IPMI LAN Session Activation 2N/A * 1. send "RMCP Presence Ping" message, response message will 2N/A * indicate whether the platform supports IPMI 2N/A * 2. send "Get Channel Authentication Capabilities" command 2N/A * with AUTHTYPE = none, response packet will contain information 2N/A * 3. send "Get Session Challenge" command with AUTHTYPE = none 2N/A * and indicate the authentication type in the message, response 2N/A * packet will contain challenge string and temporary session ID. 2N/A * 4. send "Activate Session" command, authenticated with AUTHTYPE 2N/A * sent in previous message. Also sends the initial value for 2N/A * the outbound sequence number for BMC. 2N/A * 5. BMC returns response confirming session activation and 2N/A * session ID for this session and initial inbound sequence. 2N/A * For the sake of simplicity, we're just supporting basic password 2N/A * authentication. If this authentication type is not supported then 2N/A /* ipmi errno set */ 2N/A * Parse the parameters passed in the params nvlist. The following 2N/A * parameters are required 2N/A * IPMI_LAN_HOST, IPMI_LAN_USER and IPMI_LAN_PASSWD 2N/A * If any of these were not specified then we abort 2N/A * IPMI_LAN_PORT is an optional parameter and defaults to port 623 2N/A * IPMI_LAN_PRIVLVL is also optional and defaults to admin 2N/A * IPMI_LAN_TIMEOUT is optional and will default to 3 seconds 2N/A * IPMI_LAN_NUM_RETIES is optional and will default to 5 2N/A * Open up and connect a UDP socket between us and the service 2N/A * Finally we start up the IPMI LAN session