Imported Upstream version 2.6.2

This commit is contained in:
Arnaud Quette 2011-09-29 20:14:46 +02:00
parent a367d9bc54
commit 45043b58d0
246 changed files with 18228 additions and 1415 deletions

View file

@ -1,10 +1,37 @@
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py device-recorder.sh svn2cl.authors
# 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
all: nut-scanner-deps
nut-scanner-deps:
@if python -c 1; then \
echo "Regenerating the SNMP helper files."; \
$(top_srcdir)/tools/nut-snmpinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
echo "Skipping the SNMP helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
@if perl -e 1; then \
echo "Regenerating the USB helper files."; \
$(top_srcdir)/tools/nut-usbinfo.pl; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Perl is not available."; \
echo "Skipping the USB helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
website:
@if python -c pass; then \
echo "Regenerating the HTML and JSON formated HCL tables."; \
./nut-hclinfo.py; \
$(top_srcdir)/tools/nut-hclinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
@ -12,8 +39,20 @@ website:
echo "----------------------------------------------------------------------"; \
fi
# only call the USB info script upon "make dist", and if Perl is present
# call the USB info script upon "make dist", and if Perl is present
# call the SNMP info script upon "make dist", and if Python is present
# and call both for building nut-scanner
dist-hook:
@if python -c 1; then \
echo "Regenerating the SNMP helper files."; \
$(distdir)/nut-snmpinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
echo "Skipping the SNMP helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
@if perl -e 1; then \
echo "Regenerating the USB helper files."; \
$(distdir)/nut-usbinfo.pl; \
@ -23,3 +62,5 @@ dist-hook:
echo "Skipping the USB helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
.PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps

View file

@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -64,7 +66,47 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
distdir
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@ -109,10 +151,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -150,6 +196,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -214,6 +264,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
@ -223,8 +275,12 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py device-recorder.sh svn2cl.authors
all: all-am
# 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
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@ -263,12 +319,141 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS:
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS:
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@ -300,22 +485,51 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
check-am: all-am
check: check-am
check: check-recursive
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@ -332,91 +546,117 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi: dvi-recursive
dvi-am:
html: html-am
html: html-recursive
html-am:
info: info-am
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html: install-html-recursive
install-html-am:
install-info: install-info-am
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-am
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf: pdf-recursive
pdf-am:
ps: ps-am
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
install-am install-strip tags-recursive
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
dist-hook distclean distclean-generic distclean-libtool \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am check check-am clean clean-generic clean-libtool \
ctags ctags-recursive dist-hook distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
all: nut-scanner-deps
nut-scanner-deps:
@if python -c 1; then \
echo "Regenerating the SNMP helper files."; \
$(top_srcdir)/tools/nut-snmpinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
echo "Skipping the SNMP helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
@if perl -e 1; then \
echo "Regenerating the USB helper files."; \
$(top_srcdir)/tools/nut-usbinfo.pl; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Perl is not available."; \
echo "Skipping the USB helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
website:
@if python -c pass; then \
echo "Regenerating the HTML and JSON formated HCL tables."; \
./nut-hclinfo.py; \
$(top_srcdir)/tools/nut-hclinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
@ -424,8 +664,20 @@ website:
echo "----------------------------------------------------------------------"; \
fi
# only call the USB info script upon "make dist", and if Perl is present
# call the USB info script upon "make dist", and if Perl is present
# call the SNMP info script upon "make dist", and if Python is present
# and call both for building nut-scanner
dist-hook:
@if python -c 1; then \
echo "Regenerating the SNMP helper files."; \
$(distdir)/nut-snmpinfo.py; \
else \
echo "----------------------------------------------------------------------"; \
echo "Warning: Python is not available."; \
echo "Skipping the SNMP helper files regeneration."; \
echo "----------------------------------------------------------------------"; \
fi
@if perl -e 1; then \
echo "Regenerating the USB helper files."; \
$(distdir)/nut-usbinfo.pl; \
@ -436,6 +688,8 @@ dist-hook:
echo "----------------------------------------------------------------------"; \
fi
.PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -0,0 +1,46 @@
BUILT_SOURCES = nutscan-usb.h nutscan-snmp.h
nutscan-usb.h nutscan-snmp.h:
cd ..; $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps
lib_LTLIBRARIES = libnutscan.la
libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \
nutscan-device.c nutscan-ip.c nutscan-display.c
libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS)
libnutscan_la_LDFLAGS = -version-info 1:0:0
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include
bin_PROGRAMS = nut-scanner
nut_scanner_SOURCES = nut-scanner.c
nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include
nut_scanner_LDADD = libnutscan.la
if WITH_SSL
libnutscan_la_CFLAGS += $(LIBSSL_CFLAGS)
libnutscan_la_LIBADD += $(LIBSSL_LIBS)
endif
if WITH_USB
libnutscan_la_SOURCES += scan_usb.c
libnutscan_la_CFLAGS += $(LIBUSB_CFLAGS)
libnutscan_la_LIBADD += $(LIBUSB_LIBS)
endif
if WITH_SNMP
libnutscan_la_SOURCES += scan_snmp.c
libnutscan_la_CFLAGS += $(LIBNETSNMP_CFLAGS)
libnutscan_la_LIBADD += $(LIBNETSNMP_LIBS)
endif
if WITH_NEONXML
libnutscan_la_SOURCES += scan_xml_http.c
libnutscan_la_CFLAGS += $(LIBNEON_CFLAGS)
libnutscan_la_LIBADD += $(LIBNEON_LIBS)
endif
if WITH_AVAHI
libnutscan_la_SOURCES += scan_avahi.c
libnutscan_la_CFLAGS += $(LIBAVAHI_CFLAGS)
libnutscan_la_LIBADD += $(LIBAVAHI_LIBS)
endif
dist_noinst_HEADERS = nut-scan.h nutscan-usb.h nutscan-snmp.h nutscan-device.h nutscan-ip.h
CLEANFILES = nutscan-usb.h nutscan-snmp.h

View file

