-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2449 from jimklimov/issue-2246
`nut-scanner`: Fix "Old NUT" detection and clarify some log messages
- Loading branch information
Showing
3 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* Copyright (C) 2011 - 2024 Arnaud Quette (Design and part of implementation) | ||
* Copyright (C) 2011-2021 - EATON | ||
* Copyright (C) 2011 - 2021 EATON | ||
* Copyright (C) 2016 - 2021 Jim Klimov <[email protected]> | ||
* Copyright (C) 2022 - 2024 Jim Klimov <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -21,7 +23,8 @@ | |
\brief init functions for nut scanner library | ||
\author Frederic Bohe <[email protected]> | ||
\author Arnaud Quette <[email protected]> | ||
\author Arnaud Quette <[email protected]> | ||
\author Arnaud Quette <[email protected]> | ||
\author Jim Klimov <[email protected]> | ||
*/ | ||
|
||
#include "common.h" | ||
|
@@ -38,15 +41,14 @@ | |
#define SOEXT ".dll" | ||
#endif | ||
|
||
/* Flags for code paths we can support in this run (libs available or not | ||
* needed). For consistency, only set non-zero values via nutscan_init() call. | ||
*/ | ||
int nutscan_avail_avahi = 0; | ||
int nutscan_avail_ipmi = 0; | ||
int nutscan_avail_nut = 0; | ||
int nutscan_avail_nut_simulation = 1; | ||
#ifdef WITH_SNMP_STATIC | ||
int nutscan_avail_snmp = 1; | ||
#else | ||
int nutscan_avail_nut = 0; /* aka oldnut detection via libupsclient compared to avahi as newnut */ | ||
int nutscan_avail_nut_simulation = 0; | ||
int nutscan_avail_snmp = 0; | ||
#endif | ||
int nutscan_avail_usb = 0; | ||
int nutscan_avail_xml_http = 0; | ||
|
||
|
@@ -209,12 +211,23 @@ void nutscan_init(void) | |
#endif /* WITH_USB */ | ||
|
||
#ifdef WITH_SNMP | ||
#ifdef WITH_SNMP_STATIC | ||
/* This is a rare situation, reserved for platforms where libnetsnmp or | ||
* equivalent (some other ucd-snmp descendants) was not packaged, and | ||
* thus was custom-built for NUT (so linked statically to avoid potential | ||
* conflicts with whatever else people may have practically deployed | ||
* nearby). | ||
*/ | ||
upsdebugx(1, "%s: skipped loading the library for %s: was linked statically during NUT build", | ||
__func__, "LibSNMP"); | ||
nutscan_avail_snmp = 1; | ||
#else | ||
libname = get_libname("libnetsnmp" SOEXT); | ||
#ifdef WIN32 | ||
#ifdef WIN32 | ||
if (!libname) { | ||
libname = get_libname("libnetsnmp-40" SOEXT); | ||
} | ||
#endif | ||
#endif | ||
if (libname) { | ||
upsdebugx(1, "%s: get_libname() resolved '%s' for %s, loading it", | ||
__func__, libname, "LibSNMP"); | ||
|
@@ -226,14 +239,15 @@ void nutscan_init(void) | |
"trying to load it with libtool default resolver", | ||
__func__, "LibSNMP"); | ||
nutscan_avail_snmp = nutscan_load_snmp_library("libnetsnmp" SOEXT); | ||
#ifdef WIN32 | ||
#ifdef WIN32 | ||
if (!nutscan_avail_snmp) { | ||
nutscan_avail_snmp = nutscan_load_snmp_library("libnetsnmp-40" SOEXT); | ||
} | ||
#endif | ||
#endif | ||
} | ||
upsdebugx(1, "%s: %s to load the library for %s", | ||
__func__, nutscan_avail_snmp ? "succeeded" : "failed", "LibSNMP"); | ||
#endif /* WITH_SNMP_STATIC */ | ||
#else | ||
upsdebugx(1, "%s: skipped loading the library for %s: was absent during NUT build", | ||
__func__, "LibSNMP"); | ||
|
@@ -363,7 +377,7 @@ void nutscan_init(void) | |
|
||
/* start of "NUT Simulation" - unconditional */ | ||
/* no need for additional library */ | ||
nutscan_avail_nut = 1; | ||
nutscan_avail_nut_simulation = 1; | ||
|
||
} | ||
|
||
|