Source for file docsis_snmp_v3.php

Documentation is available at docsis_snmp_v3.php

  1. <?php
  2. /**
  3. * DOCSIS SNMP v3
  4. *
  5. * @author David Eder <david@eder.us>
  6. * @copyright 2004 David Eder
  7. * @package docsis_config
  8. * @version .1
  9. */
  10.  
  11. /**
  12. */
  13. require_once('docsis_common.php');
  14.  
  15. define('DOCSIS_SNMP_V3_KICKSTART', 34);
  16. define('DOCSIS_SNMP_V3_SECURITY_NAME', 1);
  17. define('DOCSIS_SNMP_V3_MANAGER_PUBLIC_NUMBER', 2);
  18. define('DOCSIS_SNMP_V3_TRAP', 38);
  19. define('DOCSIS_SNMP_V3_TRAP_ADDRESS', 1);
  20. define('DOCSIS_SNMP_V3_TRAP_PORT', 2);
  21. define('DOCSIS_SNMP_V3_TRAP_TYPE', 3);
  22. define('DOCSIS_SNMP_V3_TRAP_TIMEOUT', 4);
  23. define('DOCSIS_SNMP_V3_TRAP_RETRIES', 5);
  24. define('DOCSIS_SNMP_V3_TRAP_FILTER', 6);
  25. define('DOCSIS_SNMP_V3_TRAP_SECURITY_NAME', 7);
  26.  
  27. /**
  28. * DOCSIS SNMP v3 Kickstart
  29. *
  30. * @package docsis_config
  31. * @subpackage docsis_snmp_v3
  32. */
  33. class docsis_snmp_v3_kickstart extends docsis_encoder_complex
  34. {
  35. /**
  36. * Constructor
  37. *
  38. * @param int $code docsis code
  39. * @param array $value predefined values
  40. */
  41. function docsis_snmp_v3_kickstart($code=DOCSIS_SNMP_V3_KICKSTART, $value=array())
  42. {
  43. parent::docsis_encoder_complex($code, $value);
  44. }
  45.  
  46. /**
  47. * Set Security Name
  48. *
  49. * @param string $value
  50. */
  51. function set_security_name($value)
  52. {
  53. if(strlen($value) < 2 || strlen($value) > 16) trigger_error('Security Name must be 2 to 16 characters', E_USER_WARNING);
  54. $this->value[DOCSIS_SNMP_V3_SECURITY_NAME] = new docsis_encoder_string(DOCSIS_SNMP_V3_SECURITY_NAME, $value);
  55. }
  56.  
  57. /**
  58. * Set Manager Public Number
  59. *
  60. * This number is the Diffe-Helman public number derived from a privately (by the manager or operator) generated random number and transformed
  61. * according to RFC-2786. This is reported in the usmDHKickStartTable as usmKickstartMgrPublic. When combined with the object reported in the
  62. * same row as usmKickstartMyPublicit can be used to derive keys in the related row in the usmUserTable.
  63. *
  64. * @param string $value
  65. */
  66. function set_manager_public_number($value)
  67. {
  68. $this->value[DOCSIS_SNMP_V3_MANAGER_PUBLIC_NUMBER] = new docsis_encoder_hex_string(DOCSIS_SNMP_V3_MANAGER_PUBLIC_NUMBER, $value);
  69. }
  70. }
  71.  
  72. /**
  73. * DOCSIS SNMP v3 Notification Receiver
  74. *
  75. * @package docsis_config
  76. * @subpackage docsis_snmp_v3
  77. */
  78. class docsis_snmp_v3_trap extends docsis_encoder_complex
  79. {
  80. /**
  81. * Constructor
  82. *
  83. * @param int $code docsis code
  84. * @param array $value predefined values
  85. */
  86. function docsis_snmp_v3_trap($code=DOCSIS_SNMP_V3_TRAP, $value=array())
  87. {
  88. parent::docsis_encoder_complex($code, $value);
  89. }
  90.  
  91. /**
  92. * Set IP Address
  93. *
  94. * @param string $ip
  95. */
  96. function set_address($ip)
  97. {
  98. $this->value[DOCSIS_SNMP_V3_TRAP_ADDRESS] = new docsis_encoder_ip(DOCSIS_SNMP_V3_TRAP_ADDRESS, $ip);
  99. }
  100.  
  101. /**
  102. * Set UDP Port Number
  103. *
  104. * @param int $port
  105. */
  106. function set_port($port)
  107. {
  108. $this->value[DOCSIS_SNMP_V3_TRAP_PORT] = new docsis_encoder_ushort(DOCSIS_SNMP_V3_TRAP_PORT, $port);
  109. }
  110.  
  111. /**
  112. * Set Type
  113. *
  114. * <ul>
  115. * <li><b>1</b> SNMP v1 trap in an SNMP v1 packet</li>
  116. * <li><b>2</b> SNMP v2c trap in an SNMP v2c packet</li>
  117. * <li><b>3</b> SNMP v2c inform in an SNMP v2c packet</li>
  118. * <li><b>4</b> SNMP v2c trap in an SNMP v3 packet</li>
  119. * <li><b>4</b> SNMP inform in an SNMP v3 packet</li>
  120. * </ul>
  121. *
  122. * @param int $value
  123. function set_type($value)
  124. {
  125. if($value < 1 || $value > 5) trigger_error('Type must by 1 to 5', E_USER_WARNING);
  126. $this->value[DOCSIS_SNMP_V3_TRAP_TYPE] = new docsis_encoder_ushort(DOCSIS_SNMP_V3_TRAP_TYPE, $value);
  127. }
  128. /**
  129. * Set Receiver Timeout
  130. *
  131. * This specifies the round trip timeout used to wait before sending a retry of an inform notification if sender does not get an
  132. * acknowledgement from the receiver. Defaults to 15000 if not set.
  133. *
  134. * @param int $value in milliseconds
  135. */
  136. function set_timeout($value)
  137. {
  138. $this->value[DOCSIS_SNMP_V3_TRAP_TIMEOUT] = new docsis_encoder_ushort(DOCSIS_SNMP_V3_TRAP_TIMEOUT, $value);
  139. }
  140.  
  141. /**
  142. * Set Receiver Retries
  143. *
  144. * Defines the number of times to retry an Inform after the first Inform transmission. Defaults to 3.
  145. *
  146. * @param int $value
  147. */
  148. function set_retries($value)
  149. {
  150. if($value < 0 || $value > 255) trigger_error('Retries must by 0 to 255', E_USER_WARNING);
  151. $this->value[DOCSIS_SNMP_V3_TRAP_RETRIES] = new docsis_encoder_ushort(DOCSIS_SNMP_V3_TRAP_RETRIES, $value);
  152. }
  153.  
  154. /**
  155. * Set Filtering Parameters
  156. *
  157. * Specifies the OID of the snmpTrapOID value that is the root of the MIB subtree that defines all of the notifications to be sent
  158. * to the Notification Receiver.
  159. *
  160. * @param string $oid
  161. */
  162. function set_filter($oid)
  163. {
  164. $this->value[DOCSIS_SNMP_V3_TRAP_FILTER] = new docsis_encoder_oid(DOCSIS_SNMP_V3_TRAP_FILTER, $oid);
  165. }
  166.  
  167. /**
  168. * Set Reciever Security Name
  169. *
  170. * When Trap of Type value field is set to 1, 2, or 3, this value should not be intrepreted (has no meaning) and Informs messages will be
  171. * sent with community string "public". In the case of Trap of Type 4 or 5, two situations happent:
  172. * <ul>
  173. * <li>If the Security Name is not set, the V3 Notification will be sent in the NoAuthNoPriv security level using security name "@config".</li>
  174. * <li>If the Security Name is set, $value must be the same as set in the DH Kickstart procedure. The notifications will be sent using
  175. * the Authenficiation and Privacy Keys calculated by the modem during the DH Kickstart procedure.</li>
  176. * </ul>
  177. *
  178. * @param string $value
  179. */
  180. function set_security_name($value)
  181. {
  182. if(strlen($value) < 2 || strlen($value) > 16) trigger_error('Security Name must be 2 to 16 characters', E_USER_WARNING);
  183. $this->value[DOCSIS_SNMP_V3_TRAP_SECURITY_NAME] = new docsis_encoder_string(DOCSIS_SNMP_V3_TRAP_SECURITY_NAME, $value);
  184. }
  185. }
  186. ?>

Documentation generated on Mon, 14 Nov 2005 18:00:32 -0700 by phpDocumentor 1.3.0RC3