@ -0,0 +1,797 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = nut-scanner$(EXEEXT)
@WITH_SSL_TRUE@am__append_1 = $(LIBSSL_CFLAGS)
@WITH_SSL_TRUE@am__append_2 = $(LIBSSL_LIBS)
@WITH_USB_TRUE@am__append_3 = scan_usb.c
@WITH_USB_TRUE@am__append_4 = $(LIBUSB_CFLAGS)
@WITH_USB_TRUE@am__append_5 = $(LIBUSB_LIBS)
@WITH_SNMP_TRUE@am__append_6 = scan_snmp.c
@WITH_SNMP_TRUE@am__append_7 = $(LIBNETSNMP_CFLAGS)
@WITH_SNMP_TRUE@am__append_8 = $(LIBNETSNMP_LIBS)
@WITH_NEONXML_TRUE@am__append_9 = scan_xml_http.c
@WITH_NEONXML_TRUE@am__append_10 = $(LIBNEON_CFLAGS)
@WITH_NEONXML_TRUE@am__append_11 = $(LIBNEON_LIBS)
@WITH_AVAHI_TRUE@am__append_12 = scan_avahi.c
@WITH_AVAHI_TRUE@am__append_13 = $(LIBAVAHI_CFLAGS)
@WITH_AVAHI_TRUE@am__append_14 = $(LIBAVAHI_LIBS)
subdir = tools/nut-scanner
DIST_COMMON = $(dist_noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
$(top_srcdir)/m4/nut_check_libssl.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_config_libhal.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
@WITH_SSL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
@WITH_USB_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
@WITH_SNMP_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1)
@WITH_NEONXML_TRUE@am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1)
@WITH_AVAHI_TRUE@am__DEPENDENCIES_6 = $(am__DEPENDENCIES_1)
libnutscan_la_DEPENDENCIES = ../../clients/libupsclient.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) \
$(am__DEPENDENCIES_5) $(am__DEPENDENCIES_6)
am__libnutscan_la_SOURCES_DIST = scan_nut.c scan_ipmi.c \
nutscan-device.c nutscan-ip.c nutscan-display.c scan_usb.c \
scan_snmp.c scan_xml_http.c scan_avahi.c
@WITH_USB_TRUE@am__objects_1 = libnutscan_la-scan_usb.lo
@WITH_SNMP_TRUE@am__objects_2 = libnutscan_la-scan_snmp.lo
@WITH_NEONXML_TRUE@am__objects_3 = libnutscan_la-scan_xml_http.lo
@WITH_AVAHI_TRUE@am__objects_4 = libnutscan_la-scan_avahi.lo
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 \
$(am__objects_1) $(am__objects_2) $(am__objects_3) \
$(am__objects_4)
libnutscan_la_OBJECTS = $(am_libnutscan_la_OBJECTS)
libnutscan_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libnutscan_la_CFLAGS) \
$(CFLAGS) $(libnutscan_la_LDFLAGS) $(LDFLAGS) -o $@
PROGRAMS = $(bin_PROGRAMS)
am_nut_scanner_OBJECTS = nut_scanner-nut-scanner.$(OBJEXT)
nut_scanner_OBJECTS = $(am_nut_scanner_OBJECTS)
nut_scanner_DEPENDENCIES = libnutscan.la
nut_scanner_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(nut_scanner_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libnutscan_la_SOURCES) $(nut_scanner_SOURCES)
DIST_SOURCES = $(am__libnutscan_la_SOURCES_DIST) \
$(nut_scanner_SOURCES)
HEADERS = $(dist_noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BINDIR = @BINDIR@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DBLATEX = @DBLATEX@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
HAL_FDI_PATH = @HAL_FDI_PATH@
HAL_USER = @HAL_USER@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBTOOL = @LIBTOOL@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_NAME = @OS_NAME@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
cgiexecdir = @cgiexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
driverexecdir = @driverexecdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
hotplugdir = @hotplugdir@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
BUILT_SOURCES = nutscan-usb.h nutscan-snmp.h
lib_LTLIBRARIES = libnutscan.la
libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c nutscan-device.c \
nutscan-ip.c nutscan-display.c $(am__append_3) $(am__append_6) \
$(am__append_9) $(am__append_12)
libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS) \
$(am__append_2) $(am__append_5) $(am__append_8) \
$(am__append_11) $(am__append_14)
libnutscan_la_LDFLAGS = -version-info 1:0:0
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \
$(am__append_1) $(am__append_4) $(am__append_7) \
$(am__append_10) $(am__append_13)
nut_scanner_SOURCES = nut-scanner.c
nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include
nut_scanner_LDADD = libnutscan.la
dist_noinst_HEADERS = nut-scan.h nutscan-usb.h nutscan-snmp.h nutscan-device.h nutscan-ip.h
CLEANFILES = nutscan-usb.h nutscan-snmp.h
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/nut-scanner/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu tools/nut-scanner/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libnutscan.la: $(libnutscan_la_OBJECTS) $(libnutscan_la_DEPENDENCIES)
$(libnutscan_la_LINK) -rpath $(libdir) $(libnutscan_la_OBJECTS) $(libnutscan_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p || test -f $$p1; \
then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' `; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
nut-scanner$(EXEEXT): $(nut_scanner_OBJECTS) $(nut_scanner_DEPENDENCIES)
@rm -f nut-scanner$(EXEEXT)
$(nut_scanner_LINK) $(nut_scanner_OBJECTS) $(nut_scanner_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-device.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-display.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_avahi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_nut.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_snmp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nut_scanner-nut-scanner.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
libnutscan_la-scan_nut.lo: scan_nut.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_nut.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_nut.Tpo -c -o libnutscan_la-scan_nut.lo `test -f 'scan_nut.c' || echo '$(srcdir)/'`scan_nut.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_nut.Tpo $(DEPDIR)/libnutscan_la-scan_nut.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_nut.c' object='libnutscan_la-scan_nut.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_nut.lo `test -f 'scan_nut.c' || echo '$(srcdir)/'`scan_nut.c
libnutscan_la-scan_ipmi.lo: scan_ipmi.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_ipmi.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_ipmi.Tpo -c -o libnutscan_la-scan_ipmi.lo `test -f 'scan_ipmi.c' || echo '$(srcdir)/'`scan_ipmi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_ipmi.Tpo $(DEPDIR)/libnutscan_la-scan_ipmi.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_ipmi.c' object='libnutscan_la-scan_ipmi.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_ipmi.lo `test -f 'scan_ipmi.c' || echo '$(srcdir)/'`scan_ipmi.c
libnutscan_la-nutscan-device.lo: nutscan-device.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-nutscan-device.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-nutscan-device.Tpo -c -o libnutscan_la-nutscan-device.lo `test -f 'nutscan-device.c' || echo '$(srcdir)/'`nutscan-device.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-nutscan-device.Tpo $(DEPDIR)/libnutscan_la-nutscan-device.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nutscan-device.c' object='libnutscan_la-nutscan-device.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-nutscan-device.lo `test -f 'nutscan-device.c' || echo '$(srcdir)/'`nutscan-device.c
libnutscan_la-nutscan-ip.lo: nutscan-ip.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-nutscan-ip.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-nutscan-ip.Tpo -c -o libnutscan_la-nutscan-ip.lo `test -f 'nutscan-ip.c' || echo '$(srcdir)/'`nutscan-ip.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-nutscan-ip.Tpo $(DEPDIR)/libnutscan_la-nutscan-ip.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nutscan-ip.c' object='libnutscan_la-nutscan-ip.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-nutscan-ip.lo `test -f 'nutscan-ip.c' || echo '$(srcdir)/'`nutscan-ip.c
libnutscan_la-nutscan-display.lo: nutscan-display.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-nutscan-display.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-nutscan-display.Tpo -c -o libnutscan_la-nutscan-display.lo `test -f 'nutscan-display.c' || echo '$(srcdir)/'`nutscan-display.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-nutscan-display.Tpo $(DEPDIR)/libnutscan_la-nutscan-display.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nutscan-display.c' object='libnutscan_la-nutscan-display.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-nutscan-display.lo `test -f 'nutscan-display.c' || echo '$(srcdir)/'`nutscan-display.c
libnutscan_la-scan_usb.lo: scan_usb.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_usb.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_usb.Tpo -c -o libnutscan_la-scan_usb.lo `test -f 'scan_usb.c' || echo '$(srcdir)/'`scan_usb.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_usb.Tpo $(DEPDIR)/libnutscan_la-scan_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_usb.c' object='libnutscan_la-scan_usb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_usb.lo `test -f 'scan_usb.c' || echo '$(srcdir)/'`scan_usb.c
libnutscan_la-scan_snmp.lo: scan_snmp.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_snmp.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_snmp.Tpo -c -o libnutscan_la-scan_snmp.lo `test -f 'scan_snmp.c' || echo '$(srcdir)/'`scan_snmp.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_snmp.Tpo $(DEPDIR)/libnutscan_la-scan_snmp.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_snmp.c' object='libnutscan_la-scan_snmp.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_snmp.lo `test -f 'scan_snmp.c' || echo '$(srcdir)/'`scan_snmp.c
libnutscan_la-scan_xml_http.lo: scan_xml_http.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_xml_http.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_xml_http.Tpo -c -o libnutscan_la-scan_xml_http.lo `test -f 'scan_xml_http.c' || echo '$(srcdir)/'`scan_xml_http.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_xml_http.Tpo $(DEPDIR)/libnutscan_la-scan_xml_http.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_xml_http.c' object='libnutscan_la-scan_xml_http.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_xml_http.lo `test -f 'scan_xml_http.c' || echo '$(srcdir)/'`scan_xml_http.c
libnutscan_la-scan_avahi.lo: scan_avahi.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-scan_avahi.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-scan_avahi.Tpo -c -o libnutscan_la-scan_avahi.lo `test -f 'scan_avahi.c' || echo '$(srcdir)/'`scan_avahi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libnutscan_la-scan_avahi.Tpo $(DEPDIR)/libnutscan_la-scan_avahi.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan_avahi.c' object='libnutscan_la-scan_avahi.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-scan_avahi.lo `test -f 'scan_avahi.c' || echo '$(srcdir)/'`scan_avahi.c
nut_scanner-nut-scanner.o: nut-scanner.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nut_scanner_CFLAGS) $(CFLAGS) -MT nut_scanner-nut-scanner.o -MD -MP -MF $(DEPDIR)/nut_scanner-nut-scanner.Tpo -c -o nut_scanner-nut-scanner.o `test -f 'nut-scanner.c' || echo '$(srcdir)/'`nut-scanner.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nut_scanner-nut-scanner.Tpo $(DEPDIR)/nut_scanner-nut-scanner.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nut-scanner.c' object='nut_scanner-nut-scanner.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nut_scanner_CFLAGS) $(CFLAGS) -c -o nut_scanner-nut-scanner.o `test -f 'nut-scanner.c' || echo '$(srcdir)/'`nut-scanner.c
nut_scanner-nut-scanner.obj: nut-scanner.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nut_scanner_CFLAGS) $(CFLAGS) -MT nut_scanner-nut-scanner.obj -MD -MP -MF $(DEPDIR)/nut_scanner-nut-scanner.Tpo -c -o nut_scanner-nut-scanner.obj `if test -f 'nut-scanner.c'; then $(CYGPATH_W) 'nut-scanner.c'; else $(CYGPATH_W) '$(srcdir)/nut-scanner.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nut_scanner-nut-scanner.Tpo $(DEPDIR)/nut_scanner-nut-scanner.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nut-scanner.c' object='nut_scanner-nut-scanner.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nut_scanner_CFLAGS) $(CFLAGS) -c -o nut_scanner-nut-scanner.obj `if test -f 'nut-scanner.c'; then $(CYGPATH_W) 'nut-scanner.c'; else $(CYGPATH_W) '$(srcdir)/nut-scanner.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
install-binPROGRAMS: install-libLTLIBRARIES
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES
.MAKE: all check install install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libLTLIBRARIES clean-libtool ctags \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-libLTLIBRARIES \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-libLTLIBRARIES
nutscan-usb.h nutscan-snmp.h:
cd ..; $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -0,0 +1,65 @@
/* nut-scan.h: detect NUT services
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef NUT_SCAN_H
#define NUT_SCAN_H
#include <nutscan-device.h>
#include <nutscan-ip.h>
/* SNMP structure */
typedef struct nutscan_snmp {
char * community;
char * secLevel;
char * secName;
char * authPassword;
char * privPassword;
char * authProtocol;
char * privProtocol;
char * peername;
void * handle;
} nutscan_snmp_t;
/* Scanning */
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
nutscan_device_t * nutscan_scan_snmp(const char * start_ip,const char * stop_ip,long usec_timeout, nutscan_snmp_t * sec);
#endif
#ifdef HAVE_USB_H
nutscan_device_t * nutscan_scan_usb();
#endif
#ifdef WITH_NEON
nutscan_device_t * nutscan_scan_xml_http(long usec_timeout);
#endif
nutscan_device_t * nutscan_scan_nut(const char * startIP, const char * stopIP, const char * port, long usec_timeout);
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
nutscan_device_t * nutscan_scan_avahi(long usec_timeout);
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
nutscan_device_t * nutscan_scan_ipmi(void);
#endif
/* Displaying */
void nutscan_display_ups_conf(nutscan_device_t * device);
void nutscan_display_parsable(nutscan_device_t * device);
#endif

View file

@ -0,0 +1,415 @@
/* nut-scanner.c: a tool to detect NUT supported devices
*
* Copyright (C) 2011 - Arnaud Quette <arnaud.quette@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "common.h"
#include <unistd.h>
#include <string.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
#include "nut-scan.h"
#define DEFAULT_TIMEOUT 5
const char optstring[] = "?ht:s:e:c:l:u:W:X:w:x:p:CUSMOAm:NPqI";
#ifdef HAVE_GETOPT_LONG
const struct option longopts[] =
{{ "timeout",required_argument,NULL,'t' },
{ "start_ip",required_argument,NULL,'s' },
{ "end_ip",required_argument,NULL,'e' },
{ "mask_cidr",required_argument,NULL,'m' },
{ "community",required_argument,NULL,'c' },
{ "secLevel",required_argument,NULL,'l' },
{ "secName",required_argument,NULL,'u' },
{ "authPassword",required_argument,NULL,'W' },
{ "privPassword",required_argument,NULL,'X' },
{ "authProtocol",required_argument,NULL,'w' },
{ "privProtocol",required_argument,NULL,'x' },
{ "port",required_argument,NULL,'p' },
{ "complete_scan",no_argument,NULL,'C' },
{ "usb_scan",no_argument,NULL,'U' },
{ "snmp_scan",no_argument,NULL,'S' },
{ "xml_scan",no_argument,NULL,'M' },
{ "oldnut_scan",no_argument,NULL,'O' },
{ "avahi_scan",no_argument,NULL,'A' },
{ "ipmi_scan",no_argument,NULL,'I' },
{ "disp_nut_conf",no_argument,NULL,'N' },
{ "disp_parsable",no_argument,NULL,'P' },
{ "quiet",no_argument,NULL,'q' },
{ "help",no_argument,NULL,'h' },
{NULL,0,NULL,0}};
#else
#define getopt_long(a,b,c,d,e) getopt(a,b,c)
#endif /* HAVE_GETOPT_LONG */
static nutscan_device_t *dev[TYPE_END];
static pthread_t thread[TYPE_END];
static long timeout = DEFAULT_TIMEOUT*1000*1000; /* in usec */
static char * start_ip = NULL;
static char * end_ip = NULL;
static char * port = NULL;
#ifdef HAVE_PTHREAD
#ifdef HAVE_USB_H
static void * run_usb(void * arg)
{
dev[TYPE_USB] = nutscan_scan_usb();
return NULL;
}
#endif
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
static void * run_snmp(void * arg)
{
nutscan_snmp_t * sec = (nutscan_snmp_t *)arg;
dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip,end_ip,timeout,sec);
return NULL;
}
#endif
#ifdef WITH_NEON
static void * run_xml(void * arg)
{
dev[TYPE_XML] = nutscan_scan_xml_http(timeout);
return NULL;
}
#endif
static void * run_nut_old(void * arg)
{
dev[TYPE_NUT] = nutscan_scan_nut(start_ip,end_ip,port,timeout);
return NULL;
}
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
static void * run_avahi(void * arg)
{
dev[TYPE_AVAHI] = nutscan_scan_avahi(timeout);
return NULL;
}
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
static void * run_ipmi(void * arg)
{
dev[TYPE_IPMI] = nutscan_scan_ipmi();
return NULL;
}
#endif
#endif /* HAVE_PTHREAD */
static int printq(int quiet,const char *fmt, ...)
{
va_list ap;
int ret;
if(quiet) {
return 0;
}
va_start(ap, fmt);
ret = vprintf(fmt, ap);
va_end(ap);
return ret;
}
int main(int argc, char *argv[])
{
nutscan_snmp_t sec;
int opt_ret;
char * cidr = NULL;
int allow_all = 0;
int allow_usb = 0;
int allow_snmp = 0;
int allow_xml = 0;
int allow_oldnut = 0;
int allow_avahi = 0;
int allow_ipmi = 0;
int quiet = 0;
void (*display_func)(nutscan_device_t * device);
memset(&sec,0,sizeof(sec));
display_func = nutscan_display_ups_conf;
while((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL))!=-1) {
switch(opt_ret) {
case 't':
timeout = atol(optarg)*1000*1000; /*in usec*/
if( timeout == 0 ) {
fprintf(stderr,"Illegal timeout value, using default %ds\n", DEFAULT_TIMEOUT);
timeout = DEFAULT_TIMEOUT*1000*1000;
}
break;
case 's':
start_ip = strdup(optarg);
end_ip = start_ip;
break;
case 'e':
end_ip = strdup(optarg);
break;
case 'm':
cidr = strdup(optarg);
break;
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
case 'c':
sec.community = strdup(optarg);
break;
case 'l':
sec.secLevel = strdup(optarg);
break;
case 'u':
sec.secName = strdup(optarg);
break;
case 'W':
sec.authPassword = strdup(optarg);
break;
case 'X':
sec.privPassword = strdup(optarg);
break;
case 'w':
sec.authProtocol = strdup(optarg);
break;
case 'x':
sec.privProtocol = strdup(optarg);
break;
#endif
case 'p':
port = strdup(optarg);
break;
case 'C':
allow_all = 1;
break;
#ifdef HAVE_USB_H
case 'U':
allow_usb = 1;
break;
#endif
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
case 'S':
allow_snmp = 1;
break;
#endif
#ifdef WITH_NEON
case 'M':
allow_xml = 1;
break;
#endif
case 'O':
allow_oldnut = 1;
break;
#ifdef WITH_AVAHI
case 'A':
allow_avahi = 1;
break;
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
case 'I':
allow_ipmi = 1;
break;
#endif
case 'N':
display_func = nutscan_display_ups_conf;
break;
case 'P':
display_func = nutscan_display_parsable;
break;
case 'q':
quiet = 1;
break;
case 'h':
case '?':
default:
puts("nut-scanner : detecting available UPS.\n");
puts("OPTIONS:");
printf(" -C, --complete_scan : Scan all available devices (default).\n");
#ifdef HAVE_USB_H
printf(" -U, --usb_scan : Scan USB devices.\n");
#endif
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
printf(" -S, --snmp_scan : Scan SNMP devices.\n");
#endif
#ifdef WITH_NEON
printf(" -M, --xml_scan : Scan XML/HTTP devices.\n");
#endif
printf(" -O, --oldnut_scan : Scan NUT devices (old method).\n");
#ifdef WITH_AVAHI
printf(" -A, --avahi_scan : Scan NUT devices (avahi method).\n");
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
printf(" -I, --ipmi_scan : Scan IPMI devices.\n");
#endif
printf(" -t, --timeout <timeout in seconds>: network operation timeout (default %d).\n",DEFAULT_TIMEOUT);
printf(" -s, --start_ip <IP address>: First IP address to scan.\n");
printf(" -e, --end_ip <IP address>: Last IP address to scan.\n");
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
printf("\nSNMP v1 specific options:\n");
printf(" -c, --community <community name>: Set SNMP v1 community name (default = public)\n");
printf("\nSNMP v3 specific options:\n");
printf(" -l, --secLevel <security level>: Set the securityLevel used for SNMPv3 messages (allowed values: noAuthNoPriv,authNoPriv,authPriv)\n");
printf(" -u, --secName <security name>: Set the securityName used for authenticated SNMPv3 messages (mandatory if you set secLevel. No default)\n");
printf(" -a, --authProtocol <authentication protocol>: Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5)\n");
printf(" -A, --authPassword <authentication pass phrase>: Set the authentication pass phrase used for authenticated SNMPv3 messages (mandatory if you set secLevel to authNoPriv or authPriv)\n");
printf(" -x, --privProtocol <privacy protocol>: Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES)\n");
printf(" -X, --privPassword <privacy pass phrase>: Set the privacy pass phrase used for encrypted SNMPv3 messages (mandatory if you set secLevel to authPriv)\n");
#endif
printf("\nNUT device specific options:\n");
printf(" -p, --port <port number>: Port number of remote NUT devices\n");
printf("\ndisplay specific options:\n");
printf(" -N, --disp_nut_conf : Display result in the ups.conf format\n");
printf(" -P, --disp_parsable : Display result in a parsable format\n");
return 0;
}
}
if( cidr ) {
nutscan_cidr_to_ip(cidr, &start_ip, &end_ip);
}
if( !allow_usb && !allow_snmp && !allow_xml && !allow_oldnut &&
!allow_avahi && !allow_ipmi ) {
allow_all = 1;
}
#ifdef HAVE_USB_H
if( allow_all || allow_usb) {
printq(quiet,"Scanning USB bus.\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_USB],NULL,run_usb,NULL);
#else
dev[TYPE_USB] = nutscan_scan_usb();
#endif
}
#endif /* HAVE_USB_H */
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
if( allow_all || allow_snmp) {
if( start_ip == NULL ) {
printq(quiet,"No start IP, skipping SNMP\n");
}
else {
printq(quiet,"Scanning SNMP bus.\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_SNMP],NULL,run_snmp,&sec);
#else
dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip,end_ip,timeout,&sec);
#endif
}
}
#endif /* HAVE_NET_SNMP_NET_SNMP_CONFIG_H */
#ifdef WITH_NEON
if( allow_all || allow_xml) {
printq(quiet,"Scanning XML/HTTP bus.\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_XML],NULL,run_xml,NULL);
#else
dev[TYPE_XML] = nutscan_scan_xml_http(timeout);
#endif
}
#endif
if( allow_all || allow_oldnut) {
if( start_ip == NULL ) {
printq(quiet,"No start IP, skipping NUT bus (old connect method)\n");
}
else {
printq(quiet,"Scanning NUT bus (old connect method).\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_NUT],NULL,run_nut_old,NULL);
#else
dev[TYPE_NUT] = nutscan_scan_nut(start_ip,end_ip,port,timeout);
#endif
}
}
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
if( allow_all || allow_avahi) {
printq(quiet,"Scanning NUT bus (avahi method).\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_AVAHI],NULL,run_avahi,NULL);
#else
dev[TYPE_AVAHI] = nutscan_scan_avahi();
#endif
}
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
if( allow_all || allow_ipmi) {
printq(quiet,"Scanning IPMI bus.\n");
#ifdef HAVE_PTHREAD
pthread_create(&thread[TYPE_IPMI],NULL,run_ipmi,NULL);
#else
dev[TYPE_IPMI] = nutscan_scan_ipmi();
#endif
}
#endif
#ifdef HAVE_PTHREAD
#ifdef HAVE_USB_H
pthread_join(thread[TYPE_USB],NULL);
#endif
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
pthread_join(thread[TYPE_SNMP],NULL);
#endif
#ifdef WITH_NEON
pthread_join(thread[TYPE_XML],NULL);
#endif
pthread_join(thread[TYPE_NUT],NULL);
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
pthread_join(thread[TYPE_AVAHI],NULL);
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
pthread_join(thread[TYPE_IPMI],NULL);
#endif
#endif /* HAVE_PTHREAD */
#ifdef HAVE_USB_H
display_func(dev[TYPE_USB]);
nutscan_free_device(dev[TYPE_USB]);
#endif
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
display_func(dev[TYPE_SNMP]);
nutscan_free_device(dev[TYPE_SNMP]);
#endif
#ifdef WITH_NEON
display_func(dev[TYPE_XML]);
nutscan_free_device(dev[TYPE_XML]);
#endif
display_func(dev[TYPE_NUT]);
nutscan_free_device(dev[TYPE_NUT]);
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
display_func(dev[TYPE_AVAHI]);
nutscan_free_device(dev[TYPE_AVAHI]);
#endif
#ifdef HAVE_FREEIPMI_FREEIPMI_H
display_func(dev[TYPE_IPMI]);
nutscan_free_device(dev[TYPE_IPMI]);
#endif
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,183 @@
/* device.c: manipulation of a container describing a NUT device
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "nutscan-device.h"
#include <stdlib.h>
#include <string.h>
nutscan_device_t * nutscan_new_device()
{
nutscan_device_t * device;
device = malloc(sizeof(nutscan_device_t));
if( device==NULL) {
return NULL;
}
memset(device,0,sizeof(nutscan_device_t));
return device;
}
static void deep_free_device(nutscan_device_t * device)
{
nutscan_options_t * current;
nutscan_options_t * old;
if(device==NULL) {
return;
}
if(device->driver) {
free(device->driver);
}
if(device->port) {
free(device->port);
}
current = &device->opt;
if(current->option != NULL) {
free(current->option);
}
if(current->value != NULL) {
free(current->value);
}
current = current->next;
while (current != NULL) {
if(current->option != NULL) {
free(current->option);
}
if(current->value != NULL) {
free(current->value);
}
old = current;
current = current->next;
free(old);
};
if(device->prev) {
device->prev->next = device->next;
}
if(device->next) {
device->next->prev = device->prev;
}
free(device);
}
void nutscan_free_device(nutscan_device_t * device)
{
if(device==NULL) {
return;
}
while(device->prev != NULL) {
deep_free_device(device->prev);
}
while(device->next != NULL) {
deep_free_device(device->next);
}
free(device);
}
void nutscan_add_option_to_device(nutscan_device_t * device,char * option, char * value)
{
nutscan_options_t * opt;
opt = &(device->opt);
/* search for last entry */
if( opt->option != NULL ) {
while( opt->next != NULL ) {
opt = opt->next;
}
opt->next = malloc(sizeof(nutscan_options_t));
opt = opt->next;
memset(opt,0,sizeof(nutscan_options_t));
}
if( option != NULL ) {
opt->option = strdup(option);
}
else {
opt->option = NULL;
}
if( value != NULL ) {
opt->value = strdup(value);
}
else {
opt->value = NULL;
}
}
nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second)
{
nutscan_device_t * dev1=NULL;
nutscan_device_t * dev2=NULL;
/* Get end of first device */
if( first != NULL) {
dev1 = first;
while(dev1->next != NULL) {
dev1 = dev1->next;
}
}
else {
if( second == NULL ) {
return NULL;
}
/* return end of second */
dev2 = second;
while(dev2->next != NULL) {
dev2 = dev2->next;
}
return dev2;
}
/* Get start of second */
if( second != NULL ) {
dev2 = second;
while(dev2->prev != NULL) {
dev2 = dev2->prev;
}
}
else {
/* return end of first */
dev1 = first;
while(dev1->next != NULL) {
dev1 = dev1->next;
}
return dev1;
}
/* join both */
dev1->next = dev2;
dev2->prev = dev1;
/* return end of both */
while(dev2->next != NULL) {
dev2 = dev2->next;
}
return dev2;
}

View file

@ -0,0 +1,52 @@
/* device.h: definition of a container describing a NUT device
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef SCAN_DEVICE
#define SCAN_DEVICE
typedef enum nutscan_device_type {
TYPE_NONE=0,
TYPE_USB,
TYPE_SNMP,
TYPE_XML,
TYPE_NUT,
TYPE_IPMI,
TYPE_AVAHI,
TYPE_END
} nutscan_device_type_t;
typedef struct nutscan_options {
char * option;
char * value;
struct nutscan_options* next;
} nutscan_options_t;
typedef struct nutscan_device {
nutscan_device_type_t type;
char * driver;
char * port;
nutscan_options_t opt;
struct nutscan_device * prev;
struct nutscan_device * next;
} nutscan_device_t;
nutscan_device_t * nutscan_new_device();
void nutscan_free_device(nutscan_device_t * device);
void nutscan_add_option_to_device(nutscan_device_t * device,char * option, char * value);
nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second);
#endif

View file

@ -0,0 +1,112 @@
/* display.c: format and display scanned devices
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#include <stdio.h>
#include "nutscan-device.h"
char nutscan_device_type_string[TYPE_END][6] = {
"NONE",
"USB",
"SNMP",
"XML",
"NUT",
"IPMI",
"AVAHI" };
void nutscan_display_ups_conf(nutscan_device_t * device)
{
nutscan_device_t * current_dev = device;
nutscan_options_t * opt;
static int nutdev_num = 1;
if(device==NULL) {
return;
}
/* Find start of the list */
while(current_dev->prev != NULL) {
current_dev = current_dev->prev;
}
/* Display each devices */
do {
printf("[nutdev%i]\n\tdriver = \"%s\"\n\tport = \"%s\"\n",
nutdev_num, current_dev->driver,
current_dev->port);
opt = &(current_dev->opt);
do {
if( opt->option != NULL ) {
printf("\t%s",opt->option);
if( opt->value != NULL ) {
printf(" = \"%s\"", opt->value);
}
printf("\n");
}
opt = opt->next;
} while( opt != NULL );
nutdev_num++;
current_dev = current_dev->next;
}
while( current_dev != NULL );
}
void nutscan_display_parsable(nutscan_device_t * device)
{
nutscan_device_t * current_dev = device;
nutscan_options_t * opt;
if(device==NULL) {
return;
}
/* Find start of the list */
while(current_dev->prev != NULL) {
current_dev = current_dev->prev;
}
/* Display each devices */
do {
printf("%s:driver=\"%s\",port=\"%s\"",
nutscan_device_type_string[current_dev->type],
current_dev->driver,
current_dev->port);
opt = &(current_dev->opt);
do {
if( opt->option != NULL ) {
printf(",%s",opt->option);
if( opt->value != NULL ) {
printf("=\"%s\"", opt->value);
}
}
opt = opt->next;
} while( opt != NULL );
printf("\n");
current_dev = current_dev->next;
}
while( current_dev != NULL );
}

View file

@ -0,0 +1,219 @@
/* ip.c: iterator for IPv4 or IPv6 addresses
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "nutscan-ip.h"
#include <stdio.h>
#include "common.h"
static void increment_IPv6(struct in6_addr * addr)
{
int i;
for( i=15 ; i>= 0 ; i--) {
addr->s6_addr[i]++;
if( addr->s6_addr[i] != 0) {
break;
}
}
}
static void invert_IPv6(struct in6_addr * addr1, struct in6_addr * addr2)
{
struct in6_addr addr;
memcpy(addr.s6_addr,addr1->s6_addr,sizeof(addr.s6_addr));
memcpy(addr1->s6_addr,addr2->s6_addr,sizeof(addr.s6_addr));
memcpy(addr2->s6_addr,addr.s6_addr,sizeof(addr.s6_addr));
}
/* Return the first ip or NULL if error */
char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const char * stopIP)
{
int addr;
int i;
char buf[SMALLBUF];
if( startIP == NULL ) {
return NULL;
}
if(stopIP == NULL ) {
stopIP = startIP;
}
ip->type = IPv4;
/* Detecting IPv4 vs IPv6 */
if(!inet_aton(startIP, &ip->start)) {
/*Try IPv6 detection */
ip->type = IPv6;
if(!inet_pton(AF_INET6, startIP, &ip->start6)){
fprintf(stderr,"Invalid address : %s\n",startIP);
return NULL;
}
}
/* Compute stop IP */
if( ip->type == IPv4 ) {
if(!inet_aton(stopIP, &ip->stop)) {
fprintf(stderr,"Invalid address : %s\n",stopIP);
return NULL;
}
}
else {
if(!inet_pton(AF_INET6, stopIP, &ip->stop6)){
fprintf(stderr,"Invalid address : %s\n",stopIP);
return NULL;
}
}
/* Make sure start IP is lesser than stop IP */
if( ip->type == IPv4 ) {
if( ntohl(ip->start.s_addr) > ntohl(ip->stop.s_addr) ) {
addr = ip->start.s_addr;
ip->start.s_addr = ip->stop.s_addr;
ip->stop.s_addr = addr;
}
return strdup(inet_ntoa(ip->start));
}
else { /* IPv6 */
for( i=0; i<16; i++ ) {
if( ip->start6.s6_addr[i] !=ip->stop6.s6_addr[i] ) {
if(ip->start6.s6_addr[i]>ip->stop6.s6_addr[i]){
invert_IPv6(&ip->start6,&ip->stop6);
}
break;
}
}
return strdup(inet_ntop(AF_INET6,&ip->start6,buf,sizeof(buf)));
}
}
/* return the next IP
return NULL if there is no more IP
*/
char * nutscan_ip_iter_inc(nutscan_ip_iter_t * ip)
{
char buf[SMALLBUF];
if( ip->type == IPv4 ) {
/* Check if this is the last address to scan */
if(ip->start.s_addr == ip->stop.s_addr) {
return NULL;
}
/* increment the address (need to pass address in host
byte order, then pass back in network byte order */
ip->start.s_addr = htonl((ntohl(ip->start.s_addr)+1));
return strdup(inet_ntoa(ip->start));
}
else {
/* Check if this is the last address to scan */
if( memcmp(&ip->start6.s6_addr, &ip->stop6.s6_addr,
sizeof(ip->start6.s6_addr)) == 0 ) {
return NULL;
}
increment_IPv6(&ip->start6);
return strdup(inet_ntop(AF_INET6,&ip->start6,buf,sizeof(buf)));
}
}
int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip)
{
char * cidr_tok;
char * first_ip;
char * mask;
char * saveptr = NULL;
nutscan_ip_iter_t ip;
int mask_val;
int mask_byte;
long mask_bit;
char buf[SMALLBUF];
*start_ip = NULL;
*stop_ip = NULL;
cidr_tok = strdup(cidr);
first_ip = strdup(strtok_r(cidr_tok,"/",&saveptr));
if( first_ip == NULL) {
return 0;
}
mask = strtok_r(NULL,"/",&saveptr);
if( mask == NULL ) {
return 0;
}
free(cidr_tok);
mask_val = atoi(mask);
/* Detecting IPv4 vs IPv6 */
ip.type = IPv4;
if(!inet_aton(first_ip, &ip.start)) {
/*Try IPv6 detection */
ip.type = IPv6;
if(!inet_pton(AF_INET6, first_ip, &ip.start6)){
free(first_ip);
return 0;
}
}
if( ip.type == IPv4 ) {
if( mask_val > 0 ) {
mask_val --;
mask_bit = 0x80000000;
mask_bit >>= mask_val;
mask_bit--;
}
else {
mask_bit = 0xffffffff;
}
ip.stop.s_addr = htonl(ntohl(ip.start.s_addr)|mask_bit);
ip.start.s_addr = htonl(ntohl(ip.start.s_addr)&(~mask_bit));
*start_ip = strdup(inet_ntoa(ip.start));
*stop_ip = strdup(inet_ntoa(ip.stop));
free(first_ip);
return 1;
}
else {
inet_pton(AF_INET6, first_ip, &ip.stop6);
mask_byte = mask_val / 8;
if( mask_byte < 16 ) {
memset( &(ip.stop6.s6_addr[mask_byte+1]), 0xFF, 15 - mask_byte);
memset( &(ip.start6.s6_addr[mask_byte+1]), 0x00, 15 - mask_byte);
mask_bit = (0x100 >> mask_val%8)-1;
ip.stop6.s6_addr[mask_byte] |= mask_bit;
ip.start6.s6_addr[mask_byte] &= (~mask_bit);
}
inet_ntop(AF_INET6,&ip.start6,buf,sizeof(buf));
*start_ip = strdup(buf);
inet_ntop(AF_INET6,&ip.stop6,buf,sizeof(buf));
*stop_ip = strdup(buf);
}
free(first_ip);
return 1;
}

View file

@ -0,0 +1,42 @@
/* ip.h: iterator for IPv4 or IPv6 addresses
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef SCAN_IP
#define SCAN_IP
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
enum network_type {
IPv4,
IPv6
};
typedef struct nutscan_ip_iter {
enum network_type type;
struct in_addr start;
struct in_addr stop;
struct in6_addr start6;
struct in6_addr stop6;
} nutscan_ip_iter_t;
char * nutscan_ip_iter_init(nutscan_ip_iter_t *, const char * startIP, const char * stopIP);
char * nutscan_ip_iter_inc(nutscan_ip_iter_t *);
int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip);
#endif

View file

@ -0,0 +1,45 @@
/* nutscan-snmp
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef DEVSCAN_SNMP_H
#define DEVSCAN_SNMP_H
typedef struct {
char * oid;
char * mib;
char * sysoid;
} snmp_device_id_t;
/* SNMP IDs device table */
static snmp_device_id_t snmp_device_table[] = {
{ ".1.3.6.1.4.1.2947.1.1.2.0" , "bestpower", NULL},
{ ".1.3.6.1.4.1.13742.1.1.12.0" , "raritan", ".1.3.6.1.4.1.13742"},
{ "1.3.6.1.2.1.33.1.1.1.0" , "ietf", ".1.3.6.1.2.1.33"},
{ ".1.3.6.1.4.1.17373.3.1.1.0" , "aphel_genesisII", ".1.3.6.1.4.1.17373"},
{ ".1.3.6.1.4.1.534.6.6.6.1.1.12.0" , "aphel_revelation", ".1.3.6.1.4.1.534.6.6.6"},
{ ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" , "eaton_epdu", ".1.3.6.1.4.1.534.6.6.7"},
{ "1.3.6.1.4.1.534.1.1.2.0" , "pw", ".1.3.6.1.4.1.534.1"},
{ ".1.3.6.1.4.1.705.1.1.1.0" , "mge", ".1.3.6.1.4.1.705.1"},
{ ".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.232.165.3.1.1.0" , "cpqpower", NULL},
{ ".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}
};
#endif /* DEVSCAN_SNMP_H */

View file

@ -0,0 +1,111 @@
/* nutscan-usb
* Copyright (C) 2011 - Arnaud Quette <arnaud.quette@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef DEVSCAN_USB_H
#define DEVSCAN_USB_H
#include <usb.h>
#include "nut_stdint.h" /* for uint16_t */
typedef struct {
uint16_t vendorID;
uint16_t productID;
char* driver_name;
} usb_device_id_t;
/* USB IDs device table */
static usb_device_id_t usb_device_table[] = {
{ 0x03f0, 0x1f01, "bcmxcp_usb" },
{ 0x03f0, 0x1f02, "bcmxcp_usb" },
{ 0x03f0, 0x1f06, "usbhid-ups" },
{ 0x03f0, 0x1f08, "usbhid-ups" },
{ 0x03f0, 0x1f09, "usbhid-ups" },
{ 0x03f0, 0x1f0a, "usbhid-ups" },
{ 0x03f0, 0x1fe0, "usbhid-ups" },
{ 0x03f0, 0x1fe1, "usbhid-ups" },
{ 0x0463, 0x0001, "usbhid-ups" },
{ 0x0463, 0xffff, "usbhid-ups" },
{ 0x047c, 0xffff, "usbhid-ups" },
{ 0x050d, 0x0375, "usbhid-ups" },
{ 0x050d, 0x0551, "usbhid-ups" },
{ 0x050d, 0x0750, "usbhid-ups" },
{ 0x050d, 0x0751, "usbhid-ups" },
{ 0x050d, 0x0900, "usbhid-ups" },
{ 0x050d, 0x0910, "usbhid-ups" },
{ 0x050d, 0x0912, "usbhid-ups" },
{ 0x050d, 0x0980, "usbhid-ups" },
{ 0x050d, 0x1100, "usbhid-ups" },
{ 0x051d, 0x0002, "usbhid-ups" },
{ 0x051d, 0x0003, "usbhid-ups" },
{ 0x0592, 0x0002, "bcmxcp_usb" },
{ 0x0592, 0x0004, "usbhid-ups" },
{ 0x05b8, 0x0000, "blazer_usb" },
{ 0x0665, 0x5161, "blazer_usb" },
{ 0x06da, 0x0002, "bcmxcp_usb" },
{ 0x06da, 0x0003, "blazer_usb" },
{ 0x06da, 0xffff, "usbhid-ups" },
{ 0x075d, 0x0300, "usbhid-ups" },
{ 0x0764, 0x0005, "usbhid-ups" },
{ 0x0764, 0x0501, "usbhid-ups" },
{ 0x0764, 0x0601, "usbhid-ups" },
{ 0x0925, 0x1234, "richcomm_usb" },
{ 0x09ae, 0x0001, "tripplite_usb" },
{ 0x09ae, 0x1003, "usbhid-ups" },
{ 0x09ae, 0x1007, "usbhid-ups" },
{ 0x09ae, 0x1008, "usbhid-ups" },
{ 0x09ae, 0x1009, "usbhid-ups" },
{ 0x09ae, 0x1010, "usbhid-ups" },
{ 0x09ae, 0x2005, "usbhid-ups" },
{ 0x09ae, 0x2007, "usbhid-ups" },
{ 0x09ae, 0x2008, "usbhid-ups" },
{ 0x09ae, 0x2009, "usbhid-ups" },
{ 0x09ae, 0x2010, "usbhid-ups" },
{ 0x09ae, 0x2011, "usbhid-ups" },
{ 0x09ae, 0x2012, "usbhid-ups" },
{ 0x09ae, 0x2013, "usbhid-ups" },
{ 0x09ae, 0x2014, "usbhid-ups" },
{ 0x09ae, 0x3008, "usbhid-ups" },
{ 0x09ae, 0x3009, "usbhid-ups" },
{ 0x09ae, 0x3010, "usbhid-ups" },
{ 0x09ae, 0x3011, "usbhid-ups" },
{ 0x09ae, 0x3012, "usbhid-ups" },
{ 0x09ae, 0x3013, "usbhid-ups" },
{ 0x09ae, 0x3014, "usbhid-ups" },
{ 0x09ae, 0x3015, "usbhid-ups" },
{ 0x09ae, 0x4001, "usbhid-ups" },
{ 0x09ae, 0x4002, "usbhid-ups" },
{ 0x09ae, 0x4003, "usbhid-ups" },
{ 0x09ae, 0x4004, "usbhid-ups" },
{ 0x09ae, 0x4005, "usbhid-ups" },
{ 0x09ae, 0x4006, "usbhid-ups" },
{ 0x09ae, 0x4007, "usbhid-ups" },
{ 0x09ae, 0x4008, "usbhid-ups" },
{ 0x0d9f, 0x00a2, "usbhid-ups" },
{ 0x0d9f, 0x00a3, "usbhid-ups" },
{ 0x0d9f, 0x00a4, "usbhid-ups" },
{ 0x0d9f, 0x00a5, "usbhid-ups" },
{ 0x0d9f, 0x00a6, "usbhid-ups" },
{ 0x0f03, 0x0001, "blazer_usb" },
{ 0x10af, 0x0001, "usbhid-ups" },
{ 0x14f0, 0x00c9, "blazer_usb" },
/* Terminating entry */
{ -1, -1, NULL }
};
#endif /* DEVSCAN_USB_H */

View file

@ -0,0 +1,338 @@
/* scan_avahi.c: detect NUT avahi services
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
#include "nut-scan.h"
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <avahi-client/client.h>
#include <avahi-client/lookup.h>
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
#include <avahi-common/error.h>
static AvahiSimplePoll *simple_poll = NULL;
static nutscan_device_t * dev_ret = NULL;
static long avahi_usec_timeout = 0;
static void update_device(const char * host_name,const char *ip, uint16_t port,char * text, int proto)
{
nutscan_device_t * dev = NULL;
char * t = NULL;
char * t_saveptr = NULL;
char * phrase = NULL;
char * phrase_saveptr = NULL;
char * word = NULL;
char * value = NULL;
char * device = NULL;
char * device_saveptr = NULL;
int device_found = 0;
char buf[6];
int buf_size;
if( text == NULL ) {
return;
}
t = strdup(text);
phrase = strtok_r(t,"\"",&t_saveptr);
while(phrase != NULL ) {
word = strtok_r(phrase,"=",&phrase_saveptr);
if( word == NULL ) {
phrase = strtok_r(NULL,"\"",&t_saveptr);
continue;
}
value = strtok_r(NULL,"=",&phrase_saveptr);
if( value == NULL ) {
phrase = strtok_r(NULL,"\"",&t_saveptr);
continue;
}
if( strcmp(word,"device_list") != 0 ) {
phrase = strtok_r(NULL,"\"",&t_saveptr);
continue;
}
device = strtok_r(value,";",&device_saveptr);
while( device != NULL ) {
device_found = 1;
dev = nutscan_new_device();
dev->type = TYPE_NUT;
dev->driver = strdup("nutclient");
if( proto == AVAHI_PROTO_INET) {
nutscan_add_option_to_device(dev,"desc","IPv4");
}
if( proto == AVAHI_PROTO_INET6 ) {
nutscan_add_option_to_device(dev,"desc","IPv6");
}
if( port != PORT) {
/* +5+1+1+1 is for :
- port number (max 65535 so 5 characters),
- '@' and ':' characters
- terminating 0 */
buf_size = strlen(device)+strlen(host_name)+
5+1+1+1;
dev->port=malloc(buf_size);
if(dev->port) {
snprintf(dev->port,buf_size,"%s@%s:%u",
device,host_name,port);
}
}
else {
/*+1+1 is for '@' character and terminating 0 */
buf_size = strlen(device)+strlen(host_name)+1+1;
dev->port=malloc(buf_size);
if(dev->port) {
snprintf(dev->port,buf_size,"%s@%s",
device,host_name);
}
}
if( dev->port ) {
dev_ret = nutscan_add_device_to_device(dev_ret,dev);
}
else {
nutscan_free_device(dev);
}
device = strtok_r(NULL,";",&device_saveptr);
};
phrase = strtok_r(NULL,"\"",&t_saveptr);
};
free(t);
/* If no device published in avahi data, try to get the device by
connecting directly to upsd */
if( !device_found) {
snprintf(buf,sizeof(buf),"%u",port);
dev = nutscan_scan_nut(ip,ip,buf,avahi_usec_timeout);
if(dev) {
dev_ret = nutscan_add_device_to_device(dev_ret,dev);
}
/* add an upsd entry without associated device */
else {
dev = nutscan_new_device();
dev->type = TYPE_NUT;
dev->driver = strdup("nutclient");
if( proto == AVAHI_PROTO_INET) {
nutscan_add_option_to_device(dev,"desc","IPv4");
}
if( proto == AVAHI_PROTO_INET6 ) {
nutscan_add_option_to_device(dev,"desc","IPv6");
}
if( port != PORT) {
/*+1+1 is for ':' character and terminating 0 */
/*buf is the string containing the port number*/
buf_size = strlen(host_name)+strlen(buf)+1+1;
dev->port=malloc(buf_size);
if(dev->port) {
snprintf(dev->port,buf_size,"%s:%s",
host_name,buf);
}
}
else {
dev->port=strdup(host_name);
}
if( dev->port ) {
dev_ret = nutscan_add_device_to_device(dev_ret,dev);
}
else {
nutscan_free_device(dev);
}
}
}
}
static void resolve_callback(
AvahiServiceResolver *r,
AVAHI_GCC_UNUSED AvahiIfIndex interface,
AVAHI_GCC_UNUSED AvahiProtocol protocol,
AvahiResolverEvent event,
const char *name,
const char *type,
const char *domain,
const char *host_name,
const AvahiAddress *address,
uint16_t port,
AvahiStringList *txt,
AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata) {
assert(r);
/* Called whenever a service has been resolved successfully or timed out */
switch (event) {
case AVAHI_RESOLVER_FAILURE:
fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
break;
case AVAHI_RESOLVER_FOUND: {
char a[AVAHI_ADDRESS_STR_MAX], *t;
/* fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain); */
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
/*
fprintf(stderr,
"\t%s:%u (%s)\n"
"\tTXT=%s\n"
"\tcookie is %u\n"
"\tis_local: %i\n"
"\tour_own: %i\n"
"\twide_area: %i\n"
"\tmulticast: %i\n"
"\tcached: %i\n",
host_name, port, a,
t,
avahi_string_list_get_service_cookie(txt),
!!(flags & AVAHI_LOOKUP_RESULT_LOCAL),
!!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN),
!!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA),
!!(flags & AVAHI_LOOKUP_RESULT_MULTICAST),
!!(flags & AVAHI_LOOKUP_RESULT_CACHED));
*/
update_device(host_name,a,port,t,address->proto);
avahi_free(t);
}
}
avahi_service_resolver_free(r);
}
static void browse_callback(
AvahiServiceBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
const char *name,
const char *type,
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
AvahiClient *c = userdata;
assert(b);
/* Called whenever a new services becomes available on the LAN or is removed from the LAN */
switch (event) {
case AVAHI_BROWSER_FAILURE:
fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
avahi_simple_poll_quit(simple_poll);
return;
case AVAHI_BROWSER_NEW:
/* fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); */
/* We ignore the returned resolver object. In the callback
function we free it. If the server is terminated before
the callback function is called the server will free
the resolver for us. */
if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c)))
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c)));
break;
case AVAHI_BROWSER_REMOVE:
fprintf(stderr, "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
break;
case AVAHI_BROWSER_ALL_FOR_NOW:
avahi_simple_poll_quit(simple_poll);
case AVAHI_BROWSER_CACHE_EXHAUSTED:
/* fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); */
break;
}
}
static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) {
assert(c);
/* Called whenever the client or server state changes */
if (state == AVAHI_CLIENT_FAILURE) {
fprintf(stderr, "Server connection failure: %s\n", avahi_strerror(avahi_client_errno(c)));
avahi_simple_poll_quit(simple_poll);
}
}
nutscan_device_t * nutscan_scan_avahi(long usec_timeout)
{
/* Example service publication
* $ avahi-publish -s nut _upsd._tcp 3493 txtvers=1 protovers=1.0.0 device_list="dev1;dev2"
*/
AvahiClient *client = NULL;
AvahiServiceBrowser *sb = NULL;
int error;
int ret = 1;
avahi_usec_timeout = usec_timeout;
/* Allocate main loop object */
if (!(simple_poll = avahi_simple_poll_new())) {
fprintf(stderr, "Failed to create simple poll object.\n");
goto fail;
}
/* Allocate a new client */
client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error);
/* Check wether creating the client object succeeded */
if (!client) {
fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error));
goto fail;
}
/* Create the service browser */
if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_upsd._tcp", NULL, 0, browse_callback, client))) {
fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client)));
goto fail;
}
/* Run the main loop */
avahi_simple_poll_loop(simple_poll);
ret = 0;
fail:
/* Cleanup things */
if (sb)
avahi_service_browser_free(sb);
if (client)
avahi_client_free(client);
if (simple_poll)
avahi_simple_poll_free(simple_poll);
return dev_ret;
}
#endif /* HAVE_AVAHI_CLIENT_CLIENT_H */

