1*3798Seschrock /* 2*3798Seschrock * CDDL HEADER START 3*3798Seschrock * 4*3798Seschrock * The contents of this file are subject to the terms of the 5*3798Seschrock * Common Development and Distribution License (the "License"). 6*3798Seschrock * You may not use this file except in compliance with the License. 7*3798Seschrock * 8*3798Seschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*3798Seschrock * or http://www.opensolaris.org/os/licensing. 10*3798Seschrock * See the License for the specific language governing permissions 11*3798Seschrock * and limitations under the License. 12*3798Seschrock * 13*3798Seschrock * When distributing Covered Code, include this CDDL HEADER in each 14*3798Seschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*3798Seschrock * If applicable, add the following below this CDDL HEADER, with the 16*3798Seschrock * fields enclosed by brackets "[]" replaced with your own identifying 17*3798Seschrock * information: Portions Copyright [yyyy] [name of copyright owner] 18*3798Seschrock * 19*3798Seschrock * CDDL HEADER END 20*3798Seschrock */ 21*3798Seschrock /* 22*3798Seschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*3798Seschrock * Use is subject to license terms. 24*3798Seschrock */ 25*3798Seschrock 26*3798Seschrock #pragma ident "%Z%%M% %I% %E% SMI" 27*3798Seschrock 28*3798Seschrock #include <libipmi.h> 29*3798Seschrock #include <string.h> 30*3798Seschrock 31*3798Seschrock #include "ipmi_impl.h" 32*3798Seschrock 33*3798Seschrock ipmi_deviceid_t * 34*3798Seschrock ipmi_get_deviceid(ipmi_handle_t *ihp) 35*3798Seschrock { 36*3798Seschrock ipmi_cmd_t cmd, *resp; 37*3798Seschrock 38*3798Seschrock if (ihp->ih_deviceid_valid) 39*3798Seschrock return (&ihp->ih_deviceid); 40*3798Seschrock 41*3798Seschrock cmd.ic_netfn = IPMI_NETFN_APP; 42*3798Seschrock cmd.ic_lun = 0; 43*3798Seschrock cmd.ic_cmd = IPMI_CMD_GET_DEVICEID; 44*3798Seschrock cmd.ic_data = NULL; 45*3798Seschrock cmd.ic_dlen = 0; 46*3798Seschrock 47*3798Seschrock if ((resp = ipmi_send(ihp, &cmd)) == NULL) 48*3798Seschrock return (NULL); 49*3798Seschrock 50*3798Seschrock if (resp->ic_dlen < sizeof (ipmi_deviceid_t)) { 51*3798Seschrock (void) ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL); 52*3798Seschrock return (NULL); 53*3798Seschrock } 54*3798Seschrock 55*3798Seschrock (void) memcpy(&ihp->ih_deviceid, resp->ic_data, 56*3798Seschrock sizeof (ipmi_deviceid_t)); 57*3798Seschrock ihp->ih_deviceid.id_product = LE_16(ihp->ih_deviceid.id_product); 58*3798Seschrock ihp->ih_deviceid_valid = B_TRUE; 59*3798Seschrock 60*3798Seschrock return (&ihp->ih_deviceid); 61*3798Seschrock } 62