summaryrefslogtreecommitdiff
path: root/lib/ipmi_firewall.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_firewall.c')
-rw-r--r--lib/ipmi_firewall.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/lib/ipmi_firewall.c b/lib/ipmi_firewall.c
index 26bfd30..640a4ad 100644
--- a/lib/ipmi_firewall.c
+++ b/lib/ipmi_firewall.c
@@ -128,7 +128,7 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
return -1;
}
for (i=0; i<argc; i++) {
- if (strncmp(argv[i], "channel", 7) == 0 && (++i < argc)) {
+ 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;
@@ -137,31 +137,31 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
p->channel = channel_tmp;
}
}
- else if (strncmp(argv[i], "lun", 3) == 0 && (++i < argc)) {
+ 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 (strncmp(argv[i], "force", 5) == 0) {
+ else if (!strcmp(argv[i], "force")) {
p->force = 1;
}
- else if (strncmp(argv[i], "netfn", 5) == 0 && (++i < argc)) {
+ 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 (strncmp(argv[i], "command", 7) == 0 && (++i < argc)) {
+ 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 (strncmp(argv[i], "subfn", 5) == 0 && (++i < argc)) {
+ 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;
@@ -235,11 +235,11 @@ _get_netfn_support(struct ipmi_intf * intf, int channel, unsigned char * lun, un
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Get NetFn Support command failed");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Get NetFn Support command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -289,11 +289,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -316,11 +316,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -368,11 +368,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -395,11 +395,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -447,11 +447,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -474,11 +474,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -558,11 +558,11 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -579,11 +579,11 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -625,11 +625,11 @@ _get_subfn_support(struct ipmi_intf * intf,
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -672,11 +672,11 @@ _get_subfn_configurable(struct ipmi_intf * intf,
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -719,11 +719,11 @@ _get_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -787,11 +787,11 @@ _set_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 8;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ 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 > 0) {
+ 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;
@@ -888,7 +888,7 @@ static int _gather_info(struct ipmi_intf * intf, struct ipmi_function_params * p
/* ipmi_firewall_info - print out info for firewall functions
*
- * @intf: ipmi inteface
+ * @intf: ipmi interface
* @argc: argument count
* @argv: argument list
*
@@ -903,7 +903,7 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
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)
+ if ((argc > 0 && !strcmp(argv[0], "help")) || ipmi_firewall_parse_args(argc, argv, &p) < 0)
{
printf_firewall_info_usage();
return 0;
@@ -1001,7 +1001,7 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
/* ipmi_firewall_enable_disable - enable/disable BMC functions
*
- * @intf: ipmi inteface
+ * @intf: ipmi interface
* @enable: whether to enable or disable
* @argc: argument count
* @argv: argument list
@@ -1018,7 +1018,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
unsigned int l, n, c;
unsigned char enables[MAX_COMMAND_BYTES];
- if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
+ 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);
@@ -1055,7 +1055,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
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
+ // (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);
@@ -1065,7 +1065,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
} 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
+ // (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);
@@ -1076,14 +1076,14 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
&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
+ // (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 commnads on all netfn pairs for this lun
+ // (en|dis)able all command on all netfn pairs for this lun
*/
}
free(bmc_fn_support);
@@ -1093,7 +1093,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
/* ipmi_firewall_reset - reset firmware firewall to enable everything
*
- * @intf: ipmi inteface
+ * @intf: ipmi interface
* @argc: argument count
* @argv: argument list
*
@@ -1113,7 +1113,7 @@ ipmi_firewall_reset(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_ERR, "Not enough parameters given.");
printf_firewall_usage();
return (-1);
- } else if (argc > 0 && strncmp(argv[0], "help", 4) == 0) {
+ } else if (argc > 0 && !strcmp(argv[0], "help")) {
printf_firewall_usage();
return 0;
}
@@ -1171,19 +1171,19 @@ ipmi_firewall_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
- if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
+ if (argc < 1 || !strcmp(argv[0], "help")) {
printf_firewall_usage();
}
- else if (strncmp(argv[0], "info", 4) == 0) {
+ else if (!strcmp(argv[0], "info")) {
rc = ipmi_firewall_info(intf, argc-1, &(argv[1]));
}
- else if (strncmp(argv[0], "enable", 6) == 0) {
+ else if (!strcmp(argv[0], "enable")) {
rc = ipmi_firewall_enable_disable(intf, 1, argc-1, &(argv[1]));
}
- else if (strncmp(argv[0], "disable", 7) == 0) {
+ else if (!strcmp(argv[0], "disable")) {
rc = ipmi_firewall_enable_disable(intf, 0, argc-1, &(argv[1]));
}
- else if (strncmp(argv[0], "reset", 5) == 0) {
+ else if (!strcmp(argv[0], "reset")) {
rc = ipmi_firewall_reset(intf, argc-1, &(argv[1]));
}
else {