View file

@ -0,0 +1,29 @@
/* scan_ipmi.c: detect NUT supported Power Supply Units
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#ifdef HAVE_FREEIPMI_FREEIPMI_H
#include "nut-scan.h"
/* TODO */
nutscan_device_t * nutscan_scan_ipmi()
{
return NULL;
}
#endif /* HAVE_FREEIPMI_FREEIPMI_H */

View file

@ -0,0 +1,194 @@
/* scan_nut.c: detect remote NUT services
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#include "upsclient.h"
#include "nut-scan.h"
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
static nutscan_device_t * dev_ret = NULL;
#ifdef HAVE_PTHREAD
static pthread_mutex_t dev_mutex;
#endif
struct scan_nut_arg {
char * hostname;
long timeout;
};
/* FIXME: SSL support */
static void * list_nut_devices(void * arg)
{
struct scan_nut_arg * nut_arg = (struct scan_nut_arg*)arg;
char *target_hostname = nut_arg->hostname;
struct timeval tv;
int port;
unsigned int numq, numa;
const char *query[4];
char **answer;
char *hostname = NULL;
UPSCONN_t *ups = malloc(sizeof(*ups));
nutscan_device_t * dev = NULL;
int buf_size;
tv.tv_sec = nut_arg->timeout / (1000*1000);
tv.tv_usec = nut_arg->timeout % (1000*1000);
query[0] = "UPS";
numq = 1;
if (upscli_splitaddr(target_hostname, &hostname, &port) != 0) {
free(target_hostname);
free(nut_arg);
return NULL;
}
if (upscli_tryconnect(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) {
free(target_hostname);
free(nut_arg);
return NULL;
}
if(upscli_list_start(ups, numq, query) < 0) {
free(target_hostname);
free(nut_arg);
return NULL;
}
while (upscli_list_next(ups, numq, query, &numa, &answer) == 1) {
/* UPS <upsname> <description> */
if (numa < 3) {
free(target_hostname);
free(nut_arg);
return NULL;
}
/* FIXME: check for duplication by getting driver.port and device.serial
* for comparison with other busses results */
/* FIXME:
* - also print answer[2] if != "Unavailable"?
* - for upsmon.conf or ups.conf (using dummy-ups)? */
if (numa >= 3) {
dev = nutscan_new_device();
dev->type = TYPE_NUT;
dev->driver = strdup("nutclient");
/* +1+1 is for '@' character and terminnating 0 */
buf_size = strlen(answer[1])+strlen(hostname)+1+1;
dev->port = malloc(buf_size);
if( dev->port ) {
snprintf(dev->port,buf_size,"%s@%s",answer[1],
hostname);
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&dev_mutex);
#endif
dev_ret = nutscan_add_device_to_device(dev_ret,dev);
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&dev_mutex);
#endif
}
}
}
free(target_hostname);
free(nut_arg);
return NULL;
}
nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, const char* port,long usec_timeout)
{
nutscan_ip_iter_t ip;
char * ip_str = NULL;
char * ip_dest = NULL;
char buf[SMALLBUF];
struct sigaction oldact;
int change_action_handler = 0;
int i;
struct scan_nut_arg *nut_arg;
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_t * thread_array = NULL;
int thread_count = 0;
pthread_mutex_init(&dev_mutex,NULL);
#endif
/* Ignore SIGPIPE if the caller hasn't set a handler for it yet */
if( sigaction(SIGPIPE, NULL, &oldact) == 0 ) {
if( oldact.sa_handler == SIG_DFL ) {
change_action_handler = 1;
signal(SIGPIPE,SIG_IGN);
}
}
ip_str = nutscan_ip_iter_init(&ip,startIP,stopIP);
while( ip_str != NULL )
{
if( port ) {
if( ip.type == IPv4 ) {
snprintf(buf,sizeof(buf),"%s:%s",ip_str,port);
}
else {
snprintf(buf,sizeof(buf),"[%s]:%s",ip_str,port);
}
ip_dest = strdup(buf);
}
else {
ip_dest = strdup(ip_str);
}
if((nut_arg = malloc(sizeof(struct scan_nut_arg))) == NULL ) {
free(ip_dest);
break;
}
nut_arg->timeout = usec_timeout;
nut_arg->hostname = ip_dest;
#ifdef HAVE_PTHREAD
if (pthread_create(&thread,NULL,list_nut_devices,(void*)nut_arg)==0){
thread_count++;
thread_array = realloc(thread_array,
thread_count*sizeof(pthread_t));
thread_array[thread_count-1] = thread;
}
#else
list_nut_devices(nut_arg);
#endif
free(ip_str);
ip_str = nutscan_ip_iter_inc(&ip);
}
#ifdef HAVE_PTHREAD
for ( i=0; i < thread_count ; i++) {
pthread_join(thread_array[i],NULL);
}
pthread_mutex_destroy(&dev_mutex);
free(thread_array);
#endif
if(change_action_handler) {
signal(SIGPIPE,SIG_DFL);
}
return dev_ret;
}

