Imported Upstream version 2.6.4
This commit is contained in:
parent
fad6ced6f6
commit
fefe62b2bd
257 changed files with 6020 additions and 1394 deletions
|
@ -1,13 +1,29 @@
|
|||
# TODO: remove redundancies!
|
||||
|
||||
# Force build in ./ before nut-scanner, to have nutscan-{usb,snmp}.h
|
||||
# built before going into the nut-scanner sub-directory
|
||||
# XXX this does not work with Automake!!!
|
||||
#
|
||||
# In fact the very concept is entirely antithetical to Automake.
|
||||
#
|
||||
# SUBDIRS are explicitly a listing of all the directories that make
|
||||
# must recurse into BEFORE processing the current directory.
|
||||
#
|
||||
# These python scripts must be moved into a sub-directory, and _only_
|
||||
# executed IF they need to be, and all the nut-scanner sources need
|
||||
# to be moved out of a sub-directory into this directory.
|
||||
#
|
||||
# Anyway, for the time being, we force build in ./ before nut-scanner,
|
||||
# to have nutscan-{usb,snmp}.h built before going into the nut-scanner
|
||||
# sub-directory
|
||||
SUBDIRS = . nut-scanner
|
||||
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py device-recorder.sh svn2cl.authors nut-snmpinfo.py
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py nut-recorder.sh svn2cl.authors nut-snmpinfo.py
|
||||
|
||||
all: nut-scanner-deps
|
||||
|
||||
# XXX these rules are all bogus! They cause un-named target files to
|
||||
# always be rebuilt! None of that is ever the right way to use make,
|
||||
# and especially not Automake. Explicit filenames and their exact
|
||||
# dependencies need to be properly listed.
|
||||
nut-scanner-deps:
|
||||
@if python -c 1; then \
|
||||
echo "Regenerating the SNMP helper files."; \
|
||||
|
|
|
@ -190,6 +190,7 @@ MKDIR_P = @MKDIR_P@
|
|||
NETLIBS = @NETLIBS@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
NUT_NETVERSION = @NUT_NETVERSION@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OS_NAME = @OS_NAME@
|
||||
|
@ -203,6 +204,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
|||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PIDPATH = @PIDPATH@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
|
@ -210,6 +212,7 @@ PORT = @PORT@
|
|||
RANLIB = @RANLIB@
|
||||
RUN_AS_GROUP = @RUN_AS_GROUP@
|
||||
RUN_AS_USER = @RUN_AS_USER@
|
||||
SBINDIR = @SBINDIR@
|
||||
SED = @SED@
|
||||
SERLIBS = @SERLIBS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
|
@ -284,10 +287,22 @@ top_builddir = @top_builddir@
|
|||
top_srcdir = @top_srcdir@
|
||||
udevdir = @udevdir@
|
||||
|
||||
# Force build in ./ before nut-scanner, to have nutscan-{usb,snmp}.h
|
||||
# built before going into the nut-scanner sub-directory
|
||||
# XXX this does not work with Automake!!!
|
||||
#
|
||||
# In fact the very concept is entirely antithetical to Automake.
|
||||
#
|
||||
# SUBDIRS are explicitly a listing of all the directories that make
|
||||
# must recurse into BEFORE processing the current directory.
|
||||
#
|
||||
# These python scripts must be moved into a sub-directory, and _only_
|
||||
# executed IF they need to be, and all the nut-scanner sources need
|
||||
# to be moved out of a sub-directory into this directory.
|
||||
#
|
||||
# Anyway, for the time being, we force build in ./ before nut-scanner,
|
||||
# to have nutscan-{usb,snmp}.h built before going into the nut-scanner
|
||||
# sub-directory
|
||||
SUBDIRS = . nut-scanner
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py device-recorder.sh svn2cl.authors nut-snmpinfo.py
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py nut-recorder.sh svn2cl.authors nut-snmpinfo.py
|
||||
all: all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -640,6 +655,10 @@ uninstall-am:
|
|||
|
||||
all: nut-scanner-deps
|
||||
|
||||
# XXX these rules are all bogus! They cause un-named target files to
|
||||
# always be rebuilt! None of that is ever the right way to use make,
|
||||
# and especially not Automake. Explicit filenames and their exact
|
||||
# dependencies need to be properly listed.
|
||||
nut-scanner-deps:
|
||||
@if python -c 1; then \
|
||||
echo "Regenerating the SNMP helper files."; \
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# device-recorder.sh
|
||||
# A script to record device running sequence and dump it in a .seq format
|
||||
# The .seq file can then be used by dummy-ups to replay the sequence.
|
||||
# nut-recorder
|
||||
# An utility to record device running sequence (Ie power failures or any
|
||||
# other change) and dump it in a .seq format
|
||||
# The .seq file can then be used by the 'dummy-ups driver to replay the
|
||||
# sequence.
|
||||
#
|
||||
################################################################################
|
||||
# FIXME:
|
||||
# - implement PAUSE / RESUME (do not increment TIMER) on pressing space
|
||||
# - implement PAUSE / RESUME (do not increment TIMER) on pressing space (?)
|
||||
# - implement support for creating either .dev (static dump) or .seq
|
||||
# - implement dump of instcmd and upsrw
|
||||
################################################################################
|
||||
|
||||
strUsage="Usage: dummy-recorder.sh <device-name> [output-file] [interval]"
|
||||
strUsage="Usage: nut-recorder <device-name> [output-file] [interval]"
|
||||
|
||||
# log data each 5 seconds
|
||||
DEFAULT_INTERVAL=5
|
||||
|
@ -18,7 +22,7 @@ DEFAULT_INTERVAL=5
|
|||
# temporary files location
|
||||
TEMP_DIR="/tmp"
|
||||
|
||||
# output to dummy-device.dev by default
|
||||
# output this file by default
|
||||
DEFAULT_OUTPUT="dummy-device.seq"
|
||||
|
||||
# Process command line parameters
|
|
@ -11,7 +11,7 @@ endif
|
|||
libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \
|
||||
nutscan-device.c nutscan-ip.c nutscan-display.c nutscan-init.c \
|
||||
scan_usb.c scan_snmp.c scan_xml_http.c scan_avahi.c
|
||||
libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS) $(LIBLTDL_LIBS)
|
||||
libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS)
|
||||
libnutscan_la_LDFLAGS = -version-info 1:0:0
|
||||
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include $(LIBLTDL_CFLAGS)
|
||||
|
||||
|
|
|
@ -105,9 +105,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
|
|||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
@WITH_SSL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
libnutscan_la_DEPENDENCIES = ../../clients/libupsclient.la \
|
||||
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
||||
$(am__DEPENDENCIES_2)
|
||||
libnutscan_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||
am_libnutscan_la_OBJECTS = libnutscan_la-scan_nut.lo \
|
||||
libnutscan_la-scan_ipmi.lo libnutscan_la-nutscan-device.lo \
|
||||
libnutscan_la-nutscan-ip.lo libnutscan_la-nutscan-display.lo \
|
||||
|
@ -229,6 +228,7 @@ MKDIR_P = @MKDIR_P@
|
|||
NETLIBS = @NETLIBS@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
NUT_NETVERSION = @NUT_NETVERSION@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OS_NAME = @OS_NAME@
|
||||
|
@ -242,6 +242,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
|||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PIDPATH = @PIDPATH@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
|
@ -249,6 +250,7 @@ PORT = @PORT@
|
|||
RANLIB = @RANLIB@
|
||||
RUN_AS_GROUP = @RUN_AS_GROUP@
|
||||
RUN_AS_USER = @RUN_AS_USER@
|
||||
SBINDIR = @SBINDIR@
|
||||
SED = @SED@
|
||||
SERLIBS = @SERLIBS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
|
@ -328,8 +330,7 @@ libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \
|
|||
nutscan-device.c nutscan-ip.c nutscan-display.c nutscan-init.c \
|
||||
scan_usb.c scan_snmp.c scan_xml_http.c scan_avahi.c
|
||||
|
||||
libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS) \
|
||||
$(LIBLTDL_LIBS) $(am__append_2)
|
||||
libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) $(am__append_2)
|
||||
libnutscan_la_LDFLAGS = -version-info 1:0:0
|
||||
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \
|
||||
$(LIBLTDL_CFLAGS) $(am__append_1) $(am__append_3) \
|
||||
|
|
|
@ -470,5 +470,8 @@ display_help:
|
|||
|
||||
display_func(dev[TYPE_IPMI]);
|
||||
nutscan_free_device(dev[TYPE_IPMI]);
|
||||
|
||||
nutscan_free();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <ltdl.h>
|
||||
|
||||
int nutscan_avail_avahi = 0;
|
||||
int nutscan_avail_ipmi = 0;
|
||||
int nutscan_avail_nut = 1;
|
||||
int nutscan_avail_nut = 0;
|
||||
int nutscan_avail_snmp = 0;
|
||||
int nutscan_avail_usb = 0;
|
||||
int nutscan_avail_xml_http = 0;
|
||||
|
@ -31,6 +32,7 @@ int nutscan_load_snmp_library(void);
|
|||
int nutscan_load_neon_library(void);
|
||||
int nutscan_load_avahi_library(void);
|
||||
int nutscan_load_ipmi_library(void);
|
||||
int nutscan_load_upsclient_library(void);
|
||||
|
||||
void nutscan_init(void)
|
||||
{
|
||||
|
@ -49,4 +51,27 @@ void nutscan_init(void)
|
|||
#ifdef WITH_FREEIPMI
|
||||
nutscan_avail_ipmi = nutscan_load_ipmi_library();
|
||||
#endif
|
||||
nutscan_avail_nut = nutscan_load_upsclient_library();
|
||||
}
|
||||
|
||||
void nutscan_free(void)
|
||||
{
|
||||
if( nutscan_avail_usb ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
if( nutscan_avail_snmp ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
if( nutscan_avail_xml_http ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
if( nutscan_avail_avahi ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
if( nutscan_avail_ipmi ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
if( nutscan_avail_nut ) {
|
||||
lt_dlexit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ extern int nutscan_avail_usb;
|
|||
extern int nutscan_avail_xml_http;
|
||||
|
||||
void nutscan_init(void);
|
||||
void nutscan_free(void);
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ static snmp_device_id_t snmp_device_table[] = {
|
|||
{ ".1.3.6.1.4.1.318.1.1.1.1.1.1.0" , "apcc", NULL},
|
||||
{ ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1" , "baytech", NULL},
|
||||
{ ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0" , "cyberpower", ".1.3.6.1.4.1.3808"},
|
||||
{ "1.3.6.1.4.1.232.165.3.1.1.0" , "cpqpower", NULL},
|
||||
{ ".1.3.6.1.4.1.232.165.3.1.1.0" , "cpqpower", ".1.3.6.1.4.1.232.165.3"},
|
||||
{ ".1.3.6.1.4.1.4555.1.1.1.1.1.1.0" , "netvision", ".1.3.6.1.4.1.4555.1.1.1"},
|
||||
/* Terminating entry */
|
||||
{ NULL, NULL, NULL}
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct {
|
|||
static usb_device_id_t usb_device_table[] = {
|
||||
|
||||
{ 0x0001, 0x0000, "blazer_usb" },
|
||||
{ 0x03f0, 0x0001, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1f01, "bcmxcp_usb" },
|
||||
{ 0x03f0, 0x1f02, "bcmxcp_usb" },
|
||||
{ 0x03f0, 0x1f06, "usbhid-ups" },
|
||||
|
@ -40,6 +41,12 @@ static usb_device_id_t usb_device_table[] = {
|
|||
{ 0x03f0, 0x1f0a, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe0, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe1, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe2, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe3, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe5, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe6, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe7, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1fe8, "usbhid-ups" },
|
||||
{ 0x0463, 0x0001, "usbhid-ups" },
|
||||
{ 0x0463, 0xffff, "usbhid-ups" },
|
||||
{ 0x047c, 0xffff, "usbhid-ups" },
|
||||
|
@ -58,8 +65,11 @@ static usb_device_id_t usb_device_table[] = {
|
|||
{ 0x0592, 0x0004, "usbhid-ups" },
|
||||
{ 0x05b8, 0x0000, "blazer_usb" },
|
||||
{ 0x0665, 0x5161, "blazer_usb" },
|
||||
{ 0x06da, 0x0002, "bcmxcp_usb" },
|
||||
{ 0x06da, 0x0002, "blazer_usb" },
|
||||
{ 0x06da, 0x0003, "blazer_usb" },
|
||||
{ 0x06da, 0x0004, "blazer_usb" },
|
||||
{ 0x06da, 0x0005, "blazer_usb" },
|
||||
{ 0x06da, 0x0201, "blazer_usb" },
|
||||
{ 0x06da, 0xffff, "usbhid-ups" },
|
||||
{ 0x075d, 0x0300, "usbhid-ups" },
|
||||
{ 0x0764, 0x0005, "usbhid-ups" },
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <ltdl.h>
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libavahi-client";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
|
||||
|
@ -98,7 +99,7 @@ int nutscan_load_avahi_library()
|
|||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext("libavahi-client");
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
|
@ -196,8 +197,10 @@ int nutscan_load_avahi_library()
|
|||
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "%s\n", dl_error);
|
||||
fprintf(stderr, "Cannot load AVAHI library (%s) : %s. AVAHI search disabled.\n", libname, dl_error);
|
||||
|
||||
dl_handle = (void *)1;
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
/* end of dynamic link library stuff */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define NUT_IPMI_DRV_NAME "nut-ipmipsu"
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libfreeipmi";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
|
||||
|
@ -77,7 +78,7 @@ int nutscan_load_ipmi_library()
|
|||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext("libfreeipmi");
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
|
@ -163,8 +164,9 @@ int nutscan_load_ipmi_library()
|
|||
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "%s\n", dl_error);
|
||||
fprintf(stderr, "Cannot load IPMI library (%s) : %s. IPMI search disabled.\n", libname, dl_error);
|
||||
dl_handle = (void *)1;
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
/* end of dynamic link library stuff */
|
||||
|
|
|
@ -23,7 +23,20 @@
|
|||
#ifdef HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <ltdl.h>
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libupsclient";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
|
||||
static int (*nut_upscli_splitaddr)(const char *buf,char **hostname, int *port);
|
||||
static int (*nut_upscli_tryconnect)(UPSCONN_t *ups, const char *host, int port,
|
||||
int flags,struct timeval * timeout);
|
||||
static int (*nut_upscli_list_start)(UPSCONN_t *ups, unsigned int numq,
|
||||
const char **query);
|
||||
static int (*nut_upscli_list_next)(UPSCONN_t *ups, unsigned int numq,
|
||||
const char **query,unsigned int *numa, char ***answer);
|
||||
|
||||
static nutscan_device_t * dev_ret = NULL;
|
||||
#ifdef HAVE_PTHREAD
|
||||
|
@ -35,6 +48,64 @@ struct scan_nut_arg {
|
|||
long timeout;
|
||||
};
|
||||
|
||||
/* return 0 on error */
|
||||
int nutscan_load_upsclient_library()
|
||||
{
|
||||
|
||||
if( dl_handle != NULL ) {
|
||||
/* if previous init failed */
|
||||
if( dl_handle == (void *)1 ) {
|
||||
return 0;
|
||||
}
|
||||
/* init has already been done */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( lt_dlinit() != 0 ) {
|
||||
fprintf(stderr, "Error initializing lt_init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
}
|
||||
|
||||
lt_dlerror(); /* Clear any existing error */
|
||||
|
||||
*(void **) (&nut_upscli_splitaddr) = lt_dlsym(dl_handle,
|
||||
"upscli_splitaddr");
|
||||
if ((dl_error = lt_dlerror()) != NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(void **) (&nut_upscli_tryconnect) = lt_dlsym(dl_handle,
|
||||
"upscli_tryconnect");
|
||||
if ((dl_error = lt_dlerror()) != NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(void **) (&nut_upscli_list_start) = lt_dlsym(dl_handle,
|
||||
"upscli_list_start");
|
||||
if ((dl_error = lt_dlerror()) != NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(void **) (&nut_upscli_list_next) = lt_dlsym(dl_handle,
|
||||
"upscli_list_next");
|
||||
if ((dl_error = lt_dlerror()) != NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "Cannot load NUT library (%s) : %s. NUT search disabled.\n", libname, dl_error);
|
||||
dl_handle = (void *)1;
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: SSL support */
|
||||
static void * list_nut_devices(void * arg)
|
||||
{
|
||||
|
@ -56,28 +127,32 @@ static void * list_nut_devices(void * arg)
|
|||
query[0] = "UPS";
|
||||
numq = 1;
|
||||
|
||||
if (upscli_splitaddr(target_hostname, &hostname, &port) != 0) {
|
||||
if ((*nut_upscli_splitaddr)(target_hostname, &hostname, &port) != 0) {
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
if (upscli_tryconnect(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) {
|
||||
if ((*nut_upscli_tryconnect)(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) {
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(upscli_list_start(ups, numq, query) < 0) {
|
||||
if((*nut_upscli_list_start)(ups, numq, query) < 0) {
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (upscli_list_next(ups, numq, query, &numa, &answer) == 1) {
|
||||
while ((*nut_upscli_list_next)(ups,numq, query, &numa, &answer) == 1) {
|
||||
/* UPS <upsname> <description> */
|
||||
if (numa < 3) {
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
/* FIXME: check for duplication by getting driver.port and device.serial
|
||||
|
@ -109,6 +184,7 @@ static void * list_nut_devices(void * arg)
|
|||
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,19 +56,25 @@
|
|||
#endif
|
||||
#include "nutscan-snmp.h"
|
||||
|
||||
/* Address API change */
|
||||
#ifndef usmAESPrivProtocol
|
||||
#define USMAESPRIVPROTOCOL "usmAES128PrivProtocol"
|
||||
#else
|
||||
#define USMAESPRIVPROTOCOL "usmAESPrivProtocol"
|
||||
#endif
|
||||
|
||||
#define SysOID ".1.3.6.1.2.1.1.2.0"
|
||||
|
||||
static nutscan_device_t * dev_ret = NULL;
|
||||
#ifdef HAVE_PTHREAD
|
||||
static pthread_mutex_t dev_mutex;
|
||||
static pthread_mutex_t lib_mutex;
|
||||
static pthread_t * thread_array = NULL;
|
||||
static int thread_count = 0;
|
||||
#endif
|
||||
long g_usec_timeout ;
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libnetsnmp";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
|
||||
|
@ -99,10 +105,6 @@ static oid * (*nut_usmDESPrivProtocol);
|
|||
/* return 0 on error */
|
||||
int nutscan_load_snmp_library()
|
||||
{
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&lib_mutex);
|
||||
#endif
|
||||
|
||||
if( dl_handle != NULL ) {
|
||||
/* if previous init failed */
|
||||
if( dl_handle == (void *)1 ) {
|
||||
|
@ -117,7 +119,7 @@ int nutscan_load_snmp_library()
|
|||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext("libnetsnmp");
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
|
@ -205,7 +207,7 @@ int nutscan_load_snmp_library()
|
|||
}
|
||||
|
||||
*(void **) (&nut_usmAESPrivProtocol) = lt_dlsym(dl_handle,
|
||||
"usmAESPrivProtocol");
|
||||
USMAESPRIVPROTOCOL);
|
||||
if ((dl_error = lt_dlerror()) != NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
@ -228,16 +230,11 @@ int nutscan_load_snmp_library()
|
|||
goto err;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&dev_mutex);
|
||||
#endif
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "%s\n", dl_error);
|
||||
fprintf(stderr, "Cannot load SNMP library (%s) : %s. SNMP search disabled.\n", libname, dl_error);
|
||||
dl_handle = (void *)1;
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&dev_mutex);
|
||||
#endif
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
/* end of dynamic link library stuff */
|
||||
|
@ -660,7 +657,6 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
|
|||
pthread_t thread;
|
||||
|
||||
pthread_mutex_init(&dev_mutex,NULL);
|
||||
pthread_mutex_init(&lib_mutex,NULL);
|
||||
#endif
|
||||
|
||||
if( !nutscan_avail_snmp ) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <ltdl.h>
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libusb";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
static int (*nut_usb_close)(usb_dev_handle *dev);
|
||||
|
@ -57,7 +58,7 @@ int nutscan_load_usb_library()
|
|||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext("libusb");
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
|
@ -106,8 +107,9 @@ int nutscan_load_usb_library()
|
|||
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "%s\n", dl_error);
|
||||
fprintf(stderr, "Cannot load USB library (%s) : %s. USB search disabled.\n", libname, dl_error);
|
||||
dl_handle = (void *)1;
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
/* end of dynamic link library stuff */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <ltdl.h>
|
||||
|
||||
/* dynamic link library stuff */
|
||||
static char * libname = "libneon";
|
||||
static lt_dlhandle dl_handle = NULL;
|
||||
static const char *dl_error = NULL;
|
||||
|
||||
|
@ -63,7 +64,7 @@ int nutscan_load_neon_library()
|
|||
return 0;
|
||||
}
|
||||
|
||||
dl_handle = lt_dlopenext("libneon");
|
||||
dl_handle = lt_dlopenext(libname);
|
||||
if (!dl_handle) {
|
||||
dl_error = lt_dlerror();
|
||||
goto err;
|
||||
|
@ -93,8 +94,9 @@ int nutscan_load_neon_library()
|
|||
|
||||
return 1;
|
||||
err:
|
||||
fprintf(stderr, "%s\n", dl_error);
|
||||
fprintf(stderr, "Cannot load XML library (%s) : %s. XML search disabled.\n", libname, dl_error);
|
||||
dl_handle = (void *)1;
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -210,7 +212,7 @@ nutscan_device_t * nutscan_scan_xml_http(long usec_timeout)
|
|||
ne_xml_parser *parser = (*nut_ne_xml_create)();
|
||||
(*nut_ne_xml_push_handler)(parser, startelm_cb,
|
||||
NULL, NULL, nut_dev);
|
||||
(*nut_ne_xml_parse)(parser, buf, strlen(buf));
|
||||
(*nut_ne_xml_parse)(parser, buf, recv_size);
|
||||
(*nut_ne_xml_destroy)(parser);
|
||||
|
||||
nut_dev->driver = strdup("netxml-ups");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env perl
|
||||
# Current Version : 1.1
|
||||
# Copyright (C) 2008 - 2011
|
||||
# Current Version : 1.2
|
||||
# Copyright (C) 2008 - 2012
|
||||
# Arnaud Quette <arnaud.quette@gmail.com>
|
||||
# dloic (loic.dardant AT gmail DOT com)
|
||||
#
|
||||
|
@ -20,7 +20,11 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
# TODO list:
|
||||
# - rewrite using glob, as in other helper scripts
|
||||
# - manage deps in Makefile.am
|
||||
|
||||
use File::Find;
|
||||
use strict;
|
||||
|
||||
|
@ -211,7 +215,8 @@ sub gen_usb_files
|
|||
|
||||
sub find_usbdevs
|
||||
{
|
||||
return $File::Find::prune = 1 if $_ eq '.svn';
|
||||
# maybe there's an option to turn off all .* files, but anyway this is stupid
|
||||
return $File::Find::prune = 1 if ($_ eq '.svn') || ($_ =~ /^\.#/);
|
||||
|
||||
my $nameFile=$_;
|
||||
my $lastComment="";
|
||||
|
|
|
@ -11,3 +11,11 @@ fbohe-guest:Frederic Bohe <fbohe-guest@alioth.debian.org>
|
|||
aquette:Arnaud Quette <arnaud.quette@free.fr>
|
||||
clepple-guest:Charles Lepple <clepple+nut@gmail.com>
|
||||
adkorte-guest:Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
selinger-guest:Peter Selinger <selinger@users.sourceforge.net>
|
||||
carlosefr-guest:Carlos Rodrigues <cefrodrigues@gmail.com>
|
||||
nba-guest:Niels Baggesen <nba@users.sourceforge.net>
|
||||
lyrgard-guest:Jonathan Dion <lyrgard-guest@alioth.debian.org>
|
||||
jongough-guest:Jon Gough <jon.gough@eclipsesystems.com.au>
|
||||
mihl-guest:Michal Hlavinka <mhlavink@redhat.com>
|
||||
acolombier-guest:Antoine Colombier <acolombier-guest@alioth.debian.org>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue