Dear list,
To better reflect the behavior of the snmpget command that comes with
the Net-SNMP package the patch attached makes an array of OIDs as a
parameter for the snmpget()/snmpgetnext() function possible. This allows
more efficient querying over SNMP as the Net-SNMP API will bundle the
OIDs into one request. The patch is backwards compatible, as in,
snmpget()/snmpgetnext() will still accept a string and return a string
in that case.
For completeness' sake, I've also added snmpgetoid() and
snmpgetnextoid() as the counterparts for snmpwalkoid().
Regards,
Jorrit Kronjee
<snip>Dear list,
To better reflect the behavior of the snmpget command that comes with
the Net-SNMP package the patch attached makes an array of OIDs as a
parameter for the snmpget()/snmpgetnext() function possible.
Looks good to me, for what it's worth. Anyone got objections?
--
Cheers,
Michael
Hello,
<snip>Dear list,
To better reflect the behavior of the snmpget command that comes with
the Net-SNMP package the patch attached makes an array of OIDs as a
parameter for the snmpget()/snmpgetnext() function possible.Looks good to me, for what it's worth. Anyone got objections?
I think the patch at a first glance looks good, although it is a minor
cosmetic nitpick, I did catch a line with a couple of extra
semi-colons.
static void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
{
- char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
- int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;
- char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;;
- int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;;
This patch does move around a bit of code, are there some tests to go
along with this patch?
-Chris
Hello,
<snip>Dear list,
To better reflect the behavior of the snmpget command that comes with
the Net-SNMP package the patch attached makes an array of OIDs as a
parameter for the snmpget()/snmpgetnext() function possible.Looks good to me, for what it's worth. Anyone got objections?
I think the patch at a first glance looks good, although it is a minor
cosmetic nitpick, I did catch a line with a couple of extra
semi-colons.static void php_snmpv3(INTERNAL_FUNCTION_PARAMETERS, int st)
{
- char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
- int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;
- char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;;
- int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len, a8_len;;
This patch does move around a bit of code, are there some tests to go
along with this patch?-Chris
Chris,
Ouch, I forgot to remove those extra semicolons. Thanks for noticing.
What kind of tests are you looking for? I did run a couple of tests
against my own SNMP devices to check for regressions, like:
oldphp -r 'print_r(snmpget($host, $community, $oid))'
newphp -r 'print_r(snmpget($host, $community, $oid))'
I also noticed that the tests/ directory for snmp was empty, otherwise I
would've run and extended some of those.
Shall I just write a couple and include that in a new patch?
Regards,
Jorrit Kronjee
<snip> Shall I just write a couple and include that in a new patch?
So I wrote a couple of tests:
Running 8 tests
PASS Test function snmpget() by calling it with its expected
arguments[snmpget_basic.phpt]
PASS Test function snmpget() by calling it more than or less than its
expected arguments[snmpget_error.phpt]
PASS Test function snmpgetnext() by calling it with its expected
arguments[snmpgetnext_basic.phpt]
PASS Test function snmpgetnext() by calling it more than or less than
its expected arguments[snmpgetnext_error.phpt]
PASS Test function snmpgetnextoid() by calling it with its expected
arguments[snmpgetnextoid_basic.phpt]
PASS Test function snmpgetnextoid() by calling it more than or less than
its expected arguments[snmpgetnextoid_error.phpt]
PASS Test function snmpgetoid() by calling it with its expected
arguments[snmpgetoid_basic.phpt]
PASS Test function snmpgetoid() by calling it more than or less than its
expected arguments[snmpgetoid_error.phpt]
TOTAL TIME: 00:01
8 PASSED TESTS
0 SKIPPED TESTS
These tests only run correctly with the patch. I also removed the extra
semicolons.
HTH
Regards,
Jorrit Kronjee