fix compile problems with -g

update lan interface to send debug and errors to stderr
This commit is contained in:
Duncan Laurie 2005-01-06 22:35:35 +00:00
parent de7de91f99
commit 9c848916cc
13 changed files with 267 additions and 264 deletions

View File

@ -37,6 +37,7 @@
#ifndef IPMI_HELPER_H #ifndef IPMI_HELPER_H
#define IPMI_HELPER_H #define IPMI_HELPER_H
#include <sys/types.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
@ -62,8 +63,3 @@ FILE * ipmi_open_file(const char * file, int rw);
#endif #endif
#endif /* IPMI_HELPER_H */ #endif /* IPMI_HELPER_H */

View File

@ -400,7 +400,7 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
unsigned char msg_data[3]; unsigned char msg_data[3];
if (arg == NULL) if (arg == NULL)
return; return -1;
memset(msg_data, 0, 3); memset(msg_data, 0, 3);

View File

@ -44,6 +44,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <ctype.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>

View File

@ -506,8 +506,8 @@ static void
fru_area_print_multirec(struct ipmi_intf * intf, struct fru_info * fru, fru_area_print_multirec(struct ipmi_intf * intf, struct fru_info * fru,
unsigned char id, unsigned int offset) unsigned char id, unsigned int offset)
{ {
unsigned char * fru_area, * fru_data; unsigned char * fru_data;
unsigned int fru_len, area_len, i; unsigned int fru_len, i;
struct fru_multirec_header * h; struct fru_multirec_header * h;
struct fru_multirec_powersupply * ps; struct fru_multirec_powersupply * ps;
struct fru_multirec_dcoutput * dc; struct fru_multirec_dcoutput * dc;
@ -895,7 +895,6 @@ ipmi_fru_print_all(struct ipmi_intf * intf)
struct ipmi_sdr_iterator * itr; struct ipmi_sdr_iterator * itr;
struct sdr_get_rs * header; struct sdr_get_rs * header;
struct sdr_record_fru_locator * fru; struct sdr_record_fru_locator * fru;
char desc[17];
int rc; int rc;
printf("FRU Device Description : Builtin FRU Device (ID 0)\n"); printf("FRU Device Description : Builtin FRU Device (ID 0)\n");

View File

@ -662,7 +662,7 @@ void ipmi_sdr_print_discrete_state(unsigned char sensor_type,
printf(" States Asserted : "); printf(" States Asserted : ");
for (evt; evt->type != NULL; evt++) { for (; evt->type != NULL; evt++) {
if (evt->code == typ && ((1<<evt->offset) & state)) { if (evt->code == typ && ((1<<evt->offset) & state)) {
if (pre) if (pre)
printf(" "); printf(" ");
@ -2156,8 +2156,7 @@ ipmi_sdr_print_entity(struct ipmi_intf * intf, char * entitystr)
{ {
struct sdr_record_list * list, * entry; struct sdr_record_list * list, * entry;
struct entity_id entity; struct entity_id entity;
int count, i; unsigned int id, instance;
unsigned char id, instance;
int rc = 0; int rc = 0;
if (sscanf(entitystr, "%u.%u", &id, &instance) != 2) { if (sscanf(entitystr, "%u.%u", &id, &instance) != 2) {
@ -2165,8 +2164,8 @@ ipmi_sdr_print_entity(struct ipmi_intf * intf, char * entitystr)
return -1; return -1;
} }
entity.id = id; entity.id = (uint8_t)id;
entity.instance = instance; entity.instance = (uint8_t)instance;
list = ipmi_sdr_find_sdr_byentity(intf, &entity); list = ipmi_sdr_find_sdr_byentity(intf, &entity);
for (entry = list; entry != NULL; entry = entry->next) { for (entry = list; entry != NULL; entry = entry->next) {

View File

@ -228,6 +228,7 @@ ipmi_sel_get_info(struct ipmi_intf * intf)
printf("Largest Free Blk : %d\n", buf2short(rsp->data + 6)); printf("Largest Free Blk : %d\n", buf2short(rsp->data + 6));
printf("Max Record Size : %d\n", rsp->data[7]); printf("Max Record Size : %d\n", rsp->data[7]);
} }
return 0;
} }
static unsigned short static unsigned short
@ -872,8 +873,6 @@ ipmi_sel_delete(struct ipmi_intf * intf, int argc, char ** argv)
static int static int
ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv) ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned short id; unsigned short id;
int i, oldv; int i, oldv;
struct sel_event_record evt; struct sel_event_record evt;

View File

@ -3,8 +3,6 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI"
/* /*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -41,6 +41,7 @@
#include <config.h> #include <config.h>
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/log.h> #include <ipmitool/log.h>
#ifdef IPMI_INTF_OPEN #ifdef IPMI_INTF_OPEN

View File

@ -61,11 +61,11 @@ static const struct valstr asf_type_vals[] __attribute__((unused)) = {
/* ASF message header */ /* ASF message header */
struct asf_hdr { struct asf_hdr {
unsigned long iana; uint32_t iana;
unsigned char type; uint8_t type;
unsigned char tag; uint8_t tag;
unsigned char __reserved; uint8_t __reserved;
unsigned char len; uint8_t len;
} __attribute__((packed)); } __attribute__((packed));
int handle_asf(struct ipmi_intf * intf, unsigned char * data, int data_len); int handle_asf(struct ipmi_intf * intf, unsigned char * data, int data_len);

View File

@ -50,6 +50,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/bswap.h> #include <ipmitool/bswap.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
@ -140,7 +141,7 @@ ipmi_req_add_entry(struct ipmi_intf * intf, struct ipmi_rq * req)
struct ipmi_rq_entry * e = malloc(sizeof(struct ipmi_rq_entry)); struct ipmi_rq_entry * e = malloc(sizeof(struct ipmi_rq_entry));
if (e == NULL) { if (e == NULL) {
fprintf(stderr, "ipmitool: malloc failure\n"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL; return NULL;
} }
@ -149,15 +150,14 @@ ipmi_req_add_entry(struct ipmi_intf * intf, struct ipmi_rq * req)
e->intf = intf; e->intf = intf;
if (!ipmi_req_entries) if (ipmi_req_entries == NULL)
ipmi_req_entries = e; ipmi_req_entries = e;
else else
ipmi_req_entries_tail->next = e; ipmi_req_entries_tail->next = e;
ipmi_req_entries_tail = e; ipmi_req_entries_tail = e;
if (verbose > 3) lprintf(LOG_DEBUG+3, "added list entry seq=0x%02x cmd=0x%02x",
printf("added list entry seq=0x%02x cmd=0x%02x\n", e->rq_seq, e->req.msg.cmd);
e->rq_seq, e->req.msg.cmd);
return e; return e;
} }
@ -185,8 +185,8 @@ ipmi_req_remove_entry(unsigned char seq, unsigned char cmd)
e = e->next; e = e->next;
} }
if (e) { if (e) {
if (verbose > 3) lprintf(LOG_DEBUG+3, "removed list entry seq=0x%02x cmd=0x%02x",
printf("removed list entry seq=0x%02x cmd=0x%02x\n", seq, cmd); seq, cmd);
p->next = (p->next == e->next) ? NULL : e->next; p->next = (p->next == e->next) ? NULL : e->next;
if (ipmi_req_entries == e) { if (ipmi_req_entries == e) {
if (ipmi_req_entries != p) if (ipmi_req_entries != p)
@ -213,9 +213,8 @@ ipmi_req_clear_entries(void)
e = ipmi_req_entries; e = ipmi_req_entries;
while (e) { while (e) {
if (verbose > 3) lprintf(LOG_DEBUG+3, "cleared list entry seq=0x%02x cmd=0x%02x",
printf("cleared list entry seq=0x%02x cmd=0x%02x\n", e->rq_seq, e->req.msg.cmd);
e->rq_seq, e->req.msg.cmd);
p = e->next; p = e->next;
free(e); free(e);
e = p; e = p;
@ -315,33 +314,25 @@ struct ipmi_rs * ipmi_lan_recv_packet(struct ipmi_intf * intf)
static int static int
ipmi_handle_pong(struct ipmi_intf * intf, struct ipmi_rs * rsp) ipmi_handle_pong(struct ipmi_intf * intf, struct ipmi_rs * rsp)
{ {
struct rmcp_pong { struct rmcp_pong * pong;
struct rmcp_hdr rmcp;
struct asf_hdr asf;
uint32_t iana;
uint32_t oem;
unsigned char sup_entities;
unsigned char sup_interact;
unsigned char reserved[6];
} * pong;
if (!rsp) if (rsp == NULL)
return -1; return -1;
pong = (struct rmcp_pong *)rsp->data; pong = (struct rmcp_pong *)rsp->data;
if (verbose > 1) lprintf(LOG_DEBUG,
printf("Received IPMI/RMCP response packet: \n" "Received IPMI/RMCP response packet: \n"
" IPMI%s Supported\n" " IPMI%s Supported\n"
" ASF Version %s\n" " ASF Version %s\n"
" RMCP Version %s\n" " RMCP Version %s\n"
" RMCP Sequence %d\n" " RMCP Sequence %d\n"
" IANA Enterprise %d\n\n", " IANA Enterprise %d\n",
(pong->sup_entities & 0x80) ? "" : " NOT", (pong->sup_entities & 0x80) ? "" : " NOT",
(pong->sup_entities & 0x01) ? "1.0" : "unknown", (pong->sup_entities & 0x01) ? "1.0" : "unknown",
(pong->rmcp.ver == 6) ? "1.0" : "unknown", (pong->rmcp.ver == 6) ? "1.0" : "unknown",
pong->rmcp.seq, pong->rmcp.seq,
ntohl(pong->iana)); ntohl(pong->iana));
return (pong->sup_entities & 0x80) ? 1 : 0; return (pong->sup_entities & 0x80) ? 1 : 0;
} }
@ -383,26 +374,25 @@ ipmi_lan_ping(struct ipmi_intf * intf)
data = malloc(len); data = malloc(len);
if (data == NULL) { if (data == NULL) {
fprintf(stderr, "ipmitool: malloc failure\n"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1; return -1;
} }
memset(data, 0, len); memset(data, 0, len);
memcpy(data, &rmcp_ping, sizeof(rmcp_ping)); memcpy(data, &rmcp_ping, sizeof(rmcp_ping));
memcpy(data+sizeof(rmcp_ping), &asf_ping, sizeof(asf_ping)); memcpy(data+sizeof(rmcp_ping), &asf_ping, sizeof(asf_ping));
if (verbose > 1) lprintf(LOG_DEBUG, "Sending IPMI/RMCP presence ping packet");
printf("Sending IPMI/RMCP presence ping packet\n");
rv = ipmi_lan_send_packet(intf, data, len); rv = ipmi_lan_send_packet(intf, data, len);
free(data); free(data);
if (rv < 0) { if (rv < 0) {
printf("Unable to send IPMI presence ping packet\n"); lprintf(LOG_ERR, "Unable to send IPMI presence ping packet");
return -1; return -1;
} }
if (!ipmi_lan_poll_recv(intf)) if (ipmi_lan_poll_recv(intf) == 0)
return 0; return 0;
return 1; return 1;
@ -449,8 +439,8 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* handled by rest of function */ /* handled by rest of function */
break; break;
default: default:
if (verbose > 1) lprintf(LOG_DEBUG, "Invalid RMCP class: %x",
printf("Invalid RMCP class: %x\n", rmcp_rsp.class); rmcp_rsp.class);
rsp = ipmi_lan_recv_packet(intf); rsp = ipmi_lan_recv_packet(intf);
continue; continue;
} }
@ -476,36 +466,45 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
rsp->payload.ipmi_response.cmd = rsp->data[x++]; rsp->payload.ipmi_response.cmd = rsp->data[x++];
rsp->ccode = rsp->data[x++]; rsp->ccode = rsp->data[x++];
if (verbose > 2) { if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "ipmi message header"); printbuf(rsp->data, rsp->data_len, "ipmi message header");
printf("<< IPMI Response Session Header\n");
printf("<< Authtype : %s\n", lprintf(LOG_DEBUG+1, "<< IPMI Response Session Header");
val2str(rsp->session.authtype, ipmi_authtype_session_vals)); lprintf(LOG_DEBUG+1, "<< Authtype : %s",
printf("<< Sequence : 0x%08lx\n", (long)rsp->session.seq); val2str(rsp->session.authtype, ipmi_authtype_session_vals));
printf("<< Session ID : 0x%08lx\n", (long)rsp->session.id); lprintf(LOG_DEBUG+1, "<< Sequence : 0x%08lx",
(long)rsp->session.seq);
lprintf(LOG_DEBUG+1, "<< Session ID : 0x%08lx",
(long)rsp->session.id);
printf("<< IPMI Response Message Header\n"); lprintf(LOG_DEBUG+1, "<< IPMI Response Message Header");
printf("<< Rq Addr : %02x\n", rsp->payload.ipmi_response.rq_addr); lprintf(LOG_DEBUG+1, "<< Rq Addr : %02x",
printf("<< NetFn : %02x\n", rsp->payload.ipmi_response.netfn); rsp->payload.ipmi_response.rq_addr);
printf("<< Rq LUN : %01x\n", rsp->payload.ipmi_response.rq_lun); lprintf(LOG_DEBUG+1, "<< NetFn : %02x",
printf("<< Rs Addr : %02x\n", rsp->payload.ipmi_response.rs_addr); rsp->payload.ipmi_response.netfn);
printf("<< Rq Seq : %02x\n", rsp->payload.ipmi_response.rq_seq); lprintf(LOG_DEBUG+1, "<< Rq LUN : %01x",
printf("<< Rs Lun : %01x\n", rsp->payload.ipmi_response.rs_lun); rsp->payload.ipmi_response.rq_lun);
printf("<< Command : %02x\n", rsp->payload.ipmi_response.cmd); lprintf(LOG_DEBUG+1, "<< Rs Addr : %02x",
printf("<< Compl Code : 0x%02x\n", rsp->ccode); rsp->payload.ipmi_response.rs_addr);
} lprintf(LOG_DEBUG+1, "<< Rq Seq : %02x",
rsp->payload.ipmi_response.rq_seq);
lprintf(LOG_DEBUG+1, "<< Rs Lun : %01x",
rsp->payload.ipmi_response.rs_lun);
lprintf(LOG_DEBUG+1, "<< Command : %02x",
rsp->payload.ipmi_response.cmd);
lprintf(LOG_DEBUG+1, "<< Compl Code : 0x%02x",
rsp->ccode);
/* now see if we have outstanding entry in request list */ /* now see if we have outstanding entry in request list */
entry = ipmi_req_lookup_entry(rsp->payload.ipmi_response.rq_seq, entry = ipmi_req_lookup_entry(rsp->payload.ipmi_response.rq_seq,
rsp->payload.ipmi_response.cmd); rsp->payload.ipmi_response.cmd);
if (entry) { if (entry) {
if (verbose > 2) lprintf(LOG_DEBUG+2, "IPMI Request Match found");
printf("IPMI Request Match found\n");
if (intf->target_addr != IPMI_BMC_SLAVE_ADDR) { if (intf->target_addr != IPMI_BMC_SLAVE_ADDR) {
if ((verbose > 2) && rsp->data_len) if (rsp->data_len)
printf("Bridged cmd %02x resp: %s\n", lprintf(LOG_DEBUG+1, "Bridged cmd %02x resp: %s",
rsp->payload.ipmi_response.cmd, rsp->payload.ipmi_response.cmd,
buf2str(&rsp->data[x],rsp->data_len)); buf2str(&rsp->data[x],rsp->data_len));
/* bridged command: lose extra header */ /* bridged command: lose extra header */
if (rsp->payload.ipmi_response.cmd == 0x34) { if (rsp->payload.ipmi_response.cmd == 0x34) {
entry->req.msg.cmd = entry->req.msg.target_cmd; entry->req.msg.cmd = entry->req.msg.target_cmd;
@ -513,16 +512,16 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
continue; continue;
} else { } else {
//x += sizeof(rsp->payload.ipmi_response); //x += sizeof(rsp->payload.ipmi_response);
if (verbose && rsp->data[x-1] != 0) if (rsp->data[x-1] != 0)
printf("WARNING: Bridged cmd ccode = 0x%02x\n", lprintf(LOG_DEBUG, "WARNING: Bridged "
"cmd ccode = 0x%02x",
rsp->data[x-1]); rsp->data[x-1]);
} }
} }
ipmi_req_remove_entry(rsp->payload.ipmi_response.rq_seq, ipmi_req_remove_entry(rsp->payload.ipmi_response.rq_seq,
rsp->payload.ipmi_response.cmd); rsp->payload.ipmi_response.cmd);
} else { } else {
if (verbose) lprintf(LOG_INFO, "IPMI Request Match NOT FOUND");
printf("WARNING: IPMI Request Match NOT FOUND!\n");
rsp = ipmi_lan_recv_packet(intf); rsp = ipmi_lan_recv_packet(intf);
continue; continue;
} }
@ -589,7 +588,7 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
curr_seq = 0; curr_seq = 0;
entry = ipmi_req_add_entry(intf, req); entry = ipmi_req_add_entry(intf, req);
if (!entry) if (entry == NULL)
return NULL; return NULL;
len = req->msg.data_len + 29; len = req->msg.data_len + 29;
@ -597,7 +596,7 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
len += 16; len += 16;
msg = malloc(len); msg = malloc(len);
if (msg == NULL) { if (msg == NULL) {
fprintf(stderr, "ipmitool: malloc failure\n"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL; return NULL;
} }
memset(msg, 0, len); memset(msg, 0, len);
@ -658,22 +657,19 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
msg[len++] = entry->rq_seq << 2; msg[len++] = entry->rq_seq << 2;
msg[len++] = req->msg.cmd; msg[len++] = req->msg.cmd;
if (verbose > 2) { lprintf(LOG_DEBUG+1, ">> IPMI Request Session Header");
printf(">> IPMI Request Session Header\n"); lprintf(LOG_DEBUG+1, ">> Authtype : %s",
printf(">> Authtype : %s\n", val2str(s->authtype, ipmi_authtype_session_vals));
val2str(s->authtype, ipmi_authtype_session_vals)); lprintf(LOG_DEBUG+1, ">> Sequence : 0x%08lx", (long)s->in_seq);
printf(">> Sequence : 0x%08lx\n", (long)s->in_seq); lprintf(LOG_DEBUG+1, ">> Session ID : 0x%08lx", (long)s->session_id);
printf(">> Session ID : 0x%08lx\n", (long)s->session_id); lprintf(LOG_DEBUG+1, ">> IPMI Request Message Header");
lprintf(LOG_DEBUG+1, ">> Rs Addr : %02x", intf->target_addr);
printf(">> IPMI Request Message Header\n"); lprintf(LOG_DEBUG+1, ">> NetFn : %02x", req->msg.netfn);
printf(">> Rs Addr : %02x\n", intf->target_addr); lprintf(LOG_DEBUG+1, ">> Rs LUN : %01x", 0);
printf(">> NetFn : %02x\n", req->msg.netfn); lprintf(LOG_DEBUG+1, ">> Rq Addr : %02x", IPMI_REMOTE_SWID);
printf(">> Rs LUN : %01x\n", 0); lprintf(LOG_DEBUG+1, ">> Rq Seq : %02x", entry->rq_seq);
printf(">> Rq Addr : %02x\n", IPMI_REMOTE_SWID); lprintf(LOG_DEBUG+1, ">> Rq Lun : %01x", 0);
printf(">> Rq Seq : %02x\n", entry->rq_seq); lprintf(LOG_DEBUG+1, ">> Command : %02x", req->msg.cmd);
printf(">> Rq Lun : %01x\n", 0);
printf(">> Command : %02x\n", req->msg.cmd);
}
/* message data */ /* message data */
if (req->msg.data_len) { if (req->msg.data_len) {
@ -711,7 +707,7 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
if (s->in_seq) { if (s->in_seq) {
s->in_seq++; s->in_seq++;
if (!s->in_seq) if (s->in_seq == 0)
s->in_seq++; s->in_seq++;
} }
@ -734,8 +730,8 @@ ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
} }
entry = ipmi_lan_build_cmd(intf, req); entry = ipmi_lan_build_cmd(intf, req);
if (!entry) { if (entry == NULL) {
printf("Aborting send command, unable to build.\n"); lprintf(LOG_ERR, "Aborting send command, unable to build");
return NULL; return NULL;
} }
@ -757,8 +753,7 @@ ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
usleep(5000); usleep(5000);
if (++try >= IPMI_LAN_RETRY) { if (++try >= IPMI_LAN_RETRY) {
if (verbose) lprintf(LOG_DEBUG, " No response from remote controller");
printf(" No response.\n");
break; break;
} }
} }
@ -784,7 +779,7 @@ unsigned char * ipmi_lan_build_rsp(struct ipmi_intf * intf, struct ipmi_rs * rsp
msg = malloc(len); msg = malloc(len);
if (msg == NULL) { if (msg == NULL) {
fprintf(stderr, "ipmitool: malloc failure\n"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL; return NULL;
} }
memset(msg, 0, len); memset(msg, 0, len);
@ -798,7 +793,7 @@ unsigned char * ipmi_lan_build_rsp(struct ipmi_intf * intf, struct ipmi_rs * rsp
if (s->in_seq) { if (s->in_seq) {
s->in_seq++; s->in_seq++;
if (!s->in_seq) if (s->in_seq == 0)
s->in_seq++; s->in_seq++;
} }
memcpy(msg+len, &s->in_seq, 4); memcpy(msg+len, &s->in_seq, 4);
@ -864,9 +859,9 @@ int ipmi_lan_send_rsp(struct ipmi_intf * intf, struct ipmi_rs * rsp)
int len, rv; int len, rv;
msg = ipmi_lan_build_rsp(intf, rsp, &len); msg = ipmi_lan_build_rsp(intf, rsp, &len);
if (len <= 0 || !msg) { if (len <= 0 || msg == NULL) {
printf("ipmi_lan_send_rsp: invalid response packet\n"); lprintf(LOG_ERR, "Invalid response packet");
if (msg) if (msg != NULL)
free(msg); free(msg);
return -1; return -1;
} }
@ -875,13 +870,13 @@ int ipmi_lan_send_rsp(struct ipmi_intf * intf, struct ipmi_rs * rsp)
(struct sockaddr *)&intf->session->addr, (struct sockaddr *)&intf->session->addr,
intf->session->addrlen); intf->session->addrlen);
if (rv < 0) { if (rv < 0) {
printf("ipmi_lan_send_rsp: packet send failed\n"); lprintf(LOG_ERR, "Packet send failed");
if (msg) if (msg != NULL)
free(msg); free(msg);
return -1; return -1;
} }
if (msg) if (msg != NULL)
free(msg); free(msg);
return 0; return 0;
} }
@ -900,7 +895,12 @@ ipmi_lan_keepalive(struct ipmi_intf * intf)
return 0; return 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
return (!rsp || rsp->ccode) ? -1 : 0; if (rsp == NULL)
return -1;
if (rsp->ccode > 0)
return -1;
return 0;
} }
/* /*
@ -924,79 +924,77 @@ ipmi_get_auth_capabilities_cmd(struct ipmi_intf * intf)
req.msg.data_len = 2; req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
if (verbose) lprintf(LOG_INFO, "Get Auth Capabilities command failed");
printf("error in Get Auth Capabilities Command\n");
return -1; return -1;
} }
if (verbose > 2) if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "get_auth_capabilities"); printbuf(rsp->data, rsp->data_len, "get_auth_capabilities");
if (rsp->ccode) { if (rsp->ccode > 0) {
printf("Get Auth Capabilities error: %02x\n", rsp->ccode); lprintf(LOG_INFO, "Get Auth Capabilities command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
} }
if (verbose > 1) { lprintf(LOG_DEBUG, "Channel %02x Authentication Capabilities:",
printf("Channel %02x Authentication Capabilities:\n", rsp->data[0]);
rsp->data[0]); lprintf(LOG_DEBUG, " Privilege Level : %s",
printf(" Privilege Level : %s\n", val2str(req.msg.data[1], ipmi_privlvl_vals));
val2str(req.msg.data[1], ipmi_privlvl_vals)); lprintf(LOG_DEBUG, " Auth Types : %s%s%s%s%s",
printf(" Auth Types : "); (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE) ? "NONE " : "",
if (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2) ? "MD2 " : "",
printf("NONE "); (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5) ? "MD5 " : "",
if (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD) ? "PASSWORD " : "",
printf("MD2 "); (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM) ? "OEM " : "");
if (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5) lprintf(LOG_DEBUG, " Per-msg auth : %sabled",
printf("MD5 "); (rsp->data[2] & IPMI_AUTHSTATUS_PER_MSG_DISABLED) ?
if (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD) "dis" : "en");
printf("PASSWORD "); lprintf(LOG_DEBUG, " User level auth : %sabled",
if (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM) (rsp->data[2] & IPMI_AUTHSTATUS_PER_USER_DISABLED) ?
printf("OEM "); "dis" : "en");
printf("\n"); lprintf(LOG_DEBUG, " Non-null users : %sabled",
printf(" Per-msg auth : %sabled\n", (rsp->data[2] & IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED) ?
(rsp->data[2] & IPMI_AUTHSTATUS_PER_MSG_DISABLED) ? "dis" : "en"); "en" : "dis");
printf(" User level auth : %sabled\n", lprintf(LOG_DEBUG, " Null users : %sabled",
(rsp->data[2] & IPMI_AUTHSTATUS_PER_USER_DISABLED) ? "dis" : "en"); (rsp->data[2] & IPMI_AUTHSTATUS_NULL_USERS_ENABLED) ?
printf(" Non-null users : %sabled\n", "en" : "dis");
(rsp->data[2] & IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED) ? "en" : "dis"); lprintf(LOG_DEBUG, " Anonymous login : %sabled",
printf(" Null users : %sabled\n", (rsp->data[2] & IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED) ?
(rsp->data[2] & IPMI_AUTHSTATUS_NULL_USERS_ENABLED) ? "en" : "dis"); "en" : "dis");
printf(" Anonymous login : %sabled\n", lprintf(LOG_DEBUG, "");
(rsp->data[2] & IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED) ? "en" : "dis");
printf("\n");
}
s->authstatus = rsp->data[2]; s->authstatus = rsp->data[2];
if (s->password && if (s->password &&
(!s->authtype_set || (s->authtype_set == 0 ||
s->authtype_set == IPMI_SESSION_AUTHTYPE_MD5) && s->authtype_set == IPMI_SESSION_AUTHTYPE_MD5) &&
(rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5)) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5))
{ {
s->authtype = IPMI_SESSION_AUTHTYPE_MD5; s->authtype = IPMI_SESSION_AUTHTYPE_MD5;
} }
else if (s->password && else if (s->password &&
(!s->authtype_set || (s->authtype_set == 0 ||
s->authtype_set == IPMI_SESSION_AUTHTYPE_MD2) && s->authtype_set == IPMI_SESSION_AUTHTYPE_MD2) &&
(rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2)) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2))
{ {
s->authtype = IPMI_SESSION_AUTHTYPE_MD2; s->authtype = IPMI_SESSION_AUTHTYPE_MD2;
} }
else if (s->password && else if (s->password &&
(!s->authtype_set || (s->authtype_set == 0 ||
s->authtype_set == IPMI_SESSION_AUTHTYPE_PASSWORD) && s->authtype_set == IPMI_SESSION_AUTHTYPE_PASSWORD) &&
(rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD)) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD))
{ {
s->authtype = IPMI_SESSION_AUTHTYPE_PASSWORD; s->authtype = IPMI_SESSION_AUTHTYPE_PASSWORD;
} }
else if (s->password && else if (s->password &&
(!s->authtype_set || (s->authtype_set == 0 ||
s->authtype_set == IPMI_SESSION_AUTHTYPE_OEM) && s->authtype_set == IPMI_SESSION_AUTHTYPE_OEM) &&
(rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM)) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM))
{ {
s->authtype = IPMI_SESSION_AUTHTYPE_OEM; s->authtype = IPMI_SESSION_AUTHTYPE_OEM;
} }
else if ((!s->authtype_set || else if ((s->authtype_set == 0 ||
s->authtype_set == IPMI_SESSION_AUTHTYPE_NONE) && s->authtype_set == IPMI_SESSION_AUTHTYPE_NONE) &&
(rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE)) (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE))
{ {
@ -1004,16 +1002,16 @@ ipmi_get_auth_capabilities_cmd(struct ipmi_intf * intf)
} }
else { else {
if (!(rsp->data[1] & 1<<s->authtype_set)) if (!(rsp->data[1] & 1<<s->authtype_set))
printf("Authentication type %s not supported!\n", lprintf(LOG_ERR, "Authentication type %s not supported",
val2str(s->authtype_set, ipmi_authtype_session_vals)); val2str(s->authtype_set, ipmi_authtype_session_vals));
else else
printf("No supported authtypes found!\n"); lprintf(LOG_ERR, "No supported authtypes found");
return -1; return -1;
} }
if (verbose > 1) lprintf(LOG_DEBUG, "Proceeding with AuthType %s",
printf("Proceeding with AuthType %s\n", val2str(s->authtype, ipmi_authtype_session_vals));
val2str(s->authtype, ipmi_authtype_session_vals));
return 0; return 0;
} }
@ -1041,24 +1039,24 @@ ipmi_get_session_challenge_cmd(struct ipmi_intf * intf)
req.msg.data_len = 17; /* 1 byte for authtype, 16 for user */ req.msg.data_len = 17; /* 1 byte for authtype, 16 for user */
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("error in Get Session Challenge Command\n"); lprintf(LOG_ERR, "Get Session Challenge command failed");
return -1; return -1;
} }
if (verbose > 2) if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "get_session_challenge"); printbuf(rsp->data, rsp->data_len, "get_session_challenge");
if (rsp->ccode) { if (rsp->ccode > 0) {
printf("Get Session Challenge error: ");
switch (rsp->ccode) { switch (rsp->ccode) {
case 0x81: case 0x81:
printf("Invalid user name\n"); lprintf(LOG_ERR, "Invalid user name");
break; break;
case 0x82: case 0x82:
printf("NULL user name not enabled\n"); lprintf(LOG_ERR, "NULL user name not enabled");
break; break;
default: default:
printf("%02x\n", rsp->ccode); lprintf(LOG_ERR, "Get Session Challenge command failed: %s",
val2str(rsp->ccode, completion_code_vals));
} }
return -1; return -1;
} }
@ -1066,13 +1064,10 @@ ipmi_get_session_challenge_cmd(struct ipmi_intf * intf)
memcpy(&s->session_id, rsp->data, 4); memcpy(&s->session_id, rsp->data, 4);
memcpy(s->challenge, rsp->data + 4, 16); memcpy(s->challenge, rsp->data + 4, 16);
if (verbose > 1) { lprintf(LOG_DEBUG, "Opening Session");
printf("Opening Session\n"); lprintf(LOG_DEBUG, " Session ID : %08lx", (long)s->session_id);
printf(" Session ID : %08lx\n", (long)s->session_id); lprintf(LOG_DEBUG, " Challenge : %s", buf2str(s->challenge, 16));
printf(" Challenge : %s\n", buf2str(s->challenge, 16));
}
return 0; return 0;
} }
@ -1098,8 +1093,8 @@ ipmi_activate_session_cmd(struct ipmi_intf * intf)
unsigned char * special = ipmi_auth_special(s); unsigned char * special = ipmi_auth_special(s);
memcpy(s->authcode, special, 16); memcpy(s->authcode, special, 16);
memset(msg_data + 2, 0, 16); memset(msg_data + 2, 0, 16);
if (verbose > 2) lprintf(LOG_DEBUG, " OEM Auth : %s",
printf(" OEM Auth : %s\n", buf2str(special, 16)); buf2str(special, 16));
} else { } else {
memcpy(msg_data + 2, s->challenge, 16); memcpy(msg_data + 2, s->challenge, 16);
} }
@ -1112,16 +1107,14 @@ ipmi_activate_session_cmd(struct ipmi_intf * intf)
s->active = 1; s->active = 1;
if (verbose > 1) { lprintf(LOG_DEBUG, " Privilege Level : %s",
printf(" Privilege Level : %s\n", val2str(msg_data[1], ipmi_privlvl_vals));
val2str(msg_data[1], ipmi_privlvl_vals)); lprintf(LOG_DEBUG, " Auth Type : %s",
printf(" Auth Type : %s\n", val2str(s->authtype, ipmi_authtype_session_vals));
val2str(s->authtype, ipmi_authtype_session_vals));
}
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("Error in Activate Session Command\n"); lprintf(LOG_ERR, "Activate Session command failed");
s->active = 0; s->active = 0;
return -1; return -1;
} }
@ -1129,58 +1122,59 @@ ipmi_activate_session_cmd(struct ipmi_intf * intf)
printbuf(rsp->data, rsp->data_len, "activate_session"); printbuf(rsp->data, rsp->data_len, "activate_session");
if (rsp->ccode) { if (rsp->ccode) {
printf("Activate Session error: "); lprintf(LOG_ERR, "Activate Session error:");
switch (rsp->ccode) { switch (rsp->ccode) {
case 0x81: case 0x81:
printf("No session slot available\n"); lprintf(LOG_ERR, "\tNo session slot available");
break; break;
case 0x82: case 0x82:
printf("No slot available for given user - " lprintf(LOG_ERR, "\tNo slot available for given user - "
"limit reached\n"); "limit reached");
break; break;
case 0x83: case 0x83:
printf("No slot available to support user " lprintf(LOG_ERR, "\tNo slot available to support user "
"due to maximum privilege capacity\n"); "due to maximum privilege capacity");
break; break;
case 0x84: case 0x84:
printf("Session sequence number out of range\n"); lprintf(LOG_ERR, "\tSession sequence out of range");
break; break;
case 0x85: case 0x85:
printf("Invalid session ID in request\n"); lprintf(LOG_ERR, "\tInvalid session ID in request");
break; break;
case 0x86: case 0x86:
printf("Requested privilege level exceeds limit\n"); lprintf(LOG_ERR, "\tRequested privilege level "
"exceeds limit");
break; break;
case 0xd4: case 0xd4:
printf("Insufficient privilege level\n"); lprintf(LOG_ERR, "\tInsufficient privilege level");
break; break;
default: default:
printf("%02x\n", rsp->ccode); lprintf(LOG_ERR, "\t%s",
val2str(rsp->ccode, completion_code_vals));
} }
return -1; return -1;
} }
memcpy(&s->session_id, rsp->data + 1, 4); memcpy(&s->session_id, rsp->data + 1, 4);
s->in_seq = rsp->data[8] << 24 | rsp->data[7] << 16 | rsp->data[6] << 8 | rsp->data[5]; s->in_seq = rsp->data[8] << 24 | rsp->data[7] << 16 | rsp->data[6] << 8 | rsp->data[5];
if (!s->in_seq) ++s->in_seq; if (s->in_seq == 0)
++s->in_seq;
if (s->authstatus & IPMI_AUTHSTATUS_PER_MSG_DISABLED) if (s->authstatus & IPMI_AUTHSTATUS_PER_MSG_DISABLED)
s->authtype = IPMI_SESSION_AUTHTYPE_NONE; s->authtype = IPMI_SESSION_AUTHTYPE_NONE;
else if (s->authtype != rsp->data[0] & 0xf) { else if (s->authtype != (rsp->data[0] & 0xf)) {
printf("\nInvalid Session AuthType in response!!\n"); lprintf(LOG_ERR, "Invalid Session AuthType %s in response",
val2str(s->authtype, ipmi_authtype_session_vals));
return -1; return -1;
} }
if (verbose > 1) { lprintf(LOG_DEBUG, "\nSession Activated");
printf("\nSession Activated\n"); lprintf(LOG_DEBUG, " Auth Type : %s",
printf(" Auth Type : %s\n", val2str(rsp->data[0], ipmi_authtype_session_vals));
val2str(rsp->data[0], ipmi_authtype_session_vals)); lprintf(LOG_DEBUG, " Max Priv Level : %s",
printf(" Max Priv Level : %s\n", val2str(rsp->data[9], ipmi_privlvl_vals));
val2str(rsp->data[9], ipmi_privlvl_vals)); lprintf(LOG_DEBUG, " Session ID : %08lx", (long)s->session_id);
printf(" Session ID : %08lx\n", (long)s->session_id); lprintf(LOG_DEBUG, " Inbound Seq : %08lx\n", (long)s->in_seq);
printf(" Inbound Seq : %08lx\n", (long)s->in_seq);
printf("\n");
}
return 0; return 0;
} }
@ -1206,21 +1200,23 @@ ipmi_set_session_privlvl_cmd(struct ipmi_intf * intf)
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("error in Set Session Privilege Level Command\n"); lprintf(LOG_ERR, "Set Session Privilege Level to %s failed",
val2str(privlvl, ipmi_privlvl_vals));
return -1; return -1;
} }
if (verbose > 2) if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "set_session_privlvl"); printbuf(rsp->data, rsp->data_len, "set_session_privlvl");
if (rsp->ccode) { if (rsp->ccode > 0) {
printf("Failed to set session privilege level to %s\n\n", lprintf(LOG_ERR, "Set Session Privilege Level to %s failed: %s",
val2str(privlvl, ipmi_privlvl_vals)); val2str(privlvl, ipmi_privlvl_vals));
return -1; return -1;
} }
if (verbose > 1)
printf("Set Session Privilege Level to %s\n\n", lprintf(LOG_DEBUG, "Set Session Privilege Level to %s\n",
val2str(rsp->data[0], ipmi_privlvl_vals)); val2str(rsp->data[0], ipmi_privlvl_vals));
return 0; return 0;
} }
@ -1232,7 +1228,7 @@ ipmi_close_session_cmd(struct ipmi_intf * intf)
unsigned char msg_data[4]; unsigned char msg_data[4];
uint32_t session_id = intf->session->session_id; uint32_t session_id = intf->session->session_id;
if (!intf->session->active) if (intf->session->active == 0)
return -1; return -1;
intf->target_addr = IPMI_BMC_SLAVE_ADDR; intf->target_addr = IPMI_BMC_SLAVE_ADDR;
@ -1246,25 +1242,25 @@ ipmi_close_session_cmd(struct ipmi_intf * intf)
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("error in Close Session Command\n"); lprintf(LOG_ERR, "Close Session command failed");
return -1; return -1;
} }
if (verbose > 2) if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "close_session"); printbuf(rsp->data, rsp->data_len, "close_session");
if (rsp->ccode == 0x87) { if (rsp->ccode == 0x87) {
printf("Failed to Close Session: invalid session ID %08lx\n", lprintf(LOG_ERR, "Failed to Close Session: invalid "
(long)session_id); "session ID %08lx", (long)session_id);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
printf("Failed to Close Session: %x\n", rsp->ccode); lprintf(LOG_ERR, "Close Session command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
} }
if (verbose > 1) lprintf(LOG_DEBUG, "Closed Session %08lx\n", (long)session_id);
printf("\nClosed Session %08lx\n\n", (long)session_id);
return 0; return 0;
} }
@ -1294,7 +1290,7 @@ ipmi_lan_activate_session(struct ipmi_intf * intf)
/* don't fail on ping because its not always supported. /* don't fail on ping because its not always supported.
* Supermicro's IPMI LAN 1.5 cards don't tolerate pings. * Supermicro's IPMI LAN 1.5 cards don't tolerate pings.
*/ */
if (!intf->session->authspecial) if (intf->session->authspecial == 0)
ipmi_lan_ping(intf); ipmi_lan_ping(intf);
if (intf->thump) if (intf->thump)
@ -1325,13 +1321,13 @@ ipmi_lan_activate_session(struct ipmi_intf * intf)
return 0; return 0;
fail: fail:
printf("Error: Unable to establish LAN session\n"); lprintf(LOG_ERR, "Error: Unable to establish LAN session");
return -1; return -1;
} }
void ipmi_lan_close(struct ipmi_intf * intf) void ipmi_lan_close(struct ipmi_intf * intf)
{ {
if (!intf->abort) if (intf->abort == 0)
ipmi_close_session_cmd(intf); ipmi_close_session_cmd(intf);
if (intf->fd >= 0) if (intf->fd >= 0)
@ -1339,10 +1335,11 @@ void ipmi_lan_close(struct ipmi_intf * intf)
ipmi_req_clear_entries(); ipmi_req_clear_entries();
if (intf->session) if (intf->session != NULL) {
free(intf->session); free(intf->session);
intf->session = NULL;
}
intf->session = NULL;
intf->opened = 0; intf->opened = 0;
intf = NULL; intf = NULL;
} }
@ -1353,17 +1350,17 @@ int ipmi_lan_open(struct ipmi_intf * intf)
struct sigaction act; struct sigaction act;
struct ipmi_session *s; struct ipmi_session *s;
if (!intf || !intf->session) if (intf == NULL || intf->session == NULL)
return -1; return -1;
s = intf->session; s = intf->session;
if (!s->port) if (s->port == 0)
s->port = IPMI_LAN_PORT; s->port = IPMI_LAN_PORT;
if (!s->privlvl) if (s->privlvl == 0)
s->privlvl = IPMI_SESSION_PRIV_USER; s->privlvl = IPMI_SESSION_PRIV_ADMIN;
if (!strlen(s->hostname)) { if (strlen(s->hostname) == 0) {
printf("No hostname specified!\n"); lprintf(LOG_ERR, "No hostname specified!");
return -1; return -1;
} }
@ -1377,28 +1374,29 @@ int ipmi_lan_open(struct ipmi_intf * intf)
rc = inet_pton(AF_INET, s->hostname, &s->addr.sin_addr); rc = inet_pton(AF_INET, s->hostname, &s->addr.sin_addr);
if (rc <= 0) { if (rc <= 0) {
struct hostent *host = gethostbyname(s->hostname); struct hostent *host = gethostbyname(s->hostname);
if (!host) { if (host == NULL) {
printf("address lookup failed\n"); lprintf(LOG_ERR, "Address lookup for %s failed",
s->hostname);
return -1; return -1;
} }
s->addr.sin_family = host->h_addrtype; s->addr.sin_family = host->h_addrtype;
memcpy(&s->addr.sin_addr, host->h_addr, host->h_length); memcpy(&s->addr.sin_addr, host->h_addr, host->h_length);
} }
if (verbose > 1) lprintf(LOG_DEBUG, "IPMI LAN host %s port %d",
printf("IPMI LAN host %s port %d\n", s->hostname, ntohs(s->addr.sin_port));
s->hostname, ntohs(s->addr.sin_port));
intf->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); intf->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (intf->fd < 0) { if (intf->fd < 0) {
perror("socket failed"); lperror(LOG_ERR, "Socket failed");
return -1; return -1;
} }
/* connect to UDP socket so we get async errors */ /* connect to UDP socket so we get async errors */
rc = connect(intf->fd, (struct sockaddr *)&s->addr, sizeof(struct sockaddr_in)); rc = connect(intf->fd, (struct sockaddr *)&s->addr,
sizeof(struct sockaddr_in));
if (rc < 0) { if (rc < 0) {
perror("connect failed"); lperror(LOG_ERR, "Connect failed");
intf->close(intf); intf->close(intf);
return -1; return -1;
} }
@ -1406,8 +1404,9 @@ int ipmi_lan_open(struct ipmi_intf * intf)
/* setup alarm handler */ /* setup alarm handler */
act.sa_handler = query_alarm; act.sa_handler = query_alarm;
act.sa_flags = 0; act.sa_flags = 0;
if (!sigemptyset(&act.sa_mask) && sigaction(SIGALRM, &act, NULL) < 0) { if (sigemptyset(&act.sa_mask) == 0 &&
perror("alarm signal"); sigaction(SIGALRM, &act, NULL) < 0) {
lperror(LOG_ERR, "Alarm signal setup failed");
intf->close(intf); intf->close(intf);
return -1; return -1;
} }
@ -1429,7 +1428,7 @@ static int ipmi_lan_setup(struct ipmi_intf * intf)
{ {
intf->session = malloc(sizeof(struct ipmi_session)); intf->session = malloc(sizeof(struct ipmi_session));
if (intf->session == NULL) { if (intf->session == NULL) {
fprintf(stderr, "ipmitool: malloc failure\n"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1; return -1;
} }
memset(intf->session, 0, sizeof(struct ipmi_session)); memset(intf->session, 0, sizeof(struct ipmi_session));

View File

@ -39,6 +39,7 @@
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#include "lan.h" #include "lan.h"
#include "asf.h"
#define RMCP_VERSION_1 0x06 #define RMCP_VERSION_1 0x06
@ -69,10 +70,20 @@ static const struct valstr rmcp_class_vals[] __attribute__((unused)) = {
/* RMCP message header */ /* RMCP message header */
struct rmcp_hdr { struct rmcp_hdr {
unsigned char ver; uint8_t ver;
unsigned char __reserved; uint8_t __reserved;
unsigned char seq; uint8_t seq;
unsigned char class; uint8_t class;
} __attribute__((packed));
struct rmcp_pong {
struct rmcp_hdr rmcp;
struct asf_hdr asf;
uint32_t iana;
uint32_t oem;
uint8_t sup_entities;
uint8_t sup_interact;
uint8_t reserved[6];
} __attribute__((packed)); } __attribute__((packed));
int handle_rmcp(struct ipmi_intf * intf, unsigned char * data, int data_len); int handle_rmcp(struct ipmi_intf * intf, unsigned char * data, int data_len);

View File

@ -61,11 +61,11 @@ static const struct valstr asf_type_vals[] __attribute__((unused)) = {
/* ASF message header */ /* ASF message header */
struct asf_hdr { struct asf_hdr {
unsigned long iana; uint32_t iana;
unsigned char type; uint8_t type;
unsigned char tag; uint8_t tag;
unsigned char __reserved; uint8_t __reserved;
unsigned char len; uint8_t len;
} __attribute__((packed)); } __attribute__((packed));
int handle_asf(struct ipmi_intf * intf, unsigned char * data, int data_len); int handle_asf(struct ipmi_intf * intf, unsigned char * data, int data_len);

View File

@ -69,10 +69,10 @@ static const struct valstr rmcp_class_vals[] __attribute__((unused)) = {
/* RMCP message header */ /* RMCP message header */
struct rmcp_hdr { struct rmcp_hdr {
unsigned char ver; uint8_t ver;
unsigned char __reserved; uint8_t __reserved;
unsigned char seq; uint8_t seq;
unsigned char class; uint8_t class;
} __attribute__((packed)); } __attribute__((packed));
int handle_rmcp(struct ipmi_intf * intf, unsigned char * data, int data_len); int handle_rmcp(struct ipmi_intf * intf, unsigned char * data, int data_len);