Imported Upstream version 2.6.4

This commit is contained in:
Arnaud Quette 2012-06-01 15:55:19 +02:00
parent fad6ced6f6
commit fefe62b2bd
257 changed files with 6020 additions and 1394 deletions

View file

@ -56,19 +56,25 @@
#endif
#include "nutscan-snmp.h"
/* Address API change */
#ifndef usmAESPrivProtocol
#define USMAESPRIVPROTOCOL "usmAES128PrivProtocol"
#else
#define USMAESPRIVPROTOCOL "usmAESPrivProtocol"
#endif
#define SysOID ".1.3.6.1.2.1.1.2.0"
static nutscan_device_t * dev_ret = NULL;
#ifdef HAVE_PTHREAD
static pthread_mutex_t dev_mutex;
static pthread_mutex_t lib_mutex;
static pthread_t * thread_array = NULL;
static int thread_count = 0;
#endif
long g_usec_timeout ;
/* dynamic link library stuff */
static char * libname = "libnetsnmp";
static lt_dlhandle dl_handle = NULL;
static const char *dl_error = NULL;
@ -99,10 +105,6 @@ static oid * (*nut_usmDESPrivProtocol);
/* return 0 on error */
int nutscan_load_snmp_library()
{
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&lib_mutex);
#endif
if( dl_handle != NULL ) {
/* if previous init failed */
if( dl_handle == (void *)1 ) {
@ -117,7 +119,7 @@ int nutscan_load_snmp_library()
return 0;
}
dl_handle = lt_dlopenext("libnetsnmp");
dl_handle = lt_dlopenext(libname);
if (!dl_handle) {
dl_error = lt_dlerror();
goto err;
@ -205,7 +207,7 @@ int nutscan_load_snmp_library()
}
*(void **) (&nut_usmAESPrivProtocol) = lt_dlsym(dl_handle,
"usmAESPrivProtocol");
USMAESPRIVPROTOCOL);
if ((dl_error = lt_dlerror()) != NULL) {
goto err;
}
@ -228,16 +230,11 @@ int nutscan_load_snmp_library()
goto err;
}
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&dev_mutex);
#endif
return 1;
err:
fprintf(stderr, "%s\n", dl_error);
fprintf(stderr, "Cannot load SNMP library (%s) : %s. SNMP search disabled.\n", libname, dl_error);
dl_handle = (void *)1;
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&dev_mutex);
#endif
lt_dlexit();
return 0;
}
/* end of dynamic link library stuff */
@ -660,7 +657,6 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
pthread_t thread;
pthread_mutex_init(&dev_mutex,NULL);
pthread_mutex_init(&lib_mutex,NULL);
#endif
if( !nutscan_avail_snmp ) {