]> granicus.if.org Git - php/commitdiff
follow CS:
authorBoris Lytochkin <lytboris@php.net>
Sun, 20 Mar 2011 20:07:33 +0000 (20:07 +0000)
committerBoris Lytochkin <lytboris@php.net>
Sun, 20 Mar 2011 20:07:33 +0000 (20:07 +0000)
 - method set_security should be named as setSecurity
 - SNMP_VERSION_2C constant

13 files changed:
ext/snmp/php_snmp.h
ext/snmp/snmp.c
ext/snmp/tests/generic_timeout_error.phpt
ext/snmp/tests/snmp-object-errno-errstr.phpt
ext/snmp/tests/snmp-object-error.phpt
ext/snmp/tests/snmp-object-properties.phpt
ext/snmp/tests/snmp-object-setSecurity_error.phpt [new file with mode: 0644]
ext/snmp/tests/snmp-object-set_security_error.phpt [deleted file]
ext/snmp/tests/snmp-object.phpt
ext/snmp/tests/snmp2_set-nomib.phpt
ext/snmp/tests/snmp3-error.phpt
ext/snmp/tests/snmpset-nomib.phpt
ext/snmp/tests/wrong_hostname.phpt

index b4b6f560ab481ba4224c9bff2cd4bc3993148381..230132b330cf45d06caf2b797b72b936bb43a9d1 100644 (file)
@@ -73,7 +73,7 @@ PHP_FUNCTION(snmp_get_valueretrieval);
 PHP_FUNCTION(snmp_read_mib);
 
 PHP_METHOD(SNMP, open);
-PHP_METHOD(SNMP, set_security);
+PHP_METHOD(SNMP, setSecurity);
 PHP_METHOD(SNMP, close);
 PHP_METHOD(SNMP, get);
 PHP_METHOD(SNMP, getnext);
index d0c972b5f091d8a2d8b75ba0c98cead162b9a9cf..50ee35891663d522ba4142cdb677417ef17dfc1f 100644 (file)
@@ -374,7 +374,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_snmp_void, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_set_security, 0, 0, 8)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_snmp_setSecurity, 0, 0, 8)
        ZEND_ARG_INFO(0, session)
        ZEND_ARG_INFO(0, sec_level)
        ZEND_ARG_INFO(0, auth_protocol)
@@ -1847,9 +1847,9 @@ PHP_METHOD(snmp, set)
        php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1));
 }
 
-/* {{{ proto bool SNMP::set_security(resource session, string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID]]]])
+/* {{{ proto bool SNMP::setSecurity(resource session, string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID]]]])
        Set SNMPv3 security-related session parameters */
