1--TEST-- 2Function snmp2_set (without MIBs loading) 3--CREDITS-- 4Boris Lytockin 5--EXTENSIONS-- 6snmp 7--SKIPIF-- 8<?php 9require_once(__DIR__.'/skipif.inc'); 10?> 11--ENV-- 12MIBS= 13--FILE-- 14<?php 15require_once(__DIR__.'/snmp_include.inc'); 16 17//EXPECTF format is quickprint OFF 18snmp_set_quick_print(false); 19snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 20 21echo "Check error handing\n"; 22echo "Nonexisting OID\n"; 23$z = snmp2_set($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries); 24var_dump($z); 25 26echo "Bogus OID\n"; 27$z = snmp2_set($hostname, $communityWrite, '.1.3.6...777.888.999.444.0', 's', 'bbb', $timeout, $retries); 28var_dump($z); 29 30echo "Checking working\n"; 31$oid1 = '.1.3.6.1.2.1.1.4.0'; 32$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries); 33$newvalue1 = $oldvalue1 . '0'; 34 35echo "Single OID\n"; 36$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries); 37var_dump($z); 38var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1)); 39$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries); 40var_dump($z); 41var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1)); 42 43?> 44--EXPECTF-- 45Check error handing 46Nonexisting OID 47 48Warning: snmp2_set(): Error in packet at '%s': notWritable (That object does not support modification) in %s on line %d 49bool(false) 50Bogus OID 51 52Warning: snmp2_set(): Invalid object identifier: %s in %s on line %d 53bool(false) 54Checking working 55Single OID 56bool(true) 57bool(true) 58bool(true) 59bool(true) 60