/* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. */ #include #include #include #include #include #include #include #include int ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; uint8_t netfn, cmd; int i; uint8_t data[32]; if (argc < 2 || strncmp(argv[0], "help", 4) == 0) { lprintf(LOG_NOTICE, "RAW Commands: raw [data]"); return -1; } netfn = (uint8_t)strtol(argv[0], NULL, 0); cmd = (uint8_t)strtol(argv[1], NULL, 0); memset(data, 0, sizeof(data)); memset(&req, 0, sizeof(req)); req.msg.netfn = netfn; req.msg.cmd = cmd; req.msg.data = data; for (i=2; isendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Unable to send RAW command " "(netfn=0x%x cmd=0x%x)", req.msg.netfn, req.msg.cmd); return -1; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Unable to send RAW command " "(netfn=0x%x cmd=0x%x): %s", req.msg.netfn, req.msg.cmd, val2str(rsp->ccode, completion_code_vals)); return -1; } lprintf(LOG_INFO, "RAW RSP (%d bytes)", rsp->data_len); /* print the raw response buffer */ for (i=0; idata_len; i++) { if (((i%16) == 0) && (i != 0)) printf("\n"); printf(" %2.2x", rsp->data[i]); } printf("\n"); return 0; }