@@ -475,15 +475,15 @@ static void php_snmp_session_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
475
475
static void php_snmp_object_free_storage (void * object TSRMLS_DC )
476
476
{
477
477
php_snmp_object * intern = (php_snmp_object * )object ;
478
-
478
+
479
479
if (!intern ) {
480
480
return ;
481
481
}
482
482
483
483
netsnmp_session_free (& (intern -> session ));
484
484
485
485
zend_object_std_dtor (& intern -> zo TSRMLS_CC );
486
-
486
+
487
487
efree (intern );
488
488
}
489
489
@@ -503,7 +503,7 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS
503
503
retval .handlers = (zend_object_handlers * ) & php_snmp_object_handlers ;
504
504
505
505
return retval ;
506
-
506
+
507
507
}
508
508
509
509
/* {{{ php_snmp_error
@@ -556,7 +556,7 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D
556
556
char * dbuf = (char * )NULL ;
557
557
int buflen = sizeof (sbuf ) - 1 ;
558
558
int val_len = vars -> val_len ;
559
-
559
+
560
560
/* use emalloc() for large values, use static array otherwize */
561
561
562
562
/* There is no way to know the size of buffer snprint_value() needs in order to print a value there.
@@ -702,7 +702,7 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D
702
702
* SNMP object fetcher/setter for all SNMP versions
703
703
*
704
704
*/
705
- static void php_snmp_internal (INTERNAL_FUNCTION_PARAMETERS , int st ,
705
+ static void php_snmp_internal (INTERNAL_FUNCTION_PARAMETERS , int st ,
706
706
struct snmp_session * session ,
707
707
struct objid_query * objid_query )
708
708
{
@@ -721,7 +721,7 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
721
721
722
722
/* we start with retval=FALSE. If any actual data is acquired, retval will be set to appropriate type */
723
723
RETVAL_FALSE ;
724
-
724
+
725
725
/* reset errno and errstr */
726
726
php_snmp_error (getThis (), NULL TSRMLS_CC , PHP_SNMP_ERRNO_NOERROR , "" );
727
727
@@ -805,8 +805,8 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
805
805
}
806
806
for (vars = response -> variables ; vars ; vars = vars -> next_variable ) {
807
807
/* do not output errors as values */
808
- if ( vars -> type == SNMP_ENDOFMIBVIEW ||
809
- vars -> type == SNMP_NOSUCHOBJECT ||
808
+ if ( vars -> type == SNMP_ENDOFMIBVIEW ||
809
+ vars -> type == SNMP_NOSUCHOBJECT ||
810
810
vars -> type == SNMP_NOSUCHINSTANCE ) {
811
811
if ((st & SNMP_CMD_WALK ) && Z_TYPE_P (return_value ) == IS_ARRAY ) {
812
812
break ;
@@ -816,8 +816,8 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
816
816
php_snmp_error (getThis (), NULL TSRMLS_CC , PHP_SNMP_ERRNO_ERROR_IN_REPLY , "Error in packet at '%s': %s" , buf , buf2 );
817
817
continue ;
818
818
}
819
-
820
- if ((st & SNMP_CMD_WALK ) &&
819
+
820
+ if ((st & SNMP_CMD_WALK ) &&
821
821
(vars -> name_length < rootlen || memcmp (root , vars -> name , rootlen * sizeof (oid )))) { /* not part of this subtree */
822
822
if (Z_TYPE_P (return_value ) == IS_ARRAY ) { /* some records are fetched already, shut down further lookup */
823
823
keepwalking = 0 ;
@@ -1101,7 +1101,7 @@ static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_qu
1101
1101
efree (objid_query -> vars );
1102
1102
return FALSE;
1103
1103
}
1104
- } else {
1104
+ } else {
1105
1105
memmove ((char * )objid_query -> vars [0 ].name , (char * )objid_mib , sizeof (objid_mib ));
1106
1106
objid_query -> vars [0 ].name_length = sizeof (objid_mib ) / sizeof (oid );
1107
1107
}
@@ -1437,7 +1437,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
1437
1437
int session_less_mode = (getThis () == NULL );
1438
1438
php_snmp_object * snmp_object ;
1439
1439
php_snmp_object glob_snmp_object ;
1440
-
1440
+
1441
1441
objid_query .max_repetitions = -1 ;
1442
1442
objid_query .non_repeaters = 0 ;
1443
1443
objid_query .valueretrieval = SNMP_G (valueretrieval );
@@ -1550,7 +1550,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
1550
1550
}
1551
1551
1552
1552
php_snmp_internal (INTERNAL_FUNCTION_PARAM_PASSTHRU , st , session , & objid_query );
1553
-
1553
+
1554
1554
efree (objid_query .vars );
1555
1555
1556
1556
if (session_less_mode ) {
@@ -1563,23 +1563,23 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
1563
1563
}
1564
1564
/* }}} */
1565
1565
1566
- /* {{{ proto mixed snmpget(string host, string community, mixed object_id [, int timeout [, int retries]])
1566
+ /* {{{ proto mixed snmpget(string host, string community, mixed object_id [, int timeout [, int retries]])
1567
1567
Fetch a SNMP object */
1568
1568
PHP_FUNCTION (snmpget )
1569
1569
{
1570
1570
php_snmp (INTERNAL_FUNCTION_PARAM_PASSTHRU , SNMP_CMD_GET , SNMP_VERSION_1 );
1571
1571
}
1572
1572
/* }}} */
1573
1573
1574
- /* {{{ proto mixed snmpgetnext(string host, string community, mixed object_id [, int timeout [, int retries]])
1574
+ /* {{{ proto mixed snmpgetnext(string host, string community, mixed object_id [, int timeout [, int retries]])
1575
1575
Fetch a SNMP object */
1576
1576
PHP_FUNCTION (snmpgetnext )
1577
1577
{
1578
1578
php_snmp (INTERNAL_FUNCTION_PARAM_PASSTHRU , SNMP_CMD_GETNEXT , SNMP_VERSION_1 );
1579
1579
}
1580
1580
/* }}} */
1581
1581
1582
- /* {{{ proto mixed snmpwalk(string host, string community, mixed object_id [, int timeout [, int retries]])
1582
+ /* {{{ proto mixed snmpwalk(string host, string community, mixed object_id [, int timeout [, int retries]])
1583
1583
Return all objects under the specified object id */
1584
1584
PHP_FUNCTION (snmpwalk )
1585
1585
{
@@ -1595,7 +1595,7 @@ PHP_FUNCTION(snmprealwalk)
1595
1595
}
1596
1596
/* }}} */
1597
1597
1598
- /* {{{ proto bool snmpset(string host, string community, mixed object_id, mixed type, mixed value [, int timeout [, int retries]])
1598
+ /* {{{ proto bool snmpset(string host, string community, mixed object_id, mixed type, mixed value [, int timeout [, int retries]])
1599
1599
Set the value of a SNMP object */
1600
1600
PHP_FUNCTION (snmpset )
1601
1601
{
@@ -1642,7 +1642,7 @@ PHP_FUNCTION(snmp_set_enum_print)
1642
1642
1643
1643
netsnmp_ds_set_boolean (NETSNMP_DS_LIBRARY_ID , NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM , (int ) a1 );
1644
1644
RETURN_TRUE ;
1645
- }
1645
+ }
1646
1646
/* }}} */
1647
1647
1648
1648
/* {{{ proto bool snmp_set_oid_output_format(int oid_format)
@@ -1670,26 +1670,26 @@ PHP_FUNCTION(snmp_set_oid_output_format)
1670
1670
RETURN_FALSE ;
1671
1671
break ;
1672
1672
}
1673
- }
1673
+ }
1674
1674
/* }}} */
1675
1675
1676
- /* {{{ proto mixed snmp2_get(string host, string community, mixed object_id [, int timeout [, int retries]])
1676
+ /* {{{ proto mixed snmp2_get(string host, string community, mixed object_id [, int timeout [, int retries]])
1677
1677
Fetch a SNMP object */
1678
1678
PHP_FUNCTION (snmp2_get )
1679
1679
{
1680
1680
php_snmp (INTERNAL_FUNCTION_PARAM_PASSTHRU , SNMP_CMD_GET , SNMP_VERSION_2c );
1681
1681
}
1682
1682
/* }}} */
1683
1683
1684
- /* {{{ proto mixed snmp2_getnext(string host, string community, mixed object_id [, int timeout [, int retries]])
1684
+ /* {{{ proto mixed snmp2_getnext(string host, string community, mixed object_id [, int timeout [, int retries]])
1685
1685
Fetch a SNMP object */
1686
1686
PHP_FUNCTION (snmp2_getnext )
1687
1687
{
1688
1688
php_snmp (INTERNAL_FUNCTION_PARAM_PASSTHRU , SNMP_CMD_GETNEXT , SNMP_VERSION_2c );
1689
1689
}
1690
1690
/* }}} */
1691
1691
1692
- /* {{{ proto mixed snmp2_walk(string host, string community, mixed object_id [, int timeout [, int retries]])
1692
+ /* {{{ proto mixed snmp2_walk(string host, string community, mixed object_id [, int timeout [, int retries]])
1693
1693
Return all objects under the specified object id */
1694
1694
PHP_FUNCTION (snmp2_walk )
1695
1695
{
@@ -1705,7 +1705,7 @@ PHP_FUNCTION(snmp2_real_walk)
1705
1705
}
1706
1706
/* }}} */
1707
1707
1708
- /* {{{ proto bool snmp2_set(string host, string community, mixed object_id, mixed type, mixed value [, int timeout [, int retries]])
1708
+ /* {{{ proto bool snmp2_set(string host, string community, mixed object_id, mixed type, mixed value [, int timeout [, int retries]])
1709
1709
Set the value of a SNMP object */
1710
1710
PHP_FUNCTION (snmp2_set )
1711
1711
{
@@ -1821,7 +1821,7 @@ PHP_METHOD(snmp, __construct)
1821
1821
1822
1822
snmp_object = (php_snmp_object * )zend_object_store_get_object (object TSRMLS_CC );
1823
1823
zend_replace_error_handling (EH_THROW , NULL , & error_handling TSRMLS_CC );
1824
-
1824
+
1825
1825
if (zend_parse_parameters (argc TSRMLS_CC , "lss|ll" , & version , & a1 , & a1_len , & a2 , & a2_len , & timeout , & retries ) == FAILURE ) {
1826
1826
zend_restore_error_handling (& error_handling TSRMLS_CC );
1827
1827
return ;
@@ -1843,7 +1843,7 @@ PHP_METHOD(snmp, __construct)
1843
1843
if (snmp_object -> session ) {
1844
1844
netsnmp_session_free (& (snmp_object -> session ));
1845
1845
}
1846
-
1846
+
1847
1847
if (netsnmp_session_init (& (snmp_object -> session ), version , a1 , a2 , timeout , retries TSRMLS_CC )) {
1848
1848
return ;
1849
1849
}
@@ -1857,7 +1857,7 @@ PHP_METHOD(snmp, __construct)
1857
1857
}
1858
1858
/* }}} */
1859
1859
1860
- /* {{{ proto bool SNMP::close()
1860
+ /* {{{ proto bool SNMP::close()
1861
1861
Close SNMP session */
1862
1862
PHP_METHOD (snmp , close )
1863
1863
{
@@ -1900,7 +1900,7 @@ PHP_METHOD(snmp, walk)
1900
1900
}
1901
1901
/* }}} */
1902
1902
1903
- /* {{{ proto bool SNMP::set(mixed object_id, mixed type, mixed value)
1903
+ /* {{{ proto bool SNMP::set(mixed object_id, mixed type, mixed value)
1904
1904
Set the value of a SNMP object */
1905
1905
PHP_METHOD (snmp , set )
1906
1906
{
@@ -1918,7 +1918,7 @@ PHP_METHOD(snmp, setSecurity)
1918
1918
int argc = ZEND_NUM_ARGS ();
1919
1919
1920
1920
snmp_object = (php_snmp_object * )zend_object_store_get_object (object TSRMLS_CC );
1921
-
1921
+
1922
1922
if (zend_parse_parameters (argc TSRMLS_CC , "s|ssssss" , & a1 , & a1_len , & a2 , & a2_len , & a3 , & a3_len ,
1923
1923
& a4 , & a4_len , & a5 , & a5_len , & a6 , & a6_len , & a7 , & a7_len ) == FAILURE ) {
1924
1924
RETURN_FALSE ;
@@ -1932,7 +1932,7 @@ PHP_METHOD(snmp, setSecurity)
1932
1932
}
1933
1933
/* }}} */
1934
1934
1935
- /* {{{ proto long SNMP::getErrno()
1935
+ /* {{{ proto long SNMP::getErrno()
1936
1936
Get last error code number */
1937
1937
PHP_METHOD (snmp , getErrno )
1938
1938
{
@@ -1946,7 +1946,7 @@ PHP_METHOD(snmp, getErrno)
1946
1946
}
1947
1947
/* }}} */
1948
1948
1949
- /* {{{ proto long SNMP::getError()
1949
+ /* {{{ proto long SNMP::getError()
1950
1950
Get last error message */
1951
1951
PHP_METHOD (snmp , getError )
1952
1952
{
@@ -2095,6 +2095,14 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
2095
2095
}
2096
2096
/* }}} */
2097
2097
2098
+ static HashTable * php_snmp_get_gc (zval * object , zval * * * gc_data , int * gc_data_count TSRMLS_DC ) /* {{{ */
2099
+ {
2100
+ * gc_data = NULL ;
2101
+ * gc_data_count = 0 ;
2102
+ return zend_std_get_properties (object TSRMLS_CC );
2103
+ }
2104
+ /* }}} */
2105
+
2098
2106
/* {{{ php_snmp_get_properties(zval *object)
2099
2107
Returns all object properties. Injects SNMP properties into object on first call */
2100
2108
static HashTable * php_snmp_get_properties (zval * object TSRMLS_DC )
@@ -2137,23 +2145,23 @@ static int php_snmp_read_info(php_snmp_object *snmp_object, zval **retval TSRMLS
2137
2145
if (snmp_object -> session == NULL ) {
2138
2146
return SUCCESS ;
2139
2147
}
2140
-
2148
+
2141
2149
MAKE_STD_ZVAL (val );
2142
2150
ZVAL_STRINGL (val , snmp_object -> session -> peername , strlen (snmp_object -> session -> peername ), 1 );
2143
2151
add_assoc_zval (* retval , "hostname" , val );
2144
-
2152
+
2145
2153
MAKE_STD_ZVAL (val );
2146
2154
ZVAL_LONG (val , snmp_object -> session -> remote_port );
2147
2155
add_assoc_zval (* retval , "port" , val );
2148
-
2156
+
2149
2157
MAKE_STD_ZVAL (val );
2150
2158
ZVAL_LONG (val , snmp_object -> session -> timeout );
2151
2159
add_assoc_zval (* retval , "timeout" , val );
2152
-
2160
+
2153
2161
MAKE_STD_ZVAL (val );
2154
2162
ZVAL_LONG (val , snmp_object -> session -> retries );
2155
2163
add_assoc_zval (* retval , "retries" , val );
2156
-
2164
+
2157
2165
return SUCCESS ;
2158
2166
}
2159
2167
/* }}} */
@@ -2226,7 +2234,7 @@ static int php_snmp_write_max_oids(php_snmp_object *snmp_object, zval *newval TS
2226
2234
} else {
2227
2235
php_error_docref (NULL TSRMLS_CC , E_WARNING , "max_oids should be positive integer or NULL, got %ld" , Z_LVAL_P (newval ));
2228
2236
}
2229
-
2237
+
2230
2238
if (newval == & ztmp ) {
2231
2239
zval_dtor (newval );
2232
2240
}
@@ -2254,7 +2262,7 @@ static int php_snmp_write_valueretrieval(php_snmp_object *snmp_object, zval *new
2254
2262
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unknown SNMP value retrieval method '%ld'" , Z_LVAL_P (newval ));
2255
2263
ret = FAILURE ;
2256
2264
}
2257
-
2265
+
2258
2266
if (newval == & ztmp ) {
2259
2267
zval_dtor (newval );
2260
2268
}
@@ -2297,7 +2305,7 @@ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *
2297
2305
convert_to_long (& ztmp );
2298
2306
newval = & ztmp ;
2299
2307
}
2300
-
2308
+
2301
2309
switch (Z_LVAL_P (newval )) {
2302
2310
case NETSNMP_OID_OUTPUT_SUFFIX :
2303
2311
case NETSNMP_OID_OUTPUT_MODULE :
@@ -2332,7 +2340,7 @@ static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval
2332
2340
newval = & ztmp ;
2333
2341
}
2334
2342
2335
- snmp_object -> exceptions_enabled = Z_LVAL_P (newval );
2343
+ snmp_object -> exceptions_enabled = Z_LVAL_P (newval );
2336
2344
2337
2345
if (newval == & ztmp ) {
2338
2346
zval_dtor (newval );
@@ -2401,6 +2409,7 @@ PHP_MINIT_FUNCTION(snmp)
2401
2409
php_snmp_object_handlers .write_property = php_snmp_write_property ;
2402
2410
php_snmp_object_handlers .has_property = php_snmp_has_property ;
2403
2411
php_snmp_object_handlers .get_properties = php_snmp_get_properties ;
2412
+ php_snmp_object_handlers .get_gc = php_snmp_get_gc ;
2404
2413
2405
2414
/* Register SNMP Class */
2406
2415
INIT_CLASS_ENTRY (ce , "SNMP" , php_snmp_class_methods );
@@ -2467,7 +2476,7 @@ PHP_MINIT_FUNCTION(snmp)
2467
2476
PHP_MSHUTDOWN_FUNCTION (snmp )
2468
2477
{
2469
2478
snmp_shutdown ("snmpapp" );
2470
-
2479
+
2471
2480
zend_hash_destroy (& php_snmp_properties );
2472
2481
2473
2482
return SUCCESS ;
0 commit comments