/* * 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 int ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; unsigned char netfn, cmd; int i; unsigned char data[32]; if (argc < 2 || !strncmp(argv[0], "help", 4)) { printf("RAW Commands: raw [data]\n"); return -1; } netfn = (unsigned char)strtol(argv[0], NULL, 0); cmd = (unsigned char)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 || rsp->ccode) { printf("Error:%x sending RAW command\n", rsp ? rsp->ccode : 0); return -1; } if (verbose) printf("RAW RSP (%d bytes)\n", rsp->data_len); for (i=0; idata_len; i++) { if (((i%16) == 0) && (i != 0)) printf("\n"); printf(" %2.2x", rsp->data[i]); } printf("\n"); return 0; }