-PHP_METHOD(snmp, set_security)
+PHP_METHOD(snmp, setSecurity)
 {
        php_snmp_object *snmp_object;
        zval *object = getThis();
@@ -2338,7 +2338,7 @@ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *
 static zend_function_entry php_snmp_class_methods[] = {
        PHP_ME(snmp,     open,                          arginfo_snmp_open,              ZEND_ACC_PUBLIC)
        PHP_ME(snmp,     close,                         arginfo_snmp_void,              ZEND_ACC_PUBLIC)
-       PHP_ME(snmp,     set_security,                  arginfo_snmp_set_security,      ZEND_ACC_PUBLIC)
+       PHP_ME(snmp,     setSecurity,                   arginfo_snmp_setSecurity,       ZEND_ACC_PUBLIC)
 
        PHP_ME(snmp,     get,                           arginfo_snmp_get,               ZEND_ACC_PUBLIC)
        PHP_ME(snmp,     getnext,                       arginfo_snmp_get,               ZEND_ACC_PUBLIC)
@@ -2434,6 +2434,7 @@ PHP_MINIT_FUNCTION(snmp)
 
        REGISTER_LONG_CONSTANT("SNMP_VERSION_1",        SNMP_VERSION_1,         CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SNMP_VERSION_2c",       SNMP_VERSION_2c,        CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("SNMP_VERSION_2C",       SNMP_VERSION_2c,        CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SNMP_VERSION_3",        SNMP_VERSION_3,         CONST_CS | CONST_PERSISTENT);
 
        REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR",                 (long)PHP_SNMP_ERRNO_NOERROR);
index 8a06c50bbf3e557187af14129ad1871ce7897bde..0f5101a43972c980bf6b2ad9675477146a207547 100644 (file)
@@ -19,4 +19,4 @@ var_dump(snmpget($hostname, 'timeout_community_432', '.1.3.6.1.2.1.1.1.0', $time
 ?>
 --EXPECTF--
 Warning: snmpget(): No response from %s in %s on line %d
-bool(false)
\ No newline at end of file
+bool(false)
index 769588165df5884e25df6d82a21636ffde177e38..5b29ff3ee04cc5bcba5fc7b84f732691d851399c 100644 (file)
@@ -38,7 +38,7 @@ var_dump($session->get_error());
 $session->close();
 echo "SNMP::ERRNO_GENERIC\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, 'somebogususer', $timeout, $retries);
-$session->set_security('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
 var_dump(@$session->get('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->get_errno() == SNMP::ERRNO_GENERIC);
 var_dump($session->get_error());
@@ -60,4 +60,4 @@ bool(true)
 SNMP::ERRNO_GENERIC
 bool(false)
 bool(true)
-%string|unicode%(%d) "Fatal error: Unknown user name"
\ No newline at end of file
+%string|unicode%(%d) "Fatal error: Unknown user name"
index 5b771124089d07c20126d0ffad024eabe3cebd73..5520958acfaf53871d801137417875be7203d013 100644 (file)
@@ -91,4 +91,4 @@ NULL
 Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
 
 Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
-NULL
\ No newline at end of file
+NULL
index 6610d080012c1fb25eea4f2fb572c320a233eec5..0bdf51b46e98868e2a174b05d4a0e95e79c545b4 100644 (file)
@@ -187,4 +187,4 @@ array(4) {
   ["retries"]=>
   int(%d)
 }
-NULL
\ No newline at end of file
+NULL
diff --git a/ext/snmp/tests/snmp-object-setSecurity_error.phpt b/ext/snmp/tests/snmp-object-setSecurity_error.phpt
new file mode 100644 (file)
index 0000000..b532764
--- /dev/null
@@ -0,0 +1,66 @@
+--TEST--                                 
+OO API: SNMP::setSecurity (errors)
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+$session = new SNMP(SNMP_VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+$session->setSecurity('noAuthNoPriv');
+
+#echo "Checking error handling\n";
+var_dump($session->setSecurity());
+var_dump($session->setSecurity(''));
+var_dump($session->setSecurity('bugusPriv'));
+var_dump($session->setSecurity('authNoPriv', 'TTT'));
+var_dump($session->setSecurity('authNoPriv', 'MD5', ''));
+var_dump($session->setSecurity('authNoPriv', 'MD5', 'te'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'BBB'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', ''));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'ty'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'test12345', 'context', 'dsa'));
+
+var_dump($session->close());
+
+?>
+--EXPECTF--
+
+Warning: SNMP::setSecurity() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Invalid security level '' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Invalid security level 'bugusPriv' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Unknown authentication protocol 'TTT' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Unknown security protocol 'BBB' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Bad engine ID value 'dsa' in %s on line %d
+bool(false)
+bool(true)
diff --git a/ext/snmp/tests/snmp-object-set_security_error.phpt b/ext/snmp/tests/snmp-object-set_security_error.phpt
deleted file mode 100644 (file)
index 596fb53..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
---TEST--                                 
-OO API: SNMP::set_security (errors)
---CREDITS--
-Boris Lytochkin
---SKIPIF--
-<?php
-require_once(dirname(__FILE__).'/skipif.inc');
-?>
---FILE--
-<?php
-require_once(dirname(__FILE__).'/snmp_include.inc');
-
-//EXPECTF format is quickprint OFF
-snmp_set_quick_print(false);
-snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
-
-$session = new SNMP(SNMP_VERSION_3, $hostname, $user_noauth, $timeout, $retries);
-$session->set_security('noAuthNoPriv');
-
-#echo "Checking error handling\n";
-var_dump($session->set_security());
-var_dump($session->set_security(''));
-var_dump($session->set_security('bugusPriv'));
-var_dump($session->set_security('authNoPriv', 'TTT'));
-var_dump($session->set_security('authNoPriv', 'MD5', ''));
-var_dump($session->set_security('authNoPriv', 'MD5', 'te'));
-var_dump($session->set_security('authPriv', 'MD5', $auth_pass, 'BBB'));
-var_dump($session->set_security('authPriv', 'MD5', $auth_pass, 'AES', ''));
-var_dump($session->set_security('authPriv', 'MD5', $auth_pass, 'AES', 'ty'));
-var_dump($session->set_security('authPriv', 'MD5', $auth_pass, 'AES', 'test12345', 'context', 'dsa'));
-
-var_dump($session->close());
-
-?>
---EXPECTF--
-
-Warning: SNMP::set_security() expects at least 1 parameter, 0 given in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Invalid security level '' in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Invalid security level 'bugusPriv' in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Unknown authentication protocol 'TTT' in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Unknown security protocol 'BBB' in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
-bool(false)
-
-Warning: SNMP::set_security(): Bad engine ID value 'dsa' in %s on line %d
-bool(false)
-bool(true)
\ No newline at end of file
index 70bc86a6c9155c624adfee6637a9fd6b5b85eace..d27e9db0a60d63fea352217ec857b351045698c6 100644 (file)
@@ -69,21 +69,21 @@ var_dump($session->close());
 
 echo "SNMPv3 (default security settings)\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, $user_noauth, $timeout, $retries);
-#$session->set_security($user_noauth, 'noAuthNoPriv', '', '', '', '', '', '');
+#$session->setSecurity($user_noauth, 'noAuthNoPriv', '', '', '', '', '', '');
 var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->close());
 
 echo "SNMPv3 (noAuthNoPriv)\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, $user_noauth, $timeout, $retries);
-$session->set_security('noAuthNoPriv');
+$session->setSecurity('noAuthNoPriv');
 var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->close());
 
 echo "SNMPv3 (authPriv)\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, $rwuser, $timeout, $retries);
-$session->set_security('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
 var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->walk('.1.3.6.1.2.1.1.1.0'));
@@ -91,7 +91,7 @@ var_dump($session->close());
 
 echo "SET single OID\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, $rwuser, $timeout, $retries);
-$session->set_security('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
 $oid1 = 'SNMPv2-MIB::sysContact.0';
 $oldvalue1 = $session->get($oid1);
 $newvalue1 = $oldvalue1 . '0';
@@ -106,7 +106,7 @@ var_dump($session->close());
 
 echo "SNMPv3, setting contextEngineID (authPriv)\n";
 $session = new SNMP(SNMP_VERSION_3, $hostname, $rwuser, $timeout, $retries);
-$session->set_security('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '', 'aeeeff');
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '', 'aeeeff');
 var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
 var_dump($session->close());
 
@@ -174,4 +174,4 @@ bool(true)
 bool(true)
 SNMPv3, setting contextEngineID (authPriv)
 string(%d) "%S"
-bool(true)
\ No newline at end of file
+bool(true)
index e8106d81ccd2e3458320c9e3ae5f2f5a46d1fd5c..af0baa3fdde0e36d4510513211a7ab1b9c8b13b8 100644 (file)
@@ -56,4 +56,4 @@ Single OID
 bool(true)
 bool(true)
 bool(true)
-bool(true)
\ No newline at end of file
+bool(true)
index 26551e7744bb49177cae36b7bbdaaf668aabd1f5..b2e51da3f91bbce4c61a3c4e11e8b73a8b0ae49a 100644 (file)
@@ -73,4 +73,4 @@ Warning: snmp3_set(): Invalid object identifier: .1.3.6.777...7.5.3 in %s on lin
 bool(false)
 
 Warning: snmp3_set(): Single objid and multiple type or values are not supported in %s on line %d
-bool(false)
\ No newline at end of file
+bool(false)
index 39a455bafe0313e9b8798279b49b8e7320452598..7428e57c788290a74261916f0a302c9de0b60c21 100644 (file)
@@ -57,4 +57,4 @@ Single OID
 bool(true)
 bool(true)
 bool(true)
-bool(true)
\ No newline at end of file
+bool(true)
index 7b56e5c29446a113d19c62696b02d8bb5fba8961..1227318078cbf1fc6e5b16bea0db48e1c6ba7f99 100644 (file)
@@ -19,4 +19,4 @@ var_dump(snmpget('192.168..6.1', 'community', '.1.3.6.1.2.1.1.1.0', $timeout, $r
 ?>
 --EXPECTF--
 Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (%s) in %s on line %d
-bool(false)
\ No newline at end of file
+bool(false)