mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
new propery noOIDIncreasingCheck allowing to skip
OID increasing check (userful for bogus SNMP agents)
This commit is contained in:
parent
e1d4676065
commit
5c110b9a76
3 changed files with 55 additions and 70 deletions
|
@ -93,6 +93,7 @@ typedef struct _php_snmp_object {
|
||||||
int enum_print;
|
int enum_print;
|
||||||
int oid_output_format;
|
int oid_output_format;
|
||||||
int snmp_errno;
|
int snmp_errno;
|
||||||
|
int noOIDIncreasingCheck;
|
||||||
char snmp_errstr[128];
|
char snmp_errstr[128];
|
||||||
} php_snmp_object;
|
} php_snmp_object;
|
||||||
|
|
||||||
|
|
110
ext/snmp/snmp.c
110
ext/snmp/snmp.c
|
@ -376,6 +376,7 @@ struct objid_query {
|
||||||
long max_repetitions;
|
long max_repetitions;
|
||||||
int valueretrieval;
|
int valueretrieval;
|
||||||
int array_output;
|
int array_output;
|
||||||
|
int noOIDIncreasingCheck;
|
||||||
snmpobjarg *vars;
|
snmpobjarg *vars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -878,7 +879,7 @@ retry:
|
||||||
|
|
||||||
/* OID increase check */
|
/* OID increase check */
|
||||||
if (st & SNMP_CMD_WALK) {
|
if (st & SNMP_CMD_WALK) {
|
||||||
if (snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) {
|
if (objid_query->noOIDIncreasingCheck == FALSE && snmp_oid_compare(name, name_length, vars->name, vars->name_length) >= 0) {
|
||||||
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
|
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
|
||||||
php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2);
|
php_snmp_error(getThis(), NULL TSRMLS_CC, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2);
|
||||||
keepwalking = 0;
|
keepwalking = 0;
|
||||||
|
@ -1331,6 +1332,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
|
||||||
objid_query.max_repetitions = -1;
|
objid_query.max_repetitions = -1;
|
||||||
objid_query.non_repeaters = 0;
|
objid_query.non_repeaters = 0;
|
||||||
objid_query.valueretrieval = SNMP_G(valueretrieval);
|
objid_query.valueretrieval = SNMP_G(valueretrieval);
|
||||||
|
objid_query.noOIDIncreasingCheck = FALSE;
|
||||||
|
|
||||||
if (session_less_mode) {
|
if (session_less_mode) {
|
||||||
if (version == SNMP_VERSION_3) {
|
if (version == SNMP_VERSION_3) {
|
||||||
|
@ -1424,6 +1426,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
|
||||||
objid_query.max_repetitions = snmp_object->max_oids;
|
objid_query.max_repetitions = snmp_object->max_oids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
objid_query.noOIDIncreasingCheck = snmp_object->noOIDIncreasingCheck;
|
||||||
objid_query.valueretrieval = snmp_object->valueretrieval;
|
objid_query.valueretrieval = snmp_object->valueretrieval;
|
||||||
glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
|
glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
|
||||||
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print);
|
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print);
|
||||||
|
@ -2107,41 +2110,28 @@ static int php_snmp_read_max_oids(php_snmp_object *snmp_object, zval **retval TS
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ */
|
#define PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(name) \
|
||||||
static int php_snmp_read_valueretrieval(php_snmp_object *snmp_object, zval **retval TSRMLS_DC)
|
static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \
|
||||||
{
|
{ \
|
||||||
MAKE_STD_ZVAL(*retval);
|
MAKE_STD_ZVAL(*retval); \
|
||||||
ZVAL_LONG(*retval, snmp_object->valueretrieval);
|
ZVAL_BOOL(*retval, snmp_object->name); \
|
||||||
return SUCCESS;
|
return SUCCESS; \
|
||||||
}
|
}
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(noOIDIncreasingCheck)
|
||||||
static int php_snmp_read_quick_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC)
|
PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(quick_print)
|
||||||
{
|
PHP_SNMP_BOOL_PROPERTY_READER_FUNCTION(enum_print)
|
||||||
MAKE_STD_ZVAL(*retval);
|
|
||||||
ZVAL_BOOL(*retval, snmp_object->quick_print);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
#define PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(name) \
|
||||||
static int php_snmp_read_enum_print(php_snmp_object *snmp_object, zval **retval TSRMLS_DC)
|
static int php_snmp_read_##name(php_snmp_object *snmp_object, zval **retval TSRMLS_DC) \
|
||||||
{
|
{ \
|
||||||
MAKE_STD_ZVAL(*retval);
|
MAKE_STD_ZVAL(*retval); \
|
||||||
ZVAL_BOOL(*retval, snmp_object->enum_print);
|
ZVAL_LONG(*retval, snmp_object->name); \
|
||||||
return SUCCESS;
|
return SUCCESS; \
|
||||||
}
|
}
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(valueretrieval)
|
||||||
static int php_snmp_read_oid_output_format(php_snmp_object *snmp_object, zval **retval TSRMLS_DC)
|
PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(oid_output_format)
|
||||||
{
|
|
||||||
MAKE_STD_ZVAL(*retval);
|
|
||||||
ZVAL_LONG(*retval, snmp_object->oid_output_format);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
/* {{{ */
|
||||||
static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
||||||
|
@ -2211,45 +2201,28 @@ static int php_snmp_write_valueretrieval(php_snmp_object *snmp_object, zval *new
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ */
|
#define PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(name) \
|
||||||
static int php_snmp_write_quick_print(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
static int php_snmp_write_##name(php_snmp_object *snmp_object, zval *newval TSRMLS_DC) \
|
||||||
{
|
{ \
|
||||||
zval ztmp;
|
zval ztmp; \
|
||||||
if (Z_TYPE_P(newval) != IS_BOOL) {
|
if (Z_TYPE_P(newval) != IS_BOOL) { \
|
||||||
ztmp = *newval;
|
ztmp = *newval; \
|
||||||
zval_copy_ctor(&ztmp);
|
zval_copy_ctor(&ztmp); \
|
||||||
convert_to_boolean(&ztmp);
|
convert_to_boolean(&ztmp); \
|
||||||
newval = &ztmp;
|
newval = &ztmp; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
snmp_object->name = Z_LVAL_P(newval); \
|
||||||
|
\
|
||||||
|
if (newval == &ztmp) { \
|
||||||
|
zval_dtor(newval); \
|
||||||
|
} \
|
||||||
|
return SUCCESS; \
|
||||||
}
|
}
|
||||||
|
|
||||||
snmp_object->quick_print = Z_LVAL_P(newval);
|
PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(quick_print)
|
||||||
|
PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(enum_print)
|
||||||
if (newval == &ztmp) {
|
PHP_SNMP_BOOL_PROPERTY_WRITER_FUNCTION(noOIDIncreasingCheck)
|
||||||
zval_dtor(newval);
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
|
||||||
static int php_snmp_write_enum_print(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
|
||||||
{
|
|
||||||
zval ztmp;
|
|
||||||
if (Z_TYPE_P(newval) != IS_BOOL) {
|
|
||||||
ztmp = *newval;
|
|
||||||
zval_copy_ctor(&ztmp);
|
|
||||||
convert_to_boolean(&ztmp);
|
|
||||||
newval = &ztmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
snmp_object->enum_print = Z_LVAL_P(newval);
|
|
||||||
|
|
||||||
if (newval == &ztmp) {
|
|
||||||
zval_dtor(newval);
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ */
|
/* {{{ */
|
||||||
static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval TSRMLS_DC)
|
||||||
|
@ -2311,6 +2284,7 @@ const php_snmp_prop_handler php_snmp_property_entries[] = {
|
||||||
PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print),
|
PHP_SNMP_PROPERTY_ENTRY_RECORD(quick_print),
|
||||||
PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print),
|
PHP_SNMP_PROPERTY_ENTRY_RECORD(enum_print),
|
||||||
PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format),
|
PHP_SNMP_PROPERTY_ENTRY_RECORD(oid_output_format),
|
||||||
|
PHP_SNMP_PROPERTY_ENTRY_RECORD(noOIDIncreasingCheck),
|
||||||
{ NULL, 0, NULL, NULL}
|
{ NULL, 0, NULL, NULL}
|
||||||
};
|
};
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
|
@ -26,6 +26,7 @@ $session->enum_print = TRUE;
|
||||||
$session->quick_print = TRUE;
|
$session->quick_print = TRUE;
|
||||||
$session->valueretrieval = SNMP_VALUE_LIBRARY;
|
$session->valueretrieval = SNMP_VALUE_LIBRARY;
|
||||||
$session->oid_output_format = SNMP_OID_OUTPUT_NUMERIC;
|
$session->oid_output_format = SNMP_OID_OUTPUT_NUMERIC;
|
||||||
|
$session->noOIDIncreasingCheck = TRUE;
|
||||||
|
|
||||||
var_dump($session);
|
var_dump($session);
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ $session->enum_print = "1";
|
||||||
$session->quick_print = "1";
|
$session->quick_print = "1";
|
||||||
$session->valueretrieval = "1";
|
$session->valueretrieval = "1";
|
||||||
$session->oid_output_format = "3";
|
$session->oid_output_format = "3";
|
||||||
|
$session->noOIDIncreasingCheck = "45";
|
||||||
|
|
||||||
var_dump($session);
|
var_dump($session);
|
||||||
|
|
||||||
|
@ -87,6 +89,8 @@ object(SNMP)#%d (%d) {
|
||||||
bool(false)
|
bool(false)
|
||||||
["oid_output_format"]=>
|
["oid_output_format"]=>
|
||||||
int(3)
|
int(3)
|
||||||
|
["noOIDIncreasingCheck"]=>
|
||||||
|
bool(false)
|
||||||
}
|
}
|
||||||
object(SNMP)#%d (%d) {
|
object(SNMP)#%d (%d) {
|
||||||
["info"]=>
|
["info"]=>
|
||||||
|
@ -110,6 +114,8 @@ object(SNMP)#%d (%d) {
|
||||||
bool(true)
|
bool(true)
|
||||||
["oid_output_format"]=>
|
["oid_output_format"]=>
|
||||||
int(4)
|
int(4)
|
||||||
|
["noOIDIncreasingCheck"]=>
|
||||||
|
bool(true)
|
||||||
}
|
}
|
||||||
object(SNMP)#%d (%d) {
|
object(SNMP)#%d (%d) {
|
||||||
["info"]=>
|
["info"]=>
|
||||||
|
@ -133,6 +139,8 @@ object(SNMP)#%d (%d) {
|
||||||
bool(true)
|
bool(true)
|
||||||
["oid_output_format"]=>
|
["oid_output_format"]=>
|
||||||
int(3)
|
int(3)
|
||||||
|
["noOIDIncreasingCheck"]=>
|
||||||
|
bool(true)
|
||||||
}
|
}
|
||||||
bool(true)
|
bool(true)
|
||||||
bool(true)
|
bool(true)
|
||||||
|
@ -159,6 +167,8 @@ object(SNMP)#%d (%d) {
|
||||||
bool(true)
|
bool(true)
|
||||||
["oid_output_format"]=>
|
["oid_output_format"]=>
|
||||||
int(3)
|
int(3)
|
||||||
|
["noOIDIncreasingCheck"]=>
|
||||||
|
bool(true)
|
||||||
["123"]=>
|
["123"]=>
|
||||||
string(11) "param_value"
|
string(11) "param_value"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue