summaryrefslogtreecommitdiff
path: root/src/plugins/dummy
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/dummy')
-rw-r--r--src/plugins/dummy/Makefile.am4
-rw-r--r--src/plugins/dummy/Makefile.in4
-rw-r--r--src/plugins/dummy/dummy.c17
-rw-r--r--src/plugins/dummy/dummy.h28
4 files changed, 48 insertions, 5 deletions
diff --git a/src/plugins/dummy/Makefile.am b/src/plugins/dummy/Makefile.am
index 8a53bbe..bbc8048 100644
--- a/src/plugins/dummy/Makefile.am
+++ b/src/plugins/dummy/Makefile.am
@@ -1,8 +1,8 @@
MAINTAINERCLEANFILES = Makefile.in
-INCLUDES = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_dummy.la
noinst_LTLIBRARIES = @INTF_DUMMY_LIB@
libintf_dummy_la_LIBADD = $(top_builddir)/lib/libipmitool.la
-libintf_dummy_la_SOURCES = dummy.c
+libintf_dummy_la_SOURCES = dummy.c dummy.h
diff --git a/src/plugins/dummy/Makefile.in b/src/plugins/dummy/Makefile.in
index 86475ba..1850430 100644
--- a/src/plugins/dummy/Makefile.in
+++ b/src/plugins/dummy/Makefile.in
@@ -308,11 +308,11 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
MAINTAINERCLEANFILES = Makefile.in
-INCLUDES = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_dummy.la
noinst_LTLIBRARIES = @INTF_DUMMY_LIB@
libintf_dummy_la_LIBADD = $(top_builddir)/lib/libipmitool.la
-libintf_dummy_la_SOURCES = dummy.c
+libintf_dummy_la_SOURCES = dummy.c dummy.h
all: all-am
.SUFFIXES:
diff --git a/src/plugins/dummy/dummy.c b/src/plugins/dummy/dummy.c
index 8bfc4cf..8600a84 100644
--- a/src/plugins/dummy/dummy.c
+++ b/src/plugins/dummy/dummy.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
@@ -175,6 +176,14 @@ ipmi_dummyipmi_open(struct ipmi_intf *intf)
struct sockaddr_un address;
int len;
int rc;
+ char *dummy_sock_path;
+
+ dummy_sock_path = getenv("IPMI_DUMMY_SOCK");
+ if (dummy_sock_path == NULL) {
+ lprintf(LOG_DEBUG, "No IPMI_DUMMY_SOCK set. Dummy mode ON.");
+ intf->opened = 1;
+ return intf->fd;
+ }
if (intf->opened == 1) {
return intf->fd;
@@ -185,7 +194,7 @@ ipmi_dummyipmi_open(struct ipmi_intf *intf)
return (-1);
}
address.sun_family = AF_UNIX;
- strcpy(address.sun_path, DUMMY_SOCKET_PATH);
+ strcpy(address.sun_path, dummy_sock_path);
len = sizeof(address);
rc = connect(intf->fd, (struct sockaddr *)&address, len);
if (rc != 0) {
@@ -209,6 +218,12 @@ ipmi_dummyipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
static struct ipmi_rs rsp;
struct dummy_rq req_dummy;
struct dummy_rs rsp_dummy;
+ char *dummy_sock_path;
+ dummy_sock_path = getenv("IPMI_DUMMY_SOCK");
+ if (dummy_sock_path == NULL) {
+ lprintf(LOG_DEBUG, "No IPMI_DUMMY_SOCK set. Dummy mode ON.");
+ return NULL;
+ }
if (intf == NULL || intf->fd < 0 || intf->opened != 1) {
lprintf(LOG_ERR, "dummy failed on intf check.");
return NULL;
diff --git a/src/plugins/dummy/dummy.h b/src/plugins/dummy/dummy.h
new file mode 100644
index 0000000..bbe3aa3
--- /dev/null
+++ b/src/plugins/dummy/dummy.h
@@ -0,0 +1,28 @@
+#ifndef IPMI_DUMMYIPMI_H
+# define IPMI_DUMMYIPMI_H
+
+struct dummy_rq {
+ struct {
+ uint8_t netfn;
+ uint8_t lun;
+ uint8_t cmd;
+ uint8_t target_cmd;
+ uint16_t data_len;
+ uint8_t *data;
+ } msg;
+};
+
+struct dummy_rs {
+ struct {
+ uint8_t netfn;
+ uint8_t cmd;
+ uint8_t seq;
+ uint8_t lun;
+ } msg;
+
+ uint8_t ccode;
+ int data_len;
+ uint8_t *data;
+};
+
+#endif