rework these to open on first call to sendrecv

This commit is contained in:
Duncan Laurie 2004-04-15 20:26:18 +00:00
parent 85e70c1b8d
commit 182fd656d2
4 changed files with 35 additions and 18 deletions

View File

@ -49,9 +49,7 @@
#include "lipmi.h"
static int curr_seq;
extern int verbose;
struct ipmi_session lan_session;
struct ipmi_intf ipmi_lipmi_intf = {
.open = ipmi_lipmi_open,
@ -66,17 +64,14 @@ void ipmi_lipmi_close(struct ipmi_intf * intf)
intf->fd = -1;
}
int ipmi_lipmi_open(struct ipmi_intf * intf, char * dev,
int __unused1, char * __unused2, char * __unused3)
int ipmi_lipmi_open(struct ipmi_intf * intf)
{
intf->fd = open(dev ? : LIPMI_DEV, O_RDWR);
intf->fd = open(LIPMI_DEV, O_RDWR);
if (intf->fd < 0) {
perror("Could not open lipmi device");
return -1;
}
curr_seq = 0;
return intf->fd;
}
@ -85,6 +80,19 @@ struct ipmi_rs * ipmi_lipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * r
struct strioctl istr;
static struct lipmi_reqrsp reqrsp;
static struct ipmi_rs rsp;
static int curr_seq = 0;
if (!intf)
return NULL;
if (!intf->opened) {
intf->opened = 1;
if (intf->open(intf) < 0) {
printf("Unable to open LIPMI interface!\n");
intf->opened = 0;
return NULL;
}
}
memset(&reqrsp, 0, sizeof(reqrsp));
reqrsp.req.fn = req->msg.netfn;
@ -128,3 +136,4 @@ int lipmi_intf_setup(struct ipmi_intf ** intf)
}
int intf_setup(struct ipmi_intf ** intf) __attribute__ ((weak, alias("lipmi_intf_setup")));

View File

@ -38,11 +38,12 @@
#define IPMI_LIPMI_H
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#define LIPMI_DEV "/dev/lipmi"
struct ipmi_rs * ipmi_lipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
int ipmi_lipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2, char * __unused3);
int ipmi_lipmi_open(struct ipmi_intf * intf);
void ipmi_lipmi_close(struct ipmi_intf * intf);
int lipmi_intf_setup(struct ipmi_intf ** intf);

View File

@ -51,9 +51,7 @@
#include "open.h"
static int curr_seq;
extern int verbose;
struct ipmi_session lan_session;
struct ipmi_intf ipmi_openipmi_intf = {
.open = ipmi_openipmi_open,
@ -67,14 +65,11 @@ void ipmi_openipmi_close(struct ipmi_intf * intf)
close(intf->fd);
}
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2, char * __unused3)
int ipmi_openipmi_open(struct ipmi_intf * intf)
{
int i = 0;
if (!dev)
intf->fd = open(OPENIPMI_DEV, O_RDWR);
else
intf->fd = open(dev, O_RDWR);
intf->fd = open(OPENIPMI_DEV, O_RDWR);
if (intf->fd < 0) {
perror("Could not open ipmi device");
@ -86,8 +81,6 @@ int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char
return -1;
}
curr_seq = 0;
return intf->fd;
}
@ -98,8 +91,21 @@ struct ipmi_rs * ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq
struct ipmi_system_interface_addr bmc_addr;
struct ipmi_req _req;
static struct ipmi_rs rsp;
static int curr_seq = 0;
fd_set rset;
if (!intf)
return NULL;
if (!intf->opened) {
intf->opened = 1;
if (intf->open(intf) < 0) {
printf("Unable to open OpenIPMI interface!\n");
intf->opened = 0;
return NULL;
}
}
if (!req)
return NULL;

View File

@ -38,11 +38,12 @@
#define IPMI_OPENIPMI_H
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#define OPENIPMI_DEV "/dev/ipmi0"
struct ipmi_rs * ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2, char * __unused3);
int ipmi_openipmi_open(struct ipmi_intf * intf);
void ipmi_openipmi_close(struct ipmi_intf * intf);
int open_intf_setup(struct ipmi_intf ** intf);