View file

@ -0,0 +1,520 @@
/* scan_snmp.c: detect NUT supported SNMP devices
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#ifdef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
#include "nut-scan.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
/* workaround for buggy Net-SNMP config
* from drivers/snmp-ups.h */
#ifdef PACKAGE_BUGREPORT
#undef PACKAGE_BUGREPORT
#endif
#ifdef PACKAGE_NAME
#undef PACKAGE_NAME
#endif
#ifdef PACKAGE_VERSION
#undef PACKAGE_VERSION
#endif
#ifdef PACKAGE_STRING
#undef PACKAGE_STRING
#endif
#ifdef PACKAGE_TARNAME
#undef PACKAGE_TARNAME
#endif
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
#include "nutscan-snmp.h"
#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_t * thread_array = NULL;
static int thread_count = 0;
#endif
long g_usec_timeout ;
static void scan_snmp_add_device(nutscan_snmp_t * sec, struct snmp_pdu *response,char * mib)
{
nutscan_device_t * dev = NULL;
struct snmp_session * session;
char * buf;
session = snmp_sess_session(sec->handle);
/* SNMP device found */
dev = nutscan_new_device();
dev->type = TYPE_SNMP;
dev->driver = strdup("snmp-ups");
dev->port = strdup(session->peername);
buf = malloc( response->variables->val_len + 1 );
if( buf ) {
memcpy(buf,response->variables->val.string,
response->variables->val_len);
buf[response->variables->val_len]=0;
nutscan_add_option_to_device(dev,"desc",buf);
free(buf);
}
nutscan_add_option_to_device(dev,"mibs",mib);
/* SNMP v3 */
if( session->community == NULL || session->community[0] == 0) {
if( sec->secLevel ) {
nutscan_add_option_to_device(dev,"secLevel",
sec->secLevel);
}
if( sec->secName ) {
nutscan_add_option_to_device(dev,"secName",
sec->secName);
}
if( sec->authPassword ) {
nutscan_add_option_to_device(dev,"authPassword",
sec->authPassword);
}
if( sec->privPassword ) {
nutscan_add_option_to_device(dev,"privPassword",
sec->privPassword);
}
if( sec->authProtocol ) {
nutscan_add_option_to_device(dev,"authProtocol",
sec->authProtocol);
}
if( sec->privProtocol ) {
nutscan_add_option_to_device(dev,"privProtocol",
sec->privProtocol);
}
}
else {
buf = malloc( session->community_len + 1 );
if( buf ) {
memcpy(buf,session->community,
session->community_len);
buf[session->community_len]=0;
nutscan_add_option_to_device(dev,"community",buf);
free(buf);
}
}
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&dev_mutex);
#endif
dev_ret = nutscan_add_device_to_device(dev_ret,dev);
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&dev_mutex);
#endif
}
static struct snmp_pdu * scan_snmp_get_manufacturer(char* oid_str,void* handle)
{
size_t name_len;
oid name[MAX_OID_LEN];
struct snmp_pdu *pdu, *response = NULL;
int status;
int index = 0;
/* create and send request. */
name_len = MAX_OID_LEN;
if (!snmp_parse_oid(oid_str, name, &name_len)) {
index++;
return NULL;
}
pdu = snmp_pdu_create(SNMP_MSG_GET);
if (pdu == NULL) {
index++;
return NULL;
}
snmp_add_null_var(pdu, name, name_len);
status = snmp_sess_synch_response(handle,pdu, &response);
if( response == NULL ) {
index++;
return NULL;
}
if(status!=STAT_SUCCESS||response->errstat!=SNMP_ERR_NOERROR||
response->variables == NULL ||
response->variables->name == NULL ||
snmp_oid_compare(response->variables->name,
response->variables->name_length,
name, name_len) != 0 ||
response->variables->val.string == NULL ) {
snmp_free_pdu(response);
index++;
return NULL;
}
return response;
}
static void try_all_oid(void * arg)
{
struct snmp_pdu *response = NULL;
int index = 0;
nutscan_snmp_t * sec = (nutscan_snmp_t *)arg;
while(snmp_device_table[index].oid != NULL) {
response = scan_snmp_get_manufacturer(snmp_device_table[index].oid,sec->handle);
if( response == NULL ) {
index++;
continue;
}
scan_snmp_add_device(sec,response,snmp_device_table[index].mib);
snmp_free_pdu(response);
response = NULL;
index++;
}
}
static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec)
{
snmp_sess_init(snmp_sess);
snmp_sess->peername = sec->peername;
if( sec->community != NULL || sec->secLevel == NULL ) {
snmp_sess->version = SNMP_VERSION_1;
if( sec->community != NULL ) {
snmp_sess->community = (unsigned char *)sec->community;
snmp_sess->community_len = strlen(sec->community);
}
else {
snmp_sess->community = (unsigned char *)"public";
snmp_sess->community_len = strlen("public");
}
}
else { /* SNMP v3 */
snmp_sess->version = SNMP_VERSION_3;
/* Security level */
if (strcmp(sec->secLevel, "noAuthNoPriv") == 0)
snmp_sess->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
else if (strcmp(sec->secLevel, "authNoPriv") == 0)
snmp_sess->securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
else if (strcmp(sec->secLevel, "authPriv") == 0)
snmp_sess->securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;
else {
fprintf(stderr,"Bad SNMPv3 securityLevel: %s\n",
sec->secLevel);
return 0;
}
/* Security name */
if( sec->secName == NULL ) {
fprintf(stderr,"securityName is required for SNMPv3\n");
return 0;
}
snmp_sess->securityName = strdup(sec->secName);
snmp_sess->securityNameLen = strlen(snmp_sess->securityName);
/* Everything is ready for NOAUTH */
if( snmp_sess->securityLevel == SNMP_SEC_LEVEL_NOAUTH ) {
return 1;
}
/* Process mandatory fields, based on the security level */
switch (snmp_sess->securityLevel) {
case SNMP_SEC_LEVEL_AUTHNOPRIV:
if (sec->authPassword == NULL) {
fprintf(stderr,
"authPassword is required for SNMPv3 in %s mode\n",
sec->secLevel);
return 0;
}
break;
case SNMP_SEC_LEVEL_AUTHPRIV:
if ((sec->authPassword == NULL) ||
(sec->privPassword == NULL)) {
fprintf(stderr,
"authPassword and privPassword are required for SNMPv3 in %s mode\n",
sec->secLevel);
return 0;
}
break;
default:
/* nothing else needed */
break;
}
/* Process authentication protocol and key */
snmp_sess->securityAuthKeyLen = USM_AUTH_KU_LEN;
/* default to MD5 */
snmp_sess->securityAuthProto = usmHMACMD5AuthProtocol;
snmp_sess->securityAuthProtoLen =sizeof(usmHMACMD5AuthProtocol)/
sizeof(oid);
if( sec->authProtocol ) {
if (strcmp(sec->authProtocol, "SHA") == 0) {
snmp_sess->securityAuthProto =
usmHMACSHA1AuthProtocol;
snmp_sess->securityAuthProtoLen =
sizeof(usmHMACSHA1AuthProtocol)/
sizeof(oid);
}
else {
if (strcmp(sec->authProtocol, "MD5") != 0) {
fprintf(stderr,
"Bad SNMPv3 authProtocol: %s",
sec->authProtocol);
return 0;
}
}
}
/* set the authentication key to a MD5/SHA1 hashed version of
* our passphrase (must be at least 8 characters long) */
if (generate_Ku(snmp_sess->securityAuthProto,
snmp_sess->securityAuthProtoLen,
(u_char *) sec->authPassword,
strlen(sec->authPassword),
snmp_sess->securityAuthKey,
&snmp_sess->securityAuthKeyLen)
!= SNMPERR_SUCCESS) {
fprintf(stderr,
"Error generating Ku from authentication pass phrase\n");
return 0;
}
/* Everything is ready for AUTHNOPRIV */
if( snmp_sess->securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV ) {
return 1;
}
/* default to DES */
snmp_sess->securityPrivProto=usmDESPrivProtocol;
snmp_sess->securityPrivProtoLen =
sizeof(usmDESPrivProtocol)/sizeof(oid);
if( sec->privProtocol ) {
if (strcmp(sec->privProtocol, "AES") == 0) {
snmp_sess->securityPrivProto=usmAESPrivProtocol;
snmp_sess->securityPrivProtoLen =
sizeof(usmAESPrivProtocol)/sizeof(oid);
}
else {
if (strcmp(sec->privProtocol, "DES") != 0) {
fprintf(stderr,
"Bad SNMPv3 authProtocol: %s\n"
,sec->authProtocol);
return 0;
}
}
}
/* set the private key to a MD5/SHA hashed version of
* our passphrase (must be at least 8 characters long) */
snmp_sess->securityPrivKeyLen = USM_PRIV_KU_LEN;
if (generate_Ku(snmp_sess->securityAuthProto,
snmp_sess->securityAuthProtoLen,
(u_char *) sec->privPassword,
strlen(sec->privPassword),
snmp_sess->securityPrivKey,
&snmp_sess->securityPrivKeyLen)
!= SNMPERR_SUCCESS) {
fprintf(stderr,
"Error generating Ku from private pass phrase\n");
return 0;
}
}
return 1;
}
static void * try_SysOID(void * arg)
{
struct snmp_session snmp_sess;
void * handle;
struct snmp_pdu *pdu, *response = NULL;
oid name[MAX_OID_LEN];
size_t name_len = MAX_OID_LEN;
nutscan_snmp_t * sec = (nutscan_snmp_t *)arg;
int index = 0;
int sysoid_found = 0;
/* Initialize session */
if( !init_session(&snmp_sess,sec) ) {
goto try_SysOID_free;
}
snmp_sess.retries = 0;
snmp_sess.timeout = g_usec_timeout;
/* Open the session */
handle = snmp_sess_open(&snmp_sess); /* establish the session */
if (handle == NULL) {
fprintf(stderr,"Failed to open SNMP session for %s.\n",
sec->peername);
goto try_SysOID_free;
}
/* create and send request. */
if (!snmp_parse_oid(SysOID, name, &name_len)) {
fprintf(stderr,"SNMP errors: %s\n",
snmp_api_errstring(snmp_errno));
snmp_sess_close(handle);
goto try_SysOID_free;
}
pdu = snmp_pdu_create(SNMP_MSG_GET);
if (pdu == NULL) {
fprintf(stderr,"Not enough memory\n");
snmp_sess_close(handle);
goto try_SysOID_free;
}
snmp_add_null_var(pdu, name, name_len);
snmp_sess_synch_response(handle,
pdu, &response);
if (response) {
sec->handle = handle;
/* SNMP device found */
/* SysOID is supposed to give the required MIB. */
/* Check if the received OID match with a known sysOID */
if(response->variables != NULL &&
response->variables->val.objid != NULL){
while(snmp_device_table[index].oid != NULL) {
if(snmp_device_table[index].sysoid == NULL ) {
index++;
continue;
}
name_len = MAX_OID_LEN;
if (!snmp_parse_oid(
snmp_device_table[index].sysoid,
name, &name_len)) {
index++;
continue;
}
if ( snmp_oid_compare(
response->variables->val.objid,
response->variables->val_len/sizeof(oid),
name, name_len) == 0 ) {
/* we have found a relevent sysoid */
snmp_free_pdu(response);
response = scan_snmp_get_manufacturer(
snmp_device_table[index].oid,
handle);
scan_snmp_add_device(sec,response,
snmp_device_table[index].mib);
sysoid_found = 1;
}
index++;
}
}
/* try a list of known OID */
if( !sysoid_found ) {
try_all_oid(sec);
}
snmp_free_pdu(response);
response = NULL;
}
snmp_sess_close(handle);
try_SysOID_free:
if( sec->peername ) {
free(sec->peername);
}
free(sec);
return NULL;
}
nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip,long usec_timeout, nutscan_snmp_t * sec)
{
int i;
nutscan_snmp_t * tmp_sec;
nutscan_ip_iter_t ip;
char * ip_str = NULL;
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_mutex_init(&dev_mutex,NULL);
#endif
g_usec_timeout = usec_timeout;
/* Initialize the SNMP library */
init_snmp("nut-scanner");
ip_str = nutscan_ip_iter_init(&ip, start_ip, stop_ip);
while(ip_str != NULL) {
tmp_sec = malloc(sizeof(nutscan_snmp_t));
memcpy(tmp_sec, sec, sizeof(nutscan_snmp_t));
tmp_sec->peername = ip_str;
#ifdef HAVE_PTHREAD
if (pthread_create(&thread,NULL,try_SysOID,(void*)tmp_sec)==0){
thread_count++;
thread_array = realloc(thread_array,
thread_count*sizeof(pthread_t));
thread_array[thread_count-1] = thread;
}
#else
try_SysOID((void *)tmp_sec);
#endif
ip_str = nutscan_ip_iter_inc(&ip);
};
#ifdef HAVE_PTHREAD
for ( i=0; i < thread_count ; i++) {
pthread_join(thread_array[i],NULL);
}
pthread_mutex_destroy(&dev_mutex);
free(thread_array);
#endif
return dev_ret;
}
#endif /* HAVE_NET_SNMP_NET_SNMP_CONFIG_H */

