1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
|
/*
* 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 (!strcmp(argv[i], "channel") && (++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 (!strcmp(argv[i], "lun") && (++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 (!strcmp(argv[i], "force")) {
p->force = 1;
}
else if (!strcmp(argv[i], "netfn") && (++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 (!strcmp(argv[i], "command") && (++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 (!strcmp(argv[i], "subfn") && (++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) {
lprintf(LOG_ERR, "Get NetFn Support command failed");
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1;
}
if (rsp->ccode) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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 interface
* @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 && !strcmp(argv[0], "help")) || 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 interface
* @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 || !strcmp(argv[0], "help")) {
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 command 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 command 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 command 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 command 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 interface
* @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 && !strcmp(argv[0], "help")) {
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 || !strcmp(argv[0], "help")) {
printf_firewall_usage();
}
else if (!strcmp(argv[0], "info")) {
rc = ipmi_firewall_info(intf, argc-1, &(argv[1]));
}
else if (!strcmp(argv[0], "enable")) {
rc = ipmi_firewall_enable_disable(intf, 1, argc-1, &(argv[1]));
}
else if (!strcmp(argv[0], "disable")) {
rc = ipmi_firewall_enable_disable(intf, 0, argc-1, &(argv[1]));
}
else if (!strcmp(argv[0], "reset")) {
rc = ipmi_firewall_reset(intf, argc-1, &(argv[1]));
}
else {
printf_firewall_usage();
}
return rc;
}
|