123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194 |
- /*
- * Copyright (c) 2005 International Business Machines, Inc. All Rights Reserved.
- * 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.
- */
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <time.h>
- #include <ipmitool/helper.h>
- #include <ipmitool/log.h>
- #include <ipmitool/bswap.h>
- #include <ipmitool/ipmi.h>
- #include <ipmitool/ipmi_intf.h>
- #include <ipmitool/ipmi_firewall.h>
- #include <ipmitool/ipmi_strings.h>
- static void
- printf_firewall_usage(void)
- {
- lprintf(LOG_NOTICE,
- "Firmware Firewall Commands:");
- lprintf(LOG_NOTICE,
- "\tinfo [channel H] [lun L]");
- lprintf(LOG_NOTICE,
- "\tinfo [channel H] [lun L [netfn N [command C [subfn S]]]]");
- lprintf(LOG_NOTICE,
- "\tenable [channel H] [lun L [netfn N [command C [subfn S]]]]");
- lprintf(LOG_NOTICE,
- "\tdisable [channel H] [lun L [netfn N [command C [subfn S]]]] [force])");
- lprintf(LOG_NOTICE,
- "\treset [channel H]");
- lprintf(LOG_NOTICE,
- "\t\twhere H is a Channel, L is a LUN, N is a NetFn,");
- lprintf(LOG_NOTICE,
- "\t\tC is a Command and S is a Sub-Function");
- }
- void
- printf_firewall_info_usage(void)
- {
- lprintf(LOG_NOTICE,
- "info [channel H]");
- lprintf(LOG_NOTICE,
- "\tList all of the firewall information for all LUNs, NetFns");
- lprintf(LOG_NOTICE,
- "\tand Commands, This is a long list and is not very human readable.");
- lprintf(LOG_NOTICE,
- "info [channel H] lun L");
- lprintf(LOG_NOTICE,
- "\tThis also prints a long list that is not very human readable.");
- lprintf(LOG_NOTICE,
- "info [channel H] lun L netfn N");
- lprintf(LOG_NOTICE,
- "\tThis prints out information for a single LUN/NetFn pair.");
- lprintf(LOG_NOTICE,
- "\tThat is not really very usable, but at least it is short.");
- lprintf(LOG_NOTICE,
- "info [channel H] lun L netfn N command C");
- lprintf(LOG_NOTICE,
- "\tThis is the one you want -- it prints out detailed human");
- lprintf(LOG_NOTICE,
- "\treadable information. It shows the support, configurable, and");
- lprintf(LOG_NOTICE,
- "\tenabled bits for the Command C on LUN/NetFn pair L,N and the");
- lprintf(LOG_NOTICE,
- "\tsame information about each of its Sub-functions.");
- }
- // print n bytes of bit field bf (if invert, print ~bf)
- static void print_bitfield(const unsigned char * bf, int n, int invert, int loglevel) {
- int i = 0;
- if (loglevel < 0) {
- while (i<n) {
- printf("%02x", (unsigned char) (invert?~bf[i]:bf[i]));
- if (++i % 4 == 0)
- printf(" ");
- }
- printf("\n");
- } else {
- while (i<n) {
- lprintf(loglevel, "%02x", (unsigned char) (invert?~bf[i]:bf[i]));
- if (++i % 4 == 0)
- lprintf(loglevel, " ");
- }
- lprintf(loglevel, "\n");
- }
- }
- static int
- ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p)
- {
- int i;
- uint8_t conv_err = 0;
- if (!p) {
- lprintf(LOG_ERR, "ipmi_firewall_parse_args: p is NULL");
- return -1;
- }
- for (i=0; i<argc; i++) {
- if (strncmp(argv[i], "channel", 7) == 0 && (++i < argc)) {
- uint8_t channel_tmp = 0;
- if (is_ipmi_channel_num(argv[i], &channel_tmp) != 0) {
- conv_err = 1;
- break;
- } else {
- p->channel = channel_tmp;
- }
- }
- else if (strncmp(argv[i], "lun", 3) == 0 && (++i < argc)) {
- if (str2int(argv[i], &(p->lun)) != 0) {
- lprintf(LOG_ERR, "Given lun '%s' is invalid.", argv[i]);
- conv_err = 1;
- break;
- }
- }
- else if (strncmp(argv[i], "force", 5) == 0) {
- p->force = 1;
- }
- else if (strncmp(argv[i], "netfn", 5) == 0 && (++i < argc)) {
- if (str2int(argv[i], &(p->netfn)) != 0) {
- lprintf(LOG_ERR, "Given netfn '%s' is invalid.", argv[i]);
- conv_err = 1;
- break;
- }
- }
- else if (strncmp(argv[i], "command", 7) == 0 && (++i < argc)) {
- if (str2int(argv[i], &(p->command)) != 0) {
- lprintf(LOG_ERR, "Given command '%s' is invalid.", argv[i]);
- conv_err = 1;
- break;
- }
- }
- else if (strncmp(argv[i], "subfn", 5) == 0 && (++i < argc)) {
- if (str2int(argv[i], &(p->subfn)) != 0) {
- lprintf(LOG_ERR, "Given subfn '%s' is invalid.", argv[i]);
- conv_err = 1;
- break;
- }
- }
- }
- if (conv_err != 0) {
- return (-1);
- }
- if (p->subfn >= MAX_SUBFN) {
- lprintf(LOG_ERR, "subfn is out of range (0-%d)", MAX_SUBFN-1);
- return -1;
- }
- if (p->command >= MAX_COMMAND) {
- lprintf(LOG_ERR, "command is out of range (0-%d)", MAX_COMMAND-1);
- return -1;
- }
- if (p->netfn >= MAX_NETFN) {
- lprintf(LOG_ERR, "netfn is out of range (0-%d)", MAX_NETFN-1);
- return -1;
- }
- if (p->lun >= MAX_LUN) {
- lprintf(LOG_ERR, "lun is out of range (0-%d)", MAX_LUN-1);
- return -1;
- }
- if (p->netfn >= 0 && p->lun < 0) {
- lprintf(LOG_ERR, "if netfn is set, so must be lun");
- return -1;
- }
- if (p->command >= 0 && p->netfn < 0) {
- lprintf(LOG_ERR, "if command is set, so must be netfn");
- return -1;
- }
- if (p->subfn >= 0 && p->command < 0) {
- lprintf(LOG_ERR, "if subfn is set, so must be command");
- return -1;
- }
- return 0;
- }
- /* _get_netfn_suport
- *
- * @intf: ipmi interface
- * @channel: ipmi channel
- * @lun: a pointer to a 4 byte field
- * @netfn: a pointer to a 128-bit bitfield (16 bytes)
- *
- * returns 0 on success and fills in the bitfield for
- * the 32 netfn * 4 LUN pairs that support commands
- * returns -1 on error
- */
- static int
- _get_netfn_support(struct ipmi_intf * intf, int channel, unsigned char * lun, unsigned char * netfn)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char * d, rqdata;
- unsigned int l;
- if (!lun || !netfn) {
- lprintf(LOG_ERR, "_get_netfn_suport: lun or netfn is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_NETFN_SUPPORT;
- rqdata = (unsigned char) channel;
- req.msg.data = &rqdata;
- req.msg.data_len = 1;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get NetFn Support command failed");
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get NetFn Support command failed: %s",
- val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (l=0; l<4; l++) {
- lun[l] = (*d)>>(2*l) & 0x3;
- }
- d++;
- memcpy(netfn, d, 16);
- return 0;
- }
- /* _get_command_suport
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @lnfn: a pointer to a struct lun_netfn_support
- *
- * returns 0 on success and fills in lnfn according to the request in p
- * returns -1 on error
- */
- static int
- _get_command_support(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct lun_netfn_support * lnfn)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char * d, rqdata[3];
- unsigned int c;
- if (!p || !lnfn) {
- lprintf(LOG_ERR, "_get_netfn_suport: p or lnfn is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_SUPPORT;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (!(d[c>>3] & (1<<(c%8))))
- lnfn->command[c].support |= BIT_AVAILABLE;
- }
- memcpy(lnfn->command_mask, d, MAX_COMMAND_BYTES/2);
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_SUPPORT;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = 0x40 | p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (!(d[c>>3] & (1<<(c%8))))
- lnfn->command[128+c].support |= BIT_AVAILABLE;
- }
- memcpy(lnfn->command_mask+MAX_COMMAND_BYTES/2, d, MAX_COMMAND_BYTES/2);
- return 0;
- }
- /* _get_command_configurable
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @lnfn: a pointer to a struct lun_netfn_support
- *
- * returns 0 on success and fills in lnfn according to the request in p
- * returns -1 on error
- */
- static int
- _get_command_configurable(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct lun_netfn_support * lnfn)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char * d, rqdata[3];
- unsigned int c;
- if (!p || !lnfn) {
- lprintf(LOG_ERR, "_get_command_configurable: p or lnfn is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_CONFIGURABLE_COMMANDS;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (d[c>>3] & (1<<(c%8)))
- lnfn->command[c].support |= BIT_CONFIGURABLE;
- }
- memcpy(lnfn->config_mask, d, MAX_COMMAND_BYTES/2);
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_CONFIGURABLE_COMMANDS;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = 0x40 | p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (d[c>>3] & (1<<(c%8)))
- lnfn->command[128+c].support |= BIT_CONFIGURABLE;
- }
- memcpy(lnfn->config_mask+MAX_COMMAND_BYTES/2, d, MAX_COMMAND_BYTES/2);
- return 0;
- }
- /* _get_command_enables
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @lnfn: a pointer to a struct lun_netfn_support
- *
- * returns 0 on success and fills in lnfn according to the request in p
- * returns -1 on error
- */
- static int
- _get_command_enables(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct lun_netfn_support * lnfn)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char * d, rqdata[3];
- unsigned int c;
- if (!p || !lnfn) {
- lprintf(LOG_ERR, "_get_command_enables: p or lnfn is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (d[c>>3] & (1<<(c%8)))
- lnfn->command[c].support |= BIT_ENABLED;
- }
- memcpy(lnfn->enable_mask, d, MAX_COMMAND_BYTES/2);
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = 0x40 | p->netfn;
- rqdata[2] = p->lun;
- req.msg.data = rqdata;
- req.msg.data_len = 3;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- d = rsp->data;
- for (c=0; c<128; c++) {
- if (d[c>>3] & (1<<(c%8)))
- lnfn->command[128+c].support |= BIT_ENABLED;
- }
- memcpy(lnfn->enable_mask+MAX_COMMAND_BYTES/2, d, MAX_COMMAND_BYTES/2);
- return 0;
- }
- /* _set_command_enables
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @lnfn: a pointer to a struct lun_netfn_support that contains current info
- * @enable: a pointer to a 32 byte bitfield that contains the desired enable state
- * @gun: here is a gun to shoot yourself in the foot. If this is true
- * you are allowed to disable this command
- *
- * returns 0 on success
- * returns -1 on error
- */
- static int
- _set_command_enables(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct lun_netfn_support * lnfn,
- unsigned char * enable, int gun)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char rqdata[19];
- unsigned int c;
- if (!p || !lnfn) {
- lprintf(LOG_ERR, "_set_command_enables: p or lnfn is NULL");
- return -1;
- }
- lprintf(LOG_INFO, "support: ");
- print_bitfield(lnfn->command_mask, MAX_COMMAND_BYTES, 1, LOG_INFO);
- lprintf(LOG_INFO, "configurable: ");
- print_bitfield(lnfn->config_mask, MAX_COMMAND_BYTES, 0, LOG_INFO);
- lprintf(LOG_INFO, "enabled: ");
- print_bitfield(lnfn->enable_mask, MAX_COMMAND_BYTES, 0, LOG_INFO);
- lprintf(LOG_INFO, "enable mask before: ");
- print_bitfield(enable, MAX_COMMAND_BYTES, 0, LOG_INFO);
- // mask off the appropriate bits (if not configurable, set enable bit
- // must be the same as the current enable bit)
- for (c=0; c<(MAX_COMMAND_BYTES); c++) {
- enable[c] = (lnfn->config_mask[c] & enable[c]) |
- (~lnfn->config_mask[c] & lnfn->enable_mask[c]);
- }
- // take the gun out of their hand if they are not supposed to have it
- if (!gun) {
- enable[SET_COMMAND_ENABLE_BYTE] =
- (lnfn->config_mask[SET_COMMAND_ENABLE_BYTE]
- & SET_COMMAND_ENABLE_BIT) |
- (~lnfn->config_mask[SET_COMMAND_ENABLE_BYTE]
- & lnfn->enable_mask[SET_COMMAND_ENABLE_BYTE]);
- }
- lprintf(LOG_INFO, "enable mask after: ");
- print_bitfield(enable, MAX_COMMAND_BYTES, 0, LOG_INFO);
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_SET_COMMAND_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- memcpy(&rqdata[3], enable, MAX_COMMAND_BYTES/2);
- req.msg.data = rqdata;
- req.msg.data_len = 19;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_SET_COMMAND_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = 0x40 | p->netfn;
- rqdata[2] = p->lun;
- memcpy(&rqdata[3], enable+MAX_COMMAND_BYTES/2, MAX_COMMAND_BYTES/2);
- req.msg.data = rqdata;
- req.msg.data_len = 19;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s",
- p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- return 0;
- }
- /* _get_subfn_support
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @cmd: a pointer to a struct command_support
- *
- * returns 0 on success and fills in cmd according to the request in p
- * returns -1 on error
- */
- static int
- _get_subfn_support(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct command_support * cmd)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char rqdata[4];
- if (!p || !cmd) {
- lprintf(LOG_ERR, "_get_subfn_support: p or cmd is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_SUBFUNCTION_SUPPORT;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- rqdata[3] = p->command;
- req.msg.data = rqdata;
- req.msg.data_len = 4;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed: %s",
- p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- memcpy(cmd->subfn_support, rsp->data, sizeof(cmd->subfn_support));
- return 0;
- }
- /* _get_subfn_configurable
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @cmd: a pointer to a struct command_support
- *
- * returns 0 on success and fills in cmd according to the request in p
- * returns -1 on error
- */
- static int
- _get_subfn_configurable(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct command_support * cmd)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char rqdata[4];
- if (!p || !cmd) {
- lprintf(LOG_ERR, "_get_subfn_configurable: p or cmd is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_CONFIGURABLE_COMMAND_SUBFUNCTIONS;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- rqdata[3] = p->command;
- req.msg.data = rqdata;
- req.msg.data_len = 4;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed: %s",
- p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- memcpy(cmd->subfn_config, rsp->data, sizeof(cmd->subfn_config));
- return 0;
- }
- /* _get_subfn_enables
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @cmd: a pointer to a struct command_support
- *
- * returns 0 on success and fills in cmd according to the request in p
- * returns -1 on error
- */
- static int
- _get_subfn_enables(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct command_support * cmd)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char rqdata[4];
- if (!p || !cmd) {
- lprintf(LOG_ERR, "_get_subfn_enables: p or cmd is NULL");
- return -1;
- }
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_COMMAND_SUBFUNCTION_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- rqdata[3] = p->command;
- req.msg.data = rqdata;
- req.msg.data_len = 4;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s",
- p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- memcpy(cmd->subfn_enable, rsp->data, sizeof(cmd->subfn_enable));
- return 0;
- }
- /* _set_subfn_enables
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @cmd: a pointer to a struct command_support
- * @enable: a pointer to a 4 byte bitfield that contains the desired enable state
- *
- * returns 0 on success (and modifies enable to be the bits it actually set)
- * returns -1 on error
- */
- static int
- _set_subfn_enables(struct ipmi_intf * intf,
- struct ipmi_function_params * p, struct command_support * cmd,
- unsigned char * enable)
- {
- struct ipmi_rs * rsp;
- struct ipmi_rq req;
- unsigned char rqdata[8];
- unsigned int c;
- if (!p || !cmd) {
- lprintf(LOG_ERR, "_set_subfn_enables: p or cmd is NULL");
- return -1;
- }
- lprintf(LOG_INFO, "support: ");
- print_bitfield(cmd->subfn_support, MAX_SUBFN_BYTES, 1, LOG_INFO);
- lprintf(LOG_INFO, "configurable: ");
- print_bitfield(cmd->subfn_config, MAX_SUBFN_BYTES, 0, LOG_INFO);
- lprintf(LOG_INFO, "enabled: ");
- print_bitfield(cmd->subfn_enable, MAX_SUBFN_BYTES, 0, LOG_INFO);
- lprintf(LOG_INFO, "enable mask before: ");
- print_bitfield(enable, MAX_SUBFN_BYTES, 0, LOG_INFO);
- // mask off the appropriate bits (if not configurable, set enable bit
- // must be the same as the current enable bit)
- for (c=0; c<sizeof(cmd->subfn_enable); c++) {
- enable[c] = (cmd->subfn_config[c] & enable[c]) |
- (~cmd->subfn_config[c] & cmd->subfn_enable[c]);
- }
- lprintf(LOG_INFO, "enable mask after: ");
- print_bitfield(enable, MAX_SUBFN_BYTES, 0, LOG_INFO);
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_SET_COMMAND_SUBFUNCTION_ENABLES;
- rqdata[0] = (unsigned char) p->channel;
- rqdata[1] = p->netfn;
- rqdata[2] = p->lun;
- rqdata[3] = p->command;
- memcpy(&rqdata[4], enable, MAX_SUBFN_BYTES);
- req.msg.data = rqdata;
- req.msg.data_len = 8;
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
- lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
- return -1;
- }
- if (rsp->ccode > 0) {
- lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s",
- p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
- return -1;
- }
- return 0;
- }
- /* _gather_info
- *
- * @intf: ipmi interface
- * @p: a pointer to a struct ipmi_function_params
- * @bmc: a pointer to a struct bmc_fn_support
- * @enable: a pointer to a 4 byte bitfield that contains the desired enable state
- *
- * returns 0 on success and fills in bmc according to request p
- * returns -1 on error
- */
- static int _gather_info(struct ipmi_intf * intf, struct ipmi_function_params * p, struct bmc_fn_support * bmc)
- {
- int ret, l, n;
- unsigned char lun[MAX_LUN], netfn[16];
- ret = _get_netfn_support(intf, p->channel, lun, netfn);
- if (!ret) {
- for (l=0; l<MAX_LUN; l++) {
- if (p->lun >= 0 && p->lun != l)
- continue;
- bmc->lun[l].support = lun[l];
- if (lun[l]) {
- for (n=0; n<MAX_NETFN_PAIR; n++) {
- int offset = l*MAX_NETFN_PAIR+n;
- bmc->lun[l].netfn[n].support =
- !!(netfn[offset>>3] & (1<<(offset%8)));
- }
- }
- }
- }
- if (p->netfn >= 0) {
- if (!((p->lun < 0 || bmc->lun[p->lun].support) &&
- (p->netfn < 0 || bmc->lun[p->lun].netfn[p->netfn>>1].support))) {
- lprintf(LOG_ERR, "LUN or LUN/NetFn pair %d,%d not supported", p->lun, p->netfn);
- return 0;
- }
- ret = _get_command_support(intf, p, &(bmc->lun[p->lun].netfn[p->netfn>>1]));
- ret |= _get_command_configurable(intf, p, &(bmc->lun[p->lun].netfn[p->netfn>>1]));
- ret |= _get_command_enables(intf, p, &(bmc->lun[p->lun].netfn[p->netfn>>1]));
- if (!ret && p->command >= 0) {
- ret = _get_subfn_support(intf, p,
- &(bmc->lun[p->lun].netfn[p->netfn>>1].command[p->command]));
- ret |= _get_subfn_configurable(intf, p,
- &(bmc->lun[p->lun].netfn[p->netfn>>1].command[p->command]));
- ret |= _get_subfn_enables(intf, p,
- &(bmc->lun[p->lun].netfn[p->netfn>>1].command[p->command]));
- }
- }
- else if (p->lun >= 0) {
- l = p->lun;
- if (bmc->lun[l].support) {
- for (n=0; n<MAX_NETFN_PAIR; n++) {
- p->netfn = n*2;
- if (bmc->lun[l].netfn[n].support) {
- ret = _get_command_support(intf, p, &(bmc->lun[l].netfn[n]));
- ret |= _get_command_configurable(intf, p, &(bmc->lun[l].netfn[n]));
- ret |= _get_command_enables(intf, p, &(bmc->lun[l].netfn[n]));
- }
- if (ret)
- bmc->lun[l].netfn[n].support = 0;
- }
- }
- p->netfn = -1;
- } else {
- for (l=0; l<4; l++) {
- p->lun = l;
- if (bmc->lun[l].support) {
- for (n=0; n<MAX_NETFN_PAIR; n++) {
- p->netfn = n*2;
- if (bmc->lun[l].netfn[n].support) {
- ret = _get_command_support(intf, p, &(bmc->lun[l].netfn[n]));
- ret |= _get_command_configurable(intf, p, &(bmc->lun[l].netfn[n]));
- ret |= _get_command_enables(intf, p, &(bmc->lun[l].netfn[n]));
- }
- if (ret)
- bmc->lun[l].netfn[n].support = 0;
- }
- }
- }
- p->lun = -1;
- p->netfn = -1;
- }
- return 0;
- }
- /* ipmi_firewall_info - print out info for firewall functions
- *
- * @intf: ipmi inteface
- * @argc: argument count
- * @argv: argument list
- *
- * returns 0 on success
- * returns -1 on error
- */
- static int
- ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
- {
- int ret = 0;
- struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
- struct bmc_fn_support * bmc_fn_support;
- unsigned int l, n, c;
- if ((argc > 0 && strncmp(argv[0], "help", 4) == 0) || ipmi_firewall_parse_args(argc, argv, &p) < 0)
- {
- printf_firewall_info_usage();
- return 0;
- }
- bmc_fn_support = malloc(sizeof(struct bmc_fn_support));
- if (!bmc_fn_support) {
- lprintf(LOG_ERR, "malloc struct bmc_fn_support failed");
- return -1;
- }
- ret = _gather_info(intf, &p, bmc_fn_support);
- if (p.command >= 0) {
- struct command_support * cmd;
- if (!((p.lun < 0 || bmc_fn_support->lun[p.lun].support) &&
- (p.netfn < 0 || bmc_fn_support->lun[p.lun].netfn[p.netfn>>1].support) &&
- bmc_fn_support->lun[p.lun].netfn[p.netfn>>1].command[p.command].support))
- {
- lprintf(LOG_ERR, "Command 0x%02x not supported on LUN/NetFn pair %02x,%02x",
- p.command, p.lun, p.netfn);
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return 0;
- }
- cmd =
- &bmc_fn_support->lun[p.lun].netfn[p.netfn>>1].command[p.command];
- c = cmd->support;
- printf("(A)vailable, (C)onfigurable, (E)nabled: | A | C | E |\n");
- printf("-----------------------------------------------------\n");
- printf("LUN %01d, NetFn 0x%02x, Command 0x%02x: | %c | %c | %c |\n",
- p.lun, p.netfn, p.command,
- (c & BIT_AVAILABLE) ? 'X' : ' ',
- (c & BIT_CONFIGURABLE) ? 'X' : ' ',
- (c & BIT_ENABLED) ? 'X': ' ');
- for (n=0; n<MAX_SUBFN; n++) {
- printf("sub-function 0x%02x: | %c | %c | %c |\n", n,
- (!bit_test(cmd->subfn_support, n)) ? 'X' : ' ',
- (bit_test(cmd->subfn_config, n)) ? 'X' : ' ',
- (bit_test(cmd->subfn_enable, n)) ? 'X' : ' ');
- }
- }
- else if (p.netfn >= 0) {
- if (!((p.lun < 0 || bmc_fn_support->lun[p.lun].support) &&
- (bmc_fn_support->lun[p.lun].netfn[p.netfn>>1].support)))
- {
- lprintf(LOG_ERR, "LUN or LUN/NetFn pair %02x,%02x not supported",
- p.lun, p.netfn);
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return 0;
- }
- n = p.netfn >> 1;
- l = p.lun;
- printf("Commands on LUN 0x%02x, NetFn 0x%02x\n", p.lun, p.netfn);
- printf("support: ");
- print_bitfield(bmc_fn_support->lun[l].netfn[n].command_mask,
- MAX_COMMAND_BYTES, 1, -1);
- printf("configurable: ");
- print_bitfield(bmc_fn_support->lun[l].netfn[n].config_mask,
- MAX_COMMAND_BYTES, 0, -1);
- printf("enabled: ");
- print_bitfield(bmc_fn_support->lun[l].netfn[n].enable_mask,
- MAX_COMMAND_BYTES, 0, -1);
- }
- else {
- for (l=0; l<4; l++) {
- p.lun = l;
- if (bmc_fn_support->lun[l].support) {
- for (n=0; n<MAX_NETFN_PAIR; n++) {
- p.netfn = n*2;
- if (bmc_fn_support->lun[l].netfn[n].support) {
- printf("%02x,%02x support: ", p.lun, p.netfn);
- print_bitfield(bmc_fn_support->lun[l].netfn[n].command_mask,
- MAX_COMMAND_BYTES, 1, -1);
- printf("%02x,%02x configurable: ", p.lun, p.netfn);
- print_bitfield(bmc_fn_support->lun[l].netfn[n].config_mask,
- MAX_COMMAND_BYTES, 0, -1);
- printf("%02x,%02x enabled: ", p.lun, p.netfn);
- print_bitfield(bmc_fn_support->lun[l].netfn[n].enable_mask,
- MAX_COMMAND_BYTES, 0, -1);
- }
- }
- }
- }
- p.lun = -1;
- p.netfn = -1;
- }
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return ret;
- }
- /* ipmi_firewall_enable_disable - enable/disable BMC functions
- *
- * @intf: ipmi inteface
- * @enable: whether to enable or disable
- * @argc: argument count
- * @argv: argument list
- *
- * returns 0 on success
- * returns -1 on error
- */
- static int
- ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char ** argv)
- {
- struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
- struct bmc_fn_support * bmc_fn_support;
- int ret;
- unsigned int l, n, c;
- unsigned char enables[MAX_COMMAND_BYTES];
- if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
- char * s1 = enable?"en":"dis";
- char * s2 = enable?"":" [force]";
- printf("%sable [channel H] lun L netfn N%s\n", s1, s2);
- printf("\t%sable all commands on this LUN/NetFn pair\n", s1);
- printf("%sable [channel H] lun L netfn N command C%s\n", s1, s2);
- printf("\t%sable Command C and all its Sub-functions for this LUN/NetFn pair\n", s1);
- printf("%sable [channel H] lun L netfn N command C subfn S\n", s1);
- printf("\t%sable Sub-function S for Command C for this LUN/NetFn pair\n", s1);
- if (!enable) {
- printf("* force will allow you to disable the \"Command Set Enable\" command\n");
- printf("\tthereby letting you shoot yourself in the foot\n");
- printf("\tthis is only recommended for advanced users\n");
- }
- return 0;
- }
- if (ipmi_firewall_parse_args(argc, argv, &p) < 0)
- return -1;
- bmc_fn_support = malloc(sizeof(struct bmc_fn_support));
- if (!bmc_fn_support) {
- lprintf(LOG_ERR, "malloc struct bmc_fn_support failed");
- return -1;
- }
- ret = _gather_info(intf, &p, bmc_fn_support);
- if (ret < 0) {
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return ret;
- }
- l = p.lun;
- n = p.netfn>>1;
- c = p.command;
- if (p.subfn >= 0) {
- // firewall (en|dis)able [channel c] lun l netfn n command m subfn s
- // (en|dis)able this sub-function for this commnad on this lun/netfn pair
- memcpy(enables,
- bmc_fn_support->lun[l].netfn[n].command[c].subfn_enable,
- MAX_SUBFN_BYTES);
- bit_set(enables, p.subfn, enable);
- ret = _set_subfn_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n].command[c], enables);
- } else if (p.command >= 0) {
- // firewall (en|dis)able [channel c] lun l netfn n command m
- // (en|dis)able all subfn and command for this commnad on this lun/netfn pair
- memset(enables, enable?0xff:0, MAX_SUBFN_BYTES);
- ret = _set_subfn_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n].command[c], enables);
- memcpy(enables,
- &bmc_fn_support->lun[l].netfn[n].enable_mask, sizeof(enables));
- bit_set(enables, p.command, enable);
- ret |= _set_command_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n], enables, p.force);
- } else if (p.netfn >= 0) {
- // firewall (en|dis)able [channel c] lun l netfn n
- // (en|dis)able all commnads on this lun/netfn pair
- memset(enables, enable?0xff:0, sizeof(enables));
- ret = _set_command_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n], enables, p.force);
- /*
- } else if (p.lun >= 0) {
- // firewall (en|dis)able [channel c] lun l
- // (en|dis)able all commnads on all netfn pairs for this lun
- */
- }
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return ret;
- }
- /* ipmi_firewall_reset - reset firmware firewall to enable everything
- *
- * @intf: ipmi inteface
- * @argc: argument count
- * @argv: argument list
- *
- * returns 0 on success
- * returns -1 on error
- */
- static int
- ipmi_firewall_reset(struct ipmi_intf * intf, int argc, char ** argv)
- {
- struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
- struct bmc_fn_support * bmc_fn_support;
- int ret;
- unsigned int l, n, c;
- unsigned char enables[MAX_COMMAND_BYTES];
- if (argc < 1) {
- lprintf(LOG_ERR, "Not enough parameters given.");
- printf_firewall_usage();
- return (-1);
- } else if (argc > 0 && strncmp(argv[0], "help", 4) == 0) {
- printf_firewall_usage();
- return 0;
- }
- if (ipmi_firewall_parse_args(argc, argv, &p) < 0)
- return -1;
- bmc_fn_support = malloc(sizeof(struct bmc_fn_support));
- if (!bmc_fn_support) {
- lprintf(LOG_ERR, "malloc struct bmc_fn_support failed");
- return -1;
- }
- ret = _gather_info(intf, &p, bmc_fn_support);
- if (ret < 0) {
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return ret;
- }
- for (l=0; l<MAX_LUN; l++) {
- p.lun = l;
- for (n=0; n<MAX_NETFN_PAIR; n++) {
- p.netfn = n*2;
- for (c=0; c<MAX_COMMAND; c++) {
- p.command = c;
- printf("reset lun %d, netfn %d, command %d, subfn\n", l, n, c);
- memset(enables, 0xff, MAX_SUBFN_BYTES);
- ret = _set_subfn_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n].command[c], enables);
- }
- printf("reset lun %d, netfn %d, command\n", l, n);
- memset(enables, 0xff, sizeof(enables));
- ret = _set_command_enables(intf, &p,
- &bmc_fn_support->lun[l].netfn[n], enables, 0);
- }
- }
- free(bmc_fn_support);
- bmc_fn_support = NULL;
- return ret;
- }
- /* ipmi_firewall_main - top-level handler for firmware firewall functions
- *
- * @intf: ipmi interface
- * @argc: number of arguments
- * @argv: argument list
- *
- * returns 0 on success
- * returns -1 on error
- */
- int
- ipmi_firewall_main(struct ipmi_intf * intf, int argc, char ** argv)
- {
- int rc = 0;
- if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
- printf_firewall_usage();
- }
- else if (strncmp(argv[0], "info", 4) == 0) {
- rc = ipmi_firewall_info(intf, argc-1, &(argv[1]));
- }
- else if (strncmp(argv[0], "enable", 6) == 0) {
- rc = ipmi_firewall_enable_disable(intf, 1, argc-1, &(argv[1]));
- }
- else if (strncmp(argv[0], "disable", 7) == 0) {
- rc = ipmi_firewall_enable_disable(intf, 0, argc-1, &(argv[1]));
- }
- else if (strncmp(argv[0], "reset", 5) == 0) {
- rc = ipmi_firewall_reset(intf, argc-1, &(argv[1]));
- }
- else {
- printf_firewall_usage();
- }
- return rc;
- }
|