View file

@ -0,0 +1,168 @@
/* scan_usb.c: detect NUT supported USB devices
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#ifdef HAVE_USB_H
#include "upsclient.h"
#include "nutscan-usb.h"
#include <stdio.h>
#include <string.h>
#include "nutscan-device.h"
static char* is_usb_device_supported(usb_device_id_t *usb_device_id_list,
int dev_VendorID, int dev_ProductID)
{
usb_device_id_t *usbdev;
for (usbdev=usb_device_id_list; usbdev->driver_name != NULL; usbdev++) {
if ( (usbdev->vendorID == dev_VendorID)
&& (usbdev->productID == dev_ProductID) ) {
return usbdev->driver_name;
}
}
return NULL;
}
/* return NULL if error */
nutscan_device_t * nutscan_scan_usb()
{
int ret;
char string[256];
char *driver_name = NULL;
char *serialnumber = NULL;
char *device_name = NULL;
char *vendor_name = NULL;
struct usb_device *dev;
struct usb_bus *bus;
usb_dev_handle *udev;
nutscan_device_t * nut_dev = NULL;
nutscan_device_t * current_nut_dev = NULL;
/* libusb base init */
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if ((driver_name =
is_usb_device_supported(usb_device_table,
dev->descriptor.idVendor,
dev->descriptor.idProduct)) != NULL) {
/* open the device */
udev = usb_open(dev);
if (!udev) {
fprintf(stderr,"Failed to open device, \
skipping. (%s)\n",
usb_strerror());
continue;
}
/* get serial number */
if (dev->descriptor.iSerialNumber) {
ret = usb_get_string_simple(udev,
dev->descriptor.iSerialNumber,
string, sizeof(string));
if (ret > 0) {
serialnumber = strdup(string);
}
}
/* get product name */
if (dev->descriptor.iProduct) {
ret = usb_get_string_simple(udev,
dev->descriptor.iProduct,
string, sizeof(string));
if (ret > 0) {
device_name = strdup(string);
}
}
/* get vendor name */
if (dev->descriptor.iManufacturer) {
ret = usb_get_string_simple(udev,
dev->descriptor.iManufacturer,
string, sizeof(string));
if (ret > 0) {
vendor_name = strdup(string);
}
}
nut_dev = nutscan_new_device();
if(nut_dev == NULL) {
fprintf(stderr,"Memory allocation \
error\n");
nutscan_free_device(current_nut_dev);
free(serialnumber);
free(device_name);
free(vendor_name);
return NULL;
}
nut_dev->type = TYPE_USB;
if(driver_name) {
nut_dev->driver = strdup(driver_name);
}
nut_dev->port = strdup("auto");
sprintf(string,"%04X",dev->descriptor.idVendor);
nutscan_add_option_to_device(nut_dev,"vendorid",
string);
sprintf(string,"%04X",
dev->descriptor.idProduct);
nutscan_add_option_to_device(nut_dev,"productid",
string);
if(device_name) {
nutscan_add_option_to_device(nut_dev,
"product",
device_name);
free(device_name);
}
if(serialnumber) {
nutscan_add_option_to_device(nut_dev,
"serial",
serialnumber);
free(serialnumber);
}
if(vendor_name) {
nutscan_add_option_to_device(nut_dev,
"vendor",
vendor_name);
free(vendor_name);
}
nutscan_add_option_to_device(nut_dev,"bus",
bus->dirname);
current_nut_dev = nutscan_add_device_to_device(
current_nut_dev,
nut_dev);
memset (string, 0, sizeof(string));
usb_close(udev);
}
}
}
return current_nut_dev;
}
#endif /* HAVE_USB_H */

View file

@ -0,0 +1,160 @@
/* scan_xml_http.c: detect NUT supported XML HTTP devices
*
* Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#include "common.h"
#ifdef WITH_NEON
#include <netinet/in.h>
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>
#include <sys/select.h>
#include <errno.h>
#include <arpa/inet.h>
#include <ne_xml.h>
#include "nutscan-device.h"
static int startelm_cb(void *userdata, int parent, const char *nspace, const char *name, const char **atts) {
nutscan_device_t * dev = (nutscan_device_t *)userdata;
char buf[SMALLBUF];
int i = 0;
while( atts[i] != NULL ) {
if(strcmp(atts[i],"type") == 0) {
snprintf(buf,sizeof(buf),"%s",atts[i+1]);
nutscan_add_option_to_device(dev,"desc",buf);
return 0;
}
i=i+2;
}
return 0;
}
nutscan_device_t * nutscan_scan_xml_http(long usec_timeout)
{
char *scanMsg = "<SCAN_REQUEST/>";
int port = 4679;
int peerSocket;
int sockopt_on = 1;
struct sockaddr_in sockAddress;
socklen_t sockAddressLength = sizeof(sockAddress);
memset(&sockAddress, 0, sizeof(sockAddress));
fd_set fds;
struct timeval timeout;
int ret;
char buf[SMALLBUF];
char string[SMALLBUF];
ssize_t recv_size;
nutscan_device_t * nut_dev = NULL;
nutscan_device_t * current_nut_dev = NULL;
if((peerSocket = socket(AF_INET, SOCK_DGRAM, 0)) != -1)
{
/* Initialize socket */
sockAddress.sin_family = AF_INET;
sockAddress.sin_addr.s_addr = INADDR_BROADCAST;
sockAddress.sin_port = htons(port);
setsockopt(peerSocket, SOL_SOCKET, SO_BROADCAST, &sockopt_on,
sizeof(sockopt_on));
/* Send scan request */
if(sendto(peerSocket, scanMsg, strlen(scanMsg), 0,
(struct sockaddr *)&sockAddress,
sockAddressLength) <= 0)
{
fprintf(stderr,"Error sending Eaton <SCAN_REQUEST/>\n");
}
else
{
FD_ZERO(&fds);
FD_SET(peerSocket,&fds);
timeout.tv_sec = usec_timeout / 1000000;
timeout.tv_usec = usec_timeout % 1000000;
while ((ret=select(peerSocket+1,&fds,NULL,NULL,
&timeout) )) {
timeout.tv_sec = usec_timeout / 1000000;
timeout.tv_usec = usec_timeout % 1000000;
if( ret == -1 ) {
fprintf(stderr,
"Error waiting on \
socket: %d\n",errno);
break;
}
sockAddressLength = sizeof(struct sockaddr_in);
recv_size = recvfrom(peerSocket,buf,
sizeof(buf),0,
(struct sockaddr *)&sockAddress,
&sockAddressLength);
if(recv_size==-1) {
fprintf(stderr,
"Error reading \
socket: %d\n",errno);
continue;
}
if( inet_ntop(AF_INET,
&(sockAddress.sin_addr),
string,sizeof(buf)) == NULL ) {
fprintf(stderr,
"Error converting IP address \
: %d\n",errno);
continue;
}
nut_dev = nutscan_new_device();
if(nut_dev == NULL) {
fprintf(stderr,"Memory allocation \
error\n");
return NULL;
}
nut_dev->type = TYPE_XML;
/* Try to read device type */
ne_xml_parser *parser = ne_xml_create();
ne_xml_push_handler(parser, startelm_cb, NULL,
NULL, nut_dev);
ne_xml_parse(parser, buf, strlen(buf));
ne_xml_destroy(parser);
nut_dev->driver = strdup("netxml-ups");
sprintf(buf,"http://%s",string);
nut_dev->port = strdup(buf);
current_nut_dev = nutscan_add_device_to_device(
current_nut_dev,nut_dev);
}
}
}
else
{
fprintf(stderr,"Error creating socket\n");
}
return current_nut_dev;
}
#endif /* WITH_NEON */

137
tools/nut-snmpinfo.py Executable file
View file

@ -0,0 +1,137 @@
#!/usr/bin/env python
# Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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
# This program extracts all SNMP information related to NUT snmp-ups
# drivers.
import glob
import re
output_file_name="./nut-scanner/nutscan-snmp.h"
output_file = open(output_file_name,'w')
#expand #define constant
def expand_define(filename,constant):
ret_line = ""
f = open(filename, 'r')
for line in f:
if constant in line and "#define" in line:
line_without_carriage_return = re.sub("[\n\r]", "", line)
line_with_single_blank = re.sub("[ \t]+", " ", line_without_carriage_return)
define_line = line_with_single_blank.split(" ");
#define_line[0] = "#define"
#define_line[1] = const name
#define_line[2...] = const value (may be other const name)
if constant in define_line[1]:
define_line.pop(0) #remove #define
define_line.pop(0) #remove the constant name
for elem in define_line:
if elem[0] == "\"":
clean_elem = re.sub("\"", "", elem)
ret_line = ret_line + clean_elem
else:
ret_line = ret_line + expand_define(filename,elem);
return ret_line
output_file.write( "/* nutscan-snmp\n" )
output_file.write( " * Copyright (C) 2011 - Frederic Bohe <fredericbohe@eaton.com>\n" )
output_file.write( " *\n" )
output_file.write( " * This program is free software; you can redistribute it and/or modify\n" )
output_file.write( " * it under the terms of the GNU General Public License as published by\n" )
output_file.write( " * the Free Software Foundation; either version 2 of the License, or\n" )
output_file.write( " * (at your option) any later version.\n" )
output_file.write( " *\n" )
output_file.write( " * This program is distributed in the hope that it will be useful,\n" )
output_file.write( " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" )
output_file.write( " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" )
output_file.write( " * GNU General Public License for more details.\n" )
output_file.write( " *\n" )
output_file.write( " * You should have received a copy of the GNU General Public License\n" )
output_file.write( " * along with this program; if not, write to the Free Software\n" )
output_file.write( " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" )
output_file.write( " */\n" )
output_file.write( "\n" )
output_file.write( "#ifndef DEVSCAN_SNMP_H\n" )
output_file.write( "#define DEVSCAN_SNMP_H\n" )
output_file.write( "\n" )
output_file.write( "typedef struct {\n" )
output_file.write( " char * oid;\n" )
output_file.write( " char * mib;\n" )
output_file.write( " char * sysoid;\n" )
output_file.write( "} snmp_device_id_t;\n" )
output_file.write( "\n" )
output_file.write( "/* SNMP IDs device table */\n" )
output_file.write( "static snmp_device_id_t snmp_device_table[] = {\n" )
for filename in glob.glob('../drivers/*-mib.c'):
list_of_line = file(filename,'r').read().split(';')
for line in list_of_line:
if "mib2nut_info_t" in line:
#clean up line
line2 = re.sub("[\n\t\r}]", "", line)
# split line
line = line2.split("{",1)
#line[1] is the part between {}
line2 = line[1].split(",")
mib = line2[0]
#line2[3] is the OID of the device model name which
#could be made of #define const and string.
source_oid = line2[3]
#line2[5] is the SysOID of the device which
#could be made of #define const and string.
if len(line2) >= 6:
source_sysoid = line2[5]
else:
source_sysoid = "NULL"
#decode source_oid
line = source_oid.lstrip(" ")
line2 = line.split(" ")
oid = ""
for elem in line2:
if elem[0] == "\"":
clean_elem = re.sub("\"", "", elem)
oid = oid+clean_elem
else:
oid = oid + expand_define(filename,elem);
#decode source_sysoid
line = source_sysoid.lstrip(" ")
line = line.rstrip(" ")
line2 = line.split(" ")
sysoid = ""
for elem in line2:
if elem[0] == "\"":
clean_elem = re.sub("\"", "", elem)
sysoid = sysoid+clean_elem
else:
sysoid = sysoid + expand_define(filename,elem);
if sysoid == "":
sysoid = "NULL"
else:
sysoid = "\"" + sysoid + "\""
output_file.write( "\t{ \"" + oid + "\" , " + mib + ", " + sysoid + "},\n" )
output_file.write( " /* Terminating entry */\n" )
output_file.write( " { NULL, NULL, NULL}\n" )
output_file.write( "};\n" )
output_file.write( "#endif /* DEVSCAN_SNMP_H */\n" )

View file

@ -1,6 +1,6 @@
#!/usr/bin/env perl
# Current Version : 1.0
# Copyright (C) 2008 - 2010
# Current Version : 1.1
# Copyright (C) 2008 - 2011
# Arnaud Quette <arnaud.quette@gmail.com>
# dloic (loic.dardant AT gmail DOT com)
#
@ -43,6 +43,26 @@ my $tmpOutputUPower;
# mfr header flag
my $upowerMfrHeaderDone = 0;
# NUT device scanner - C header
my $outputDevScanner = "./nut-scanner/nutscan-usb.h";
my $GPL_header = "\
* Copyright (C) 2011 - Arnaud Quette <arnaud.quette\@free.fr>\
*\
* This program is free software; you can redistribute it and/or modify\
* it under the terms of the GNU General Public License as published by\
* the Free Software Foundation; either version 2 of the License, or\
* (at your option) any later version.\
*\
* This program is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of\
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
* GNU General Public License for more details.\
*\
* 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";
# array of products indexed by vendorID
my %vendor;
@ -94,6 +114,16 @@ sub gen_usb_files
print $outputUPower '# if usbraw device, ignore'."\n".'KERNEL!="hiddev*", GOTO="up_hid_end"'."\n\n";
print $outputUPower '# if an interface, ignore'."\n".'ENV{DEVTYPE}=="usb_interface", GOTO="up_hid_end"'."\n\n";
# Device scanner header
open my $outputDevScanner, ">$outputDevScanner" || die "error $outputDevScanner : $!";
print $outputDevScanner '/* nutscan-usb'.$GPL_header."\n */\n\n";
print $outputDevScanner "#ifndef DEVSCAN_USB_H\n#define DEVSCAN_USB_H\n\n";
print $outputDevScanner "#include <usb.h>\n";
print $outputDevScanner "#include \"nut_stdint.h\"\t/* for uint16_t */\n\n";
# vid, pid, driver
print $outputDevScanner "typedef struct {\n\tuint16_t\tvendorID;\n\tuint16_t\tproductID;\n\tchar*\tdriver_name;\n} usb_device_id_t;\n\n";
print $outputDevScanner "/* USB IDs device table */\nstatic usb_device_id_t usb_device_table[] = {\n\n";
# generate the file in alphabetical order (first for VendorID, then for ProductID)
foreach my $vendorId (sort { lc $a cmp lc $b } keys %vendorName)
{
@ -154,6 +184,9 @@ sub gen_usb_files
$tmpOutputUPower = $tmpOutputUPower."\", ATTRS{idProduct}==\"".removeHexPrefix($productId)."\",";
$tmpOutputUPower = $tmpOutputUPower.' ENV{UPOWER_BATTERY_TYPE}="ups"'."\n";
}
# Device scanner entry
print $outputDevScanner "\t{ ".$vendorId.', '.$productId.", \"".$vendor{$vendorId}{$productId}{"driver"}."\" },\n";
}
# HAL vendor footer
print $outHAL " </match>\n";
@ -171,6 +204,9 @@ sub gen_usb_files
print $outputUPower $tmpOutputUPower;
# ...and print footer
print $outputUPower "\n".'LABEL="up_hid_end"'."\n";
# Device scanner footer
print $outputDevScanner "\t/* Terminating entry */\n\t{ -1, -1, NULL }\n};\n#endif /* DEVSCAN_USB_H */\n\n";
}
sub find_usbdevs
@ -231,8 +267,9 @@ sub find_usbdevs
}
}
# store data (to be optimized)
if (($vendorName{$VendorID} eq "") && ($VendorName))
# store date (to be optimized)
# and don't overwritte actual vendor names with empty values
if( (!$vendorName{$VendorID}) or (($vendorName{$VendorID} eq "") and ($VendorName ne "")) )
{
$vendorName{$VendorID}=trim($VendorName);
}

View file

@ -1,5 +1,13 @@
esr-guest:Eric S. Raymond <esr-guest@alioth.debian.org>
lestat-guest:David Goncalves <david@lestat.st>
agordeev-guest:Alexander Gordeev <agordeev-guest@alioth.debian.org>
emilienkia-guest:Emilien Kia <emilienkia-guest@alioth.debian.org>
prachi-guest:Prachi Gandhi <prachi-guest@alioth.debian.org>
praveenkumar-guest:Praveen Kumar <praveenkumar-guest@alioth.debian.org>
msoltyspl-guest:Michal Soltys <msoltyspl-guest@alioth.debian.org>
keyson-guest:Kjell Claesson <keyson-guest@alioth.debian.org>
chetanagarwal-guest:Chetan Agarwal <chetanagarwal-guest@alioth.debian.org>
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>
aquette:Arnaud Quette <arnaud.quette@free.fr>
lestat-guest:David Goncalves <david@lestat.st>
chetanagarwal-guest: Chetan Agarwal <chetanagarwal-guest@alioth.debian.org>