freeipmi 0.6.0 support added;adjust autoconf as needed for changes

This commit is contained in:
Albert Chu 2008-01-05 17:50:46 +00:00
parent d9e561a4cf
commit 6a269e5741
2 changed files with 90 additions and 16 deletions

View File

@ -226,6 +226,9 @@ AC_CHECK_HEADER([linux/ipmi.h],
dnl look for FreeIPMI files dnl look for FreeIPMI files
AC_CHECK_LIB(freeipmi, ipmi_open_inband, [have_free=yes], [have_free=no]) AC_CHECK_LIB(freeipmi, ipmi_open_inband, [have_free=yes], [have_free=no])
if test "x$have_free" != "xyes"; then
AC_CHECK_LIB(freeipmi, ipmi_ctx_open_inband, [have_free=yes], [have_free=no])
fi
AC_ARG_ENABLE([intf-free], AC_ARG_ENABLE([intf-free],
[AC_HELP_STRING([--enable-intf-free], [AC_HELP_STRING([--enable-intf-free],
[enable FreeIPMI IPMI interface [default=auto]])], [enable FreeIPMI IPMI interface [default=auto]])],
@ -274,7 +277,6 @@ dnl Determine if you got the right FreeIPMI version
0); 0);
], ac_free_version_0_4_0=yes,ac_free_version_0_4_0=no) ], ac_free_version_0_4_0=yes,ac_free_version_0_4_0=no)
AC_MSG_RESULT($ac_free_version_0_4_0) AC_MSG_RESULT($ac_free_version_0_4_0)
AC_MSG_CHECKING([for libfreeipmi version 0.5.0]) AC_MSG_CHECKING([for libfreeipmi version 0.5.0])
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#include <sys/types.h> /* For size_t */ #include <sys/types.h> /* For size_t */
@ -296,21 +298,44 @@ dnl Determine if you got the right FreeIPMI version
], ac_free_version_0_5_0=yes,ac_free_version_0_5_0=no) ], ac_free_version_0_5_0=yes,ac_free_version_0_5_0=no)
AC_MSG_RESULT($ac_free_version_0_5_0) AC_MSG_RESULT($ac_free_version_0_5_0)
AC_MSG_CHECKING([for libfreeipmi version 0.6.0])
AC_TRY_COMPILE([
#include <stdio.h> /* For NULL */
#include <freeipmi/freeipmi.h>
], [
ipmi_ctx_t ctx = NULL;
int rv;
ctx = ipmi_ctx_create();
rv = ipmi_ctx_open_inband(ctx,
IPMI_DEVICE_KCS,
0,
0,
0,
NULL,
0,
0);
], ac_free_version_0_6_0=yes,ac_free_version_0_6_0=no)
AC_MSG_RESULT($ac_free_version_0_6_0)
if test "x$ac_free_version_0_3_0" = "xyes" \ if test "x$ac_free_version_0_3_0" = "xyes" \
|| test "x$ac_free_version_0_4_0" = "xyes" \ || test "x$ac_free_version_0_4_0" = "xyes" \
|| test "x$ac_free_version_0_5_0" = "xyes"; then || test "x$ac_free_version_0_5_0" = "xyes" \
|| test "x$ac_free_version_0_6_0" = "xyes"; then
AC_DEFINE(IPMI_INTF_FREE, [1], [Define to 1 to enable FreeIPMI interface.]) AC_DEFINE(IPMI_INTF_FREE, [1], [Define to 1 to enable FreeIPMI interface.])
AC_SUBST(INTF_FREE, [free]) AC_SUBST(INTF_FREE, [free])
AC_SUBST(INTF_FREE_LIB, [libintf_free.la]) AC_SUBST(INTF_FREE_LIB, [libintf_free.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB free/libintf_free.la" IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB free/libintf_free.la"
if test "x$ac_free_version_0_3_0" = "xyes"; then if test "x$ac_free_version_0_3_0" = "xyes"; then
AC_DEFINE(IPMI_INTF_FREE_VERSION_0_3_0, [1], [Define to 1 for FreeIPMI 0.3.0.]) AC_DEFINE(IPMI_INTF_FREE_0_3_0, [1], [Define to 1 for FreeIPMI 0.3.0.])
fi fi
if test "x$ac_free_version_0_4_0" = "xyes"; then if test "x$ac_free_version_0_4_0" = "xyes"; then
AC_DEFINE(IPMI_INTF_FREE_VERSION_0_4_0, [1], [Define to 1 for FreeIPMI 0.4.0.]) AC_DEFINE(IPMI_INTF_FREE_0_4_0, [1], [Define to 1 for FreeIPMI 0.4.0.])
fi fi
if test "x$ac_free_version_0_5_0" = "xyes"; then if test "x$ac_free_version_0_5_0" = "xyes"; then
AC_DEFINE(IPMI_INTF_FREE_VERSION_0_5_0, [1], [Define to 1 for FreeIPMI 0.5.0.]) AC_DEFINE(IPMI_INTF_FREE_0_5_0, [1], [Define to 1 for FreeIPMI 0.5.0.])
fi
if test "x$ac_free_version_0_6_0" = "xyes"; then
AC_DEFINE(IPMI_INTF_FREE_0_6_0, [1], [Define to 1 for FreeIPMI 0.6.0.])
fi fi
else else
enable_intf_free=no enable_intf_free=no

View File

@ -34,6 +34,10 @@
* facility. * facility.
*/ */
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -43,11 +47,15 @@
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
#include <freeipmi/freeipmi.h> #include <freeipmi/freeipmi.h>
#if IPMI_INTF_FREE_0_3_0 || IPMI_INTF_FREE_0_4_0 || IPMI_INTF_FREE_0_5_0
#include <freeipmi/udm/ipmi-udm.h> #include <freeipmi/udm/ipmi-udm.h>
#endif
#include <config.h> #if IPMI_INTF_FREE_0_6_0
ipmi_ctx_t dev = NULL;
#else /* !IPMI_INTF_FREE_0_6_0 */
ipmi_device_t dev = NULL; ipmi_device_t dev = NULL;
#endif /* !IPMI_INTF_FREE_0_6_0 */
extern int verbose; extern int verbose;
@ -58,7 +66,7 @@ static int ipmi_free_open(struct ipmi_intf * intf)
return -1; return -1;
} }
#if IPMI_INTF_FREE_VERSION_0_3_0 #if IPMI_INTF_FREE_0_3_0
if (!(dev = ipmi_open_inband (IPMI_DEVICE_KCS, if (!(dev = ipmi_open_inband (IPMI_DEVICE_KCS,
0, 0,
0, 0,
@ -75,9 +83,9 @@ static int ipmi_free_open(struct ipmi_intf * intf)
goto cleanup; goto cleanup;
} }
} }
#elif IPMI_INTF_FREE_VERSION_0_4_0 #elif IPMI_INTF_FREE_0_4_0
if (!(dev = ipmi_device_create())) { if (!(dev = ipmi_device_create())) {
perror("ipmi_open_inband()"); perror("ipmi_device_create");
goto cleanup; goto cleanup;
} }
if (ipmi_open_inband (dev, if (ipmi_open_inband (dev,
@ -100,9 +108,9 @@ static int ipmi_free_open(struct ipmi_intf * intf)
goto cleanup; goto cleanup;
} }
} }
#elif IPMI_INTF_FREE_VERSION_0_5_0 #elif IPMI_INTF_FREE_0_5_0
if (!(dev = ipmi_device_create())) { if (!(dev = ipmi_device_create())) {
perror("ipmi_open_inband()"); perror("ipmi_device_create");
goto cleanup; goto cleanup;
} }
if (ipmi_open_inband (dev, if (ipmi_open_inband (dev,
@ -127,15 +135,47 @@ static int ipmi_free_open(struct ipmi_intf * intf)
goto cleanup; goto cleanup;
} }
} }
#elif IPMI_INTF_FREE_0_6_0
if (!(dev = ipmi_ctx_create())) {
perror("ipmi_ctx_create");
goto cleanup;
}
if (ipmi_ctx_open_inband (dev,
IPMI_DEVICE_KCS,
0,
0,
0,
NULL,
0,
IPMI_FLAGS_DEFAULT) < 0) {
if (ipmi_ctx_open_inband (dev,
IPMI_DEVICE_SSIF,
0,
0,
0,
NULL,
0,
IPMI_FLAGS_DEFAULT) < 0) {
fprintf(stderr,
"ipmi_open_inband(): %s\n",
ipmi_ctx_strerror(ipmi_ctx_errnum(dev)));
goto cleanup;
}
}
#endif #endif
intf->opened = 1; intf->opened = 1;
return 0; return 0;
cleanup: cleanup:
if (dev) { if (dev) {
#if IPMI_INTF_FREE_0_3_0
ipmi_close_device(dev);
#elif IPMI_INTF_FREE_0_4_0 || IPMI_INTF_FREE_0_5_0
ipmi_close_device(dev); ipmi_close_device(dev);
#if IPMI_INTF_FREE_VERSION_0_4_0
ipmi_device_destroy(dev); ipmi_device_destroy(dev);
#elif IPMI_INTF_FREE_0_6_0
ipmi_ctx_close(dev);
ipmi_ctx_destroy(dev);
#endif #endif
} }
return -1; return -1;
@ -144,9 +184,14 @@ static int ipmi_free_open(struct ipmi_intf * intf)
static void ipmi_free_close(struct ipmi_intf * intf) static void ipmi_free_close(struct ipmi_intf * intf)
{ {
if (dev) { if (dev) {
#if IPMI_INTF_FREE_0_3_0
ipmi_close_device(dev);
#elif IPMI_INTF_FREE_0_4_0 || IPMI_INTF_FREE_0_5_0
ipmi_close_device(dev); ipmi_close_device(dev);
#if IPMI_INTF_FREE_VERSION_0_4_0
ipmi_device_destroy(dev); ipmi_device_destroy(dev);
#elif IPMI_INTF_FREE_0_6_0
ipmi_ctx_close(dev);
ipmi_ctx_destroy(dev);
#endif #endif
} }
intf->opened = 0; intf->opened = 0;
@ -194,12 +239,16 @@ static struct ipmi_rs * ipmi_free_send_cmd(struct ipmi_intf * intf, struct ipmi_
req->msg.data_len + 1, req->msg.data_len + 1,
rs_buf, rs_buf,
rs_buf_len)) < 0) { rs_buf_len)) < 0) {
#if IPMI_INTF_FREE_VERSION_0_3_0 #if IPMI_INTF_FREE_0_3_0
perror("ipmi_cmd_raw"); perror("ipmi_cmd_raw");
#elif IPMI_INTF_FREE_VERSION_0_4_0 #elif IPMI_INTF_FREE_0_4_0 || IPMI_INTF_FREE_0_5_0
fprintf(stderr, fprintf(stderr,
"ipmi_cmd_raw: %s\n", "ipmi_cmd_raw: %s\n",
ipmi_device_strerror(ipmi_device_errnum(dev))); ipmi_device_strerror(ipmi_device_errnum(dev)));
#elif IPMI_INTF_FREE_0_6_0
fprintf(stderr,
"ipmi_cmd_raw: %s\n",
ipmi_ctx_strerror(ipmi_ctx_errnum(dev)));
#endif #endif
return NULL; return NULL;
} }