--- Begin Message ---
--On Tuesday, September 10, 2002 12:18 PM +0200 Markus Fischer
<[EMAIL PROTECTED]> wrote:
> Here's a guide for patches:
>
> .) If not a security or serious bug fix, always diff -u against
> HEAD branch
>
> .) Attach as mimetype text/plain or provide it with an url.
> Many clients including your are garbling and wraping the
> diffs badly making them unreadable.
I have attached the patch again according to your rulebook.
regards,
Harrie
Index: ext/snmp/config.m4
===================================================================
RCS file: /repository/php4/ext/snmp/config.m4,v
retrieving revision 1.26
diff -u -u -r1.26 config.m4
--- ext/snmp/config.m4 1 Jun 2002 20:14:58 -0000 1.26
+++ ext/snmp/config.m4 10 Sep 2002 12:27:55 -0000
@@ -2,8 +2,8 @@
dnl $Id: config.m4,v 1.26 2002/06/01 20:14:58 sr Exp $
dnl
-PHP_ARG_WITH(snmp,for SNMP support,
-[ --with-snmp[=DIR] Include SNMP support.])
+PHP_ARG_WITH(snmp,for SNMP support - old UCD SNNP,
+[ --with-snmp[=DIR] Include SNMP support - old UCD SNNP.])
if test "$PHP_SNMP" != "no"; then
@@ -61,6 +61,7 @@
AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ])
+ AC_DEFINE(OLD_UCD_SNMP,1,[ ])
AC_DEFINE(HAVE_SNMP,1,[ ])
PHP_ADD_INCLUDE($SNMP_INCDIR)
PHP_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD)
@@ -82,3 +83,68 @@
],[
AC_MSG_RESULT(no)
])
+
+PHP_ARG_WITH(net-snmp,for SNMP support - NET SNNP,
+[ --with-net-snmp[=DIR] Include SNMP support - NET SNNP.])
+
+ if test "$PHP_NET_SNMP" != "no"; then
+
+ if test "$PHP_NET_SNMP" = "yes"; then
+ for i in /usr/include /usr/local/include; do
+ test -f $i/net-snmp-config.h && SNMP_INCDIR=$i
+ test -f $i/snmp/net-snmp-config.h && SNMP_INCDIR=$i/snmp
+ test -f $i/snmp/include/net-snmp/net-snmp-config.h &&
+SNMP_INCDIR=$i/snmp/include
+ done
+ for i in /usr /usr/snmp /usr/local /usr/local/snmp; do
+ test -f $i/lib/libnetsnmp.a -o -f $i/lib/libnetsnmp.$SHLIB_SUFFIX_NAME &&
+SNMP_LIBDIR=$i/lib
+ done
+ else
+ SNMP_INCDIR=$PHP_NET_SNMP/include
+ test -f $PHP_NET_SNMP/include/net-snmp/net-snmp-config.h &&
+SNMP_INCDIR=$PHP_NET_SNMP/include
+ test -f $PHP_NET_SNMP/lib/libnetsnmp.a -o -f
+$PHP_NET_SNMP/lib/libnetsnmp.$SHLIB_SUFFIX_NAME \
+ &&
+SNMP_LIBDIR=$PHP_NET_SNMP/lib
+ fi
+
+ if test -z "$SNMP_INCDIR"; then
+ AC_MSG_ERROR(net-snmp-config.h not found. Check your SNMP installation.)
+ elif test -z "$SNMP_LIBDIR"; then
+ AC_MSG_ERROR(libnetsnmp not found. Check your SNMP installation.)
+ fi
+
+ old_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS=-I$SNMP_INCDIR
+ AC_MSG_CHECKING(for OpenSSL support in SNMP libraries)
+ AC_EGREP_CPP(yes,[
+ #include <net-snmp/net-snmp-config.h>
+ #if USE_OPENSSL
+ yes
+ #endif
+ ],[
+ SNMP_SSL=yes
+ ],[
+ SNMP_SSL=no
+ ])
+ CPPFLAGS=$old_CPPFLAGS
+ AC_MSG_RESULT($SNMP_SSL)
+
+ if test "$SNMP_SSL" = "yes"; then
+ if test "$PHP_OPENSSL" != "no"; then
+ PHP_ADD_LIBRARY(ssl, 1, SNMP_SHARED_LIBADD)
+ PHP_ADD_LIBRARY(crypto,1, SNMP_SHARED_LIBADD)
+ else
+ AC_MSG_ERROR(The NET-SNMP in this system is built with SSL support.
+
+ Add --with-openssl<=DIR> to your configure line.)
+ fi
+ fi
+
+ AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ])
+
+ AC_DEFINE(HAVE_SNMP,1,[ ])
+ PHP_ADD_INCLUDE($SNMP_INCDIR)
+ PHP_ADD_LIBRARY_WITH_PATH(netsnmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD)
+
+ PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
+ PHP_SUBST(SNMP_SHARED_LIBADD)
+ fi
+
Index: ext/snmp/snmp.c
===================================================================
RCS file: /repository/php4/ext/snmp/snmp.c,v
retrieving revision 1.60
diff -u -u -r1.60 snmp.c
--- ext/snmp/snmp.c 5 Sep 2002 11:50:43 -0000 1.60
+++ ext/snmp/snmp.c 10 Sep 2002 12:27:56 -0000
@@ -70,9 +70,7 @@
#endif
#endif
-#ifdef HAVE_DEFAULT_STORE_H
-#include "default_store.h"
-#endif
+#ifdef OLD_UCD_SNMP
#include "asn1.h"
#include "snmp_api.h"
#include "snmp_client.h"
@@ -81,6 +79,17 @@
#include "parse.h"
#include "mib.h"
#include "version.h"
+#else
+#include "net-snmp/net-snmp-config.h"
+#include "net-snmp/version.h"
+#include "net-snmp/library/asn1.h"
+#include "net-snmp/library/snmp_api.h"
+#include "net-snmp/library/snmp_client.h"
+#include "net-snmp/library/snmp_impl.h"
+#include "net-snmp/library/snmp.h"
+#include "net-snmp/library/parse.h"
+#include "net-snmp/library/mib.h"
+#endif
/* ucd-snmp 3.3.1 changed the name of a few #defines... They've been changed back to
the original ones in 3.5.3! */
#ifndef SNMP_MSG_GET
@@ -142,7 +151,11 @@
{
php_info_print_table_start();
php_info_print_table_row(2, "UCD-SNMP Support", "enabled");
+#ifdef OLD_UCD_SNMP
php_info_print_table_row(2, "UCD-SNMP Version", VersionInfo);
+#else
+ php_info_print_table_row(2, "UCD-SNMP Version", netsnmp_get_version());
+#endif
php_info_print_table_end();
}
/* }}} */
@@ -270,7 +283,6 @@
session.timeout = timeout;
session.authenticator = NULL;
- snmp_synch_setup(&session);
if ((ss = snmp_open(&session)) == NULL) {
php_error(E_WARNING,"Could not open snmp\n");
@@ -329,7 +341,11 @@
}
if (st != 11) {
+#ifdef OLD_UCD_SNMP
sprint_value((struct sbuf
*)buf,vars->name, vars->name_length, vars);
+#else
+ snprint_value(buf, sizeof(buf),
+vars->name, vars->name_length, vars);
+#endif
}
if (st == 1) {
@@ -337,7 +353,11 @@
} else if (st == 2) {
add_next_index_string(return_value,buf,1); /* Add to returned array */
} else if (st == 3) {
+#ifdef OLD_UCD_SNMP
sprint_objid((struct sbuf *)buf2,
vars->name, vars->name_length);
+#else
+ snprint_objid(buf2, sizeof(buf2),
+vars->name, vars->name_length);
+#endif
add_assoc_string(return_value,buf2,buf,1);
}
if (st >= 2 && st != 11) {
@@ -356,7 +376,11 @@
for (count=1, vars =
response->variables; vars && count != response->errindex;
vars = vars->next_variable, count++);
if (vars) {
+#ifdef OLD_UCD_SNMP
sprint_objid((struct sbuf
*)buf,vars->name, vars->name_length);
+#else
+ snprint_objid(buf,
+sizeof(buf), vars->name, vars->name_length);
+#endif
}
php_error(E_WARNING,"This name does
not exist: %s\n",buf);
}
--- End Message ---