Source for file rfc1902.php

Documentation is available at rfc1902.php

  1. <?php
  2. /**
  3. * phpsnmp - a PHP SNMP library
  4. *
  5. * Copyright (C) 2004 David Eder <david@eder,us>
  6. *
  7. * Based on snmp - a Python SNMP library
  8. * Copyright (C) 2003 Unicity Pty Ltd <libsnmp@unicity.com.au>
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. * @author David Eder <david@eder.us>
  25. * @copyright 2004 David Eder
  26. * @package phpSNMP
  27. * @subpackage rfc1902
  28. * @version .7
  29. */
  30.  
  31. /**
  32. */
  33. define('ASN_TAG_COUNTER64', 0x06);
  34.  
  35. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php');
  36.  
  37. /*** These tags are commented because they don't add any funcionality and conflict with rfc1155 codes ***/
  38. // $ASN_TAG_DICT[0x41] = 'rfc1902_Counter32';
  39. // $ASN_TAG_DICT[0x42] = 'rfc1902_Guage32';
  40.  
  41. $ASN_TAG_DICT[0x46] = 'rfc1902_Counter64';
  42.  
  43. /**
  44. * Integer32
  45. *
  46. * A 32 bit integer
  47. *
  48. * @package phpSNMP
  49. * @subpackage rfc1902
  50. */
  51. class rfc1902_Integer32 extends rfc1155_Integer
  52. {
  53. /**
  54. * Constructor
  55. *
  56. * @param integer $value
  57. */
  58. function rfc1902_Integer32($value)
  59. {
  60. parent::rfc1155_Integer($value);
  61. }
  62. }
  63.  
  64. /**
  65. * Counter32
  66. *
  67. * A 32 bit counter
  68. *
  69. * @package phpSNMP
  70. * @subpackage rfc1902
  71. */
  72. class rfc1902_Counter32 extends rfc1155_Counter
  73. {
  74. /**
  75. * Constructor
  76. *
  77. * @param integer $value
  78. */
  79. function rfc1902_Counter32($value)
  80. {
  81. parent::rfc1155_Counter($value);
  82. }
  83. }
  84.  
  85. /**
  86. * Guage32
  87. *
  88. * A 32 bit guage
  89. *
  90. * @package phpSNMP
  91. * @subpackage rfc1902
  92. */
  93. class rfc1902_Guage32 extends rfc1155_Guage
  94. {
  95. /**
  96. * Constructor
  97. *
  98. * @param integer $value
  99. */
  100. function rfc1902_Guage32($value)
  101. {
  102. parent::rfc1155_Guage($value);
  103. }
  104. }
  105.  
  106. /**
  107. * Counter64
  108. *
  109. * A 64 bit counter
  110. *
  111. * @package phpSNMP
  112. * @subpackage rfc1902
  113. */
  114. class rfc1902_Counter64 extends rfc1155_Counter
  115. {
  116. /**
  117. * Constructor
  118. *
  119. * @param integer $value
  120. */
  121. function rfc1902_Counter64($value=0)
  122. {
  123. $this->check_range($value, 0, 18446744073709551615);
  124. parent::rfc1155_Counter($value);
  125. $this->asnTagClass = ASN_TAG_COUNTER64;
  126. }
  127. }
  128.  
  129. /**
  130. * Octet String
  131. *
  132. * An SNMP v2 OctetString must be between 0 and 65535 bytes in length
  133. *
  134. * @package phpSNMP
  135. * @subpackage rfc1902
  136. */
  137. class rfc1902_OctetString extends rfc1155_OctetString
  138. {
  139. /**
  140. * Constructor
  141. *
  142. * @param string $value
  143. */
  144. function rfc1902_OctetString($value)
  145. {
  146. if(strlen($value) > 65535)
  147. trigger_error('OctetString must be shorter than 65535 bytes', E_USER_WARNING);
  148. parent::rfc1155_OctetString($value);
  149. }
  150. }
  151. ?>

Documentation generated on Mon, 14 Nov 2005 17:55:22 -0700 by phpDocumentor 1.3.0RC3