mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 19:17:22 +00:00
rework these to open on first call to sendrecv
This commit is contained in:
parent
85e70c1b8d
commit
182fd656d2
@ -49,9 +49,7 @@
|
|||||||
|
|
||||||
#include "lipmi.h"
|
#include "lipmi.h"
|
||||||
|
|
||||||
static int curr_seq;
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
struct ipmi_session lan_session;
|
|
||||||
|
|
||||||
struct ipmi_intf ipmi_lipmi_intf = {
|
struct ipmi_intf ipmi_lipmi_intf = {
|
||||||
.open = ipmi_lipmi_open,
|
.open = ipmi_lipmi_open,
|
||||||
@ -66,17 +64,14 @@ void ipmi_lipmi_close(struct ipmi_intf * intf)
|
|||||||
intf->fd = -1;
|
intf->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipmi_lipmi_open(struct ipmi_intf * intf, char * dev,
|
int ipmi_lipmi_open(struct ipmi_intf * intf)
|
||||||
int __unused1, char * __unused2, char * __unused3)
|
|
||||||
{
|
{
|
||||||
intf->fd = open(dev ? : LIPMI_DEV, O_RDWR);
|
intf->fd = open(LIPMI_DEV, O_RDWR);
|
||||||
if (intf->fd < 0) {
|
if (intf->fd < 0) {
|
||||||
perror("Could not open lipmi device");
|
perror("Could not open lipmi device");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_seq = 0;
|
|
||||||
|
|
||||||
return intf->fd;
|
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;
|
struct strioctl istr;
|
||||||
static struct lipmi_reqrsp reqrsp;
|
static struct lipmi_reqrsp reqrsp;
|
||||||
static struct ipmi_rs rsp;
|
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));
|
memset(&reqrsp, 0, sizeof(reqrsp));
|
||||||
reqrsp.req.fn = req->msg.netfn;
|
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")));
|
int intf_setup(struct ipmi_intf ** intf) __attribute__ ((weak, alias("lipmi_intf_setup")));
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@
|
|||||||
#define IPMI_LIPMI_H
|
#define IPMI_LIPMI_H
|
||||||
|
|
||||||
#include <ipmitool/ipmi.h>
|
#include <ipmitool/ipmi.h>
|
||||||
|
#include <ipmitool/ipmi_intf.h>
|
||||||
|
|
||||||
#define LIPMI_DEV "/dev/lipmi"
|
#define LIPMI_DEV "/dev/lipmi"
|
||||||
|
|
||||||
struct ipmi_rs * ipmi_lipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
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);
|
void ipmi_lipmi_close(struct ipmi_intf * intf);
|
||||||
int lipmi_intf_setup(struct ipmi_intf ** intf);
|
int lipmi_intf_setup(struct ipmi_intf ** intf);
|
||||||
|
|
||||||
|
@ -51,9 +51,7 @@
|
|||||||
|
|
||||||
#include "open.h"
|
#include "open.h"
|
||||||
|
|
||||||
static int curr_seq;
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
struct ipmi_session lan_session;
|
|
||||||
|
|
||||||
struct ipmi_intf ipmi_openipmi_intf = {
|
struct ipmi_intf ipmi_openipmi_intf = {
|
||||||
.open = ipmi_openipmi_open,
|
.open = ipmi_openipmi_open,
|
||||||
@ -67,14 +65,11 @@ void ipmi_openipmi_close(struct ipmi_intf * intf)
|
|||||||
close(intf->fd);
|
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;
|
int i = 0;
|
||||||
|
|
||||||
if (!dev)
|
intf->fd = open(OPENIPMI_DEV, O_RDWR);
|
||||||
intf->fd = open(OPENIPMI_DEV, O_RDWR);
|
|
||||||
else
|
|
||||||
intf->fd = open(dev, O_RDWR);
|
|
||||||
|
|
||||||
if (intf->fd < 0) {
|
if (intf->fd < 0) {
|
||||||
perror("Could not open ipmi device");
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_seq = 0;
|
|
||||||
|
|
||||||
return intf->fd;
|
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_system_interface_addr bmc_addr;
|
||||||
struct ipmi_req _req;
|
struct ipmi_req _req;
|
||||||
static struct ipmi_rs rsp;
|
static struct ipmi_rs rsp;
|
||||||
|
static int curr_seq = 0;
|
||||||
fd_set rset;
|
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)
|
if (!req)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@
|
|||||||
#define IPMI_OPENIPMI_H
|
#define IPMI_OPENIPMI_H
|
||||||
|
|
||||||
#include <ipmitool/ipmi.h>
|
#include <ipmitool/ipmi.h>
|
||||||
|
#include <ipmitool/ipmi_intf.h>
|
||||||
|
|
||||||
#define OPENIPMI_DEV "/dev/ipmi0"
|
#define OPENIPMI_DEV "/dev/ipmi0"
|
||||||
|
|
||||||
struct ipmi_rs * ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
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);
|
void ipmi_openipmi_close(struct ipmi_intf * intf);
|
||||||
int open_intf_setup(struct ipmi_intf ** intf);
|
int open_intf_setup(struct ipmi_intf ** intf);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user