├── COPYRIGHT ├── ChangeLog ├── LICENSE ├── README.md ├── composer.json ├── mib_compiler.php ├── oid_format.data ├── oid_format.php ├── rfc1155.php ├── rfc1157.php ├── rfc1902.php ├── rfc1905.php ├── rfc2104.php ├── rfc3411.php ├── rfc3412.php ├── rfc3414.php ├── snmp.php ├── test.php └── v3test.php /COPYRIGHT: -------------------------------------------------------------------------------- 1 | phpsnmp - a PHP SNMP library 2 | Copyright (C) 2004 David Eder 3 | 4 | Based on snmp - a Python SNMP library 5 | Copyright (C) 2003 Unicity Pty Ltd 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2005-11-11 David Eder 2 | * Finished snmp v3 support 3 | 4 | 2005-08-05 David Eder 5 | * Updated rfc1155_Counter to allow an alternate decoding for 6 | values that should decode as negative. (SNMP_ABS_COUNTER) 7 | 8 | 2005-08-01 David Eder 9 | * Updated is_printable to accept \r, \n and \t. 10 | 11 | 2005-06-09 David Eder 12 | 13 | * Update build_varbind to support multiple objects 14 | 15 | 2004-10-06 David Eder 16 | 17 | * Added simple MIB compiler. 18 | 19 | 2004-10-04 David Eder 20 | 21 | * Hybridized blocking/nonblocking socket I/O to decrease CPU load 22 | while waiting for timeout. 23 | 24 | 2004-08-27 David Eder 25 | 26 | * Added v2 Bulk Get. 27 | 28 | 2004-08-24 David Eder 29 | 30 | * Fixed bug for ObjectIDs not starting with a dot. 31 | * Added a flag for short int based length encoding to be compatible 32 | with Cisco software. 33 | 34 | 2004-08-16 David Eder 35 | 36 | * Added Trap support. 37 | * Fixed bug encoding IPAddresses. 38 | 39 | 2004-08-12 David Eder 40 | 41 | * Added support for multi_get, multi_walk, and multi_set to poll 42 | in parallel. 43 | * Removed packet cache (should never have been added in the first 44 | place). 45 | 46 | 2004-08-10 David Eder 47 | 48 | * Fixed bug that allowed arbitrary hosts to inject packets. 49 | * Added microsleep to help keep load in check while waiting for 50 | packets. 51 | 52 | 2004-08-02 David Eder 53 | 54 | * Added timeout. 55 | * Added packet cache. 56 | * Added 'x' integer, 't' time ticks, 'x' hex string, 's' string, 57 | 'a' ip address, 'o' object id, and 'n' null types to snmp::set. 58 | * Change several bitwise operations to arithmetic to avoid overflow 59 | to float problems. 60 | 61 | 2004-07-06 David Eder 62 | 63 | * Converted needed portions of library to PHP. 64 | * Replaced management with an smnp class. 65 | 66 | 2003-10-26 Justin Warren 67 | 68 | * Added SNMPv2 support and fixed compatibility bugs caused 69 | by ucd-snmp returning Context Specific tags. 70 | 71 | 2003-09-21 Justin Warren 72 | 73 | * Added licensing information to release under LGPL. 74 | 75 | 2003-09-19 Jim Crumpler 76 | 77 | * lib/libsnmp/rfc1155.py (OctetString.decodeContents): changed all 78 | decodeContents() methods to set the local value of the object and 79 | to return self. This saves alot of object creations, however we 80 | need to make sure we don't use an object as a factory and expect 81 | its value to not change. 82 | 83 | 2003-09-18 Jim Crumpler 84 | 85 | * lib/libsnmp/rfc1155.py (Asn1Object.decode): move the tag and 86 | length portions of decode() to decodeTag() and decodeLength() 87 | 88 | 0.0.1 2003-08-13 Justin Warren 89 | 90 | * First version of libsnmp added to CVS 91 | 92 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # $Id: LICENSE,v 1.1 2003/09/16 06:43:17 daedalus Exp $ 2 | # $Revision: 1.1 $ 3 | 4 | GNU LESSER GENERAL PUBLIC LICENSE 5 | Version 2.1, February 1999 6 | 7 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 8 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | Everyone is permitted to copy and distribute verbatim copies 10 | of this license document, but changing it is not allowed. 11 | 12 | [This is the first released version of the Lesser GPL. It also counts 13 | as the successor of the GNU Library Public License, version 2, hence 14 | the version number 2.1.] 15 | 16 | Preamble 17 | 18 | The licenses for most software are designed to take away your 19 | freedom to share and change it. By contrast, the GNU General Public 20 | Licenses are intended to guarantee your freedom to share and change 21 | free software--to make sure the software is free for all its users. 22 | 23 | This license, the Lesser General Public License, applies to some 24 | specially designated software packages--typically libraries--of the 25 | Free Software Foundation and other authors who decide to use it. You 26 | can use it too, but we suggest you first think carefully about whether 27 | this license or the ordinary General Public License is the better 28 | strategy to use in any particular case, based on the explanations below. 29 | 30 | When we speak of free software, we are referring to freedom of use, 31 | not price. Our General Public Licenses are designed to make sure that 32 | you have the freedom to distribute copies of free software (and charge 33 | for this service if you wish); that you receive source code or can get 34 | it if you want it; that you can change the software and use pieces of 35 | it in new free programs; and that you are informed that you can do 36 | these things. 37 | 38 | To protect your rights, we need to make restrictions that forbid 39 | distributors to deny you these rights or to ask you to surrender these 40 | rights. These restrictions translate to certain responsibilities for 41 | you if you distribute copies of the library or if you modify it. 42 | 43 | For example, if you distribute copies of the library, whether gratis 44 | or for a fee, you must give the recipients all the rights that we gave 45 | you. You must make sure that they, too, receive or can get the source 46 | code. If you link other code with the library, you must provide 47 | complete object files to the recipients, so that they can relink them 48 | with the library after making changes to the library and recompiling 49 | it. And you must show them these terms so they know their rights. 50 | 51 | We protect your rights with a two-step method: (1) we copyright the 52 | library, and (2) we offer you this license, which gives you legal 53 | permission to copy, distribute and/or modify the library. 54 | 55 | To protect each distributor, we want to make it very clear that 56 | there is no warranty for the free library. Also, if the library is 57 | modified by someone else and passed on, the recipients should know 58 | that what they have is not the original version, so that the original 59 | author's reputation will not be affected by problems that might be 60 | introduced by others. 61 | 62 | Finally, software patents pose a constant threat to the existence of 63 | any free program. We wish to make sure that a company cannot 64 | effectively restrict the users of a free program by obtaining a 65 | restrictive license from a patent holder. Therefore, we insist that 66 | any patent license obtained for a version of the library must be 67 | consistent with the full freedom of use specified in this license. 68 | 69 | Most GNU software, including some libraries, is covered by the 70 | ordinary GNU General Public License. This license, the GNU Lesser 71 | General Public License, applies to certain designated libraries, and 72 | is quite different from the ordinary General Public License. We use 73 | this license for certain libraries in order to permit linking those 74 | libraries into non-free programs. 75 | 76 | When a program is linked with a library, whether statically or using 77 | a shared library, the combination of the two is legally speaking a 78 | combined work, a derivative of the original library. The ordinary 79 | General Public License therefore permits such linking only if the 80 | entire combination fits its criteria of freedom. The Lesser General 81 | Public License permits more lax criteria for linking other code with 82 | the library. 83 | 84 | We call this license the "Lesser" General Public License because it 85 | does Less to protect the user's freedom than the ordinary General 86 | Public License. It also provides other free software developers Less 87 | of an advantage over competing non-free programs. These disadvantages 88 | are the reason we use the ordinary General Public License for many 89 | libraries. However, the Lesser license provides advantages in certain 90 | special circumstances. 91 | 92 | For example, on rare occasions, there may be a special need to 93 | encourage the widest possible use of a certain library, so that it becomes 94 | a de-facto standard. To achieve this, non-free programs must be 95 | allowed to use the library. A more frequent case is that a free 96 | library does the same job as widely used non-free libraries. In this 97 | case, there is little to gain by limiting the free library to free 98 | software only, so we use the Lesser General Public License. 99 | 100 | In other cases, permission to use a particular library in non-free 101 | programs enables a greater number of people to use a large body of 102 | free software. For example, permission to use the GNU C Library in 103 | non-free programs enables many more people to use the whole GNU 104 | operating system, as well as its variant, the GNU/Linux operating 105 | system. 106 | 107 | Although the Lesser General Public License is Less protective of the 108 | users' freedom, it does ensure that the user of a program that is 109 | linked with the Library has the freedom and the wherewithal to run 110 | that program using a modified version of the Library. 111 | 112 | The precise terms and conditions for copying, distribution and 113 | modification follow. Pay close attention to the difference between a 114 | "work based on the library" and a "work that uses the library". The 115 | former contains code derived from the library, whereas the latter must 116 | be combined with the library in order to run. 117 | 118 | GNU LESSER GENERAL PUBLIC LICENSE 119 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 120 | 121 | 0. This License Agreement applies to any software library or other 122 | program which contains a notice placed by the copyright holder or 123 | other authorized party saying it may be distributed under the terms of 124 | this Lesser General Public License (also called "this License"). 125 | Each licensee is addressed as "you". 126 | 127 | A "library" means a collection of software functions and/or data 128 | prepared so as to be conveniently linked with application programs 129 | (which use some of those functions and data) to form executables. 130 | 131 | The "Library", below, refers to any such software library or work 132 | which has been distributed under these terms. A "work based on the 133 | Library" means either the Library or any derivative work under 134 | copyright law: that is to say, a work containing the Library or a 135 | portion of it, either verbatim or with modifications and/or translated 136 | straightforwardly into another language. (Hereinafter, translation is 137 | included without limitation in the term "modification".) 138 | 139 | "Source code" for a work means the preferred form of the work for 140 | making modifications to it. For a library, complete source code means 141 | all the source code for all modules it contains, plus any associated 142 | interface definition files, plus the scripts used to control compilation 143 | and installation of the library. 144 | 145 | Activities other than copying, distribution and modification are not 146 | covered by this License; they are outside its scope. The act of 147 | running a program using the Library is not restricted, and output from 148 | such a program is covered only if its contents constitute a work based 149 | on the Library (independent of the use of the Library in a tool for 150 | writing it). Whether that is true depends on what the Library does 151 | and what the program that uses the Library does. 152 | 153 | 1. You may copy and distribute verbatim copies of the Library's 154 | complete source code as you receive it, in any medium, provided that 155 | you conspicuously and appropriately publish on each copy an 156 | appropriate copyright notice and disclaimer of warranty; keep intact 157 | all the notices that refer to this License and to the absence of any 158 | warranty; and distribute a copy of this License along with the 159 | Library. 160 | 161 | You may charge a fee for the physical act of transferring a copy, 162 | and you may at your option offer warranty protection in exchange for a 163 | fee. 164 | 165 | 2. You may modify your copy or copies of the Library or any portion 166 | of it, thus forming a work based on the Library, and copy and 167 | distribute such modifications or work under the terms of Section 1 168 | above, provided that you also meet all of these conditions: 169 | 170 | a) The modified work must itself be a software library. 171 | 172 | b) You must cause the files modified to carry prominent notices 173 | stating that you changed the files and the date of any change. 174 | 175 | c) You must cause the whole of the work to be licensed at no 176 | charge to all third parties under the terms of this License. 177 | 178 | d) If a facility in the modified Library refers to a function or a 179 | table of data to be supplied by an application program that uses 180 | the facility, other than as an argument passed when the facility 181 | is invoked, then you must make a good faith effort to ensure that, 182 | in the event an application does not supply such function or 183 | table, the facility still operates, and performs whatever part of 184 | its purpose remains meaningful. 185 | 186 | (For example, a function in a library to compute square roots has 187 | a purpose that is entirely well-defined independent of the 188 | application. Therefore, Subsection 2d requires that any 189 | application-supplied function or table used by this function must 190 | be optional: if the application does not supply it, the square 191 | root function must still compute square roots.) 192 | 193 | These requirements apply to the modified work as a whole. If 194 | identifiable sections of that work are not derived from the Library, 195 | and can be reasonably considered independent and separate works in 196 | themselves, then this License, and its terms, do not apply to those 197 | sections when you distribute them as separate works. But when you 198 | distribute the same sections as part of a whole which is a work based 199 | on the Library, the distribution of the whole must be on the terms of 200 | this License, whose permissions for other licensees extend to the 201 | entire whole, and thus to each and every part regardless of who wrote 202 | it. 203 | 204 | Thus, it is not the intent of this section to claim rights or contest 205 | your rights to work written entirely by you; rather, the intent is to 206 | exercise the right to control the distribution of derivative or 207 | collective works based on the Library. 208 | 209 | In addition, mere aggregation of another work not based on the Library 210 | with the Library (or with a work based on the Library) on a volume of 211 | a storage or distribution medium does not bring the other work under 212 | the scope of this License. 213 | 214 | 3. You may opt to apply the terms of the ordinary GNU General Public 215 | License instead of this License to a given copy of the Library. To do 216 | this, you must alter all the notices that refer to this License, so 217 | that they refer to the ordinary GNU General Public License, version 2, 218 | instead of to this License. (If a newer version than version 2 of the 219 | ordinary GNU General Public License has appeared, then you can specify 220 | that version instead if you wish.) Do not make any other change in 221 | these notices. 222 | 223 | Once this change is made in a given copy, it is irreversible for 224 | that copy, so the ordinary GNU General Public License applies to all 225 | subsequent copies and derivative works made from that copy. 226 | 227 | This option is useful when you wish to copy part of the code of 228 | the Library into a program that is not a library. 229 | 230 | 4. You may copy and distribute the Library (or a portion or 231 | derivative of it, under Section 2) in object code or executable form 232 | under the terms of Sections 1 and 2 above provided that you accompany 233 | it with the complete corresponding machine-readable source code, which 234 | must be distributed under the terms of Sections 1 and 2 above on a 235 | medium customarily used for software interchange. 236 | 237 | If distribution of object code is made by offering access to copy 238 | from a designated place, then offering equivalent access to copy the 239 | source code from the same place satisfies the requirement to 240 | distribute the source code, even though third parties are not 241 | compelled to copy the source along with the object code. 242 | 243 | 5. A program that contains no derivative of any portion of the 244 | Library, but is designed to work with the Library by being compiled or 245 | linked with it, is called a "work that uses the Library". Such a 246 | work, in isolation, is not a derivative work of the Library, and 247 | therefore falls outside the scope of this License. 248 | 249 | However, linking a "work that uses the Library" with the Library 250 | creates an executable that is a derivative of the Library (because it 251 | contains portions of the Library), rather than a "work that uses the 252 | library". The executable is therefore covered by this License. 253 | Section 6 states terms for distribution of such executables. 254 | 255 | When a "work that uses the Library" uses material from a header file 256 | that is part of the Library, the object code for the work may be a 257 | derivative work of the Library even though the source code is not. 258 | Whether this is true is especially significant if the work can be 259 | linked without the Library, or if the work is itself a library. The 260 | threshold for this to be true is not precisely defined by law. 261 | 262 | If such an object file uses only numerical parameters, data 263 | structure layouts and accessors, and small macros and small inline 264 | functions (ten lines or less in length), then the use of the object 265 | file is unrestricted, regardless of whether it is legally a derivative 266 | work. (Executables containing this object code plus portions of the 267 | Library will still fall under Section 6.) 268 | 269 | Otherwise, if the work is a derivative of the Library, you may 270 | distribute the object code for the work under the terms of Section 6. 271 | Any executables containing that work also fall under Section 6, 272 | whether or not they are linked directly with the Library itself. 273 | 274 | 6. As an exception to the Sections above, you may also combine or 275 | link a "work that uses the Library" with the Library to produce a 276 | work containing portions of the Library, and distribute that work 277 | under terms of your choice, provided that the terms permit 278 | modification of the work for the customer's own use and reverse 279 | engineering for debugging such modifications. 280 | 281 | You must give prominent notice with each copy of the work that the 282 | Library is used in it and that the Library and its use are covered by 283 | this License. You must supply a copy of this License. If the work 284 | during execution displays copyright notices, you must include the 285 | copyright notice for the Library among them, as well as a reference 286 | directing the user to the copy of this License. Also, you must do one 287 | of these things: 288 | 289 | a) Accompany the work with the complete corresponding 290 | machine-readable source code for the Library including whatever 291 | changes were used in the work (which must be distributed under 292 | Sections 1 and 2 above); and, if the work is an executable linked 293 | with the Library, with the complete machine-readable "work that 294 | uses the Library", as object code and/or source code, so that the 295 | user can modify the Library and then relink to produce a modified 296 | executable containing the modified Library. (It is understood 297 | that the user who changes the contents of definitions files in the 298 | Library will not necessarily be able to recompile the application 299 | to use the modified definitions.) 300 | 301 | b) Use a suitable shared library mechanism for linking with the 302 | Library. A suitable mechanism is one that (1) uses at run time a 303 | copy of the library already present on the user's computer system, 304 | rather than copying library functions into the executable, and (2) 305 | will operate properly with a modified version of the library, if 306 | the user installs one, as long as the modified version is 307 | interface-compatible with the version that the work was made with. 308 | 309 | c) Accompany the work with a written offer, valid for at 310 | least three years, to give the same user the materials 311 | specified in Subsection 6a, above, for a charge no more 312 | than the cost of performing this distribution. 313 | 314 | d) If distribution of the work is made by offering access to copy 315 | from a designated place, offer equivalent access to copy the above 316 | specified materials from the same place. 317 | 318 | e) Verify that the user has already received a copy of these 319 | materials or that you have already sent this user a copy. 320 | 321 | For an executable, the required form of the "work that uses the 322 | Library" must include any data and utility programs needed for 323 | reproducing the executable from it. However, as a special exception, 324 | the materials to be distributed need not include anything that is 325 | normally distributed (in either source or binary form) with the major 326 | components (compiler, kernel, and so on) of the operating system on 327 | which the executable runs, unless that component itself accompanies 328 | the executable. 329 | 330 | It may happen that this requirement contradicts the license 331 | restrictions of other proprietary libraries that do not normally 332 | accompany the operating system. Such a contradiction means you cannot 333 | use both them and the Library together in an executable that you 334 | distribute. 335 | 336 | 7. You may place library facilities that are a work based on the 337 | Library side-by-side in a single library together with other library 338 | facilities not covered by this License, and distribute such a combined 339 | library, provided that the separate distribution of the work based on 340 | the Library and of the other library facilities is otherwise 341 | permitted, and provided that you do these two things: 342 | 343 | a) Accompany the combined library with a copy of the same work 344 | based on the Library, uncombined with any other library 345 | facilities. This must be distributed under the terms of the 346 | Sections above. 347 | 348 | b) Give prominent notice with the combined library of the fact 349 | that part of it is a work based on the Library, and explaining 350 | where to find the accompanying uncombined form of the same work. 351 | 352 | 8. You may not copy, modify, sublicense, link with, or distribute 353 | the Library except as expressly provided under this License. Any 354 | attempt otherwise to copy, modify, sublicense, link with, or 355 | distribute the Library is void, and will automatically terminate your 356 | rights under this License. However, parties who have received copies, 357 | or rights, from you under this License will not have their licenses 358 | terminated so long as such parties remain in full compliance. 359 | 360 | 9. You are not required to accept this License, since you have not 361 | signed it. However, nothing else grants you permission to modify or 362 | distribute the Library or its derivative works. These actions are 363 | prohibited by law if you do not accept this License. Therefore, by 364 | modifying or distributing the Library (or any work based on the 365 | Library), you indicate your acceptance of this License to do so, and 366 | all its terms and conditions for copying, distributing or modifying 367 | the Library or works based on it. 368 | 369 | 10. Each time you redistribute the Library (or any work based on the 370 | Library), the recipient automatically receives a license from the 371 | original licensor to copy, distribute, link with or modify the Library 372 | subject to these terms and conditions. You may not impose any further 373 | restrictions on the recipients' exercise of the rights granted herein. 374 | You are not responsible for enforcing compliance by third parties with 375 | this License. 376 | 377 | 11. If, as a consequence of a court judgment or allegation of patent 378 | infringement or for any other reason (not limited to patent issues), 379 | conditions are imposed on you (whether by court order, agreement or 380 | otherwise) that contradict the conditions of this License, they do not 381 | excuse you from the conditions of this License. If you cannot 382 | distribute so as to satisfy simultaneously your obligations under this 383 | License and any other pertinent obligations, then as a consequence you 384 | may not distribute the Library at all. For example, if a patent 385 | license would not permit royalty-free redistribution of the Library by 386 | all those who receive copies directly or indirectly through you, then 387 | the only way you could satisfy both it and this License would be to 388 | refrain entirely from distribution of the Library. 389 | 390 | If any portion of this section is held invalid or unenforceable under any 391 | particular circumstance, the balance of the section is intended to apply, 392 | and the section as a whole is intended to apply in other circumstances. 393 | 394 | It is not the purpose of this section to induce you to infringe any 395 | patents or other property right claims or to contest validity of any 396 | such claims; this section has the sole purpose of protecting the 397 | integrity of the free software distribution system which is 398 | implemented by public license practices. Many people have made 399 | generous contributions to the wide range of software distributed 400 | through that system in reliance on consistent application of that 401 | system; it is up to the author/donor to decide if he or she is willing 402 | to distribute software through any other system and a licensee cannot 403 | impose that choice. 404 | 405 | This section is intended to make thoroughly clear what is believed to 406 | be a consequence of the rest of this License. 407 | 408 | 12. If the distribution and/or use of the Library is restricted in 409 | certain countries either by patents or by copyrighted interfaces, the 410 | original copyright holder who places the Library under this License may add 411 | an explicit geographical distribution limitation excluding those countries, 412 | so that distribution is permitted only in or among countries not thus 413 | excluded. In such case, this License incorporates the limitation as if 414 | written in the body of this License. 415 | 416 | 13. The Free Software Foundation may publish revised and/or new 417 | versions of the Lesser General Public License from time to time. 418 | Such new versions will be similar in spirit to the present version, 419 | but may differ in detail to address new problems or concerns. 420 | 421 | Each version is given a distinguishing version number. If the Library 422 | specifies a version number of this License which applies to it and 423 | "any later version", you have the option of following the terms and 424 | conditions either of that version or of any later version published by 425 | the Free Software Foundation. If the Library does not specify a 426 | license version number, you may choose any version ever published by 427 | the Free Software Foundation. 428 | 429 | 14. If you wish to incorporate parts of the Library into other free 430 | programs whose distribution conditions are incompatible with these, 431 | write to the author to ask for permission. For software which is 432 | copyrighted by the Free Software Foundation, write to the Free 433 | Software Foundation; we sometimes make exceptions for this. Our 434 | decision will be guided by the two goals of preserving the free status 435 | of all derivatives of our free software and of promoting the sharing 436 | and reuse of software generally. 437 | 438 | NO WARRANTY 439 | 440 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 441 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 442 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 443 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 444 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 445 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 446 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 447 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 448 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 449 | 450 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 451 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 452 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 453 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 454 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 455 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 456 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 457 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 458 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 459 | DAMAGES. 460 | 461 | END OF TERMS AND CONDITIONS 462 | 463 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #phpSNMP 2 | 3 | phpSNMP is an SNMP implementation based on libsnmp, which is written in Python. It has been ported to 100% pure PHP. 4 | 5 | **Why not just use the SNMP extension?** 6 | 7 | The data return from the SNMP extension is not uniform accross platforms with different MIBs installed. 8 | The SNMP extension does not support traps. 9 | The SNMP extension does not support parallel gets. 10 | The SNMP extension does not support bulk gets. 11 | The SNMP extension results in semi-frequent core dumps on FreeBSD (I think it has something to do with threads). 12 | The SNMP extension requires building yet another extension into PHP. 13 | 14 | **Usage** 15 | ``` 16 | $z => $zz\n"; 28 | 29 | $ip = '172.16.0.116'; // ip address or hostname 30 | $ips = array($ip, '172.16.0.64'); // array of ip addresses or hostnames 31 | $community = 'public'; // community string 32 | $oid = '.1.3.6.1.2.1.1'; // only numerical oids are supported 33 | $oids = array('.1.3.6.1.2.1.1.1', '.1.3.6.1.2.1.1.3'); 34 | 35 | $snmp = new snmp(); 36 | 37 | $snmp->version = SNMP_VERSION_2; 38 | 39 | print_r($snmp->walk($ip, $oid, ['community' => $community])); 40 | print_r($snmp->multi_walk($ips, $oid, ['community' => $community])); 41 | 42 | 43 | $snmp->version = SNMP_VERSION_3; 44 | print_r($snmp->get('localhost', '.1.3.6.1.2.1.1.3.0', array('v3_flags'=>SNMP_AUTH_PRIV, 'v3_user'=>'v3user', 45 | 'v3_auth'=>'authpassword', 'v3_priv'=>'privpassword'))); 46 | 47 | // get system uptime 48 | print_r($snmp->get($ip, '.1.3.6.1.2.1.1.3.0', ['community' => $community])); 49 | print_r($snmp->multi_get($ips, '.1.3.6.1.2.1.1.3.0', ['community' => $community])); 50 | 51 | // bulk get 52 | print_r($snmp->bulk_get($ip, $oids)); 53 | 54 | // reset cable modem(s) 55 | $oid = '.1.3.6.1.3.83.1.1.4.0.1.1.3.0'; 56 | $snmp->set($ip, $oid, 1, 'i', ['community' => 'private']); 57 | $snmp->multi_set($ips, $oid, 1, 'i', ['community' => 'private']); 58 | 59 | // send a trap 60 | $ip = '123.45.12.3'; 61 | $community = 'public'; 62 | $varbind = $snmp->build_varbind('.1.3.6.1.3.83.1.1.4.1', 17, 'i'); 63 | $enterprise = '.1.3.6.1.3.83.1.1.4.0.1.1.3.0'; 64 | $agent = '127.0.0.1'; 65 | $trap_type = TRAP_LINKUP; 66 | $specific_trap_type = 2; 67 | $uptime = 123; 68 | 69 | $snmp->trap($ip, $community, $varbind, $enterprise, $agent, $trap_type, $specific_trap_type, $uptime); 70 | ?> 71 | ``` 72 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "brexis/phpsnmp", 3 | "description": "phpSNMP is an SNMP implementation based on libsnmp, which is written in Python. It has been ported to 100% pure PHP.", 4 | "type": "library", 5 | "keywords": ["php", "snmp", "net-snmp"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Boris KOUMONDJI", 10 | "email": "brexis2009@yahoo.fr" 11 | } 12 | ], 13 | "autoload": { 14 | "files": ["snmp.php"] 15 | }, 16 | "minimum-stability": "dev", 17 | "require": { 18 | "php": ">=5.6.13" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mib_compiler.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage mib_compiler 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | set_time_limit(0); 35 | ini_set('memory_limit', '256M'); 36 | error_reporting(E_ALL); 37 | 38 | $mc = new mib_compiler(); 39 | $mc->add_mibs('/usr/share/snmp/mibs'); 40 | $mc->compile(); 41 | 42 | /** 43 | * Asn1Objects 44 | * 45 | * Base class for all Asn1Objects. This is only intended to support a specific subset of ASN1 stuff as 46 | * defined by the RFCs to keep things as simple as possible. 47 | * 48 | * @package phpSNMP 49 | * @subpackage mib_compiler 50 | */ 51 | class mib_compiler 52 | { 53 | var $parsed = array(); 54 | var $outfile = 'oid_format.data'; 55 | 56 | /** 57 | * Constructor 58 | */ 59 | public function __construct() 60 | { 61 | } 62 | 63 | /** 64 | * Add mibs 65 | * 66 | * @param string $path 67 | */ 68 | public function add_mibs($path) 69 | { 70 | foreach(glob("$path/*") as $mib) 71 | { 72 | if(is_dir($mib)) 73 | $this->add_mibs($mib); 74 | else 75 | $this->add_mib($mib); 76 | } 77 | } 78 | 79 | /** 80 | * Add a mib 81 | * 82 | * @param string $filename 83 | */ 84 | public function add_mib($filename) 85 | { 86 | echo "Loading $filename\n"; 87 | $this->parse(file_get_contents($filename)); 88 | } 89 | 90 | /** 91 | * Compile mibs 92 | */ 93 | public function compile() 94 | { 95 | echo 'Found ' . count($this->parsed) . " objects\n"; 96 | echo "Building node list\n"; 97 | 98 | $nodes[''] = array(1=>'iso'); 99 | $found['iso'] = 1; 100 | $found[''] = 1; 101 | foreach($this->parsed as $obj) 102 | { 103 | if(isset($obj['VALUE'][0]) && !is_numeric($obj['VALUE'][0])) 104 | { 105 | if(isset($obj['VALUE'][1]) && is_numeric($obj['VALUE'][1])) 106 | { 107 | $nodes[$obj['VALUE'][0]][$obj['VALUE'][1]] = $obj['NAME']; 108 | $found[$obj['NAME']] = 1; 109 | } 110 | } 111 | } 112 | 113 | echo "Trimming disconnected nodes\n"; 114 | foreach(array_keys($nodes) as $key) 115 | { 116 | if(!isset($found[$key])) 117 | { 118 | echo "deleting $key\n"; 119 | unset($nodes[$key]); 120 | } 121 | } 122 | 123 | echo "Writing {$this->outfile}\n"; 124 | $fp = fopen($this->outfile, 'w'); 125 | fputs($fp, serialize($nodes)); 126 | fclose($fp); 127 | } 128 | 129 | // // // // // // // // // 130 | // NOTHING PUBLIC BELOW // 131 | // // // // // // // // // 132 | 133 | /** 134 | * Parse a MIB file 135 | * 136 | * @param string $mibtext 137 | * @param boolean $full 138 | */ 139 | public function parse($mibtext, $full=false) 140 | { 141 | $tokens = $this->get_tokens($mibtext); 142 | $cnt = count($tokens); 143 | echo "Found $cnt tokens\n"; 144 | $rec = array(); 145 | for($index = 0; $index < $cnt; $index++) 146 | { 147 | echo number_format(100 *$index / $cnt, 2) . "% \r"; 148 | if($tokens[$index] == 'OBJECT-IDENTITY' || $tokens[$index] == 'OBJECT-TYPE' || $tokens[$index] == 'MODULE-IDENTITY') 149 | { 150 | if($tokens[$index-1] != ',' && $tokens[$index+1] != 'FROM' && $tokens[$index+1] != 'MACRO') 151 | { 152 | if(isset($rec['NAME']) && isset($rec['VALUE'])) $this->parsed[] = $rec; 153 | $rec = array('NAME'=>$tokens[$index-1]); 154 | } 155 | } 156 | elseif($tokens[$index] == 'OBJECT') 157 | { 158 | if($tokens[$index+1] == 'IDENTIFIER' && $tokens[$index-1] != '(' && $tokens[$index-1] != '::=' && $tokens[$index-1] != 'SYNTAX' && $tokens[$index-2] != '(') 159 | { 160 | if(isset($rec['NAME']) && isset($rec['VALUE'])) $this->parsed[] = $rec; 161 | $rec = array('NAME'=>$tokens[$index-1]); 162 | } 163 | } 164 | elseif($tokens[$index] == '{') 165 | $this->parse_bracket_token($tokens, $index, '{', '}'); 166 | elseif(isset($rec['NAME'])) 167 | { 168 | if($tokens[$index] == '::=') 169 | { 170 | $rec['VALUE'] = $this->parse_simple_token($tokens, $index); 171 | $this->parsed[] = $rec; 172 | $rec = array(); 173 | } 174 | elseif($full) 175 | { 176 | if($tokens[$index] == 'ACCESS') 177 | $rec['ACCESS'] = $this->parse_simple_token($tokens, $index, array('read-only', 'not-accessible', 'read-write')); 178 | elseif($tokens[$index] == 'DEFVAL') 179 | $rec['DEFVAL'] = $this->parse_simple_token($tokens, $index); 180 | elseif($tokens[$index] == 'DESCRIPTION') 181 | $rec['DESCRIPTION'] = $tokens[++$index]; 182 | elseif($tokens[$index] == 'INDEX') 183 | $rec['INDEX'] = $this->parse_simple_token($tokens, $index); 184 | elseif($tokens[$index] == 'MAX-ACCESS') 185 | $rec['MAX-ACCESS'] = $this->parse_simple_token($tokens, $index, array('read-only', 'not-accessible', 'read-write', 'read-create', 'accessible-for-notify')); 186 | elseif($tokens[$index] == 'REFERENCE') 187 | $rec['REFERENCE'] = $this->parse_simple_token($tokens, $index); 188 | elseif($tokens[$index] == 'STATUS') 189 | $rec['STATUS'] = $this->parse_simple_token($tokens, $index, array('current', 'deprecated', 'obsolete', 'mandatory')); 190 | elseif($tokens[$index] == 'SYNTAX') 191 | $rec['SYNTAX'] = $this->parse_SYNTAX_token($tokens, $index); 192 | elseif($tokens[$index] == 'UNITS') 193 | $rec['UNITS'] = $this->parse_simple_token($tokens, $index); 194 | } 195 | } 196 | } 197 | echo number_format(100, 2) . "% \r"; 198 | if(isset($rec['NAME']) && isset($rec['VALUE'])) $this->parsed[] = $rec; 199 | } 200 | 201 | /** 202 | * Get Tokens 203 | * 204 | * @param string $text 205 | * @return array 206 | */ 207 | public function get_tokens($text) 208 | { 209 | $in_quote = false; 210 | $in_comment = false; 211 | $token = ''; 212 | $tokens = array(); 213 | $length = strlen($text); 214 | for($i = 0; $i < $length; $i++) 215 | { 216 | if($in_quote) 217 | { 218 | if($text{$i} == '"') 219 | { 220 | $in_quote = false; 221 | if($token != '') 222 | { 223 | $tokens[] = $token; 224 | $token = ''; 225 | } 226 | } 227 | else 228 | $token .= $text{$i}; 229 | } 230 | elseif($in_comment) 231 | { 232 | if($text{$i} == "\n" || $text{$i} == "\r") 233 | $in_comment = false; 234 | } 235 | else 236 | { 237 | switch($text{$i}) 238 | { 239 | case ':': 240 | if($text{$i+1} == ':' && $text{$i+2} == '=') 241 | { 242 | if($token != '') 243 | { 244 | $tokens[] = $token; 245 | $token = ''; 246 | } 247 | $tokens[] = '::='; 248 | $i += 2; 249 | } 250 | else 251 | $token .= $text{$i}; 252 | break; 253 | case '.': 254 | if($text{$i+1} == '.') 255 | { 256 | if($token != '') 257 | { 258 | $tokens[] = $token; 259 | $token = ''; 260 | } 261 | $tokens[] = '..'; 262 | $i++; 263 | } 264 | else 265 | $token .= $text{$i}; 266 | break; 267 | case ',': 268 | case ';': 269 | case '{': 270 | case '}': 271 | case '(': 272 | case ')': 273 | case '|': 274 | if($token != '') 275 | { 276 | $tokens[] = $token; 277 | $token = ''; 278 | } 279 | $tokens[] = $text{$i}; 280 | break; 281 | case ' ': 282 | case "\t": 283 | case "\n": 284 | case "\r": 285 | if($token != '') 286 | { 287 | $tokens[] = $token; 288 | $token = ''; 289 | } 290 | break; 291 | case '-': 292 | if($text{$i+1} == '-') 293 | $in_comment = true; 294 | else 295 | $token .= $text{$i}; 296 | break; 297 | case '"'; 298 | $in_quote = true; 299 | break; 300 | default: 301 | $token .= $text{$i}; 302 | } 303 | } 304 | } 305 | if($token != '') 306 | $tokens[] = $token; 307 | return $tokens; 308 | } 309 | 310 | /** 311 | * Parse simple token 312 | * 313 | * @param array $tokens 314 | * @param integer $index 315 | * @param array $allowed 316 | * @return array 317 | */ 318 | public function parse_simple_token($tokens, &$index, $allowed=NULL) 319 | { 320 | if(is_array($allowed)) 321 | { 322 | if(in_array(strtolower($tokens[$index+1]), $allowed)) 323 | return $tokens[++$index]; 324 | } 325 | elseif(is_null($allowed)) 326 | { 327 | if($tokens[$index+1] == '{') 328 | return $this->parse_bracket_token($tokens, ++$index, '{', '}'); 329 | else 330 | return $tokens[++$index]; 331 | } 332 | trigger_error("unknown token {$tokens[$index]} {$tokens[$index+1]}", E_USER_ERROR); 333 | return $tokens[++$index]; 334 | } 335 | 336 | /** 337 | * Parse SYNTAX token 338 | * 339 | * @param array $tokens 340 | * @param integer $index 341 | * @return array 342 | */ 343 | public function parse_SYNTAX_token($tokens, &$index) 344 | { 345 | $ret = NULL; 346 | switch($tokens[$index+1]) 347 | { 348 | case 'SEQUENCE': 349 | if($tokens[$index+2] == 'OF') 350 | { 351 | $index += 2; 352 | if($tokens[$index+1] == '{') 353 | $ret = array('SEQUENCE OF'=>$this->parse_bracket_token($tokens, ++$index, '{', '}')); 354 | else 355 | $ret = array('SEQUENCE OF'=>$tokens[++$index]); 356 | } 357 | break; 358 | case 'OCTET': 359 | if($tokens[$index+2] == 'STRING') 360 | { 361 | $index += 2; 362 | if($tokens[$index+1] == '{') 363 | $ret = array('OCTET STRING'=>$this->parse_bracket_token($tokens, ++$index, '{', '}')); 364 | elseif($tokens[$index+1] == '(') 365 | $ret = array('OCTET STRING'=>$this->parse_bracket_token($tokens, ++$index, '(', ')')); 366 | else 367 | $ret = 'OCTET STRING'; 368 | } 369 | break; 370 | case 'OBJECT': 371 | if($tokens[$index+2] == 'IDENTIFIER') 372 | $ret = $tokens[++$index] . ' ' . $tokens[++$index]; 373 | else 374 | trigger_error("unknown token {$tokens[$index+1]} {$tokens[$index+2]}", E_USER_ERROR); 375 | break; 376 | case 'INTEGER': 377 | case 'Counter': 378 | case 'Counter32': 379 | case 'Counter64': 380 | case 'Integer32': 381 | case 'Gauge': 382 | case 'Gauge32': 383 | case 'TimeStamp': 384 | case 'TimeTicks': 385 | case 'PhysAddress': 386 | case 'IpAddress': 387 | case 'DateAndTime': 388 | case 'TimeInterval': 389 | case 'Unsigned32': 390 | case 'DisplayString': 391 | $ret = $tokens[++$index]; 392 | if($tokens[$index+1] == '{') 393 | $ret = array($ret=>$this->parse_bracket_token($tokens, ++$index, '{', '}')); 394 | elseif($tokens[$index+1] == '(') 395 | $ret = array($ret=>$this->parse_bracket_token($tokens, ++$index, '(', ')')); 396 | break; 397 | default: 398 | $ret = $tokens[++$index]; 399 | if($tokens[$index+1] == '{') 400 | $ret = array($ret=>$this->parse_bracket_token($tokens, ++$index, '{', '}')); 401 | elseif($tokens[$index+1] == '(') 402 | $ret = array($ret=>$this->parse_bracket_token($tokens, ++$index, '(', ')')); 403 | break; 404 | } 405 | return $ret; 406 | } 407 | 408 | /** 409 | * Parse bracket token 410 | * 411 | * @param array $tokens 412 | * @param integer $index 413 | * @param integer $start 414 | * @param integer $end 415 | * @return array 416 | */ 417 | public function parse_bracket_token($tokens, &$index, $start, $end) 418 | { 419 | $begin = $index + 1; 420 | while($index + 1 < count($tokens) && $tokens[$index] != $end) 421 | { 422 | $index++; 423 | if($tokens[$index] == $start) 424 | { 425 | $this->parse_bracket_token($tokens, $index, $start, $end); 426 | $index++; 427 | } 428 | } 429 | return array_slice($tokens, $begin, $index - $begin); 430 | } 431 | } 432 | ?> 433 | -------------------------------------------------------------------------------- /oid_format.data: -------------------------------------------------------------------------------- 1 | a:398:{s:0:"";a:1:{i:1;s:3:"iso";}s:5:"mib-2";a:31:{i:74;s:9:"agentxMIB";i:63;s:8:"schedMIB";i:64;s:9:"scriptMIB";i:35;s:8:"etherMIB";i:78;s:7:"hcnumTC";i:25;s:4:"host";i:72;s:24:"ianaAddressFamilyNumbers";i:73;s:13:"ianaLanguages";i:84;s:14:"ianaRtProtoMIB";i:30;s:10:"ianaifType";i:77;s:18:"ifInvertedStackMIB";i:31;s:5:"ifMIB";i:2;s:10:"interfaces";i:76;s:14:"inetAddressMIB";i:48;s:5:"ipMIB";i:4;s:2:"ip";i:5;s:4:"icmp";i:56;s:11:"ipv6IcmpMIB";i:55;s:7:"ipv6MIB";i:6;s:3:"tcp";i:7;s:3:"udp";i:92;s:18:"notificationLogMIB";i:1;s:6:"system";i:3;s:2:"at";i:8;s:3:"egp";i:10;s:12:"transmission";i:11;s:4:"snmp";i:16;s:4:"rmon";i:49;s:6:"tcpMIB";i:100;s:19:"transportAddressMIB";i:50;s:6:"udpMIB";}s:9:"agentxMIB";a:2:{i:1;s:13:"agentxObjects";i:2;s:17:"agentxConformance";}s:13:"agentxObjects";a:4:{i:1;s:13:"agentxGeneral";i:2;s:16:"agentxConnection";i:3;s:13:"agentxSession";i:4;s:18:"agentxRegistration";}s:13:"agentxGeneral";a:2:{i:1;s:20:"agentxDefaultTimeout";i:2;s:21:"agentxMasterAgentXVer";}s:16:"agentxConnection";a:2:{i:1;s:25:"agentxConnTableLastChange";i:2;s:21:"agentxConnectionTable";}s:21:"agentxConnectionTable";a:1:{i:1;s:21:"agentxConnectionEntry";}s:21:"agentxConnectionEntry";a:4:{i:1;s:15:"agentxConnIndex";i:2;s:18:"agentxConnOpenTime";i:3;s:25:"agentxConnTransportDomain";i:4;s:26:"agentxConnTransportAddress";}s:13:"agentxSession";a:2:{i:1;s:28:"agentxSessionTableLastChange";i:2;s:18:"agentxSessionTable";}s:18:"agentxSessionTable";a:1:{i:1;s:18:"agentxSessionEntry";}s:18:"agentxSessionEntry";a:7:{i:1;s:18:"agentxSessionIndex";i:2;s:21:"agentxSessionObjectID";i:3;s:18:"agentxSessionDescr";i:4;s:24:"agentxSessionAdminStatus";i:5;s:21:"agentxSessionOpenTime";i:6;s:22:"agentxSessionAgentXVer";i:7;s:20:"agentxSessionTimeout";}s:18:"agentxRegistration";a:2:{i:1;s:33:"agentxRegistrationTableLastChange";i:2;s:23:"agentxRegistrationTable";}s:23:"agentxRegistrationTable";a:1:{i:1;s:23:"agentxRegistrationEntry";}s:23:"agentxRegistrationEntry";a:8:{i:1;s:14:"agentxRegIndex";i:2;s:16:"agentxRegContext";i:3;s:14:"agentxRegStart";i:4;s:19:"agentxRegRangeSubId";i:5;s:19:"agentxRegUpperBound";i:6;s:17:"agentxRegPriority";i:7;s:16:"agentxRegTimeout";i:8;s:17:"agentxRegInstance";}s:17:"agentxConformance";a:2:{i:1;s:15:"agentxMIBGroups";i:2;s:20:"agentxMIBCompliances";}s:8:"schedMIB";a:3:{i:1;s:12:"schedObjects";i:2;s:18:"schedNotifications";i:3;s:16:"schedConformance";}s:12:"schedObjects";a:2:{i:1;s:14:"schedLocalTime";i:2;s:10:"schedTable";}s:10:"schedTable";a:1:{i:1;s:10:"schedEntry";}s:10:"schedEntry";a:21:{i:1;s:10:"schedOwner";i:2;s:9:"schedName";i:3;s:10:"schedDescr";i:4;s:13:"schedInterval";i:5;s:12:"schedWeekDay";i:6;s:10:"schedMonth";i:7;s:8:"schedDay";i:8;s:9:"schedHour";i:9;s:11:"schedMinute";i:10;s:16:"schedContextName";i:11;s:13:"schedVariable";i:12;s:10:"schedValue";i:13;s:9:"schedType";i:14;s:16:"schedAdminStatus";i:15;s:15:"schedOperStatus";i:16;s:13:"schedFailures";i:17;s:16:"schedLastFailure";i:18;s:15:"schedLastFailed";i:19;s:16:"schedStorageType";i:20;s:14:"schedRowStatus";i:21;s:13:"schedTriggers";}s:18:"schedNotifications";a:1:{i:0;s:10:"schedTraps";}s:16:"schedConformance";a:2:{i:1;s:16:"schedCompliances";i:2;s:11:"schedGroups";}s:9:"scriptMIB";a:3:{i:1;s:9:"smObjects";i:2;s:15:"smNotifications";i:3;s:13:"smConformance";}s:9:"smObjects";a:4:{i:1;s:11:"smLangTable";i:2;s:12:"smExtsnTable";i:3;s:15:"smScriptObjects";i:4;s:12:"smRunObjects";}s:11:"smLangTable";a:1:{i:1;s:11:"smLangEntry";}s:11:"smLangEntry";a:6:{i:1;s:11:"smLangIndex";i:2;s:14:"smLangLanguage";i:3;s:13:"smLangVersion";i:4;s:12:"smLangVendor";i:5;s:14:"smLangRevision";i:6;s:11:"smLangDescr";}s:12:"smExtsnTable";a:1:{i:1;s:12:"smExtsnEntry";}s:12:"smExtsnEntry";a:6:{i:1;s:12:"smExtsnIndex";i:2;s:16:"smExtsnExtension";i:3;s:14:"smExtsnVersion";i:4;s:13:"smExtsnVendor";i:5;s:15:"smExtsnRevision";i:6;s:12:"smExtsnDescr";}s:15:"smScriptObjects";a:2:{i:1;s:13:"smScriptTable";i:2;s:11:"smCodeTable";}s:13:"smScriptTable";a:1:{i:1;s:13:"smScriptEntry";}s:13:"smScriptEntry";a:11:{i:1;s:13:"smScriptOwner";i:2;s:12:"smScriptName";i:3;s:13:"smScriptDescr";i:4;s:16:"smScriptLanguage";i:5;s:14:"smScriptSource";i:6;s:19:"smScriptAdminStatus";i:7;s:18:"smScriptOperStatus";i:8;s:19:"smScriptStorageType";i:9;s:17:"smScriptRowStatus";i:10;s:13:"smScriptError";i:11;s:18:"smScriptLastChange";}s:11:"smCodeTable";a:1:{i:1;s:11:"smCodeEntry";}s:11:"smCodeEntry";a:3:{i:1;s:11:"smCodeIndex";i:2;s:10:"smCodeText";i:3;s:15:"smCodeRowStatus";}s:12:"smRunObjects";a:2:{i:1;s:13:"smLaunchTable";i:2;s:10:"smRunTable";}s:13:"smLaunchTable";a:1:{i:1;s:13:"smLaunchEntry";}s:13:"smLaunchEntry";a:19:{i:1;s:13:"smLaunchOwner";i:2;s:12:"smLaunchName";i:3;s:19:"smLaunchScriptOwner";i:4;s:18:"smLaunchScriptName";i:5;s:16:"smLaunchArgument";i:6;s:18:"smLaunchMaxRunning";i:7;s:20:"smLaunchMaxCompleted";i:8;s:16:"smLaunchLifeTime";i:9;s:18:"smLaunchExpireTime";i:10;s:13:"smLaunchStart";i:11;s:15:"smLaunchControl";i:12;s:19:"smLaunchAdminStatus";i:13;s:18:"smLaunchOperStatus";i:14;s:20:"smLaunchRunIndexNext";i:15;s:19:"smLaunchStorageType";i:16;s:17:"smLaunchRowStatus";i:17;s:13:"smLaunchError";i:18;s:18:"smLaunchLastChange";i:19;s:21:"smLaunchRowExpireTime";}s:10:"smRunTable";a:1:{i:1;s:10:"smRunEntry";}s:10:"smRunEntry";a:13:{i:1;s:10:"smRunIndex";i:2;s:13:"smRunArgument";i:3;s:14:"smRunStartTime";i:4;s:12:"smRunEndTime";i:5;s:13:"smRunLifeTime";i:6;s:15:"smRunExpireTime";i:7;s:13:"smRunExitCode";i:8;s:11:"smRunResult";i:9;s:12:"smRunControl";i:10;s:10:"smRunState";i:11;s:10:"smRunError";i:12;s:15:"smRunResultTime";i:13;s:14:"smRunErrorTime";}s:15:"smNotifications";a:1:{i:0;s:7:"smTraps";}s:13:"smConformance";a:2:{i:1;s:13:"smCompliances";i:2;s:8:"smGroups";}s:8:"etherMIB";a:2:{i:1;s:15:"etherMIBObjects";i:2;s:16:"etherConformance";}s:12:"transmission";a:1:{i:7;s:4:"dot3";}s:4:"dot3";a:7:{i:2;s:14:"dot3StatsTable";i:5;s:13:"dot3CollTable";i:9;s:16:"dot3ControlTable";i:10;s:14:"dot3PauseTable";i:11;s:16:"dot3HCStatsTable";i:6;s:9:"dot3Tests";i:7;s:10:"dot3Errors";}s:14:"dot3StatsTable";a:1:{i:1;s:14:"dot3StatsEntry";}s:14:"dot3StatsEntry";a:18:{i:1;s:14:"dot3StatsIndex";i:2;s:24:"dot3StatsAlignmentErrors";i:3;s:18:"dot3StatsFCSErrors";i:4;s:30:"dot3StatsSingleCollisionFrames";i:5;s:32:"dot3StatsMultipleCollisionFrames";i:6;s:22:"dot3StatsSQETestErrors";i:7;s:30:"dot3StatsDeferredTransmissions";i:8;s:23:"dot3StatsLateCollisions";i:9;s:28:"dot3StatsExcessiveCollisions";i:10;s:34:"dot3StatsInternalMacTransmitErrors";i:11;s:27:"dot3StatsCarrierSenseErrors";i:13;s:22:"dot3StatsFrameTooLongs";i:16;s:33:"dot3StatsInternalMacReceiveErrors";i:17;s:21:"dot3StatsEtherChipSet";i:18;s:21:"dot3StatsSymbolErrors";i:19;s:21:"dot3StatsDuplexStatus";i:20;s:27:"dot3StatsRateControlAbility";i:21;s:26:"dot3StatsRateControlStatus";}s:13:"dot3CollTable";a:1:{i:1;s:13:"dot3CollEntry";}s:13:"dot3CollEntry";a:2:{i:2;s:13:"dot3CollCount";i:3;s:19:"dot3CollFrequencies";}s:16:"dot3ControlTable";a:1:{i:1;s:16:"dot3ControlEntry";}s:16:"dot3ControlEntry";a:3:{i:1;s:29:"dot3ControlFunctionsSupported";i:2;s:27:"dot3ControlInUnknownOpcodes";i:3;s:29:"dot3HCControlInUnknownOpcodes";}s:14:"dot3PauseTable";a:1:{i:1;s:14:"dot3PauseEntry";}s:14:"dot3PauseEntry";a:6:{i:1;s:18:"dot3PauseAdminMode";i:2;s:17:"dot3PauseOperMode";i:3;s:17:"dot3InPauseFrames";i:4;s:18:"dot3OutPauseFrames";i:5;s:19:"dot3HCInPauseFrames";i:6;s:20:"dot3HCOutPauseFrames";}s:16:"dot3HCStatsTable";a:1:{i:1;s:16:"dot3HCStatsEntry";}s:16:"dot3HCStatsEntry";a:6:{i:1;s:26:"dot3HCStatsAlignmentErrors";i:2;s:20:"dot3HCStatsFCSErrors";i:3;s:36:"dot3HCStatsInternalMacTransmitErrors";i:4;s:24:"dot3HCStatsFrameTooLongs";i:5;s:35:"dot3HCStatsInternalMacReceiveErrors";i:6;s:23:"dot3HCStatsSymbolErrors";}s:9:"dot3Tests";a:2:{i:1;s:11:"dot3TestTdr";i:2;s:16:"dot3TestLoopBack";}s:10:"dot3Errors";a:2:{i:1;s:18:"dot3ErrorInitError";i:2;s:22:"dot3ErrorLoopbackError";}s:16:"etherConformance";a:2:{i:1;s:11:"etherGroups";i:2;s:16:"etherCompliances";}s:14:"hrMIBAdminInfo";a:4:{i:1;s:22:"hostResourcesMibModule";i:2;s:16:"hrMIBCompliances";i:3;s:11:"hrMIBGroups";i:4;s:24:"hostResourcesTypesModule";}s:4:"host";a:7:{i:1;s:8:"hrSystem";i:2;s:9:"hrStorage";i:3;s:8:"hrDevice";i:4;s:7:"hrSWRun";i:5;s:11:"hrSWRunPerf";i:6;s:13:"hrSWInstalled";i:7;s:14:"hrMIBAdminInfo";}s:8:"hrSystem";a:7:{i:1;s:14:"hrSystemUptime";i:2;s:12:"hrSystemDate";i:3;s:25:"hrSystemInitialLoadDevice";i:4;s:29:"hrSystemInitialLoadParameters";i:5;s:16:"hrSystemNumUsers";i:6;s:17:"hrSystemProcesses";i:7;s:20:"hrSystemMaxProcesses";}s:9:"hrStorage";a:3:{i:1;s:14:"hrStorageTypes";i:2;s:12:"hrMemorySize";i:3;s:14:"hrStorageTable";}s:14:"hrStorageTable";a:1:{i:1;s:14:"hrStorageEntry";}s:14:"hrStorageEntry";a:7:{i:1;s:14:"hrStorageIndex";i:2;s:13:"hrStorageType";i:3;s:14:"hrStorageDescr";i:4;s:24:"hrStorageAllocationUnits";i:5;s:13:"hrStorageSize";i:6;s:13:"hrStorageUsed";i:7;s:27:"hrStorageAllocationFailures";}s:8:"hrDevice";a:9:{i:1;s:13:"hrDeviceTypes";i:2;s:13:"hrDeviceTable";i:3;s:16:"hrProcessorTable";i:4;s:14:"hrNetworkTable";i:5;s:14:"hrPrinterTable";i:6;s:18:"hrDiskStorageTable";i:7;s:16:"hrPartitionTable";i:9;s:9:"hrFSTypes";i:8;s:9:"hrFSTable";}s:13:"hrDeviceTable";a:1:{i:1;s:13:"hrDeviceEntry";}s:13:"hrDeviceEntry";a:6:{i:1;s:13:"hrDeviceIndex";i:2;s:12:"hrDeviceType";i:3;s:13:"hrDeviceDescr";i:4;s:10:"hrDeviceID";i:5;s:14:"hrDeviceStatus";i:6;s:14:"hrDeviceErrors";}s:16:"hrProcessorTable";a:1:{i:1;s:16:"hrProcessorEntry";}s:16:"hrProcessorEntry";a:2:{i:1;s:16:"hrProcessorFrwID";i:2;s:15:"hrProcessorLoad";}s:14:"hrNetworkTable";a:1:{i:1;s:14:"hrNetworkEntry";}s:14:"hrNetworkEntry";a:1:{i:1;s:16:"hrNetworkIfIndex";}s:14:"hrPrinterTable";a:1:{i:1;s:14:"hrPrinterEntry";}s:14:"hrPrinterEntry";a:2:{i:1;s:15:"hrPrinterStatus";i:2;s:27:"hrPrinterDetectedErrorState";}s:18:"hrDiskStorageTable";a:1:{i:1;s:18:"hrDiskStorageEntry";}s:18:"hrDiskStorageEntry";a:4:{i:1;s:19:"hrDiskStorageAccess";i:2;s:18:"hrDiskStorageMedia";i:3;s:22:"hrDiskStorageRemoveble";i:4;s:21:"hrDiskStorageCapacity";}s:16:"hrPartitionTable";a:1:{i:1;s:16:"hrPartitionEntry";}s:16:"hrPartitionEntry";a:5:{i:1;s:16:"hrPartitionIndex";i:2;s:16:"hrPartitionLabel";i:3;s:13:"hrPartitionID";i:4;s:15:"hrPartitionSize";i:5;s:18:"hrPartitionFSIndex";}s:9:"hrFSTable";a:1:{i:1;s:9:"hrFSEntry";}s:9:"hrFSEntry";a:9:{i:1;s:9:"hrFSIndex";i:2;s:14:"hrFSMountPoint";i:3;s:20:"hrFSRemoteMountPoint";i:4;s:8:"hrFSType";i:5;s:10:"hrFSAccess";i:6;s:12:"hrFSBootable";i:7;s:16:"hrFSStorageIndex";i:8;s:22:"hrFSLastFullBackupDate";i:9;s:25:"hrFSLastPartialBackupDate";}s:7:"hrSWRun";a:2:{i:1;s:11:"hrSWOSIndex";i:2;s:12:"hrSWRunTable";}s:12:"hrSWRunTable";a:1:{i:1;s:12:"hrSWRunEntry";}s:12:"hrSWRunEntry";a:7:{i:1;s:12:"hrSWRunIndex";i:2;s:11:"hrSWRunName";i:3;s:9:"hrSWRunID";i:4;s:11:"hrSWRunPath";i:5;s:17:"hrSWRunParameters";i:6;s:11:"hrSWRunType";i:7;s:13:"hrSWRunStatus";}s:11:"hrSWRunPerf";a:1:{i:1;s:16:"hrSWRunPerfTable";}s:16:"hrSWRunPerfTable";a:1:{i:1;s:16:"hrSWRunPerfEntry";}s:16:"hrSWRunPerfEntry";a:2:{i:1;s:14:"hrSWRunPerfCPU";i:2;s:14:"hrSWRunPerfMem";}s:13:"hrSWInstalled";a:3:{i:1;s:23:"hrSWInstalledLastChange";i:2;s:27:"hrSWInstalledLastUpdateTime";i:3;s:18:"hrSWInstalledTable";}s:18:"hrSWInstalledTable";a:1:{i:1;s:18:"hrSWInstalledEntry";}s:18:"hrSWInstalledEntry";a:5:{i:1;s:18:"hrSWInstalledIndex";i:2;s:17:"hrSWInstalledName";i:3;s:15:"hrSWInstalledID";i:4;s:17:"hrSWInstalledType";i:5;s:17:"hrSWInstalledDate";}s:14:"hrStorageTypes";a:10:{i:1;s:14:"hrStorageOther";i:2;s:12:"hrStorageRam";i:3;s:22:"hrStorageVirtualMemory";i:4;s:18:"hrStorageFixedDisk";i:5;s:22:"hrStorageRemovableDisk";i:6;s:19:"hrStorageFloppyDisk";i:7;s:20:"hrStorageCompactDisc";i:8;s:16:"hrStorageRamDisk";i:9;s:20:"hrStorageFlashMemory";i:10;s:20:"hrStorageNetworkDisk";}s:13:"hrDeviceTypes";a:18:{i:1;s:13:"hrDeviceOther";i:2;s:15:"hrDeviceUnknown";i:3;s:17:"hrDeviceProcessor";i:4;s:15:"hrDeviceNetwork";i:5;s:15:"hrDevicePrinter";i:6;s:19:"hrDeviceDiskStorage";i:10;s:13:"hrDeviceVideo";i:11;s:13:"hrDeviceAudio";i:12;s:19:"hrDeviceCoprocessor";i:13;s:16:"hrDeviceKeyboard";i:14;s:13:"hrDeviceModem";i:15;s:20:"hrDeviceParallelPort";i:16;s:16:"hrDevicePointing";i:17;s:18:"hrDeviceSerialPort";i:18;s:12:"hrDeviceTape";i:19;s:13:"hrDeviceClock";i:20;s:22:"hrDeviceVolatileMemory";i:21;s:25:"hrDeviceNonVolatileMemory";}s:9:"hrFSTypes";a:23:{i:1;s:9:"hrFSOther";i:2;s:11:"hrFSUnknown";i:3;s:15:"hrFSBerkeleyFFS";i:4;s:10:"hrFSSys5FS";i:5;s:7:"hrFSFat";i:6;s:8:"hrFSHPFS";i:7;s:7:"hrFSHFS";i:8;s:7:"hrFSMFS";i:9;s:8:"hrFSNTFS";i:10;s:9:"hrFSVNode";i:11;s:13:"hrFSJournaled";i:12;s:11:"hrFSiso9660";i:13;s:13:"hrFSRockRidge";i:14;s:7:"hrFSNFS";i:15;s:11:"hrFSNetware";i:16;s:7:"hrFSAFS";i:17;s:7:"hrFSDFS";i:18;s:14:"hrFSAppleshare";i:19;s:7:"hrFSRFS";i:20;s:9:"hrFSDGCFS";i:21;s:7:"hrFSBFS";i:22;s:9:"hrFSFAT32";i:23;s:13:"hrFSLinuxExt2";}s:13:"ianaLanguages";a:7:{i:1;s:20:"ianaLangJavaByteCode";i:2;s:11:"ianaLangTcl";i:3;s:12:"ianaLangPerl";i:4;s:14:"ianaLangScheme";i:5;s:12:"ianaLangSRSL";i:6;s:11:"ianaLangPSL";i:7;s:12:"ianaLangSMSL";}s:18:"ifInvertedStackMIB";a:1:{i:1;s:15:"ifInvMIBObjects";}s:15:"ifInvMIBObjects";a:2:{i:1;s:15:"ifInvStackTable";i:2;s:16:"ifInvConformance";}s:15:"ifInvStackTable";a:1:{i:1;s:15:"ifInvStackEntry";}s:15:"ifInvStackEntry";a:1:{i:1;s:16:"ifInvStackStatus";}s:16:"ifInvConformance";a:2:{i:1;s:11:"ifInvGroups";i:2;s:16:"ifInvCompliances";}s:5:"ifMIB";a:2:{i:1;s:12:"ifMIBObjects";i:2;s:13:"ifConformance";}s:10:"interfaces";a:2:{i:1;s:8:"ifNumber";i:2;s:7:"ifTable";}s:12:"ifMIBObjects";a:6:{i:5;s:17:"ifTableLastChange";i:1;s:8:"ifXTable";i:2;s:12:"ifStackTable";i:6;s:17:"ifStackLastChange";i:4;s:17:"ifRcvAddressTable";i:3;s:11:"ifTestTable";}s:7:"ifTable";a:1:{i:1;s:7:"ifEntry";}s:7:"ifEntry";a:22:{i:1;s:7:"ifIndex";i:2;s:7:"ifDescr";i:3;s:6:"ifType";i:4;s:5:"ifMtu";i:5;s:7:"ifSpeed";i:6;s:13:"ifPhysAddress";i:7;s:13:"ifAdminStatus";i:8;s:12:"ifOperStatus";i:9;s:12:"ifLastChange";i:10;s:10:"ifInOctets";i:11;s:13:"ifInUcastPkts";i:12;s:14:"ifInNUcastPkts";i:13;s:12:"ifInDiscards";i:14;s:10:"ifInErrors";i:15;s:17:"ifInUnknownProtos";i:16;s:11:"ifOutOctets";i:17;s:14:"ifOutUcastPkts";i:18;s:15:"ifOutNUcastPkts";i:19;s:13:"ifOutDiscards";i:20;s:11:"ifOutErrors";i:21;s:9:"ifOutQLen";i:22;s:10:"ifSpecific";}s:8:"ifXTable";a:1:{i:1;s:8:"ifXEntry";}s:8:"ifXEntry";a:19:{i:1;s:6:"ifName";i:2;s:17:"ifInMulticastPkts";i:3;s:17:"ifInBroadcastPkts";i:4;s:18:"ifOutMulticastPkts";i:5;s:18:"ifOutBroadcastPkts";i:6;s:12:"ifHCInOctets";i:7;s:15:"ifHCInUcastPkts";i:8;s:19:"ifHCInMulticastPkts";i:9;s:19:"ifHCInBroadcastPkts";i:10;s:13:"ifHCOutOctets";i:11;s:16:"ifHCOutUcastPkts";i:12;s:20:"ifHCOutMulticastPkts";i:13;s:20:"ifHCOutBroadcastPkts";i:14;s:22:"ifLinkUpDownTrapEnable";i:15;s:11:"ifHighSpeed";i:16;s:17:"ifPromiscuousMode";i:17;s:18:"ifConnectorPresent";i:18;s:7:"ifAlias";i:19;s:26:"ifCounterDiscontinuityTime";}s:12:"ifStackTable";a:1:{i:1;s:12:"ifStackEntry";}s:12:"ifStackEntry";a:3:{i:1;s:18:"ifStackHigherLayer";i:2;s:17:"ifStackLowerLayer";i:3;s:13:"ifStackStatus";}s:17:"ifRcvAddressTable";a:1:{i:1;s:17:"ifRcvAddressEntry";}s:17:"ifRcvAddressEntry";a:3:{i:1;s:19:"ifRcvAddressAddress";i:2;s:18:"ifRcvAddressStatus";i:3;s:16:"ifRcvAddressType";}s:13:"ifConformance";a:2:{i:1;s:8:"ifGroups";i:2;s:13:"ifCompliances";}s:11:"ifTestTable";a:1:{i:1;s:11:"ifTestEntry";}s:11:"ifTestEntry";a:6:{i:1;s:8:"ifTestId";i:2;s:12:"ifTestStatus";i:3;s:10:"ifTestType";i:4;s:12:"ifTestResult";i:5;s:10:"ifTestCode";i:6;s:11:"ifTestOwner";}s:2:"ip";a:24:{i:24;s:9:"ipForward";i:1;s:12:"ipForwarding";i:2;s:12:"ipDefaultTTL";i:3;s:12:"ipInReceives";i:4;s:13:"ipInHdrErrors";i:5;s:14:"ipInAddrErrors";i:6;s:15:"ipForwDatagrams";i:7;s:17:"ipInUnknownProtos";i:8;s:12:"ipInDiscards";i:9;s:12:"ipInDelivers";i:10;s:13:"ipOutRequests";i:11;s:13:"ipOutDiscards";i:12;s:13:"ipOutNoRoutes";i:13;s:14:"ipReasmTimeout";i:14;s:12:"ipReasmReqds";i:15;s:10:"ipReasmOKs";i:16;s:12:"ipReasmFails";i:17;s:9:"ipFragOKs";i:18;s:11:"ipFragFails";i:19;s:13:"ipFragCreates";i:20;s:11:"ipAddrTable";i:22;s:17:"ipNetToMediaTable";i:23;s:17:"ipRoutingDiscards";i:21;s:12:"ipRouteTable";}s:9:"ipForward";a:8:{i:6;s:19:"inetCidrRouteNumber";i:8;s:21:"inetCidrRouteDiscards";i:7;s:18:"inetCidrRouteTable";i:5;s:20:"ipForwardConformance";i:3;s:17:"ipCidrRouteNumber";i:4;s:16:"ipCidrRouteTable";i:1;s:15:"ipForwardNumber";i:2;s:14:"ipForwardTable";}s:18:"inetCidrRouteTable";a:1:{i:1;s:18:"inetCidrRouteEntry";}s:18:"inetCidrRouteEntry";a:17:{i:1;s:21:"inetCidrRouteDestType";i:2;s:17:"inetCidrRouteDest";i:3;s:19:"inetCidrRoutePfxLen";i:4;s:19:"inetCidrRoutePolicy";i:5;s:24:"inetCidrRouteNextHopType";i:6;s:20:"inetCidrRouteNextHop";i:7;s:20:"inetCidrRouteIfIndex";i:8;s:17:"inetCidrRouteType";i:9;s:18:"inetCidrRouteProto";i:10;s:16:"inetCidrRouteAge";i:11;s:22:"inetCidrRouteNextHopAS";i:12;s:20:"inetCidrRouteMetric1";i:13;s:20:"inetCidrRouteMetric2";i:14;s:20:"inetCidrRouteMetric3";i:15;s:20:"inetCidrRouteMetric4";i:16;s:20:"inetCidrRouteMetric5";i:17;s:19:"inetCidrRouteStatus";}s:20:"ipForwardConformance";a:2:{i:1;s:15:"ipForwardGroups";i:2;s:20:"ipForwardCompliances";}s:16:"ipCidrRouteTable";a:1:{i:1;s:16:"ipCidrRouteEntry";}s:16:"ipCidrRouteEntry";a:16:{i:1;s:15:"ipCidrRouteDest";i:2;s:15:"ipCidrRouteMask";i:3;s:14:"ipCidrRouteTos";i:4;s:18:"ipCidrRouteNextHop";i:5;s:18:"ipCidrRouteIfIndex";i:6;s:15:"ipCidrRouteType";i:7;s:16:"ipCidrRouteProto";i:8;s:14:"ipCidrRouteAge";i:9;s:15:"ipCidrRouteInfo";i:10;s:20:"ipCidrRouteNextHopAS";i:11;s:18:"ipCidrRouteMetric1";i:12;s:18:"ipCidrRouteMetric2";i:13;s:18:"ipCidrRouteMetric3";i:14;s:18:"ipCidrRouteMetric4";i:15;s:18:"ipCidrRouteMetric5";i:16;s:17:"ipCidrRouteStatus";}s:14:"ipForwardTable";a:1:{i:1;s:14:"ipForwardEntry";}s:14:"ipForwardEntry";a:15:{i:1;s:13:"ipForwardDest";i:2;s:13:"ipForwardMask";i:3;s:15:"ipForwardPolicy";i:4;s:16:"ipForwardNextHop";i:5;s:16:"ipForwardIfIndex";i:6;s:13:"ipForwardType";i:7;s:14:"ipForwardProto";i:8;s:12:"ipForwardAge";i:9;s:13:"ipForwardInfo";i:10;s:18:"ipForwardNextHopAS";i:11;s:16:"ipForwardMetric1";i:12;s:16:"ipForwardMetric2";i:13;s:16:"ipForwardMetric3";i:14;s:16:"ipForwardMetric4";i:15;s:16:"ipForwardMetric5";}s:11:"ipAddrTable";a:1:{i:1;s:11:"ipAddrEntry";}s:11:"ipAddrEntry";a:5:{i:1;s:11:"ipAdEntAddr";i:2;s:14:"ipAdEntIfIndex";i:3;s:14:"ipAdEntNetMask";i:4;s:16:"ipAdEntBcastAddr";i:5;s:19:"ipAdEntReasmMaxSize";}s:17:"ipNetToMediaTable";a:1:{i:1;s:17:"ipNetToMediaEntry";}s:17:"ipNetToMediaEntry";a:4:{i:1;s:19:"ipNetToMediaIfIndex";i:2;s:23:"ipNetToMediaPhysAddress";i:3;s:22:"ipNetToMediaNetAddress";i:4;s:16:"ipNetToMediaType";}s:4:"icmp";a:26:{i:1;s:10:"icmpInMsgs";i:2;s:12:"icmpInErrors";i:3;s:18:"icmpInDestUnreachs";i:4;s:15:"icmpInTimeExcds";i:5;s:15:"icmpInParmProbs";i:6;s:16:"icmpInSrcQuenchs";i:7;s:15:"icmpInRedirects";i:8;s:11:"icmpInEchos";i:9;s:14:"icmpInEchoReps";i:10;s:16:"icmpInTimestamps";i:11;s:19:"icmpInTimestampReps";i:12;s:15:"icmpInAddrMasks";i:13;s:18:"icmpInAddrMaskReps";i:14;s:11:"icmpOutMsgs";i:15;s:13:"icmpOutErrors";i:16;s:19:"icmpOutDestUnreachs";i:17;s:16:"icmpOutTimeExcds";i:18;s:16:"icmpOutParmProbs";i:19;s:17:"icmpOutSrcQuenchs";i:20;s:16:"icmpOutRedirects";i:21;s:12:"icmpOutEchos";i:22;s:15:"icmpOutEchoReps";i:23;s:17:"icmpOutTimestamps";i:24;s:20:"icmpOutTimestampReps";i:25;s:16:"icmpOutAddrMasks";i:26;s:19:"icmpOutAddrMaskReps";}s:5:"ipMIB";a:1:{i:2;s:16:"ipMIBConformance";}s:16:"ipMIBConformance";a:2:{i:1;s:16:"ipMIBCompliances";i:2;s:11:"ipMIBGroups";}s:11:"ipv6IcmpMIB";a:2:{i:1;s:18:"ipv6IcmpMIBObjects";i:2;s:19:"ipv6IcmpConformance";}s:18:"ipv6IcmpMIBObjects";a:1:{i:1;s:15:"ipv6IfIcmpTable";}s:15:"ipv6IfIcmpTable";a:1:{i:1;s:15:"ipv6IfIcmpEntry";}s:15:"ipv6IfIcmpEntry";a:34:{i:1;s:16:"ipv6IfIcmpInMsgs";i:2;s:18:"ipv6IfIcmpInErrors";i:3;s:24:"ipv6IfIcmpInDestUnreachs";i:4;s:24:"ipv6IfIcmpInAdminProhibs";i:5;s:21:"ipv6IfIcmpInTimeExcds";i:6;s:24:"ipv6IfIcmpInParmProblems";i:7;s:22:"ipv6IfIcmpInPktTooBigs";i:8;s:17:"ipv6IfIcmpInEchos";i:9;s:23:"ipv6IfIcmpInEchoReplies";i:10;s:26:"ipv6IfIcmpInRouterSolicits";i:11;s:32:"ipv6IfIcmpInRouterAdvertisements";i:12;s:28:"ipv6IfIcmpInNeighborSolicits";i:13;s:34:"ipv6IfIcmpInNeighborAdvertisements";i:14;s:21:"ipv6IfIcmpInRedirects";i:15;s:28:"ipv6IfIcmpInGroupMembQueries";i:16;s:30:"ipv6IfIcmpInGroupMembResponses";i:17;s:31:"ipv6IfIcmpInGroupMembReductions";i:18;s:17:"ipv6IfIcmpOutMsgs";i:19;s:19:"ipv6IfIcmpOutErrors";i:20;s:25:"ipv6IfIcmpOutDestUnreachs";i:21;s:25:"ipv6IfIcmpOutAdminProhibs";i:22;s:22:"ipv6IfIcmpOutTimeExcds";i:23;s:25:"ipv6IfIcmpOutParmProblems";i:24;s:23:"ipv6IfIcmpOutPktTooBigs";i:25;s:18:"ipv6IfIcmpOutEchos";i:26;s:24:"ipv6IfIcmpOutEchoReplies";i:27;s:27:"ipv6IfIcmpOutRouterSolicits";i:28;s:33:"ipv6IfIcmpOutRouterAdvertisements";i:29;s:29:"ipv6IfIcmpOutNeighborSolicits";i:30;s:35:"ipv6IfIcmpOutNeighborAdvertisements";i:31;s:22:"ipv6IfIcmpOutRedirects";i:32;s:29:"ipv6IfIcmpOutGroupMembQueries";i:33;s:31:"ipv6IfIcmpOutGroupMembResponses";i:34;s:32:"ipv6IfIcmpOutGroupMembReductions";}s:19:"ipv6IcmpConformance";a:2:{i:1;s:19:"ipv6IcmpCompliances";i:2;s:14:"ipv6IcmpGroups";}s:7:"ipv6MIB";a:3:{i:1;s:14:"ipv6MIBObjects";i:2;s:17:"ipv6Notifications";i:3;s:15:"ipv6Conformance";}s:14:"ipv6MIBObjects";a:12:{i:1;s:14:"ipv6Forwarding";i:2;s:19:"ipv6DefaultHopLimit";i:3;s:14:"ipv6Interfaces";i:4;s:21:"ipv6IfTableLastChange";i:5;s:11:"ipv6IfTable";i:6;s:16:"ipv6IfStatsTable";i:7;s:19:"ipv6AddrPrefixTable";i:8;s:13:"ipv6AddrTable";i:9;s:15:"ipv6RouteNumber";i:10;s:19:"ipv6DiscardedRoutes";i:11;s:14:"ipv6RouteTable";i:12;s:19:"ipv6NetToMediaTable";}s:11:"ipv6IfTable";a:1:{i:1;s:11:"ipv6IfEntry";}s:11:"ipv6IfEntry";a:11:{i:1;s:11:"ipv6IfIndex";i:2;s:11:"ipv6IfDescr";i:3;s:16:"ipv6IfLowerLayer";i:4;s:18:"ipv6IfEffectiveMtu";i:5;s:18:"ipv6IfReasmMaxSize";i:6;s:16:"ipv6IfIdentifier";i:7;s:22:"ipv6IfIdentifierLength";i:8;s:21:"ipv6IfPhysicalAddress";i:9;s:17:"ipv6IfAdminStatus";i:10;s:16:"ipv6IfOperStatus";i:11;s:16:"ipv6IfLastChange";}s:16:"ipv6IfStatsTable";a:1:{i:1;s:16:"ipv6IfStatsEntry";}s:16:"ipv6IfStatsEntry";a:20:{i:1;s:21:"ipv6IfStatsInReceives";i:2;s:22:"ipv6IfStatsInHdrErrors";i:3;s:25:"ipv6IfStatsInTooBigErrors";i:4;s:21:"ipv6IfStatsInNoRoutes";i:5;s:23:"ipv6IfStatsInAddrErrors";i:6;s:26:"ipv6IfStatsInUnknownProtos";i:7;s:26:"ipv6IfStatsInTruncatedPkts";i:8;s:21:"ipv6IfStatsInDiscards";i:9;s:21:"ipv6IfStatsInDelivers";i:10;s:27:"ipv6IfStatsOutForwDatagrams";i:11;s:22:"ipv6IfStatsOutRequests";i:12;s:22:"ipv6IfStatsOutDiscards";i:13;s:21:"ipv6IfStatsOutFragOKs";i:14;s:23:"ipv6IfStatsOutFragFails";i:15;s:25:"ipv6IfStatsOutFragCreates";i:16;s:21:"ipv6IfStatsReasmReqds";i:17;s:19:"ipv6IfStatsReasmOKs";i:18;s:21:"ipv6IfStatsReasmFails";i:19;s:22:"ipv6IfStatsInMcastPkts";i:20;s:23:"ipv6IfStatsOutMcastPkts";}s:19:"ipv6AddrPrefixTable";a:1:{i:1;s:19:"ipv6AddrPrefixEntry";}s:19:"ipv6AddrPrefixEntry";a:6:{i:1;s:14:"ipv6AddrPrefix";i:2;s:20:"ipv6AddrPrefixLength";i:3;s:24:"ipv6AddrPrefixOnLinkFlag";i:4;s:28:"ipv6AddrPrefixAutonomousFlag";i:5;s:34:"ipv6AddrPrefixAdvPreferredLifetime";i:6;s:30:"ipv6AddrPrefixAdvValidLifetime";}s:13:"ipv6AddrTable";a:1:{i:1;s:13:"ipv6AddrEntry";}s:13:"ipv6AddrEntry";a:5:{i:1;s:15:"ipv6AddrAddress";i:2;s:17:"ipv6AddrPfxLength";i:3;s:12:"ipv6AddrType";i:4;s:19:"ipv6AddrAnycastFlag";i:5;s:14:"ipv6AddrStatus";}s:14:"ipv6RouteTable";a:1:{i:1;s:14:"ipv6RouteEntry";}s:14:"ipv6RouteEntry";a:14:{i:1;s:13:"ipv6RouteDest";i:2;s:18:"ipv6RoutePfxLength";i:3;s:14:"ipv6RouteIndex";i:4;s:16:"ipv6RouteIfIndex";i:5;s:16:"ipv6RouteNextHop";i:6;s:13:"ipv6RouteType";i:7;s:17:"ipv6RouteProtocol";i:8;s:15:"ipv6RoutePolicy";i:9;s:12:"ipv6RouteAge";i:10;s:19:"ipv6RouteNextHopRDI";i:11;s:15:"ipv6RouteMetric";i:12;s:15:"ipv6RouteWeight";i:13;s:13:"ipv6RouteInfo";i:14;s:14:"ipv6RouteValid";}s:19:"ipv6NetToMediaTable";a:1:{i:1;s:19:"ipv6NetToMediaEntry";}s:19:"ipv6NetToMediaEntry";a:6:{i:1;s:24:"ipv6NetToMediaNetAddress";i:2;s:25:"ipv6NetToMediaPhysAddress";i:3;s:18:"ipv6NetToMediaType";i:4;s:21:"ipv6IfNetToMediaState";i:5;s:27:"ipv6IfNetToMediaLastUpdated";i:6;s:19:"ipv6NetToMediaValid";}s:17:"ipv6Notifications";a:1:{i:0;s:22:"ipv6NotificationPrefix";}s:15:"ipv6Conformance";a:2:{i:1;s:15:"ipv6Compliances";i:2;s:10:"ipv6Groups";}s:12:"experimental";a:3:{i:86;s:10:"ipv6TcpMIB";i:87;s:10:"ipv6UdpMIB";i:101;s:19:"snmpUsmDHObjectsMIB";}s:3:"tcp";a:16:{i:16;s:16:"ipv6TcpConnTable";i:1;s:15:"tcpRtoAlgorithm";i:2;s:9:"tcpRtoMin";i:3;s:9:"tcpRtoMax";i:4;s:10:"tcpMaxConn";i:5;s:14:"tcpActiveOpens";i:6;s:15:"tcpPassiveOpens";i:7;s:15:"tcpAttemptFails";i:8;s:14:"tcpEstabResets";i:9;s:12:"tcpCurrEstab";i:10;s:9:"tcpInSegs";i:11;s:10:"tcpOutSegs";i:12;s:14:"tcpRetransSegs";i:13;s:12:"tcpConnTable";i:14;s:9:"tcpInErrs";i:15;s:10:"tcpOutRsts";}s:16:"ipv6TcpConnTable";a:1:{i:1;s:16:"ipv6TcpConnEntry";}s:16:"ipv6TcpConnEntry";a:6:{i:1;s:23:"ipv6TcpConnLocalAddress";i:2;s:20:"ipv6TcpConnLocalPort";i:3;s:21:"ipv6TcpConnRemAddress";i:4;s:18:"ipv6TcpConnRemPort";i:5;s:18:"ipv6TcpConnIfIndex";i:6;s:16:"ipv6TcpConnState";}s:10:"ipv6TcpMIB";a:1:{i:2;s:18:"ipv6TcpConformance";}s:18:"ipv6TcpConformance";a:2:{i:1;s:18:"ipv6TcpCompliances";i:2;s:13:"ipv6TcpGroups";}s:3:"udp";a:6:{i:6;s:12:"ipv6UdpTable";i:1;s:14:"udpInDatagrams";i:2;s:10:"udpNoPorts";i:3;s:11:"udpInErrors";i:4;s:15:"udpOutDatagrams";i:5;s:8:"udpTable";}s:12:"ipv6UdpTable";a:1:{i:1;s:12:"ipv6UdpEntry";}s:12:"ipv6UdpEntry";a:3:{i:1;s:19:"ipv6UdpLocalAddress";i:2;s:16:"ipv6UdpLocalPort";i:3;s:14:"ipv6UdpIfIndex";}s:10:"ipv6UdpMIB";a:1:{i:2;s:18:"ipv6UdpConformance";}s:18:"ipv6UdpConformance";a:2:{i:1;s:18:"ipv6UdpCompliances";i:2;s:13:"ipv6UdpGroups";}s:9:"lmSensors";a:5:{i:1;s:12:"lmSensorsMIB";i:2;s:18:"lmTempSensorsTable";i:3;s:17:"lmFanSensorsTable";i:4;s:18:"lmVoltSensorsTable";i:5;s:18:"lmMiscSensorsTable";}s:15:"ucdExperimental";a:4:{i:16;s:9:"lmSensors";i:15;s:12:"ucdDiskIOMIB";i:14;s:11:"ucdDlmodMIB";i:1;s:13:"ucdIpFwAccMIB";}s:18:"lmTempSensorsTable";a:1:{i:1;s:18:"lmTempSensorsEntry";}s:18:"lmTempSensorsEntry";a:3:{i:1;s:18:"lmTempSensorsIndex";i:2;s:19:"lmTempSensorsDevice";i:3;s:18:"lmTempSensorsValue";}s:17:"lmFanSensorsTable";a:1:{i:1;s:17:"lmFanSensorsEntry";}s:17:"lmFanSensorsEntry";a:3:{i:1;s:17:"lmFanSensorsIndex";i:2;s:18:"lmFanSensorsDevice";i:3;s:17:"lmFanSensorsValue";}s:18:"lmVoltSensorsTable";a:1:{i:1;s:18:"lmVoltSensorsEntry";}s:18:"lmVoltSensorsEntry";a:3:{i:1;s:18:"lmVoltSensorsIndex";i:2;s:19:"lmVoltSensorsDevice";i:3;s:18:"lmVoltSensorsValue";}s:18:"lmMiscSensorsTable";a:1:{i:1;s:18:"lmMiscSensorsEntry";}s:18:"lmMiscSensorsEntry";a:3:{i:1;s:18:"lmMiscSensorsIndex";i:2;s:19:"lmMiscSensorsDevice";i:3;s:18:"lmMiscSensorsValue";}s:16:"netSnmpModuleIDs";a:2:{i:2;s:15:"netSnmpAgentMIB";i:1;s:10:"netSnmpTCs";}s:14:"netSnmpObjects";a:8:{i:1;s:9:"nsVersion";i:2;s:13:"nsMibRegistry";i:3;s:12:"nsExtensions";i:4;s:7:"nsDLMod";i:5;s:7:"nsCache";i:6;s:14:"nsErrorHistory";i:7;s:15:"nsConfiguration";i:8;s:14:"nsTransactions";}s:7:"netSnmp";a:6:{i:2;s:15:"netSnmpExamples";i:1;s:14:"netSnmpObjects";i:3;s:19:"netSnmpEnumerations";i:9999;s:19:"netSnmpExperimental";i:4;s:25:"netSnmpNotificationPrefix";i:5;s:18:"netSnmpConformance";}s:15:"netSnmpExamples";a:3:{i:1;s:21:"netSnmpExampleScalars";i:2;s:20:"netSnmpExampleTables";i:3;s:27:"netSnmpExampleNotifications";}s:27:"netSnmpExampleNotifications";a:3:{i:0;s:32:"netSnmpExampleNotificationPrefix";i:2;s:33:"netSnmpExampleNotificationObjects";i:1;s:26:"netSnmpExampleNotification";}s:21:"netSnmpExampleScalars";a:2:{i:1;s:21:"netSnmpExampleInteger";i:2;s:21:"netSnmpExampleSleeper";}s:20:"netSnmpExampleTables";a:2:{i:1;s:18:"netSnmpIETFWGTable";i:2;s:17:"netSnmpHostsTable";}s:18:"netSnmpIETFWGTable";a:1:{i:1;s:18:"netSnmpIETFWGEntry";}s:18:"netSnmpIETFWGEntry";a:3:{i:1;s:12:"nsIETFWGName";i:2;s:14:"nsIETFWGChair1";i:3;s:14:"nsIETFWGChair2";}s:17:"netSnmpHostsTable";a:1:{i:1;s:17:"netSnmpHostsEntry";}s:17:"netSnmpHostsEntry";a:5:{i:1;s:15:"netSnmpHostName";i:2;s:22:"netSnmpHostAddressType";i:3;s:18:"netSnmpHostAddress";i:4;s:18:"netSnmpHostStorage";i:5;s:20:"netSnmpHostRowStatus";}s:33:"netSnmpExampleNotificationObjects";a:2:{i:1;s:27:"netSnmpExampleHeartbeatRate";i:2;s:27:"netSnmpExampleHeartbeatName";}s:12:"nsExtensions";a:3:{i:1;s:16:"netSnmpExtendMIB";i:2;s:15:"nsExtendObjects";i:3;s:14:"nsExtendGroups";}s:15:"nsExtendObjects";a:4:{i:1;s:18:"nsExtendNumEntries";i:2;s:19:"nsExtendConfigTable";i:3;s:20:"nsExtendOutput1Table";i:4;s:20:"nsExtendOutput2Table";}s:19:"nsExtendConfigTable";a:1:{i:1;s:19:"nsExtendConfigEntry";}s:19:"nsExtendConfigEntry";a:9:{i:1;s:13:"nsExtendToken";i:2;s:15:"nsExtendCommand";i:3;s:12:"nsExtendArgs";i:4;s:13:"nsExtendInput";i:5;s:17:"nsExtendCacheTime";i:6;s:16:"nsExtendExecType";i:7;s:15:"nsExtendRunType";i:20;s:15:"nsExtendStorage";i:21;s:14:"nsExtendStatus";}s:20:"nsExtendOutput1Table";a:1:{i:1;s:20:"nsExtendOutput1Entry";}s:20:"nsExtendOutput1Entry";a:4:{i:1;s:19:"nsExtendOutput1Line";i:2;s:18:"nsExtendOutputFull";i:3;s:19:"nsExtendOutNumLines";i:4;s:14:"nsExtendResult";}s:20:"nsExtendOutput2Table";a:1:{i:1;s:20:"nsExtendOutput2Entry";}s:20:"nsExtendOutput2Entry";a:2:{i:1;s:17:"nsExtendLineIndex";i:2;s:15:"nsExtendOutLine";}s:11:"enterprises";a:3:{i:8072;s:7:"netSnmp";i:4;s:4:"unix";i:2021;s:7:"ucdavis";}s:19:"netSnmpEnumerations";a:3:{i:1;s:16:"netSnmpModuleIDs";i:2;s:16:"netSnmpAgentOIDs";i:3;s:14:"netSnmpDomains";}s:19:"netSnmpExperimental";a:1:{i:9999;s:14:"netSnmpPlaypen";}s:25:"netSnmpNotificationPrefix";a:2:{i:0;s:20:"netSnmpNotifications";i:1;s:26:"netSnmpNotificationObjects";}s:18:"netSnmpConformance";a:2:{i:1;s:18:"netSnmpCompliances";i:2;s:13:"netSnmpGroups";}s:16:"netSnmpAgentOIDs";a:15:{i:1;s:5:"hpux9";i:2;s:6:"sunos4";i:3;s:7:"solaris";i:4;s:3:"osf";i:5;s:6:"ultrix";i:6;s:6:"hpux10";i:7;s:7:"netbsd1";i:8;s:7:"freebsd";i:9;s:4:"irix";i:10;s:5:"linux";i:11;s:4:"bsdi";i:12;s:7:"openbsd";i:13;s:5:"win32";i:14;s:6:"hpux11";i:255;s:7:"unknown";}s:14:"netSnmpDomains";a:6:{i:1;s:16:"netSnmpTCPDomain";i:2;s:17:"netSnmpUnixDomain";i:3;s:20:"netSnmpAAL5PVCDomain";i:4;s:20:"netSnmpUDPIPv6Domain";i:5;s:20:"netSnmpTCPIPv6Domain";i:6;s:21:"netSnmpCallbackDomain";}s:18:"notificationLogMIB";a:2:{i:1;s:25:"notificationLogMIBObjects";i:3;s:29:"notificationLogMIBConformance";}s:25:"notificationLogMIBObjects";a:3:{i:1;s:9:"nlmConfig";i:2;s:8:"nlmStats";i:3;s:6:"nlmLog";}s:9:"nlmConfig";a:3:{i:1;s:25:"nlmConfigGlobalEntryLimit";i:2;s:21:"nlmConfigGlobalAgeOut";i:3;s:17:"nlmConfigLogTable";}s:17:"nlmConfigLogTable";a:1:{i:1;s:17:"nlmConfigLogEntry";}s:17:"nlmConfigLogEntry";a:7:{i:1;s:10:"nlmLogName";i:2;s:22:"nlmConfigLogFilterName";i:3;s:22:"nlmConfigLogEntryLimit";i:4;s:23:"nlmConfigLogAdminStatus";i:5;s:22:"nlmConfigLogOperStatus";i:6;s:23:"nlmConfigLogStorageType";i:7;s:23:"nlmConfigLogEntryStatus";}s:8:"nlmStats";a:3:{i:1;s:33:"nlmStatsGlobalNotificationsLogged";i:2;s:33:"nlmStatsGlobalNotificationsBumped";i:3;s:16:"nlmStatsLogTable";}s:16:"nlmStatsLogTable";a:1:{i:1;s:16:"nlmStatsLogEntry";}s:16:"nlmStatsLogEntry";a:2:{i:1;s:30:"nlmStatsLogNotificationsLogged";i:2;s:30:"nlmStatsLogNotificationsBumped";}s:6:"nlmLog";a:2:{i:1;s:11:"nlmLogTable";i:2;s:19:"nlmLogVariableTable";}s:11:"nlmLogTable";a:1:{i:1;s:11:"nlmLogEntry";}s:11:"nlmLogEntry";a:9:{i:1;s:11:"nlmLogIndex";i:2;s:10:"nlmLogTime";i:3;s:17:"nlmLogDateAndTime";i:4;s:14:"nlmLogEngineID";i:5;s:20:"nlmLogEngineTAddress";i:6;s:19:"nlmLogEngineTDomain";i:7;s:21:"nlmLogContextEngineID";i:8;s:17:"nlmLogContextName";i:9;s:20:"nlmLogNotificationID";}s:19:"nlmLogVariableTable";a:1:{i:1;s:19:"nlmLogVariableEntry";}s:19:"nlmLogVariableEntry";a:12:{i:1;s:19:"nlmLogVariableIndex";i:2;s:16:"nlmLogVariableID";i:3;s:23:"nlmLogVariableValueType";i:4;s:26:"nlmLogVariableCounter32Val";i:5;s:27:"nlmLogVariableUnsigned32Val";i:6;s:26:"nlmLogVariableTimeTicksVal";i:7;s:26:"nlmLogVariableInteger32Val";i:8;s:28:"nlmLogVariableOctetStringVal";i:9;s:26:"nlmLogVariableIpAddressVal";i:10;s:20:"nlmLogVariableOidVal";i:11;s:26:"nlmLogVariableCounter64Val";i:12;s:23:"nlmLogVariableOpaqueVal";}s:29:"notificationLogMIBConformance";a:2:{i:1;s:29:"notificationLogMIBCompliances";i:2;s:24:"notificationLogMIBGroups";}s:8:"internet";a:6:{i:1;s:9:"directory";i:2;s:4:"mgmt";i:3;s:12:"experimental";i:4;s:7:"private";i:5;s:8:"security";i:6;s:6:"snmpV2";}s:7:"private";a:1:{i:1;s:11:"enterprises";}s:4:"mgmt";a:1:{i:1;s:5:"mib-2";}s:6:"system";a:9:{i:1;s:8:"sysDescr";i:2;s:11:"sysObjectID";i:3;s:9:"sysUpTime";i:4;s:10:"sysContact";i:5;s:7:"sysName";i:6;s:11:"sysLocation";i:7;s:11:"sysServices";i:8;s:15:"sysORLastChange";i:9;s:10:"sysORTable";}s:2:"at";a:1:{i:1;s:7:"atTable";}s:7:"atTable";a:1:{i:1;s:7:"atEntry";}s:7:"atEntry";a:3:{i:1;s:9:"atIfIndex";i:2;s:13:"atPhysAddress";i:3;s:12:"atNetAddress";}s:12:"ipRouteTable";a:1:{i:1;s:12:"ipRouteEntry";}s:12:"ipRouteEntry";a:13:{i:1;s:11:"ipRouteDest";i:2;s:14:"ipRouteIfIndex";i:3;s:14:"ipRouteMetric1";i:4;s:14:"ipRouteMetric2";i:5;s:14:"ipRouteMetric3";i:6;s:14:"ipRouteMetric4";i:7;s:14:"ipRouteNextHop";i:8;s:11:"ipRouteType";i:9;s:12:"ipRouteProto";i:10;s:10:"ipRouteAge";i:11;s:11:"ipRouteMask";i:12;s:14:"ipRouteMetric5";i:13;s:11:"ipRouteInfo";}s:12:"tcpConnTable";a:1:{i:1;s:12:"tcpConnEntry";}s:12:"tcpConnEntry";a:5:{i:1;s:12:"tcpConnState";i:2;s:19:"tcpConnLocalAddress";i:3;s:16:"tcpConnLocalPort";i:4;s:17:"tcpConnRemAddress";i:5;s:14:"tcpConnRemPort";}s:8:"udpTable";a:1:{i:1;s:8:"udpEntry";}s:8:"udpEntry";a:2:{i:1;s:15:"udpLocalAddress";i:2;s:12:"udpLocalPort";}s:3:"egp";a:6:{i:1;s:9:"egpInMsgs";i:2;s:11:"egpInErrors";i:3;s:10:"egpOutMsgs";i:4;s:12:"egpOutErrors";i:5;s:13:"egpNeighTable";i:6;s:5:"egpAs";}s:13:"egpNeighTable";a:1:{i:1;s:13:"egpNeighEntry";}s:13:"egpNeighEntry";a:15:{i:1;s:13:"egpNeighState";i:2;s:12:"egpNeighAddr";i:3;s:10:"egpNeighAs";i:4;s:14:"egpNeighInMsgs";i:5;s:14:"egpNeighInErrs";i:6;s:15:"egpNeighOutMsgs";i:7;s:15:"egpNeighOutErrs";i:8;s:17:"egpNeighInErrMsgs";i:9;s:18:"egpNeighOutErrMsgs";i:10;s:16:"egpNeighStateUps";i:11;s:18:"egpNeighStateDowns";i:12;s:21:"egpNeighIntervalHello";i:13;s:20:"egpNeighIntervalPoll";i:14;s:12:"egpNeighMode";i:15;s:20:"egpNeighEventTrigger";}s:4:"snmp";a:30:{i:1;s:10:"snmpInPkts";i:2;s:11:"snmpOutPkts";i:3;s:17:"snmpInBadVersions";i:4;s:23:"snmpInBadCommunityNames";i:5;s:22:"snmpInBadCommunityUses";i:6;s:18:"snmpInASNParseErrs";i:8;s:13:"snmpInTooBigs";i:9;s:17:"snmpInNoSuchNames";i:10;s:15:"snmpInBadValues";i:11;s:15:"snmpInReadOnlys";i:12;s:13:"snmpInGenErrs";i:13;s:18:"snmpInTotalReqVars";i:14;s:18:"snmpInTotalSetVars";i:15;s:17:"snmpInGetRequests";i:16;s:14:"snmpInGetNexts";i:17;s:17:"snmpInSetRequests";i:18;s:18:"snmpInGetResponses";i:19;s:11:"snmpInTraps";i:20;s:14:"snmpOutTooBigs";i:21;s:18:"snmpOutNoSuchNames";i:22;s:16:"snmpOutBadValues";i:24;s:14:"snmpOutGenErrs";i:25;s:18:"snmpOutGetRequests";i:26;s:15:"snmpOutGetNexts";i:27;s:18:"snmpOutSetRequests";i:28;s:19:"snmpOutGetResponses";i:29;s:12:"snmpOutTraps";i:30;s:21:"snmpEnableAuthenTraps";i:31;s:15:"snmpSilentDrops";i:32;s:14:"snmpProxyDrops";}s:15:"rmonConformance";a:3:{i:8;s:13:"rmonMibModule";i:9;s:15:"rmonCompliances";i:10;s:10:"rmonGroups";}s:4:"rmon";a:11:{i:1;s:10:"statistics";i:2;s:7:"history";i:3;s:5:"alarm";i:4;s:5:"hosts";i:5;s:8:"hostTopN";i:6;s:6:"matrix";i:7;s:6:"filter";i:8;s:7:"capture";i:9;s:5:"event";i:20;s:15:"rmonConformance";i:0;s:12:"rmonEventsV2";}s:10:"statistics";a:1:{i:1;s:15:"etherStatsTable";}s:15:"etherStatsTable";a:1:{i:1;s:15:"etherStatsEntry";}s:15:"etherStatsEntry";a:21:{i:1;s:15:"etherStatsIndex";i:2;s:20:"etherStatsDataSource";i:3;s:20:"etherStatsDropEvents";i:4;s:16:"etherStatsOctets";i:5;s:14:"etherStatsPkts";i:6;s:23:"etherStatsBroadcastPkts";i:7;s:23:"etherStatsMulticastPkts";i:8;s:24:"etherStatsCRCAlignErrors";i:9;s:23:"etherStatsUndersizePkts";i:10;s:22:"etherStatsOversizePkts";i:11;s:19:"etherStatsFragments";i:12;s:17:"etherStatsJabbers";i:13;s:20:"etherStatsCollisions";i:14;s:22:"etherStatsPkts64Octets";i:15;s:27:"etherStatsPkts65to127Octets";i:16;s:28:"etherStatsPkts128to255Octets";i:17;s:28:"etherStatsPkts256to511Octets";i:18;s:29:"etherStatsPkts512to1023Octets";i:19;s:30:"etherStatsPkts1024to1518Octets";i:20;s:15:"etherStatsOwner";i:21;s:16:"etherStatsStatus";}s:7:"history";a:2:{i:1;s:19:"historyControlTable";i:2;s:17:"etherHistoryTable";}s:19:"historyControlTable";a:1:{i:1;s:19:"historyControlEntry";}s:19:"historyControlEntry";a:7:{i:1;s:19:"historyControlIndex";i:2;s:24:"historyControlDataSource";i:3;s:30:"historyControlBucketsRequested";i:4;s:28:"historyControlBucketsGranted";i:5;s:22:"historyControlInterval";i:6;s:19:"historyControlOwner";i:7;s:20:"historyControlStatus";}s:17:"etherHistoryTable";a:1:{i:1;s:17:"etherHistoryEntry";}s:17:"etherHistoryEntry";a:15:{i:1;s:17:"etherHistoryIndex";i:2;s:23:"etherHistorySampleIndex";i:3;s:25:"etherHistoryIntervalStart";i:4;s:22:"etherHistoryDropEvents";i:5;s:18:"etherHistoryOctets";i:6;s:16:"etherHistoryPkts";i:7;s:25:"etherHistoryBroadcastPkts";i:8;s:25:"etherHistoryMulticastPkts";i:9;s:26:"etherHistoryCRCAlignErrors";i:10;s:25:"etherHistoryUndersizePkts";i:11;s:24:"etherHistoryOversizePkts";i:12;s:21:"etherHistoryFragments";i:13;s:19:"etherHistoryJabbers";i:14;s:22:"etherHistoryCollisions";i:15;s:23:"etherHistoryUtilization";}s:5:"alarm";a:1:{i:1;s:10:"alarmTable";}s:10:"alarmTable";a:1:{i:1;s:10:"alarmEntry";}s:10:"alarmEntry";a:12:{i:1;s:10:"alarmIndex";i:2;s:13:"alarmInterval";i:3;s:13:"alarmVariable";i:4;s:15:"alarmSampleType";i:5;s:10:"alarmValue";i:6;s:17:"alarmStartupAlarm";i:7;s:20:"alarmRisingThreshold";i:8;s:21:"alarmFallingThreshold";i:9;s:21:"alarmRisingEventIndex";i:10;s:22:"alarmFallingEventIndex";i:11;s:10:"alarmOwner";i:12;s:11:"alarmStatus";}s:5:"hosts";a:3:{i:1;s:16:"hostControlTable";i:2;s:9:"hostTable";i:3;s:13:"hostTimeTable";}s:16:"hostControlTable";a:1:{i:1;s:16:"hostControlEntry";}s:16:"hostControlEntry";a:6:{i:1;s:16:"hostControlIndex";i:2;s:21:"hostControlDataSource";i:3;s:20:"hostControlTableSize";i:4;s:25:"hostControlLastDeleteTime";i:5;s:16:"hostControlOwner";i:6;s:17:"hostControlStatus";}s:9:"hostTable";a:1:{i:1;s:9:"hostEntry";}s:9:"hostEntry";a:10:{i:1;s:11:"hostAddress";i:2;s:17:"hostCreationOrder";i:3;s:9:"hostIndex";i:4;s:10:"hostInPkts";i:5;s:11:"hostOutPkts";i:6;s:12:"hostInOctets";i:7;s:13:"hostOutOctets";i:8;s:13:"hostOutErrors";i:9;s:20:"hostOutBroadcastPkts";i:10;s:20:"hostOutMulticastPkts";}s:13:"hostTimeTable";a:1:{i:1;s:13:"hostTimeEntry";}s:13:"hostTimeEntry";a:10:{i:1;s:15:"hostTimeAddress";i:2;s:21:"hostTimeCreationOrder";i:3;s:13:"hostTimeIndex";i:4;s:14:"hostTimeInPkts";i:5;s:15:"hostTimeOutPkts";i:6;s:16:"hostTimeInOctets";i:7;s:17:"hostTimeOutOctets";i:8;s:17:"hostTimeOutErrors";i:9;s:24:"hostTimeOutBroadcastPkts";i:10;s:24:"hostTimeOutMulticastPkts";}s:8:"hostTopN";a:2:{i:1;s:20:"hostTopNControlTable";i:2;s:13:"hostTopNTable";}s:20:"hostTopNControlTable";a:1:{i:1;s:20:"hostTopNControlEntry";}s:20:"hostTopNControlEntry";a:10:{i:1;s:20:"hostTopNControlIndex";i:2;s:17:"hostTopNHostIndex";i:3;s:16:"hostTopNRateBase";i:4;s:21:"hostTopNTimeRemaining";i:5;s:16:"hostTopNDuration";i:6;s:21:"hostTopNRequestedSize";i:7;s:19:"hostTopNGrantedSize";i:8;s:17:"hostTopNStartTime";i:9;s:13:"hostTopNOwner";i:10;s:14:"hostTopNStatus";}s:13:"hostTopNTable";a:1:{i:1;s:13:"hostTopNEntry";}s:13:"hostTopNEntry";a:4:{i:1;s:14:"hostTopNReport";i:2;s:13:"hostTopNIndex";i:3;s:15:"hostTopNAddress";i:4;s:12:"hostTopNRate";}s:6:"matrix";a:3:{i:1;s:18:"matrixControlTable";i:2;s:13:"matrixSDTable";i:3;s:13:"matrixDSTable";}s:18:"matrixControlTable";a:1:{i:1;s:18:"matrixControlEntry";}s:18:"matrixControlEntry";a:6:{i:1;s:18:"matrixControlIndex";i:2;s:23:"matrixControlDataSource";i:3;s:22:"matrixControlTableSize";i:4;s:27:"matrixControlLastDeleteTime";i:5;s:18:"matrixControlOwner";i:6;s:19:"matrixControlStatus";}s:13:"matrixSDTable";a:1:{i:1;s:13:"matrixSDEntry";}s:13:"matrixSDEntry";a:6:{i:1;s:21:"matrixSDSourceAddress";i:2;s:19:"matrixSDDestAddress";i:3;s:13:"matrixSDIndex";i:4;s:12:"matrixSDPkts";i:5;s:14:"matrixSDOctets";i:6;s:14:"matrixSDErrors";}s:13:"matrixDSTable";a:1:{i:1;s:13:"matrixDSEntry";}s:13:"matrixDSEntry";a:6:{i:1;s:21:"matrixDSSourceAddress";i:2;s:19:"matrixDSDestAddress";i:3;s:13:"matrixDSIndex";i:4;s:12:"matrixDSPkts";i:5;s:14:"matrixDSOctets";i:6;s:14:"matrixDSErrors";}s:6:"filter";a:2:{i:1;s:11:"filterTable";i:2;s:12:"channelTable";}s:11:"filterTable";a:1:{i:1;s:11:"filterEntry";}s:11:"filterEntry";a:11:{i:1;s:11:"filterIndex";i:2;s:18:"filterChannelIndex";i:3;s:19:"filterPktDataOffset";i:4;s:13:"filterPktData";i:5;s:17:"filterPktDataMask";i:6;s:20:"filterPktDataNotMask";i:7;s:15:"filterPktStatus";i:8;s:19:"filterPktStatusMask";i:9;s:22:"filterPktStatusNotMask";i:10;s:11:"filterOwner";i:11;s:12:"filterStatus";}s:12:"channelTable";a:1:{i:1;s:12:"channelEntry";}s:12:"channelEntry";a:12:{i:1;s:12:"channelIndex";i:2;s:14:"channelIfIndex";i:3;s:17:"channelAcceptType";i:4;s:18:"channelDataControl";i:5;s:23:"channelTurnOnEventIndex";i:6;s:24:"channelTurnOffEventIndex";i:7;s:17:"channelEventIndex";i:8;s:18:"channelEventStatus";i:9;s:14:"channelMatches";i:10;s:18:"channelDescription";i:11;s:12:"channelOwner";i:12;s:13:"channelStatus";}s:7:"capture";a:2:{i:1;s:18:"bufferControlTable";i:2;s:18:"captureBufferTable";}s:18:"bufferControlTable";a:1:{i:1;s:18:"bufferControlEntry";}s:18:"bufferControlEntry";a:13:{i:1;s:18:"bufferControlIndex";i:2;s:25:"bufferControlChannelIndex";i:3;s:23:"bufferControlFullStatus";i:4;s:23:"bufferControlFullAction";i:5;s:29:"bufferControlCaptureSliceSize";i:6;s:30:"bufferControlDownloadSliceSize";i:7;s:27:"bufferControlDownloadOffset";i:8;s:31:"bufferControlMaxOctetsRequested";i:9;s:29:"bufferControlMaxOctetsGranted";i:10;s:28:"bufferControlCapturedPackets";i:11;s:23:"bufferControlTurnOnTime";i:12;s:18:"bufferControlOwner";i:13;s:19:"bufferControlStatus";}s:18:"captureBufferTable";a:1:{i:1;s:18:"captureBufferEntry";}s:18:"captureBufferEntry";a:7:{i:1;s:25:"captureBufferControlIndex";i:2;s:18:"captureBufferIndex";i:3;s:21:"captureBufferPacketID";i:4;s:23:"captureBufferPacketData";i:5;s:25:"captureBufferPacketLength";i:6;s:23:"captureBufferPacketTime";i:7;s:25:"captureBufferPacketStatus";}s:5:"event";a:2:{i:1;s:10:"eventTable";i:2;s:8:"logTable";}s:10:"eventTable";a:1:{i:1;s:10:"eventEntry";}s:10:"eventEntry";a:7:{i:1;s:10:"eventIndex";i:2;s:16:"eventDescription";i:3;s:9:"eventType";i:4;s:14:"eventCommunity";i:5;s:17:"eventLastTimeSent";i:6;s:10:"eventOwner";i:7;s:11:"eventStatus";}s:8:"logTable";a:1:{i:1;s:8:"logEntry";}s:8:"logEntry";a:4:{i:1;s:13:"logEventIndex";i:2;s:8:"logIndex";i:3;s:7:"logTime";i:4;s:14:"logDescription";}s:4:"unix";a:1:{i:4;s:4:"smux";}s:4:"smux";a:2:{i:1;s:13:"smuxPeerTable";i:2;s:13:"smuxTreeTable";}s:13:"smuxPeerTable";a:1:{i:1;s:13:"smuxPeerEntry";}s:13:"smuxPeerEntry";a:4:{i:1;s:10:"smuxPindex";i:2;s:13:"smuxPidentity";i:3;s:16:"smuxPdescription";i:4;s:11:"smuxPstatus";}s:13:"smuxTreeTable";a:1:{i:1;s:13:"smuxTreeEntry";}s:13:"smuxTreeEntry";a:4:{i:1;s:12:"smuxTsubtree";i:2;s:13:"smuxTpriority";i:3;s:10:"smuxTindex";i:4;s:11:"smuxTstatus";}s:11:"snmpModules";a:11:{i:18;s:16:"snmpCommunityMIB";i:10;s:16:"snmpFrameworkMIB";i:11;s:10:"snmpMPDMIB";i:13;s:19:"snmpNotificationMIB";i:14;s:12:"snmpProxyMIB";i:12;s:13:"snmpTargetMIB";i:15;s:10:"snmpUsmMIB";i:20;s:13:"snmpUsmAesMIB";i:16;s:11:"snmpVacmMIB";i:1;s:7:"snmpMIB";i:19;s:8:"snmpv2tm";}s:16:"snmpCommunityMIB";a:2:{i:1;s:23:"snmpCommunityMIBObjects";i:2;s:27:"snmpCommunityMIBConformance";}s:23:"snmpCommunityMIBObjects";a:4:{i:1;s:18:"snmpCommunityTable";i:2;s:22:"snmpTargetAddrExtTable";i:3;s:15:"snmpTrapAddress";i:4;s:17:"snmpTrapCommunity";}s:18:"snmpCommunityTable";a:1:{i:1;s:18:"snmpCommunityEntry";}s:18:"snmpCommunityEntry";a:8:{i:1;s:18:"snmpCommunityIndex";i:2;s:17:"snmpCommunityName";i:3;s:25:"snmpCommunitySecurityName";i:4;s:28:"snmpCommunityContextEngineID";i:5;s:24:"snmpCommunityContextName";i:6;s:25:"snmpCommunityTransportTag";i:7;s:24:"snmpCommunityStorageType";i:8;s:19:"snmpCommunityStatus";}s:22:"snmpTargetAddrExtTable";a:1:{i:1;s:22:"snmpTargetAddrExtEntry";}s:22:"snmpTargetAddrExtEntry";a:2:{i:1;s:19:"snmpTargetAddrTMask";i:2;s:17:"snmpTargetAddrMMS";}s:27:"snmpCommunityMIBConformance";a:2:{i:1;s:27:"snmpCommunityMIBCompliances";i:2;s:22:"snmpCommunityMIBGroups";}s:16:"snmpFrameworkMIB";a:3:{i:1;s:18:"snmpFrameworkAdmin";i:2;s:23:"snmpFrameworkMIBObjects";i:3;s:27:"snmpFrameworkMIBConformance";}s:23:"snmpFrameworkMIBObjects";a:1:{i:1;s:10:"snmpEngine";}s:10:"snmpEngine";a:4:{i:1;s:12:"snmpEngineID";i:2;s:15:"snmpEngineBoots";i:3;s:14:"snmpEngineTime";i:4;s:24:"snmpEngineMaxMessageSize";}s:18:"snmpFrameworkAdmin";a:2:{i:1;s:17:"snmpAuthProtocols";i:2;s:17:"snmpPrivProtocols";}s:27:"snmpFrameworkMIBConformance";a:2:{i:1;s:27:"snmpFrameworkMIBCompliances";i:2;s:22:"snmpFrameworkMIBGroups";}s:10:"snmpMPDMIB";a:3:{i:1;s:12:"snmpMPDAdmin";i:2;s:17:"snmpMPDMIBObjects";i:3;s:21:"snmpMPDMIBConformance";}s:17:"snmpMPDMIBObjects";a:1:{i:1;s:12:"snmpMPDStats";}s:12:"snmpMPDStats";a:3:{i:1;s:25:"snmpUnknownSecurityModels";i:2;s:15:"snmpInvalidMsgs";i:3;s:22:"snmpUnknownPDUHandlers";}s:21:"snmpMPDMIBConformance";a:2:{i:1;s:21:"snmpMPDMIBCompliances";i:2;s:16:"snmpMPDMIBGroups";}s:19:"snmpNotificationMIB";a:2:{i:1;s:17:"snmpNotifyObjects";i:3;s:21:"snmpNotifyConformance";}s:17:"snmpNotifyObjects";a:3:{i:1;s:15:"snmpNotifyTable";i:2;s:28:"snmpNotifyFilterProfileTable";i:3;s:21:"snmpNotifyFilterTable";}s:15:"snmpNotifyTable";a:1:{i:1;s:15:"snmpNotifyEntry";}s:15:"snmpNotifyEntry";a:5:{i:1;s:14:"snmpNotifyName";i:2;s:13:"snmpNotifyTag";i:3;s:14:"snmpNotifyType";i:4;s:21:"snmpNotifyStorageType";i:5;s:19:"snmpNotifyRowStatus";}s:28:"snmpNotifyFilterProfileTable";a:1:{i:1;s:28:"snmpNotifyFilterProfileEntry";}s:28:"snmpNotifyFilterProfileEntry";a:3:{i:1;s:27:"snmpNotifyFilterProfileName";i:2;s:31:"snmpNotifyFilterProfileStorType";i:3;s:32:"snmpNotifyFilterProfileRowStatus";}s:21:"snmpNotifyFilterTable";a:1:{i:1;s:21:"snmpNotifyFilterEntry";}s:21:"snmpNotifyFilterEntry";a:5:{i:1;s:23:"snmpNotifyFilterSubtree";i:2;s:20:"snmpNotifyFilterMask";i:3;s:20:"snmpNotifyFilterType";i:4;s:27:"snmpNotifyFilterStorageType";i:5;s:25:"snmpNotifyFilterRowStatus";}s:21:"snmpNotifyConformance";a:2:{i:1;s:21:"snmpNotifyCompliances";i:2;s:16:"snmpNotifyGroups";}s:12:"snmpProxyMIB";a:2:{i:1;s:16:"snmpProxyObjects";i:3;s:20:"snmpProxyConformance";}s:16:"snmpProxyObjects";a:1:{i:2;s:14:"snmpProxyTable";}s:14:"snmpProxyTable";a:1:{i:1;s:14:"snmpProxyEntry";}s:14:"snmpProxyEntry";a:9:{i:1;s:13:"snmpProxyName";i:2;s:13:"snmpProxyType";i:3;s:24:"snmpProxyContextEngineID";i:4;s:20:"snmpProxyContextName";i:5;s:23:"snmpProxyTargetParamsIn";i:6;s:24:"snmpProxySingleTargetOut";i:7;s:26:"snmpProxyMultipleTargetOut";i:8;s:20:"snmpProxyStorageType";i:9;s:18:"snmpProxyRowStatus";}s:20:"snmpProxyConformance";a:2:{i:1;s:20:"snmpProxyCompliances";i:2;s:15:"snmpProxyGroups";}s:13:"snmpTargetMIB";a:2:{i:1;s:17:"snmpTargetObjects";i:3;s:21:"snmpTargetConformance";}s:17:"snmpTargetObjects";a:5:{i:1;s:18:"snmpTargetSpinLock";i:2;s:19:"snmpTargetAddrTable";i:3;s:21:"snmpTargetParamsTable";i:4;s:23:"snmpUnavailableContexts";i:5;s:19:"snmpUnknownContexts";}s:19:"snmpTargetAddrTable";a:1:{i:1;s:19:"snmpTargetAddrEntry";}s:19:"snmpTargetAddrEntry";a:9:{i:1;s:18:"snmpTargetAddrName";i:2;s:21:"snmpTargetAddrTDomain";i:3;s:22:"snmpTargetAddrTAddress";i:4;s:21:"snmpTargetAddrTimeout";i:5;s:24:"snmpTargetAddrRetryCount";i:6;s:21:"snmpTargetAddrTagList";i:7;s:20:"snmpTargetAddrParams";i:8;s:25:"snmpTargetAddrStorageType";i:9;s:23:"snmpTargetAddrRowStatus";}s:21:"snmpTargetParamsTable";a:1:{i:1;s:21:"snmpTargetParamsEntry";}s:21:"snmpTargetParamsEntry";a:7:{i:1;s:20:"snmpTargetParamsName";i:2;s:23:"snmpTargetParamsMPModel";i:3;s:29:"snmpTargetParamsSecurityModel";i:4;s:28:"snmpTargetParamsSecurityName";i:5;s:29:"snmpTargetParamsSecurityLevel";i:6;s:27:"snmpTargetParamsStorageType";i:7;s:25:"snmpTargetParamsRowStatus";}s:21:"snmpTargetConformance";a:2:{i:1;s:21:"snmpTargetCompliances";i:2;s:16:"snmpTargetGroups";}s:10:"snmpUsmMIB";a:2:{i:1;s:13:"usmMIBObjects";i:2;s:17:"usmMIBConformance";}s:17:"snmpAuthProtocols";a:3:{i:1;s:17:"usmNoAuthProtocol";i:2;s:22:"usmHMACMD5AuthProtocol";i:3;s:22:"usmHMACSHAAuthProtocol";}s:17:"snmpPrivProtocols";a:3:{i:1;s:17:"usmNoPrivProtocol";i:2;s:18:"usmDESPrivProtocol";i:4;s:20:"usmAesCfb128Protocol";}s:13:"usmMIBObjects";a:2:{i:1;s:8:"usmStats";i:2;s:7:"usmUser";}s:8:"usmStats";a:6:{i:1;s:28:"usmStatsUnsupportedSecLevels";i:2;s:24:"usmStatsNotInTimeWindows";i:3;s:24:"usmStatsUnknownUserNames";i:4;s:24:"usmStatsUnknownEngineIDs";i:5;s:20:"usmStatsWrongDigests";i:6;s:24:"usmStatsDecryptionErrors";}s:7:"usmUser";a:2:{i:1;s:15:"usmUserSpinLock";i:2;s:12:"usmUserTable";}s:12:"usmUserTable";a:1:{i:1;s:12:"usmUserEntry";}s:12:"usmUserEntry";a:13:{i:1;s:15:"usmUserEngineID";i:2;s:11:"usmUserName";i:3;s:19:"usmUserSecurityName";i:4;s:16:"usmUserCloneFrom";i:5;s:19:"usmUserAuthProtocol";i:6;s:20:"usmUserAuthKeyChange";i:7;s:23:"usmUserOwnAuthKeyChange";i:8;s:19:"usmUserPrivProtocol";i:9;s:20:"usmUserPrivKeyChange";i:10;s:23:"usmUserOwnPrivKeyChange";i:11;s:13:"usmUserPublic";i:12;s:18:"usmUserStorageType";i:13;s:13:"usmUserStatus";}s:17:"usmMIBConformance";a:2:{i:1;s:17:"usmMIBCompliances";i:2;s:12:"usmMIBGroups";}s:19:"snmpUsmDHObjectsMIB";a:2:{i:1;s:15:"usmDHKeyObjects";i:2;s:19:"usmDHKeyConformance";}s:15:"usmDHKeyObjects";a:2:{i:1;s:18:"usmDHPublicObjects";i:2;s:19:"usmDHKickstartGroup";}s:18:"usmDHPublicObjects";a:2:{i:1;s:15:"usmDHParameters";i:2;s:17:"usmDHUserKeyTable";}s:17:"usmDHUserKeyTable";a:1:{i:1;s:17:"usmDHUserKeyEntry";}s:17:"usmDHUserKeyEntry";a:4:{i:1;s:22:"usmDHUserAuthKeyChange";i:2;s:25:"usmDHUserOwnAuthKeyChange";i:3;s:22:"usmDHUserPrivKeyChange";i:4;s:25:"usmDHUserOwnPrivKeyChange";}s:19:"usmDHKickstartGroup";a:1:{i:1;s:19:"usmDHKickstartTable";}s:19:"usmDHKickstartTable";a:1:{i:1;s:19:"usmDHKickstartEntry";}s:19:"usmDHKickstartEntry";a:4:{i:1;s:19:"usmDHKickstartIndex";i:2;s:22:"usmDHKickstartMyPublic";i:3;s:23:"usmDHKickstartMgrPublic";i:4;s:26:"usmDHKickstartSecurityName";}s:19:"usmDHKeyConformance";a:2:{i:1;s:22:"usmDHKeyMIBCompliances";i:2;s:17:"usmDHKeyMIBGroups";}s:11:"snmpVacmMIB";a:2:{i:1;s:14:"vacmMIBObjects";i:2;s:18:"vacmMIBConformance";}s:14:"vacmMIBObjects";a:4:{i:1;s:16:"vacmContextTable";i:2;s:24:"vacmSecurityToGroupTable";i:4;s:15:"vacmAccessTable";i:5;s:12:"vacmMIBViews";}s:16:"vacmContextTable";a:1:{i:1;s:16:"vacmContextEntry";}s:16:"vacmContextEntry";a:1:{i:1;s:15:"vacmContextName";}s:24:"vacmSecurityToGroupTable";a:1:{i:1;s:24:"vacmSecurityToGroupEntry";}s:24:"vacmSecurityToGroupEntry";a:5:{i:1;s:17:"vacmSecurityModel";i:2;s:16:"vacmSecurityName";i:3;s:13:"vacmGroupName";i:4;s:30:"vacmSecurityToGroupStorageType";i:5;s:25:"vacmSecurityToGroupStatus";}s:15:"vacmAccessTable";a:1:{i:1;s:15:"vacmAccessEntry";}s:15:"vacmAccessEntry";a:9:{i:1;s:23:"vacmAccessContextPrefix";i:2;s:23:"vacmAccessSecurityModel";i:3;s:23:"vacmAccessSecurityLevel";i:4;s:22:"vacmAccessContextMatch";i:5;s:22:"vacmAccessReadViewName";i:6;s:23:"vacmAccessWriteViewName";i:7;s:24:"vacmAccessNotifyViewName";i:8;s:21:"vacmAccessStorageType";i:9;s:16:"vacmAccessStatus";}s:12:"vacmMIBViews";a:2:{i:1;s:16:"vacmViewSpinLock";i:2;s:23:"vacmViewTreeFamilyTable";}s:23:"vacmViewTreeFamilyTable";a:1:{i:1;s:23:"vacmViewTreeFamilyEntry";}s:23:"vacmViewTreeFamilyEntry";a:6:{i:1;s:26:"vacmViewTreeFamilyViewName";i:2;s:25:"vacmViewTreeFamilySubtree";i:3;s:22:"vacmViewTreeFamilyMask";i:4;s:22:"vacmViewTreeFamilyType";i:5;s:29:"vacmViewTreeFamilyStorageType";i:6;s:24:"vacmViewTreeFamilyStatus";}s:18:"vacmMIBConformance";a:2:{i:1;s:18:"vacmMIBCompliances";i:2;s:13:"vacmMIBGroups";}s:7:"snmpMIB";a:2:{i:1;s:14:"snmpMIBObjects";i:2;s:18:"snmpMIBConformance";}s:10:"sysORTable";a:1:{i:1;s:10:"sysOREntry";}s:10:"sysOREntry";a:4:{i:1;s:10:"sysORIndex";i:2;s:7:"sysORID";i:3;s:10:"sysORDescr";i:4;s:11:"sysORUpTime";}s:14:"snmpMIBObjects";a:3:{i:4;s:8:"snmpTrap";i:5;s:9:"snmpTraps";i:6;s:7:"snmpSet";}s:8:"snmpTrap";a:2:{i:1;s:11:"snmpTrapOID";i:3;s:18:"snmpTrapEnterprise";}s:7:"snmpSet";a:1:{i:1;s:15:"snmpSetSerialNo";}s:18:"snmpMIBConformance";a:2:{i:1;s:18:"snmpMIBCompliances";i:2;s:13:"snmpMIBGroups";}s:3:"iso";a:1:{i:3;s:3:"org";}s:3:"org";a:1:{i:6;s:3:"dod";}s:3:"dod";a:1:{i:1;s:8:"internet";}s:6:"snmpV2";a:3:{i:1;s:11:"snmpDomains";i:2;s:10:"snmpProxys";i:3;s:11:"snmpModules";}s:11:"snmpDomains";a:5:{i:1;s:13:"snmpUDPDomain";i:2;s:14:"snmpCLNSDomain";i:3;s:14:"snmpCONSDomain";i:4;s:13:"snmpDDPDomain";i:5;s:13:"snmpIPXDomain";}s:10:"snmpProxys";a:1:{i:1;s:12:"rfc1157Proxy";}s:12:"rfc1157Proxy";a:1:{i:1;s:13:"rfc1157Domain";}s:6:"tcpMIB";a:1:{i:2;s:17:"tcpMIBConformance";}s:17:"tcpMIBConformance";a:2:{i:1;s:17:"tcpMIBCompliances";i:2;s:12:"tcpMIBGroups";}s:19:"transportAddressMIB";a:1:{i:1;s:16:"transportDomains";}s:16:"transportDomains";a:16:{i:1;s:22:"transportDomainUdpIpv4";i:2;s:22:"transportDomainUdpIpv6";i:3;s:23:"transportDomainUdpIpv4z";i:4;s:23:"transportDomainUdpIpv6z";i:5;s:22:"transportDomainTcpIpv4";i:6;s:22:"transportDomainTcpIpv6";i:7;s:23:"transportDomainTcpIpv4z";i:8;s:23:"transportDomainTcpIpv6z";i:9;s:23:"transportDomainSctpIpv4";i:10;s:23:"transportDomainSctpIpv6";i:11;s:24:"transportDomainSctpIpv4z";i:12;s:24:"transportDomainSctpIpv6z";i:13;s:20:"transportDomainLocal";i:14;s:21:"transportDomainUdpDns";i:15;s:21:"transportDomainTcpDns";i:16;s:22:"transportDomainSctpDns";}s:7:"ucdavis";a:16:{i:14;s:10:"ucdDemoMIB";i:12;s:11:"ucdInternal";i:13;s:15:"ucdExperimental";i:250;s:12:"ucdSnmpAgent";i:2;s:7:"prTable";i:8;s:8:"extTable";i:4;s:6:"memory";i:9;s:8:"dskTable";i:10;s:7:"laTable";i:100;s:7:"version";i:101;s:8:"snmperrs";i:102;s:7:"mrTable";i:11;s:11:"systemStats";i:251;s:8:"ucdTraps";i:15;s:9:"fileTable";i:16;s:8:"logMatch";}s:10:"ucdDemoMIB";a:1:{i:1;s:17:"ucdDemoMIBObjects";}s:17:"ucdDemoMIBObjects";a:1:{i:1;s:13:"ucdDemoPublic";}s:13:"ucdDemoPublic";a:4:{i:1;s:16:"ucdDemoResetKeys";i:2;s:19:"ucdDemoPublicString";i:3;s:15:"ucdDemoUserList";i:4;s:17:"ucdDemoPassphrase";}s:12:"ucdDiskIOMIB";a:1:{i:1;s:11:"diskIOTable";}s:11:"diskIOTable";a:1:{i:1;s:11:"diskIOEntry";}s:11:"diskIOEntry";a:9:{i:1;s:11:"diskIOIndex";i:2;s:12:"diskIODevice";i:3;s:11:"diskIONRead";i:4;s:14:"diskIONWritten";i:5;s:11:"diskIOReads";i:6;s:12:"diskIOWrites";i:9;s:9:"diskIOLA1";i:10;s:9:"diskIOLA5";i:11;s:10:"diskIOLA15";}s:11:"ucdDlmodMIB";a:2:{i:1;s:14:"dlmodNextIndex";i:2;s:10:"dlmodTable";}s:10:"dlmodTable";a:1:{i:1;s:10:"dlmodEntry";}s:10:"dlmodEntry";a:5:{i:1;s:10:"dlmodIndex";i:2;s:9:"dlmodName";i:3;s:9:"dlmodPath";i:4;s:10:"dlmodError";i:5;s:11:"dlmodStatus";}s:13:"ucdIpFwAccMIB";a:1:{i:1;s:12:"ipFwAccTable";}s:12:"ipFwAccTable";a:1:{i:1;s:12:"ipFwAccEntry";}s:12:"ipFwAccEntry";a:26:{i:1;s:12:"ipFwAccIndex";i:2;s:14:"ipFwAccSrcAddr";i:3;s:17:"ipFwAccSrcNetMask";i:4;s:14:"ipFwAccDstAddr";i:5;s:17:"ipFwAccDstNetMask";i:6;s:14:"ipFwAccViaName";i:7;s:14:"ipFwAccViaAddr";i:8;s:12:"ipFwAccProto";i:9;s:12:"ipFwAccBidir";i:10;s:10:"ipFwAccDir";i:11;s:12:"ipFwAccBytes";i:12;s:14:"ipFwAccPackets";i:13;s:17:"ipFwAccNrSrcPorts";i:14;s:17:"ipFwAccNrDstPorts";i:15;s:17:"ipFwAccSrcIsRange";i:16;s:17:"ipFwAccDstIsRange";i:17;s:12:"ipFwAccPort1";i:18;s:12:"ipFwAccPort2";i:19;s:12:"ipFwAccPort3";i:20;s:12:"ipFwAccPort4";i:21;s:12:"ipFwAccPort5";i:22;s:12:"ipFwAccPort6";i:23;s:12:"ipFwAccPort7";i:24;s:12:"ipFwAccPort8";i:25;s:12:"ipFwAccPort9";i:26;s:13:"ipFwAccPort10";}s:12:"ucdSnmpAgent";a:15:{i:1;s:5:"hpux9";i:2;s:6:"sunos4";i:3;s:7:"solaris";i:4;s:3:"osf";i:5;s:6:"ultrix";i:6;s:6:"hpux10";i:7;s:7:"netbsd1";i:8;s:7:"freebsd";i:9;s:4:"irix";i:10;s:5:"linux";i:11;s:4:"bsdi";i:12;s:7:"openbsd";i:13;s:5:"win32";i:14;s:6:"hpux11";i:255;s:7:"unknown";}s:7:"prTable";a:1:{i:1;s:7:"prEntry";}s:7:"prEntry";a:9:{i:1;s:7:"prIndex";i:2;s:7:"prNames";i:3;s:5:"prMin";i:4;s:5:"prMax";i:5;s:7:"prCount";i:100;s:11:"prErrorFlag";i:101;s:12:"prErrMessage";i:102;s:8:"prErrFix";i:103;s:11:"prErrFixCmd";}s:8:"extTable";a:1:{i:1;s:8:"extEntry";}s:8:"extEntry";a:7:{i:1;s:8:"extIndex";i:2;s:8:"extNames";i:3;s:10:"extCommand";i:100;s:9:"extResult";i:101;s:9:"extOutput";i:102;s:9:"extErrFix";i:103;s:12:"extErrFixCmd";}s:6:"memory";a:17:{i:1;s:8:"memIndex";i:2;s:12:"memErrorName";i:3;s:12:"memTotalSwap";i:4;s:12:"memAvailSwap";i:5;s:12:"memTotalReal";i:6;s:12:"memAvailReal";i:7;s:15:"memTotalSwapTXT";i:8;s:15:"memAvailSwapTXT";i:9;s:15:"memTotalRealTXT";i:10;s:15:"memAvailRealTXT";i:11;s:12:"memTotalFree";i:12;s:14:"memMinimumSwap";i:13;s:9:"memShared";i:14;s:9:"memBuffer";i:15;s:9:"memCached";i:100;s:12:"memSwapError";i:101;s:15:"memSwapErrorMsg";}s:8:"dskTable";a:1:{i:1;s:8:"dskEntry";}s:8:"dskEntry";a:12:{i:1;s:8:"dskIndex";i:2;s:7:"dskPath";i:3;s:9:"dskDevice";i:4;s:10:"dskMinimum";i:5;s:13:"dskMinPercent";i:6;s:8:"dskTotal";i:7;s:8:"dskAvail";i:8;s:7:"dskUsed";i:9;s:10:"dskPercent";i:10;s:14:"dskPercentNode";i:100;s:12:"dskErrorFlag";i:101;s:11:"dskErrorMsg";}s:7:"laTable";a:1:{i:1;s:7:"laEntry";}s:7:"laEntry";a:8:{i:1;s:7:"laIndex";i:2;s:7:"laNames";i:3;s:6:"laLoad";i:4;s:8:"laConfig";i:5;s:9:"laLoadInt";i:6;s:11:"laLoadFloat";i:100;s:11:"laErrorFlag";i:101;s:12:"laErrMessage";}s:7:"version";a:11:{i:1;s:12:"versionIndex";i:2;s:10:"versionTag";i:3;s:11:"versionDate";i:4;s:12:"versionCDate";i:5;s:12:"versionIdent";i:6;s:23:"versionConfigureOptions";i:10;s:17:"versionClearCache";i:11;s:19:"versionUpdateConfig";i:12;s:19:"versionRestartAgent";i:13;s:25:"versionSavePersistentData";i:20;s:18:"versionDoDebugging";}s:8:"snmperrs";a:4:{i:1;s:12:"snmperrIndex";i:2;s:12:"snmperrNames";i:100;s:16:"snmperrErrorFlag";i:101;s:17:"snmperrErrMessage";}s:7:"mrTable";a:1:{i:1;s:7:"mrEntry";}s:7:"mrEntry";a:2:{i:1;s:7:"mrIndex";i:2;s:12:"mrModuleName";}s:11:"systemStats";a:25:{i:1;s:7:"ssIndex";i:2;s:11:"ssErrorName";i:3;s:8:"ssSwapIn";i:4;s:9:"ssSwapOut";i:5;s:8:"ssIOSent";i:6;s:11:"ssIOReceive";i:7;s:15:"ssSysInterrupts";i:8;s:12:"ssSysContext";i:9;s:9:"ssCpuUser";i:10;s:11:"ssCpuSystem";i:11;s:9:"ssCpuIdle";i:50;s:12:"ssCpuRawUser";i:51;s:12:"ssCpuRawNice";i:52;s:14:"ssCpuRawSystem";i:53;s:12:"ssCpuRawIdle";i:54;s:12:"ssCpuRawWait";i:55;s:14:"ssCpuRawKernel";i:56;s:17:"ssCpuRawInterrupt";i:57;s:11:"ssIORawSent";i:58;s:15:"ssIORawReceived";i:59;s:15:"ssRawInterrupts";i:60;s:13:"ssRawContexts";i:61;s:15:"ssCpuRawSoftIRQ";i:62;s:11:"ssRawSwapIn";i:63;s:12:"ssRawSwapOut";}s:9:"fileTable";a:1:{i:1;s:9:"fileEntry";}s:9:"fileEntry";a:6:{i:1;s:9:"fileIndex";i:2;s:8:"fileName";i:3;s:8:"fileSize";i:4;s:7:"fileMax";i:100;s:13:"fileErrorFlag";i:101;s:12:"fileErrorMsg";}s:8:"logMatch";a:2:{i:1;s:18:"logMatchMaxEntries";i:2;s:13:"logMatchTable";}s:13:"logMatchTable";a:1:{i:1;s:13:"logMatchEntry";}s:13:"logMatchEntry";a:13:{i:1;s:13:"logMatchIndex";i:2;s:12:"logMatchName";i:3;s:16:"logMatchFilename";i:4;s:13:"logMatchRegEx";i:5;s:21:"logMatchGlobalCounter";i:6;s:19:"logMatchGlobalCount";i:7;s:22:"logMatchCurrentCounter";i:8;s:20:"logMatchCurrentCount";i:9;s:15:"logMatchCounter";i:10;s:13:"logMatchCount";i:11;s:13:"logMatchCycle";i:100;s:17:"logMatchErrorFlag";i:101;s:24:"logMatchRegExCompilation";}s:6:"udpMIB";a:1:{i:2;s:17:"udpMIBConformance";}s:17:"udpMIBConformance";a:2:{i:1;s:17:"udpMIBCompliances";i:2;s:12:"udpMIBGroups";}} -------------------------------------------------------------------------------- /oid_format.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage mib_compiler 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | define('OID_NUMERIC', 1); 35 | define('OID_TEXT', 0); 36 | function oid_format($oid, $format=OID_TEXT) 37 | { 38 | static $nodes = NULL; 39 | 40 | if(is_null($oid) || (is_array($oid) && count($oid) == 0) || (!is_array($oid) && strlen($oid) == 0)) return $oid; 41 | 42 | if(is_null($nodes)) 43 | $nodes = unserialize(file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'oid_format.data')); 44 | 45 | $ret_type = 'string'; 46 | if(is_array($oid)) 47 | { 48 | $oid = join('.', $oid); 49 | $ret_type = 'array'; 50 | } 51 | elseif($oid{0} != '.') 52 | $oid = '1.3.6.1.2.1.' . $oid; 53 | 54 | while($oid{0} == '.') $oid = substr($oid, 1); 55 | 56 | $oid = explode('.', $oid); 57 | 58 | $parent = ''; 59 | for($i = 0; $i < count($oid); $i++) 60 | { 61 | if(!isset($nodes[$parent])) 62 | { 63 | if($ret_type == 'array') return $oid; 64 | return '.' . join('.', $oid); 65 | } 66 | $rec = $nodes[$parent]; 67 | if(is_numeric($oid[$i])) 68 | { 69 | if(!isset($rec[$oid[$i]])) 70 | { 71 | if($ret_type == 'array') return $oid; 72 | return '.' . join('.', $oid); 73 | } 74 | $parent = $rec[$oid[$i]]; 75 | if($format == OID_TEXT) $oid[$i] = $parent; 76 | } 77 | else 78 | { 79 | $z = array_search($oid[$i], $rec); 80 | if($z === false) 81 | { 82 | if($ret_type == 'array') return $oid; 83 | return '.' . join('.', $oid); 84 | } 85 | $parent = $rec[$z]; 86 | if($format == OID_NUMERIC) $oid[$i] = $z; 87 | } 88 | } 89 | if($ret_type == 'array') return $oid; 90 | return '.' . join('.', $oid); 91 | } 92 | ?> 93 | -------------------------------------------------------------------------------- /rfc1155.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc1155 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'oid_format.php'); 35 | 36 | /** 37 | * Dump a string in Hex and stripped ascii 38 | * 39 | * @param string $string 40 | * @return string 41 | */ 42 | function hexdump($string) 43 | { 44 | $ret = ''; 45 | for($i = 0; $i < strlen($string); $i++) 46 | $ret .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT) . ' '; 47 | $ret .= '['; 48 | for($i = 0; $i < strlen($string); $i++) 49 | { 50 | $o = ord($string{$i}); 51 | if($o < 32 || $o > 127) $ret .= '.'; 52 | else $ret .= chr($o); 53 | } 54 | return $ret . "]\n"; 55 | } 56 | 57 | /** 58 | * Convert a hex string to raw data 59 | * 60 | * @param string $hex 61 | * @return string 62 | */ 63 | function hexbin($hex) // convert a hex string to raw data 64 | { 65 | $ret = ''; 66 | foreach(explode(' ', $hex) as $c) 67 | $ret .= chr(hexdec($c)); 68 | return $ret; 69 | } 70 | 71 | /** 72 | * Divide with Remainder 73 | * 74 | * This public function uses float operation to do what was done with bit operations on integers previously. 75 | * This is the result of PHP automatically converting large numbers to floats. PHP has no unsigned longs. 76 | * One advantage is that it can handle 64 bit integers, although some precision is lost. 77 | * 78 | * @param integer $numerator 79 | * @param integer $denominator 80 | * @return array(quotient, remainder) 81 | */ 82 | function divide_with_remainder($numerator, $denominator) 83 | { 84 | $q = intval($numerator / $denominator); 85 | $r = intval(($numerator / $denominator - $q) * $denominator); 86 | return array($q, $r); 87 | } 88 | 89 | define('ASN_TAG_CLASS_UNIVERSAL', 0x00); 90 | define('ASN_TAG_CLASS_APPLICATION', 0x40); 91 | define('ASN_TAG_CLASS_CONTEXT', 0x80); 92 | define('ASN_TAG_CLASS_PRIVATE', 0xC0); 93 | 94 | define('ASN_TAG_FORMAT_PRIMITIVE', 0x00); 95 | define('ASN_TAG_FORMAT_CONSTRUCTED', 0x20); 96 | 97 | define('ASN_TAG_BOOLEAN', 0x01); 98 | define('ASN_TAG_INTEGER', 0x02); 99 | define('ASN_TAG_OCTETSTRING', 0x04); 100 | define('ASN_TAG_NULL', 0x05); 101 | define('ASN_TAG_OBJECTID', 0x06); 102 | define('ASN_TAG_SEQUENCE', 0x10); 103 | 104 | define('ASN_TAG_IPADDRESS', 0x00); 105 | define('ASN_TAG_COUNTER', 0x01); 106 | define('ASN_TAG_GUAGE', 0x02); 107 | define('ASN_TAG_TIMETICKS', 0x03); 108 | define('ASN_TAG_OPAQUE', 0x04); 109 | 110 | $ASN_TAG_DICT[0x01] = 'rfc1155_Boolean'; 111 | $ASN_TAG_DICT[0x02] = 'rfc1155_Integer'; 112 | $ASN_TAG_DICT[0x04] = 'rfc1155_OctetString'; 113 | $ASN_TAG_DICT[0x05] = 'rfc1155_Null'; 114 | $ASN_TAG_DICT[0x06] = 'rfc1155_ObjectID'; 115 | $ASN_TAG_DICT[0x30] = 'rfc1155_Sequence'; 116 | $ASN_TAG_DICT[0x40] = 'rfc1155_IPAddress'; 117 | $ASN_TAG_DICT[0x41] = 'rfc1155_Counter'; 118 | $ASN_TAG_DICT[0x42] = 'rfc1155_Guage'; 119 | $ASN_TAG_DICT[0x43] = 'rfc1155_TimeTicks'; 120 | $ASN_TAG_DICT[0x44] = 'rfc1155_Opaque'; 121 | $GLOBALS["ASN_TAG_DICT"] = $ASN_TAG_DICT; 122 | 123 | /** 124 | * Asn1Objects 125 | * 126 | * Base class for all Asn1Objects. This is only intended to support a specific subset of ASN1 stuff as 127 | * defined by the RFCs to keep things as simple as possible. 128 | * 129 | * @package phpSNMP 130 | * @subpackage rfc1155 131 | */ 132 | class rfc1155_Asn1Object 133 | { 134 | var $asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 135 | var $asnTagFormat= ASN_TAG_FORMAT_PRIMITIVE; 136 | var $asnTagNumber = NULL; 137 | 138 | var $value = NULL; 139 | 140 | /** 141 | * Constructor 142 | */ 143 | public function __construct(){} 144 | 145 | /** 146 | * Encode Asn1Object 147 | * 148 | * encode() this Asn1Object using BER 149 | * 150 | * @return string encoded object 151 | */ 152 | public function encode() 153 | { 154 | $contents = $this->encodeContents(); 155 | return $this->encodeIdentifier() . $this->encodeLength(strlen($contents)) . $contents; 156 | } 157 | 158 | /** 159 | * Decode Tag 160 | * 161 | * Decode a BER tag field, returning the tag and the remainder of the stream 162 | * 163 | * @param string $stream 164 | * @return array (tag, remaining_stream) 165 | */ 166 | public function decodeTag($stream) 167 | { 168 | $tag = ord($stream{0}); 169 | $n = 1; 170 | if(($tag & 0x1F) == 0x1F) 171 | { 172 | /* A large tag is encoded using concatenated 7-bit values over the following octets, ignoring the initial 5 bits 173 | in the first octet. The 8th bit represents a follow-on. */ 174 | $tag = 0; 175 | do 176 | { 177 | $byte = ord($stream{$n}); 178 | $tag = $tag * 128 + ($byte & 0x7F); 179 | $n += 1; 180 | } while($byte & 0x80); 181 | } 182 | return array($tag, substr($stream, $n)); 183 | } 184 | 185 | /** 186 | * Decode Length 187 | * 188 | * Decode a BER length field, returing the length and the remainder of the stream 189 | * 190 | * @param string $stream 191 | * @return array (length, remaining_stream) 192 | */ 193 | public function decodeLength($stream) 194 | { 195 | $length = ord($stream{0}); 196 | $i = 1; 197 | if($length & 0x80) 198 | { 199 | // Multi-Octet length encoding. The first octet represents the run-length (the number of octets used to build the length) 200 | $run = $length & 0x7F; 201 | $length = 0; 202 | for($i = 1; $i <= $run; $i++) 203 | $length = $length * 256 + ord($stream{$i}); 204 | } 205 | return array($length, substr($stream, $i)); 206 | } 207 | 208 | /** 209 | * Decode Stream 210 | * 211 | * decode() an octet stream into a sequence of Asn1Objects 212 | * 213 | * @param string $stream 214 | * @return array of rfc1155_Asn1Object 215 | */ 216 | public function decode($stream) 217 | { 218 | /* This method should be overridden by subclasses to define how to decode one of themselves from a fixed length stream. This 219 | general case method looks at the identifier at the beginning of a stream of octets and uses the appropriate decode() method 220 | of that known object. Attempts to decode() an unknown object type result in an error. */ 221 | if(!is_string($stream)) 222 | { 223 | trigger_error('stream should be of a string, not a ' . gettype($stream), E_USER_WARNING); 224 | return array(); 225 | } 226 | 227 | $objects = array(); 228 | while(strlen($stream) > 0) 229 | { 230 | 231 | list($tag, $stream) = $this->decodeTag($stream); 232 | list($length, $stream) = $this->decodeLength($stream); 233 | 234 | $objectData = substr($stream, 0, $length); 235 | $stream = substr($stream, $length); 236 | 237 | global $ASN_TAG_DICT; 238 | if(isset($ASN_TAG_DICT[$tag])) 239 | { 240 | $decoder = $ASN_TAG_DICT[$tag]; 241 | $o = new $decoder(); 242 | $objects[] = $o->decodeContents($objectData); 243 | } 244 | else 245 | trigger_error("Unknown ASN.1 Type 0x" . dechex($tag), E_USER_WARNING); 246 | } 247 | return $objects; 248 | } 249 | 250 | /** 251 | * Encode Contents 252 | * 253 | * encodeContents must be overridden by subclasses to encode the contents of a particular type 254 | * 255 | * @return string 256 | */ 257 | public function encodeContents() 258 | { 259 | trigger_error('encodeContents not implemented', E_USER_ERROR); 260 | } 261 | 262 | /** 263 | * Encode Identifier 264 | * 265 | * encodeIdentifier() returns encoded identifier octets for this object. Section 6.3 of ITU-T-X.209 266 | * 267 | * @return string 268 | */ 269 | public function encodeIdentifier() 270 | { 271 | if($this->asnTagNumber < 0x1F) 272 | { 273 | return chr($this->asnTagClass | $this->asnTagFormat | $this->asnTagNumber); 274 | } 275 | else 276 | { 277 | /* Encode each number of the asnTagNumber from 31 upwards as a sequence of 7-bit numbers with bit 8 set to 1 for 278 | all but the last octet. Bit 8 set to 0 signifies the last octet of the Identifier octets */ 279 | 280 | // encode the first octet 281 | $resultlist = array(); 282 | $resultlist[] = chr($this->asnTagClass | $this->asnTagFormat | 0x1F); 283 | 284 | // encode each subsequent octet 285 | $integer = $this->asnTagNumber; 286 | while($integer != 0) 287 | { 288 | list($integer, $remainder) = divide_with_remainder($integer, 256); 289 | $resultlist[] = chr($remainder); 290 | } 291 | 292 | return join('', $resultlist); 293 | } 294 | } 295 | 296 | /** 297 | * Encode Length 298 | * 299 | * encodeLength() takes the length of the contents and produces the encoding for that length. Section 6.3 of ITU-T-X.209 300 | * 301 | * define('SNMP_SHORT_INT_LENGTH', 1) to encode as short; needed by some Cisco software 302 | * 303 | * @param integer $length 304 | * @return string 305 | */ 306 | public function encodeLength($length) 307 | { 308 | if(defined('SNMP_SHORT_INT_LENGTH')) // hack to be compatible with Cisco software 309 | { 310 | list($a, $b) = divide_with_remainder($length, 256); 311 | return chr(0x82) . chr($a) . chr($b); 312 | } 313 | elseif($length < 127) 314 | return chr($length & 0xff); 315 | else 316 | { 317 | /* Long form - Octet one is the number of octets used to encode the length It has bit 8 set to 1 and the remaining 7 bits are 318 | used to encode the number of octets used to encode the length Each subsequent octet uses all 8 bits to encode the length */ 319 | $resultlist = array(); 320 | $numOctets = 0; 321 | while($length > 0) 322 | { 323 | list($length, $remainder) = divide_with_remainder($length, 256); 324 | array_unshift($resultlist, chr($remainder)); 325 | $numOctets++; 326 | } 327 | 328 | // Add a 1 to the front of the octet 329 | $numOctets = $numOctets | 0x80; 330 | array_unshift($resultlist, chr($numOctets & 0xff)); 331 | 332 | return join('', $resultlist); 333 | } 334 | } 335 | 336 | /** 337 | * Encode End of Contents 338 | * 339 | * @return string 340 | */ 341 | public function encodeEndOfContents() 342 | { 343 | return "\000\000"; 344 | } 345 | } 346 | 347 | /** 348 | * rfc1155 Boolean 349 | * 350 | * An ASN.1 Boolean type 351 | * 352 | * @package phpSNMP 353 | * @subpackage rfc1155 354 | */ 355 | class rfc1155_Boolean extends rfc1155_Asn1Object 356 | { 357 | /** 358 | * Constructor 359 | * 360 | * @param boolean $value 361 | */ 362 | public function __construct($value=true) 363 | { 364 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 365 | $this->asnTagNumber = ASN_TAG_BOOLEAN; 366 | 367 | $this->value = ($value) ? true : false; 368 | } 369 | 370 | /** 371 | * ToString 372 | * 373 | * @return string value of this object 374 | */ 375 | public function toString() 376 | { 377 | return ($this->value) ? 'true' : 'false'; 378 | } 379 | 380 | /** 381 | * Encode Contents 382 | * 383 | * encode into an octet stream 384 | * 385 | * @return string 386 | */ 387 | public function encodeContents() 388 | { 389 | trigger_error('encodeContents not written yet', E_USER_ERROR); 390 | } 391 | 392 | /** 393 | * Decode Contents 394 | * 395 | * Decode octet stream 396 | * 397 | * @param string $stream 398 | * @return rfc1155_Boolean 399 | */ 400 | public function decodeContents(/*$stream*/) 401 | { 402 | trigger_error('decodeContents not written yet', E_USER_ERROR); 403 | return $this; 404 | } 405 | } 406 | 407 | /** 408 | * rfc1155 Integer 409 | * 410 | * An ASN.1 Integer type 411 | * 412 | * @package phpSNMP 413 | * @subpackage rfc1155 414 | */ 415 | class rfc1155_Integer extends rfc1155_Asn1Object 416 | { 417 | /** 418 | * Constructor 419 | * 420 | * @param integer $value 421 | */ 422 | public function __construct($value=0) 423 | { 424 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 425 | $this->asnTagNumber = ASN_TAG_INTEGER; 426 | $this->check_range($value); 427 | $this->value = $value; 428 | } 429 | 430 | /** 431 | * Check range for integer value 432 | * 433 | * @param integer $value 434 | * @param integer $min 435 | * @param integer $max 436 | */ 437 | public function check_range($value, $min=NULL, $max=NULL) 438 | { 439 | static $MINVAL = -2147483648; 440 | static $MAXVAL = 2147483647; 441 | if(!is_null($min)) $MINVAL = $min; 442 | if(!is_null($max)) $MAXVAL = $max; 443 | 444 | $value = intval($value); 445 | if(is_null($min) && is_null($max) && ($value < $MINVAL || $value > $MAXVAL)) 446 | { 447 | trigger_error("Integer value of $value (".gettype($value).") is out of bounds ($MINVAL to $MAXVAL)", E_USER_WARNING); 448 | } 449 | } 450 | 451 | /** 452 | * ToString 453 | * 454 | * @return string value of this object 455 | */ 456 | public function toString() 457 | { 458 | return $this->value; 459 | } 460 | 461 | /** 462 | * Encode Contents 463 | * 464 | * encode into an octet stream 465 | * 466 | * @return string 467 | */ 468 | public function encodeContents() 469 | { 470 | // We handle two special cases otherwise we handle positive and negative numbers independently 471 | 472 | $integer = $this->value; 473 | 474 | if($integer == 0) 475 | return "\000"; 476 | elseif($integer == -1) 477 | return "\377"; 478 | elseif($integer > 0) 479 | { 480 | $result = array(); 481 | while($integer != 0) 482 | { 483 | list($integer, $remainder) = divide_with_remainder($integer, 256); 484 | array_unshift($result, $remainder); 485 | } 486 | if($result[0] & 0x80) 487 | array_unshift($result, 0); 488 | return join('', array_map('chr', $result)); 489 | } 490 | else 491 | { 492 | $result = array(); 493 | while($integer != 0) 494 | { 495 | list($integer, $remainder) = divide_with_remainder($integer, 256); 496 | array_unshift($result, $remainder); 497 | } 498 | if($result[0] & 0x80 != 0x80) 499 | array_unshift($result, 0); 500 | return join('', array_map('chr', $result)); 501 | } 502 | } 503 | 504 | /** 505 | * Decode Contents 506 | * 507 | * Decode octet stream 508 | * 509 | * @param string $stream 510 | * @return rfc1155_Integer 511 | */ 512 | public function decodeContents($stream) 513 | { 514 | $this->value = 0; 515 | $byte = ord($stream{0}); 516 | if(($byte & 0x80) == 0x80) 517 | { 518 | $negbit = 0x80; 519 | $this->value = $byte & 0x7f; 520 | for($i = 1; $i < strlen($stream); $i++) 521 | { 522 | $negbit *= 256; 523 | $this->value = $this->value * 256 + ord($stream{$i}); 524 | } 525 | $this->value = $this->value - $negbit; 526 | } 527 | else 528 | { 529 | $this->value = $byte; 530 | for($i = 1; $i < strlen($stream); $i++) 531 | $this->value = $this->value * 256 + ord($stream{$i}); 532 | } 533 | return $this; 534 | } 535 | } 536 | 537 | /** 538 | * rfc1155 Octet String 539 | * 540 | * An ASN.1 Octet String type 541 | * 542 | * @package phpSNMP 543 | * @subpackage rfc1155 544 | */ 545 | class rfc1155_OctetString extends rfc1155_Asn1Object 546 | { 547 | /** 548 | * Constructor 549 | * 550 | * @param strin $value 551 | */ 552 | public function __construct($value='') 553 | { 554 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 555 | $this->asnTagNumber = ASN_TAG_OCTETSTRING; 556 | $this->value = $value; 557 | } 558 | 559 | /** 560 | * Is Printable? 561 | * 562 | * Decides if its value is printable 563 | * 564 | * @return boolean 565 | */ 566 | public function is_printable() 567 | { 568 | for($i = strlen($this->value) - 1; $i >= 0; $i--) 569 | { 570 | if($this->value{$i} != "\n" && $this->value{$i} != "\t" && $this->value{$i} != "\r") 571 | { 572 | if(ord($this->value{$i}) < 16 || ord($this->value{$i}) > 127) 573 | { 574 | return false; 575 | } 576 | } 577 | } 578 | return true; 579 | } 580 | 581 | /** 582 | * to Hex 583 | * 584 | * Converts its value to a hex string 585 | * 586 | * @return string 587 | */ 588 | public function toHex() 589 | { 590 | $ret = ''; 591 | for($i = 0; $i < strlen($this->value); $i++) 592 | $ret .= str_pad(dechex(ord($this->value{$i})), 2, '0', STR_PAD_LEFT) . ' '; 593 | return trim($ret); 594 | } 595 | 596 | /** 597 | * toString 598 | * 599 | * @return string 600 | */ 601 | public function toString() 602 | { 603 | if($this->is_printable()) 604 | return $this->value; 605 | else 606 | return $this->toHex(); 607 | } 608 | 609 | /** 610 | * Encode Contents 611 | * 612 | * encode into an octet stream 613 | * 614 | * @return string 615 | */ 616 | public function encodeContents() 617 | { 618 | // An OctetString is already encoded. Whee! 619 | return $this->value; 620 | } 621 | 622 | /** 623 | * Decode Contents 624 | * 625 | * Decode octet stream 626 | * 627 | * @param string $stream 628 | * @return rfc1155_OctetString 629 | */ 630 | public function decodeContents($stream) 631 | { 632 | // An OctetString is already decoded. Whee! 633 | $this->value = $stream; 634 | return $this; 635 | } 636 | } 637 | 638 | /** 639 | * rfc1155 Object Identifier (oid) 640 | * 641 | * An ASN.1 Object Identifier type 642 | * 643 | * @package phpSNMP 644 | * @subpackage rfc1155 645 | */ 646 | class rfc1155_ObjectID extends rfc1155_Asn1Object 647 | { 648 | /** 649 | * Constructor 650 | * 651 | * @param string $value 652 | */ 653 | public function __construct($value=array()) 654 | { 655 | // Create an ObjectID - value is a list of subids as a string or list 656 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 657 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 658 | $this->asnTagNumber = ASN_TAG_OBJECTID; 659 | 660 | if(is_string($value)) 661 | $this->value = explode('.', $value); 662 | elseif(is_array($value)) 663 | $this->value = $value; 664 | elseif(is_null($value)) 665 | $this->value = array(); 666 | else 667 | trigger_error('Unknown type passed as OID', E_USER_WARNING); 668 | 669 | $this->value = oid_format($this->value, OID_NUMERIC); 670 | 671 | foreach($this->value as $subid) 672 | if($subid < 0 || $subid > 0x7FFFFFFF) 673 | trigger_error("SubID $subid out of range", E_USER_WARNING); 674 | } 675 | 676 | /** 677 | * toString 678 | * 679 | * @return string 680 | */ 681 | public function toString() 682 | { 683 | return '.' . join('.', $this->value); 684 | } 685 | 686 | /** 687 | * Encode Contents 688 | * 689 | * encode into an octet stream 690 | * 691 | * @return string 692 | */ 693 | public function encodeContents() 694 | { 695 | $result = array(); 696 | $idlist = $this->value; 697 | 698 | // Do the bit with the first 2 subids; section 22.4 of X.209 699 | $idlist = array_reverse($idlist); 700 | $subid1 = (array_pop($idlist) * 40) + array_pop($idlist); 701 | $idlist = array_reverse($idlist); 702 | array_unshift($idlist, $subid1); 703 | foreach($idlist as $subid) 704 | { 705 | if(!is_numeric($subid)) 706 | { 707 | trigger_error('Unable to encode non-numeric OID', E_USER_WARNING); 708 | return ''; 709 | } 710 | if($subid < 128) 711 | $result[] = chr($subid & 0x7f); 712 | else 713 | { 714 | list($subid, $remainder) = divide_with_remainder($subid, 128); 715 | $r = array(chr($remainder)); 716 | while($subid > 0) 717 | { 718 | list($subid, $remainder) = divide_with_remainder($subid, 128); 719 | $r[] = chr(0x80 | $remainder); 720 | } 721 | for($i = count($r) - 1; $i >=0; $i--) $result[] = $r[$i]; 722 | } 723 | } 724 | return join('', $result); 725 | } 726 | 727 | /** 728 | * Decode Contents 729 | * 730 | * Decode octet stream 731 | * 732 | * @param string $stream 733 | * @return rfc1155_ObjectID 734 | */ 735 | public function decodeContents($stream) 736 | { 737 | $this->value = array(); 738 | 739 | if(strlen($stream) == 0) 740 | { 741 | trigger_error('Stream of zero length in ' . get_class($this), E_USER_WARNING); 742 | return $this; 743 | } 744 | 745 | // Do the funky decode of the first octet 746 | if(ord($stream{0}) < 128) 747 | { 748 | $this->value[] = intval(ord($stream{0}) / 40); 749 | $this->value[] = ord($stream{0}) % 40; 750 | } 751 | else 752 | { 753 | /* I haven't bothered putting in the convoluted logic here because the highest likely assignment for the first 754 | octet is 83 according to Annex B of X.208 Those X.209 does give as an example 2.100.3, which is kinda stupid. 755 | Actually, a lot of the space-saving encodings, like this first octet, are a real PITA later on. So yeah, 756 | stuff it, we'll just raise an exception. */ 757 | 758 | trigger_error('NotImplementedError: First octet is > 128! Unsupported oid detected', E_USER_ERROR); 759 | return $this; 760 | } 761 | 762 | // Decode the rest of the octets 763 | $n = 1; 764 | while($n < strlen($stream)) 765 | { 766 | $subid = ord($stream{$n}); 767 | $n += 1; 768 | 769 | // If bit 8 is not set, this is the last octet of this subid 770 | // If bit 8 is set, the subid spans this octet and the ones afterwards, up until bit 8 isn't set. 771 | if(($subid & 0x80) == 0x80) 772 | { 773 | $val = $subid & 0x7f; 774 | while(($subid & 0x80) == 0x80) 775 | { 776 | $subid = ord($stream{$n}); 777 | $n += 1; 778 | $val = $val * 128 + ($subid & 0x7f); 779 | } 780 | $this->value[] = $val; 781 | } 782 | else 783 | { 784 | $this->value[] = $subid; 785 | } 786 | } 787 | return $this; 788 | } 789 | } 790 | 791 | /** 792 | * rfc1155 Null 793 | * 794 | * An ASN.1 Null type 795 | * 796 | * @package phpSNMP 797 | * @subpackage rfc1155 798 | */ 799 | class rfc1155_Null extends rfc1155_Asn1Object // An ASN.1 Object Identifier type 800 | { 801 | /** 802 | * Constructor 803 | */ 804 | public function __construct() 805 | { 806 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 807 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 808 | $this->asnTagNumber = ASN_TAG_NULL; 809 | } 810 | 811 | /** 812 | * toString 813 | * 814 | * @return string 815 | */ 816 | public function toString() 817 | { 818 | return ''; 819 | } 820 | 821 | /** 822 | * Encode Contents 823 | * 824 | * encode into an octet stream 825 | * 826 | * @return string 827 | */ 828 | public function encodeContents() 829 | { 830 | return ''; 831 | } 832 | 833 | /** 834 | * Decode Contents 835 | * 836 | * Decode octet stream 837 | * 838 | * @param string $stream 839 | * @return rfc1155_Null 840 | */ 841 | public function decodeContents($stream) 842 | { 843 | if(strlen($stream) != 0) 844 | trigger_error('Input stream too long for ' . get_class($this), E_USER_WARNING); 845 | return $this; 846 | } 847 | } 848 | 849 | /** 850 | * rfc1155 Sequence 851 | * 852 | * An ASN.1 Sequence type 853 | * 854 | * A Sequence is basically a list of name, value pairs with the name being an object Type and the 855 | * value being an instance of an Asn1Object of that Type. 856 | * 857 | * @package phpSNMP 858 | * @subpackage rfc1155 859 | */ 860 | class rfc1155_Sequence extends rfc1155_Asn1Object 861 | { 862 | /** 863 | * Constructor 864 | * 865 | * @param array $value list of rfc1155_Asn1Object 866 | */ 867 | public function __construct($value=array()) 868 | { 869 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 870 | $this->asnTagFormat = ASN_TAG_FORMAT_CONSTRUCTED; 871 | $this->asnTagNumber = ASN_TAG_SEQUENCE; 872 | $this->value = $value; 873 | } 874 | 875 | /** 876 | * Encode Contents 877 | * 878 | * encode into an octet stream 879 | * 880 | * @return string 881 | */ 882 | public function encodeContents() 883 | { 884 | // To encode a Sequence, we simply encode() each sub-object in turn. 885 | $resultlist = array(); 886 | foreach($this->value as $elem) 887 | $resultlist[] = $elem->encode(); 888 | return join('', $resultlist); 889 | } 890 | 891 | /** 892 | * Decode Contents 893 | * 894 | * Decode octet stream 895 | * 896 | * @param string $stream 897 | * @return rfc1155_Sequence 898 | */ 899 | public function decodeContents($stream) 900 | { 901 | $this->value = $this->decode($stream); 902 | return $this; 903 | } 904 | 905 | /** 906 | * toString 907 | * 908 | * @return string 909 | */ 910 | public function toString() 911 | { 912 | $vals = array(); 913 | foreach($this->value as $v) $vals[] = get_class($v) . '(' . $v->toString() . ')'; 914 | $vals = join(',', $vals); 915 | return get_class($this) . "($vals)"; 916 | } 917 | } 918 | 919 | /** 920 | * rfc1155 SequenceOf 921 | * 922 | * An ASN.1 SequenceOf type 923 | * 924 | * A Sequence is basically a list of name, value pairs with the name being an object Type and the 925 | * value being an instance of an Asn1Object of that Type. 926 | * 927 | * @package phpSNMP 928 | * @subpackage rfc1155 929 | */ 930 | class rfc1155_SequenceOf extends rfc1155_Sequence 931 | { 932 | // A SequenceOf is a special kind of sequence that places a constraint on the kind of objects it can contain. It is variable in length. 933 | 934 | var $componentType; 935 | 936 | /** 937 | * Constructor 938 | * 939 | * @param string $componentType name of object type used 940 | * @param array $value list of rfc1155_Asn1Object of type $componentType 941 | */ 942 | public function __construct($componentType='rfc1155_asn1Object', $value=array()) 943 | { 944 | parent::__construct($value); 945 | $this->asnTagClass = ASN_TAG_CLASS_UNIVERSAL; 946 | $this->asnTagFormat = ASN_TAG_FORMAT_CONSTRUCTED; 947 | $this->asnTagNumber = ASN_TAG_SEQUENCE; 948 | 949 | $this->componentType = $componentType; 950 | 951 | // Add each item in the list to ourselves, which automatically checks each one to ensure it is of the correct type. 952 | $this->value = array(); 953 | 954 | foreach($value as $item) 955 | $this->append($item); 956 | } 957 | 958 | /** 959 | * Append 960 | * 961 | * Add an object to this sequence 962 | * 963 | * @param rfc1155_Asn1Object object to add 964 | */ 965 | public function append($value) 966 | { 967 | if(!is_a($value, $this->componentType)) 968 | { 969 | if(is_subclass_of(new $this->componentType(), get_class($value))) 970 | { 971 | 972 | // broken way of doing this! 973 | $v = $value->value; 974 | $value = new $this->componentType(); 975 | $value->value = $v; 976 | } 977 | else 978 | trigger_error(get_class($this) . ' cannot contain components of type: ' . get_class($value), E_USER_WARNING); 979 | } 980 | $this->value[] = $value; 981 | } 982 | } 983 | 984 | /** 985 | * rfc1155 IPAddress 986 | * 987 | * An ASN.1 IPAddress type 988 | * 989 | * An IpAddress is a special type of OctetString. It represents a 32-bit internet address as an OctetString of length 4, in network byte order. 990 | * 991 | * @package phpSNMP 992 | * @subpackage rfc1155 993 | */ 994 | class rfc1155_IPAddress extends rfc1155_OctetString 995 | { 996 | /** 997 | * Constructor 998 | * 999 | * @param mixed $value (can be array, long, hostname or ip address) 1000 | */ 1001 | public function __construct($value='0.0.0.0') 1002 | { 1003 | parent::__construct($value); 1004 | $this->asnTagClass = ASN_TAG_CLASS_APPLICATION; 1005 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 1006 | $this->asnTagNumber = ASN_TAG_IPADDRESS; 1007 | 1008 | if(is_array($value)) 1009 | { 1010 | if(count($value) != 4) 1011 | trigger_error('IPAddress must be of length 4', E_USER_WARNING); 1012 | $value = join('.', $value); 1013 | } 1014 | 1015 | if(strpos($value, '.') !== false) // string 1016 | { 1017 | $h = ip2long($value); 1018 | if($h == -1 || $h === false) 1019 | $value = ip2long(gethostbyname($value)); 1020 | else 1021 | $value = $h; 1022 | } 1023 | $this->value = long2ip($value); 1024 | } 1025 | 1026 | /** 1027 | * toString 1028 | * 1029 | * @return string 1030 | */ 1031 | public function toString() 1032 | { 1033 | return $this->value; 1034 | } 1035 | 1036 | /** 1037 | * Encode Contents 1038 | * 1039 | * encode into an octet stream 1040 | * 1041 | * @return string 1042 | */ 1043 | public function encodeContents() 1044 | { 1045 | $ret = ''; 1046 | $value = explode('.', $this->value); 1047 | for($i = 0; $i < 4; $i++) 1048 | $ret .= chr($value[$i]); 1049 | return $ret; 1050 | } 1051 | 1052 | /** 1053 | * Decode Contents 1054 | * 1055 | * Decode octet stream 1056 | * 1057 | * @param string $stream 1058 | * @return rfc1155_IPAddress 1059 | */ 1060 | public function decodeContents($stream) 1061 | { 1062 | $this->value = ord($stream{0}) . '.' . ord($stream{1}) . '.' . ord($stream{2}) . '.' . ord($stream{3}); 1063 | return $this; 1064 | } 1065 | } 1066 | 1067 | /** 1068 | * rfc1155 NetworkAddress 1069 | * 1070 | * An ASN.1 NetworkAddress type 1071 | * 1072 | * A Network Address is a CHOICE with only one possible value: internet 1073 | * 1074 | * @package phpSNMP 1075 | * @subpackage rfc1155 1076 | */ 1077 | class rfc1155_NetworkAddress extends rfc1155_IPAddress 1078 | { 1079 | // var $name; 1080 | 1081 | /** 1082 | * Constructor 1083 | * 1084 | * @param mixed $value (can be array, long, hostname or ip address) 1085 | */ 1086 | public function __construct($value) 1087 | { 1088 | parent::__construct($value); 1089 | // $this->name = 'internet'; 1090 | } 1091 | } 1092 | 1093 | /** 1094 | * rfc1155 Counter 1095 | * 1096 | * An ASN.1 Counter type 1097 | * 1098 | * A counter starts at zero and keeps going to a maximum integer value of 2^32-1 where it wraps back to zero. 1099 | * 1100 | * @package phpSNMP 1101 | * @subpackage rfc1155 1102 | */ 1103 | class rfc1155_Counter extends rfc1155_Integer 1104 | { 1105 | /** 1106 | * Constructor 1107 | * 1108 | * @param integer $value 1109 | */ 1110 | public function __construct($value=0) 1111 | { 1112 | $this->check_range($value, 0, 4294967295); 1113 | parent::__construct($value); 1114 | $this->asnTagClass = ASN_TAG_CLASS_APPLICATION; 1115 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 1116 | $this->asnTagNumber = ASN_TAG_COUNTER; 1117 | } 1118 | 1119 | /** 1120 | * Decode Contents 1121 | * 1122 | * Decode octet stream 1123 | * 1124 | * Some SNMP stacks encode Counters incorrectly resulting in a negative value. There are two remedies: 1125 | * if you define('SNMP_ABS_COUNTER', 1), we take the absolute value of the result. 1126 | * else, we ignore the fact that the first bit is high and decode it as if it was positive. 1127 | * 1128 | * @param string $stream 1129 | * @return rfc1155_Counter 1130 | */ 1131 | public function decodeContents($stream) 1132 | { 1133 | if(defined('SNMP_ABS_COUNTER')) // hack to be compatible with Cisco software 1134 | { 1135 | /* Some agents encode Counters incorrectly (hello Solaris) as a negative number. I'm assuming most SNMP libraries don't 1136 | notice the problem because the are written in C and cast the result to an unsigned int - problem solved (if 1137 | accidentally). This ugly hack on their behalf flips the value over to the positive world. */ 1138 | parent::decodeContents($stream); 1139 | $this->value = abs($this->value); 1140 | } 1141 | else 1142 | { 1143 | $this->value = 0; 1144 | for($i = 0; $i < strlen($stream); $i++) 1145 | $this->value = $this->value * 256 + ord($stream{$i}); 1146 | } 1147 | return $this; 1148 | } 1149 | } 1150 | 1151 | /** 1152 | * rfc1155 Guage 1153 | * 1154 | * An ASN.1 Guage type 1155 | * 1156 | * A Guage is a non negative integer. It may increase or decrease. It latches at a maximum value. 1157 | * 1158 | * @package phpSNMP 1159 | * @subpackage rfc1155 1160 | */ 1161 | class rfc1155_Guage extends rfc1155_Integer 1162 | { 1163 | /** 1164 | * Constructor 1165 | * 1166 | * @param integer $value 1167 | */ 1168 | public function __construct($value=0) 1169 | { 1170 | $this->check_range($value, 0, 4294967295); 1171 | parent::__construct($value); 1172 | $this->asnTagClass = ASN_TAG_CLASS_APPLICATION; 1173 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 1174 | $this->asnTagNumber = ASN_TAG_GUAGE; 1175 | } 1176 | } 1177 | 1178 | /** 1179 | * rfc1155 TimeTicks 1180 | * 1181 | * An ASN.1 TimeTicks type 1182 | * 1183 | * TimeTicks is the number of hundredths of a second since an epoch, specified at object creation time 1184 | * 1185 | * @package phpSNMP 1186 | * @subpackage rfc1155 1187 | */ 1188 | class rfc1155_TimeTicks extends rfc1155_Integer 1189 | { 1190 | // var $epoch; 1191 | 1192 | /** 1193 | * Constructor 1194 | * 1195 | * @param integer $value 1196 | */ 1197 | public function __construct($value=0/*, $epoch=NULL*/) 1198 | { 1199 | $this->check_range($value, 0, 4294967295); 1200 | parent::__construct($value); 1201 | $this->asnTagClass = ASN_TAG_CLASS_APPLICATION; 1202 | $this->asnTagFormat = ASN_TAG_FORMAT_PRIMITIVE; 1203 | $this->asnTagNumber = ASN_TAG_TIMETICKS; 1204 | // $this->epoch = $epoch; 1205 | } 1206 | } 1207 | 1208 | /** 1209 | * rfc1155 Opaque 1210 | * 1211 | * An ASN.1 Opaque type 1212 | * 1213 | * Opaque is a fun type that allows you to pass arbitrary ASN.1 encoded stuff in an object. The value is some ASN.1 syntax 1214 | * encoded using BER which this object encodes as an OctetString. We don't do any decoding of this object because we don't 1215 | * have to, and that makes this all much quicker. 1216 | * 1217 | * @package phpSNMP 1218 | * @subpackage rfc1155 1219 | */ 1220 | class rfc1155_Opaque extends rfc1155_OctetString 1221 | { 1222 | /** 1223 | * Constructor 1224 | * 1225 | * @param string $value 1226 | */ 1227 | public function __construct($value) 1228 | { 1229 | parent::__construct($value); 1230 | } 1231 | } 1232 | ?> 1233 | -------------------------------------------------------------------------------- /rfc1157.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc1157 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 34 | 35 | define('ASN_TAG_GET', 0x00); 36 | define('ASN_TAG_GETNEXT', 0x01); 37 | define('ASN_TAG_RESPONSE', 0x02); 38 | define('ASN_TAG_SET', 0x03); 39 | define('ASN_TAG_TRAP', 0x04); 40 | 41 | $ASN_TAG_DICT[0xa0] = 'rfc1157_Get'; 42 | $ASN_TAG_DICT[0xa1] = 'rfc1157_GetNext'; 43 | $ASN_TAG_DICT[0xa2] = 'rfc1157_Response'; 44 | $ASN_TAG_DICT[0xa3] = 'rfc1157_Set'; 45 | $ASN_TAG_DICT[0xa4] = 'rfc1157_TrapPDU'; 46 | $GLOBALS["ASN_TAG_DICT"] = $ASN_TAG_DICT; 47 | /** 48 | * Error Status 49 | * 50 | * @package phpSNMP 51 | * @subpackage rfc1157 52 | */ 53 | class rfc1157_ErrorStatus extends rfc1155_Integer 54 | { 55 | /** 56 | * Constructor 57 | * 58 | * @param integer $value 59 | */ 60 | public function __construct($value) 61 | { 62 | parent::__construct($value); 63 | } 64 | 65 | /** 66 | * ToString 67 | * 68 | * @return string value of this object 69 | */ 70 | public function toString() 71 | { 72 | switch($this->value) 73 | { 74 | case 0: return 'No Error'; 75 | case 1: return 'Response message would have been too large'; 76 | case 2: return 'There is no such variable name in this MIB'; 77 | case 3: return 'The value given has the wrong type'; 78 | case 4: return 'Object is Read Only'; 79 | } 80 | return 'An unknown error occurred'; 81 | } 82 | } 83 | 84 | /** 85 | * Variable Binding 86 | * 87 | * This binds a name to an object 88 | * 89 | * @package phpSNMP 90 | * @subpackage rfc1157 91 | */ 92 | class rfc1157_VarBind extends rfc1155_Sequence 93 | { 94 | /** 95 | * Constructor 96 | * 97 | * @param rfc1155_ObjectID $name 98 | * @param rfc1155_Asn1Object $value 99 | */ 100 | public function __construct($name=NULL, $value=NULL) 101 | { 102 | if($name && !is_a($name, 'rfc1155_ObjectID')) 103 | trigger_error('name must be an rfc1155_ObjectID', E_USER_WARNING); 104 | if($value && !is_a($value, 'rfc1155_Asn1Object')) 105 | trigger_error('value must be an rfc1155_Asn1Object', E_USER_WARNING); 106 | parent::__construct(array($name, $value)); 107 | } 108 | } 109 | 110 | /** 111 | * Variable Binding List 112 | * 113 | * A Sequence of VarBinds 114 | * 115 | * @package phpSNMP 116 | * @subpackage rfc1157 117 | */ 118 | class rfc1157_VarBindList extends rfc1155_SequenceOf 119 | { 120 | /** 121 | * Constructor 122 | * 123 | * @param array $value of rfc1157_VarBind 124 | */ 125 | public function __construct($value=array()) 126 | { 127 | parent::__construct('rfc1157_VarBind', $value); 128 | } 129 | } 130 | 131 | /** 132 | * Message 133 | * 134 | * A Message is the base comms type for all SNMP messages 135 | * 136 | * @package phpSNMP 137 | * @subpackage rfc1157 138 | */ 139 | class rfc1157_Message extends rfc1155_Sequence 140 | { 141 | /** 142 | * Constructor 143 | * 144 | * @param integer $version 145 | * @param string $community 146 | * @param rfc1157_PDU $pdu 147 | */ 148 | public function __construct($version=0, $community='public', $pdu=NULL) 149 | { 150 | parent::__construct(); 151 | if(is_null($pdu)) $pdu = new rfc1157_PDU(); 152 | $this->value = array(new rfc1155_Integer($version), new rfc1155_OctetString($community), $pdu); 153 | } 154 | 155 | /** 156 | * Get/Set version 157 | * 158 | * @param integer $value 159 | * @return integer 160 | */ 161 | public function version($value=NULL) 162 | { 163 | if(!is_null($value)) $this->value[0] = new rfc1155_Integer($value); 164 | return $this->value[0]->value; 165 | } 166 | 167 | /** 168 | * Get/Set community 169 | * 170 | * @param string $value 171 | * @return string 172 | */ 173 | public function community($value=NULL) 174 | { 175 | if(!is_null($value)) $this->value[1] = new rfc1155_OctetString($value); 176 | return $this->value[1]->value; 177 | } 178 | 179 | /** 180 | * Get/Set PDU 181 | * 182 | * @param rfc1157_PDU $value 183 | * @return rfc1157_PDU 184 | */ 185 | public function pdu($value=NULL) 186 | { 187 | if(!is_null($value)) $this->value[2] = $value; 188 | return $this->value[2]; 189 | } 190 | 191 | /** 192 | * Decode Stream 193 | * 194 | * decode() an octet stream into a sequence of Asn1Objects 195 | * 196 | * @param string $stream 197 | * @return rfc1157_Message 198 | */ 199 | public function decode($stream) 200 | { 201 | $this->value = parent::decode($stream); 202 | if(count($this->value) != 1) 203 | trigger_error('Malformed Message: More than one object decoded.', E_USER_WARNING); 204 | $this->value = $this->value[0]->value; 205 | if(count($this->value) != 3) 206 | trigger_error('Malformed Message: Incorrect sequence length ' . count($this->value[0]->value), E_USER_WARNING); 207 | return $this; 208 | } 209 | } 210 | 211 | /** 212 | * PDU 213 | * 214 | * Base clss for a non-trap PDU 215 | * 216 | * @package phpSNMP 217 | * @subpackage rfc1157 218 | */ 219 | class rfc1157_PDU extends rfc1155_Sequence // Base class for a non-trap PDU 220 | { 221 | /** 222 | * Constructor 223 | * 224 | * @param integer $requestID 225 | * @param integer $errorStatus 226 | * @param integer $errorIndex 227 | * @param array $varBindList 228 | */ 229 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 230 | { 231 | /* this allows you to create a new object with no arguments, arguments of the class ultimately desired (eg Integer) 232 | or, to make like easier, it will convert basic strings and ints into the ultimately desired objects. */ 233 | 234 | parent::__construct(); 235 | $this->asnTagClass = ASN_TAG_CLASS_CONTEXT; 236 | $this->value = array(new rfc1155_Integer($requestID), new rfc1157_ErrorStatus($errorStatus), 237 | new rfc1155_Integer($errorIndex), new rfc1157_VarBindList($varBindList)); 238 | } 239 | 240 | /** 241 | * Get/Set Request ID 242 | * 243 | * @param integer $value 244 | * @return integer 245 | */ 246 | public function requestID($value=NULL) 247 | { 248 | if(!is_null($value)) $this->value[0] = new rfc1155_Integer($value); 249 | return $this->value[0]->value; 250 | } 251 | 252 | /** 253 | * Get/Set Error Status 254 | * 255 | * @param integer $value 256 | * @return integer 257 | */ 258 | public function errorStatus($value=NULL) 259 | { 260 | if(!is_null($value)) $this->value[1] = new rfc1157_ErrorStatus($value); 261 | return $this->value[1]->value; 262 | } 263 | 264 | /** 265 | * Get Error String 266 | * 267 | * @return string 268 | */ 269 | public function errorString() 270 | { 271 | return $this->value[1]->toString(); 272 | } 273 | 274 | /** 275 | * Get/Set Error Index 276 | * 277 | * @param integer $value 278 | * @return integer 279 | */ 280 | public function errorIndex($value=NULL) 281 | { 282 | if(!is_null($value)) $this->value[2] = new rfc1155_Integer($value); 283 | return $this->value[2]->value; 284 | } 285 | 286 | /** 287 | * Get/Set Var Bind List 288 | * 289 | * @param rfc1157_VarBindList $value 290 | * @return rfc1157_VarBindList 291 | */ 292 | public function varBindList($value=NULL) 293 | { 294 | if(!is_null($value)) $this->value[3] = new rfc1157_VarBindList($value); 295 | return $this->value[3]->value; 296 | } 297 | 298 | /** 299 | * Decode into a PDU Object 300 | * 301 | * @param string $stream 302 | * @return rfc1157_PDU 303 | */ 304 | public function decodeContents($stream) 305 | { 306 | parent::decodeContents($stream); 307 | if(count($this->value) != 4) 308 | trigger_error('Malformed PDU: Incorrect length ' . count($this->value), E_USER_WARNING); 309 | 310 | $this->value[1] = new rfc1157_ErrorStatus($this->value[1]->value); 311 | $this->value[3] = new rfc1157_VarBindList($this->value[3]->value); 312 | return $this; 313 | } 314 | } 315 | 316 | /** 317 | * GET request 318 | * 319 | * A Get Request PDU 320 | * 321 | * @package phpSNMP 322 | * @subpackage rfc1157 323 | */ 324 | class rfc1157_Get extends rfc1157_PDU 325 | { 326 | /** 327 | * Constructor 328 | * 329 | * @param integer $requestID 330 | * @param integer $errorStatus 331 | * @param integer $errorIndex 332 | * @param array $varBindList 333 | */ 334 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 335 | { 336 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 337 | $this->asnTagNumber = ASN_TAG_GET; 338 | } 339 | } 340 | 341 | /** 342 | * GETNEXT request 343 | * 344 | * A GetNext Request PDU 345 | * 346 | * @package phpSNMP 347 | * @subpackage rfc1157 348 | */ 349 | class rfc1157_GetNext extends rfc1157_PDU 350 | { 351 | /** 352 | * Constructor 353 | * 354 | * @param integer $requestID 355 | * @param integer $errorStatus 356 | * @param integer $errorIndex 357 | * @param array $varBindList 358 | */ 359 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 360 | { 361 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 362 | $this->asnTagNumber = ASN_TAG_GETNEXT; 363 | } 364 | } 365 | 366 | /** 367 | * RESPONSE request 368 | * 369 | * A Response PDU 370 | * 371 | * @package phpSNMP 372 | * @subpackage rfc1157 373 | */ 374 | class rfc1157_Response extends rfc1157_PDU 375 | { 376 | /** 377 | * Constructor 378 | * 379 | * @param integer $requestID 380 | * @param integer $errorStatus 381 | * @param integer $errorIndex 382 | * @param array $varBindList 383 | */ 384 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 385 | { 386 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 387 | $this->asnTagNumber = ASN_TAG_GET; 388 | } 389 | } 390 | 391 | /** 392 | * SET request 393 | * 394 | * A Set Request PDU 395 | * 396 | * @package phpSNMP 397 | * @subpackage rfc1157 398 | */ 399 | class rfc1157_Set extends rfc1157_PDU 400 | { 401 | /** 402 | * Constructor 403 | * 404 | * @param integer $requestID 405 | * @param integer $errorStatus 406 | * @param integer $errorIndex 407 | * @param array $varBindList 408 | */ 409 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 410 | { 411 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 412 | $this->asnTagNumber = ASN_TAG_SET; 413 | } 414 | } 415 | 416 | define('TRAP_COLDSTART', 0); 417 | define('TRAP_WARMSTART', 1); 418 | define('TRAP_LINKDOWN', 2); 419 | define('TRAP_LINKUP', 3); 420 | define('TRAP_AUTH_FAIL', 4); 421 | define('TRAP_EGP_NEIGHBOR_LOSS', 5); 422 | define('TRAP_ENTERPRISE_SPECIFIC', 6); 423 | 424 | /** 425 | * Generic Trap 426 | * 427 | * @package phpSNMP 428 | * @subpackage rfc1157 429 | */ 430 | class rfc1157_GenericTrap extends rfc1155_Integer 431 | { 432 | var $genericTraps; 433 | 434 | /** 435 | * Constructor 436 | * 437 | * @param integer $value 438 | */ 439 | public function __construct($value) 440 | { 441 | parent::__construct($value); 442 | } 443 | } 444 | 445 | /** 446 | * Trap PDU 447 | * 448 | * @package phpSNMP 449 | * @subpackage rfc1157 450 | */ 451 | class rfc1157_TrapPDU extends rfc1155_Sequence 452 | { 453 | /** 454 | * Constructor 455 | * 456 | * @param string $enterprise 457 | * @param string $agentAddr 458 | * @param integer $genericTrap 459 | * @param integer $specificTrap 460 | * @param integer $timestamp 461 | * @param array $varBindList 462 | */ 463 | public function __construct($enterprise=NULL, $agentAddr=NULL, $genericTrap=NULL, $specificTrap=NULL, $timestamp=NULL, $varBindList=array()) 464 | { 465 | parent::__construct(); 466 | $this->asnTagClass = ASN_TAG_CLASS_CONTEXT; 467 | $this->asnTagNumber = ASN_TAG_TRAP; 468 | $this->value = array(new rfc1155_ObjectID($enterprise), new rfc1155_NetworkAddress($agentAddr), 469 | new rfc1157_GenericTrap($genericTrap), new rfc1155_Integer($specificTrap), 470 | new rfc1155_TimeTicks($timestamp), new rfc1157_VarBindList($varBindList)); 471 | } 472 | 473 | /** 474 | * Get/Set Enterprise OID 475 | * 476 | * @param string $value 477 | * @return string 478 | */ 479 | public function enterprise($value=NULL) 480 | { 481 | if(!is_null($value)) $this->value[0] = new rfc1155_ObjectID($value); 482 | return $this->value[0]->value; 483 | } 484 | 485 | /** 486 | * Get/Set Agent Address 487 | * 488 | * @param string $value 489 | * @return string 490 | */ 491 | public function agentAddr($value=NULL) 492 | { 493 | if(!is_null($value)) $this->value[1] = new rfc1155_NetworkAddress($value); 494 | return $this->value[1]->value; 495 | } 496 | 497 | /** 498 | * Get/Set Generic Trap 499 | * 500 | * @param integer $value 501 | * @return integer 502 | */ 503 | public function genericTrap($value=NULL) 504 | { 505 | if(!is_null($value)) $this->value[2]->value = $value; 506 | return $this->value[2]->value; 507 | } 508 | 509 | /** 510 | * Get/Set Specific Trap 511 | * 512 | * @param integer $value 513 | * @return integer 514 | */ 515 | public function specificTrap($value=NULL) 516 | { 517 | if(!is_null($value)) $this->value[3]->value = $value; 518 | return $this->value[3]->value; 519 | } 520 | 521 | /** 522 | * Get/Set Timestamp 523 | * 524 | * @param integer $value 525 | * @return integer 526 | */ 527 | public function timestamp($value=NULL) 528 | { 529 | if(!is_null($value)) $this->value[4]->value = $value; 530 | return $this->value[4]->value; 531 | } 532 | 533 | /** 534 | * Get/Set Var Bind List 535 | * 536 | * @param rfc1157_VarBindList $value 537 | * @return rfc1157_VarBindList 538 | */ 539 | public function VarBindList($value=NULL) 540 | { 541 | if(!is_null($value)) $this->value[5] = $value; 542 | return $this->value[5]; 543 | } 544 | 545 | /** 546 | * Decode into a Get PDU Object 547 | * 548 | * @param string $stream 549 | * @return rfc1157_TrapPDU 550 | */ 551 | public function decodeContents($stream) 552 | { 553 | parent::decodeContents($stream); 554 | if(count($this->value) != 6) 555 | trigger_error('Malformed TrapPDU: Incorrect length ' . count($this->value), E_USER_WARNING); 556 | 557 | $this->value[1] = new rfc1155_NetworkAddress($this->value[1]->value); 558 | $this->value[5] = new rfc1157_VarBindList($this->value[5]->value); 559 | 560 | return $this; 561 | } 562 | } 563 | ?> 564 | -------------------------------------------------------------------------------- /rfc1902.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 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 | 39 | // $ASN_TAG_DICT[0x02] = 'rfc1902_Integer32'; 40 | // $ASN_TAG_DICT[0x41] = 'rfc1902_Counter32'; 41 | // $ASN_TAG_DICT[0x42] = 'rfc1902_Guage32'; 42 | $ASN_TAG_DICT[0x46] = 'rfc1902_Counter64'; 43 | $GLOBALS["ASN_TAG_DICT"] = $ASN_TAG_DICT; 44 | /** 45 | * Integer32 46 | * 47 | * A 32 bit integer 48 | * 49 | * @package phpSNMP 50 | * @subpackage rfc1902 51 | */ 52 | class rfc1902_Integer32 extends rfc1155_Integer 53 | { 54 | /** 55 | * Constructor 56 | * 57 | * @param integer $value 58 | */ 59 | public function __construct($value) 60 | { 61 | parent::__construct($value); 62 | } 63 | } 64 | 65 | /** 66 | * Counter32 67 | * 68 | * A 32 bit counter 69 | * 70 | * @package phpSNMP 71 | * @subpackage rfc1902 72 | */ 73 | class rfc1902_Counter32 extends rfc1155_Counter 74 | { 75 | /** 76 | * Constructor 77 | * 78 | * @param integer $value 79 | */ 80 | public function __construct($value) 81 | { 82 | parent::__construct($value); 83 | } 84 | } 85 | 86 | /** 87 | * Guage32 88 | * 89 | * A 32 bit guage 90 | * 91 | * @package phpSNMP 92 | * @subpackage rfc1902 93 | */ 94 | class rfc1902_Guage32 extends rfc1155_Guage 95 | { 96 | /** 97 | * Constructor 98 | * 99 | * @param integer $value 100 | */ 101 | public function __construct($value) 102 | { 103 | parent::__construct($value); 104 | } 105 | } 106 | 107 | /** 108 | * Counter64 109 | * 110 | * A 64 bit counter 111 | * 112 | * @package phpSNMP 113 | * @subpackage rfc1902 114 | */ 115 | class rfc1902_Counter64 extends rfc1155_Counter 116 | { 117 | /** 118 | * Constructor 119 | * 120 | * @param integer $value 121 | */ 122 | public function __construct($value=0) 123 | { 124 | $this->check_range($value, 0, 18446744073709551615); 125 | parent::__construct($value); 126 | $this->asnTagClass = ASN_TAG_COUNTER64; 127 | } 128 | } 129 | 130 | /** 131 | * Octet String 132 | * 133 | * An SNMP v2 OctetString must be between 0 and 65535 bytes in length 134 | * 135 | * @package phpSNMP 136 | * @subpackage rfc1902 137 | */ 138 | class rfc1902_OctetString extends rfc1155_OctetString 139 | { 140 | /** 141 | * Constructor 142 | * 143 | * @param string $value 144 | */ 145 | public function __construct($value) 146 | { 147 | if(strlen($value) > 65535) 148 | trigger_error('OctetString must be shorter than 65535 bytes', E_USER_WARNING); 149 | parent::__construct($value); 150 | } 151 | } 152 | ?> 153 | -------------------------------------------------------------------------------- /rfc1905.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc1905 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1157.php'); 35 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1902.php'); 36 | 37 | define('MAX_BINDINGS', 2147483647); 38 | 39 | define('ASN_TAG_GETBULK', 0x05); 40 | define('ASN_TAG_INFORM', 0x06); 41 | define('ASN_TAG_TRAPV2', 0x07); 42 | define('ASN_TAG_REPORT', 0x08); 43 | 44 | $ASN_TAG_DICT[0xa2] = 'rfc1905_Response'; 45 | $ASN_TAG_DICT[0xa5] = 'rfc1905_GetBulk'; 46 | $ASN_TAG_DICT[0xa6] = 'rfc1905_Inform'; 47 | $ASN_TAG_DICT[0xa7] = 'rfc1905_TrapV2'; 48 | $ASN_TAG_DICT[0xa8] = 'rfc1905_Report'; 49 | $GLOBALS["ASN_TAG_DICT"] = $ASN_TAG_DICT; 50 | 51 | // ucd-snmp returns context-specific values at time 52 | define('ASN_TAG_NO_SUCH_OBJECT', 0x80); 53 | define('ASN_TAG_NO_SUCH_INSTANCE', 0x81); 54 | define('ASN_TAG_END_OF_MIB_VIEW', 0x82); 55 | $ASN_TAG_DICT[0x80] = 'rfc1905_NoSuchObject'; 56 | $ASN_TAG_DICT[0x81] = 'rfc1905_NoSuchInstance'; 57 | $ASN_TAG_DICT[0x82] = 'rfc1905_EndOfMibView'; 58 | 59 | /** 60 | * No Such Object 61 | * 62 | * This is a special type for ucd-snmp 63 | * 64 | * @package phpSNMP 65 | * @subpackage rfc1905 66 | */ 67 | class rfc1905_NoSuchObject extends rfc1155_Null 68 | { 69 | /** 70 | * Constructor 71 | */ 72 | public function __construct() 73 | { 74 | parent::__construct(); 75 | $this->asnTagNumber = ASN_TAG_NO_SUCH_OBJECT; 76 | } 77 | 78 | /** 79 | * ToString 80 | * 81 | * @return string value of this object 82 | */ 83 | public function toString() 84 | { 85 | return 'No such Object'; 86 | } 87 | } 88 | 89 | /** 90 | * No Such Instance 91 | * 92 | * This is a special type for ucd-snmp 93 | * 94 | * @package phpSNMP 95 | * @subpackage rfc1905 96 | */ 97 | class rfc1905_NoSuchInstance extends rfc1155_Null 98 | { 99 | /** 100 | * Constructor 101 | */ 102 | public function __construct() 103 | { 104 | parent::__construct(); 105 | $this->asnTagNumber = ASN_TAG_NO_SUCH_INSTANCE; 106 | } 107 | 108 | /** 109 | * ToString 110 | * 111 | * @return string value of this object 112 | */ 113 | public function toString() 114 | { 115 | return 'No such Instance'; 116 | } 117 | } 118 | 119 | /** 120 | * End Of MIB View 121 | * 122 | * This is a special type for ucd-snmp 123 | * 124 | * @package phpSNMP 125 | * @subpackage rfc1905 126 | */ 127 | class rfc1905_EndOfMibView extends rfc1155_Null 128 | { 129 | /** 130 | * Constructor 131 | */ 132 | public function __construct() 133 | { 134 | parent::__construct(); 135 | $this->asnTagNumber = ASN_TAG_END_OF_MIB_VIEW; 136 | } 137 | 138 | /** 139 | * ToString 140 | * 141 | * @return string value of this object 142 | */ 143 | public function toString() 144 | { 145 | return 'End of MIB'; 146 | } 147 | } 148 | 149 | /** 150 | * Variable Binding List 151 | * 152 | * An SNMPv2 VarBindList has a maximum size of MAX_BINDINGS 153 | * 154 | * @package phpSNMP 155 | * @subpackage rfc1905 156 | */ 157 | class rfc1905_VarBindList extends rfc1157_VarBindList 158 | { 159 | /** 160 | * Constructor 161 | * 162 | * @param array $value 163 | */ 164 | public function __construct($value=array()) 165 | { 166 | if(count($value) > MAX_BINDINGS) 167 | trigger_error('A VarBindList must be shorter than ' . MAX_BINDINGS, E_USER_WARNING); 168 | parent::__construct($value); 169 | } 170 | } 171 | 172 | /** 173 | * Message 174 | * 175 | * @package phpSNMP 176 | * @subpackage rfc1905 177 | */ 178 | class rfc1905_Message extends rfc1157_Message 179 | { 180 | /** 181 | * Constructor 182 | * 183 | * @param integer $version 184 | * @param string $community 185 | * @param mixed $data 186 | */ 187 | public function __construct($version=1, $community='public', $data=NULL) 188 | { 189 | parent::__construct($version, $community, $data); 190 | } 191 | } 192 | 193 | /** 194 | * Error Status 195 | * 196 | * An SNMPv2 Error status 197 | * 198 | * @package phpSNMP 199 | * @subpackage rfc1905 200 | */ 201 | class rfc1905_ErrorStatus extends rfc1157_ErrorStatus 202 | { 203 | /** 204 | * Constructor 205 | * 206 | * @param integer $value 207 | */ 208 | public function __construct($value) 209 | { 210 | parent::__construct($value); 211 | } 212 | 213 | /** 214 | * ToString 215 | * 216 | * @return string value of this object 217 | */ 218 | public function toString() 219 | { 220 | switch($this->value) 221 | { 222 | case 6: return 'Access is not permitted'; 223 | case 7: return 'Type is incorrect'; 224 | case 8: return 'Length is incorrect'; 225 | case 9: return 'Encoding is incorrect'; 226 | case 10: return 'Value is incorrect'; 227 | case 11: return 'No creation'; 228 | case 12: return 'Value is inconsistent'; 229 | case 13: return 'Resourse Unavailable'; 230 | case 14: return 'Commit Failed'; 231 | case 15: return 'Undo Failed'; 232 | case 16: return 'Authorization Error'; 233 | case 17: return 'Not Writable'; 234 | case 18: return 'Inconsistent Name'; 235 | } 236 | return parent::toString(); 237 | } 238 | } 239 | 240 | /** 241 | * PDU 242 | * 243 | * SNMPv2 PDUs are very similar to SNMPv1 PDUs 244 | * 245 | * @package phpSNMP 246 | * @subpackage rfc1905 247 | */ 248 | class rfc1905_PDU extends rfc1157_PDU 249 | { 250 | /** 251 | * Constructor 252 | * 253 | * @param integer $requestID 254 | * @param integer $errorStatus 255 | * @param integer $errorIndex 256 | * @param array $varBindList 257 | */ 258 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 259 | { 260 | parent::__construct(); 261 | $this->asnTagClass = ASN_TAG_CLASS_CONTEXT; 262 | 263 | if($errorIndex > MAX_BINDINGS) 264 | trigger_error('errorIndex must be <= ' . MAX_BINDINGS, E_USER_WARNING); 265 | 266 | $this->value = array(new rfc1902_Integer32($requestID), new rfc1905_ErrorStatus($errorStatus), 267 | new rfc1155_Integer($errorIndex), new rfc1905_VarBindList($varBindList)); 268 | } 269 | 270 | /** 271 | * ToString 272 | * 273 | * @return string value of this object 274 | */ 275 | public function toString() 276 | { 277 | $req = $this->value[0]->toString(); 278 | $err = $this->value[1]->tostring(); 279 | $ei = $this->value[2]->toString(); 280 | $vb = $this->value[3]->toString(); 281 | return "rfc1905_PDU(RequestID:$req,ErrorStatus:$err,ErrorIndex:$ei,VarBind:$vb)"; 282 | } 283 | } 284 | 285 | /** 286 | * Bulk PDU 287 | * 288 | * BulkPDU is a new type of PDU specifically for doing GetBulk requests in SNMPv2. 289 | * 290 | * @package phpSNMP 291 | * @subpackage rfc1905 292 | */ 293 | class rfc1905_BulkPDU extends rfc1155_Sequence 294 | { 295 | /** 296 | * Constructor 297 | * 298 | * @param integer $requestID 299 | * @param integer $nonRepeaters 300 | * @param integer $maxRepetitions 301 | * @param array $varBindList 302 | */ 303 | public function __construct($requestID=0, $nonRepeaters=0, $maxRepetitions=0, $varBindList=array()) 304 | { 305 | parent::__construct(); 306 | $this->asnTagClass = ASN_TAG_CLASS_CONTEXT; 307 | 308 | if($nonRepeaters > MAX_BINDINGS) 309 | trigger_error('nonRepeaters must be <= ' . MAX_BINDINGS, E_USER_WARNING); 310 | if($maxRepetitions > MAX_BINDINGS) 311 | trigger_error('maxRepetitions must be <= ' . MAX_BINDINGS, E_USER_WARNING); 312 | 313 | $this->value = array(new rfc1902_Integer32($requestID), new rfc1155_Integer($nonRepeaters), 314 | new rfc1155_Integer($maxRepetitions), new rfc1905_VarBindList($varBindList)); 315 | } 316 | 317 | /** 318 | * Get/Set Request ID 319 | * 320 | * @param integer $value 321 | * @return integer 322 | */ 323 | public function requestID($value=NULL) 324 | { 325 | if(!is_null($value)) $this->value[0]->value = $value; 326 | return $this->value[0]->value; 327 | } 328 | 329 | /** 330 | * Get/Set Non Repeaters 331 | * 332 | * @param integer $value 333 | * @return integer 334 | */ 335 | public function nonRepeaters($value=NULL) 336 | { 337 | if(!is_null($value)) $this->value[1]->value = $value; 338 | return $this->value[1]->value; 339 | } 340 | 341 | /** 342 | * Get/Set Max Repetitions 343 | * 344 | * @param integer $value 345 | * @return integer 346 | */ 347 | public function maxRepetitions($value=NULL) 348 | { 349 | if(!is_null($value)) $this->value[2]->value = $value; 350 | return $this->value[2]->value; 351 | } 352 | 353 | /** 354 | * Get/Set Var Bind List 355 | * 356 | * @param rfc1905_VarBindList $value 357 | * @return rfc1905_VarBindList 358 | */ 359 | public function varBindList($value=NULL) 360 | { 361 | if(!is_null($value)) $this->value[3]->value = $value; 362 | return $this->value[3]->value; 363 | } 364 | 365 | /** 366 | * Decode Contents 367 | * 368 | * Decode octet stream 369 | * 370 | * @param string $stream 371 | * @return rfc1905_BulkPDU 372 | */ 373 | public function decodeContents($stream) // Decode into a BulkPDU object 374 | { 375 | parent::decodeContents($stream); 376 | if(count($this->value) != 4) 377 | trigger_error('Malformed BulkPDU: Incorrect length ' . count($this->value), E_USER_WARNING); 378 | return $this; 379 | } 380 | } 381 | 382 | /** 383 | * Get Request 384 | * 385 | * An SNMPv2 Get Request PDU 386 | * 387 | * @package phpSNMP 388 | * @subpackage rfc1905 389 | */ 390 | class rfc1905_Get extends rfc1905_PDU 391 | { 392 | /** 393 | * Constructor 394 | * 395 | * @param integer $requestID 396 | * @param integer $errorStatus 397 | * @param integer $errorIndex 398 | * @param array $varBindList 399 | */ 400 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 401 | { 402 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 403 | $this->asnTagNumber = ASN_TAG_GET; 404 | } 405 | } 406 | 407 | /** 408 | * Get Next Request 409 | * 410 | * An SNMPv2 Get Next Request PDU 411 | * 412 | * @package phpSNMP 413 | * @subpackage rfc1905 414 | */ 415 | class rfc1905_GetNext extends rfc1905_PDU 416 | { 417 | /** 418 | * Constructor 419 | * 420 | * @param integer $requestID 421 | * @param integer $errorStatus 422 | * @param integer $errorIndex 423 | * @param array $varBindList 424 | */ 425 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 426 | { 427 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 428 | $this->asnTagNumber = ASN_TAG_GETNEXT; 429 | } 430 | } 431 | 432 | /** 433 | * Response 434 | * 435 | * An SNMPv2 Response PDU 436 | * 437 | * @package phpSNMP 438 | * @subpackage rfc1905 439 | */ 440 | class rfc1905_Response extends rfc1905_PDU 441 | { 442 | /** 443 | * Constructor 444 | * 445 | * @param integer $requestID 446 | * @param integer $errorStatus 447 | * @param integer $errorIndex 448 | * @param array $varBindList 449 | */ 450 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 451 | { 452 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 453 | $this->asnTagNumber = ASN_TAG_RESPONSE; 454 | } 455 | } 456 | 457 | /** 458 | * Set Request 459 | * 460 | * An SNMPv2 set Request PDU 461 | * 462 | * @package phpSNMP 463 | * @subpackage rfc1905 464 | */ 465 | class rfc1905_Set extends rfc1905_PDU 466 | { 467 | /** 468 | * Constructor 469 | * 470 | * @param integer $requestID 471 | * @param integer $errorStatus 472 | * @param integer $errorIndex 473 | * @param array $varBindList 474 | */ 475 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 476 | { 477 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 478 | $this->asnTagNumber = ASN_TAG_SET; 479 | } 480 | } 481 | 482 | /** 483 | * Get Bulk Request 484 | * 485 | * An SNMPv2 Get Bulk Request PDU 486 | * 487 | * @package phpSNMP 488 | * @subpackage rfc1905 489 | */ 490 | class rfc1905_GetBulk extends rfc1905_BulkPDU 491 | { 492 | /** 493 | * Constructor 494 | * 495 | * @param integer $requestID 496 | * @param integer $nonRepeaters 497 | * @param integer $maxRepetitions 498 | * @param array $varBindList 499 | */ 500 | public function __construct($requestID=0, $nonRepeaters=0, $maxRepetitions=0, $varBindList=array()) 501 | { 502 | parent::__construct($requestID, $nonRepeaters, $maxRepetitions, $varBindList); 503 | $this->asnTagNumber = ASN_TAG_GETBULK; 504 | } 505 | } 506 | 507 | /** 508 | * Inform 509 | * 510 | * An SNMPv2 Inform PDU 511 | * 512 | * @package phpSNMP 513 | * @subpackage rfc1905 514 | */ 515 | class rfc1905_Inform extends rfc1905_PDU 516 | { 517 | /** 518 | * Constructor 519 | * 520 | * @param integer $requestID 521 | * @param integer $errorStatus 522 | * @param integer $errorIndex 523 | * @param array $varBindList 524 | */ 525 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 526 | { 527 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 528 | $this->asnTagNumber = ASN_TAG_INFORM; 529 | } 530 | } 531 | 532 | /** 533 | * Trap 534 | * 535 | * An SNMPv2 Trap PDU 536 | * 537 | * @package phpSNMP 538 | * @subpackage rfc1905 539 | */ 540 | class rfc1905_Trap extends rfc1905_PDU 541 | { 542 | /** 543 | * Constructor 544 | * 545 | * @param integer $requestID 546 | * @param integer $errorStatus 547 | * @param integer $errorIndex 548 | * @param array $varBindList 549 | */ 550 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 551 | { 552 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 553 | $this->asnTagNumber = ASN_TAG_TRAPV2; 554 | } 555 | } 556 | 557 | /** 558 | * Report 559 | * 560 | * An SNMPv2 Report PDU 561 | * 562 | * @package phpSNMP 563 | * @subpackage rfc1905 564 | */ 565 | class rfc1905_Report extends rfc1905_PDU 566 | { 567 | /** 568 | * Constructor 569 | * 570 | * @param integer $requestID 571 | * @param integer $errorStatus 572 | * @param integer $errorIndex 573 | * @param array $varBindList 574 | */ 575 | public function __construct($requestID=0, $errorStatus=0, $errorIndex=0, $varBindList=array()) 576 | { 577 | parent::__construct($requestID, $errorStatus, $errorIndex, $varBindList); 578 | $this->asnTagNumber = ASN_TAG_REPORT; 579 | } 580 | } 581 | ?> 582 | -------------------------------------------------------------------------------- /rfc2104.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc2104 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | /** 35 | * generate HMAC 36 | * 37 | * @param string $data 38 | * @param string $key 39 | * @param string $hash_function 40 | * @param integer $block_size 41 | * @return string 42 | */ 43 | function HMAC($data, $key, $hash_function='md5', $block_size=64) 44 | { 45 | if(!is_callable($hash_function)) 46 | { 47 | trigger_error("$hash_function does not exist.", E_USER_WARNING); 48 | return ''; 49 | } 50 | 51 | if(strlen($key) > $block_size) $key = pack('H*', $hash_function($key)); 52 | 53 | $key = str_pad($key, $block_size, chr(0)); 54 | 55 | $ipad = $key ^ str_repeat(chr(0x36), $block_size); 56 | $opad = $key ^ str_repeat(chr(0x5c), $block_size); 57 | 58 | $digest = pack('H*', $hash_function($ipad . $data)); 59 | 60 | return pack('H*', $hash_function($opad . $digest)); 61 | } 62 | 63 | ?> 64 | -------------------------------------------------------------------------------- /rfc3411.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc1155 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 35 | 36 | /** 37 | * SNMP V3 Engine ID 38 | * 39 | * @package phpSNMP 40 | * @subpackage rfc3411 41 | */ 42 | class rfc3411_EngineID extends rfc1155_OctetString 43 | { 44 | /** 45 | * Constructor 46 | * 47 | * @param string $value 48 | */ 49 | public function __construct($value) 50 | { 51 | if($value != '') 52 | { 53 | if(strlen($value) < 5 || strlen($value) > 32) 54 | trigger_error('rfc3411_EngineID must be of length 5 to 32', E_USER_WARNING); 55 | if(!(ord($value{0}) & 0x80) && strlen($value) != 12) 56 | trigger_error('rfc3411_EngineID size mismatch', E_USER_WARNING); 57 | } 58 | parent::__construct($value); 59 | } 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /rfc3412.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc1155 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 35 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1905.php'); 36 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc3411.php'); 37 | 38 | define('SNMP_NOAUTH_NOPRIV', 0); 39 | define('SNMP_AUTH_NOPRIV', 1); 40 | define('SNMP_AUTH_PRIV', 3); 41 | define('SNMP_REPORTABLE', 4); 42 | 43 | define('SNMP_SECURITY_ANY', 0); 44 | define('SNMP_SECURITY_V1', 1); 45 | define('SNMP_SECURITY_V2C', 2); 46 | define('SNMP_SECURITY_USM', 3); 47 | 48 | /** 49 | * SNMP v3 Message 50 | * 51 | * @package phpSNMP 52 | * @subpackage rfc3412 53 | */ 54 | class rfc3412_Message extends rfc1155_Sequence 55 | { 56 | /** 57 | * Constructor 58 | * 59 | * @param integer $version 60 | * @param rfc3412_Header $header 61 | * @param rfc3414_USM $security 62 | * @param rfc3412_ScopedPDU $scopedpdu 63 | */ 64 | public function __construct($version=SNMP_VERSION_3, $header=NULL, $usm_security=NULL, $scopedpdu=NULL) 65 | { 66 | parent::__construct(); 67 | 68 | if(is_null($header)) $header = new rfc3412_Header(); 69 | if(is_null($usm_security)) $usm_security = new rfc3414_USM(); 70 | if(is_null($scopedpdu)) $scopedpdu = new rfc3412_ScopedPDU(); 71 | 72 | $this->value = array(new rfc1155_Integer($version), $header, $usm_security, $scopedpdu); 73 | } 74 | 75 | /** 76 | * Get/Set Version 77 | * 78 | * @param integer $value 79 | * @return integer 80 | */ 81 | public function version($value=NULL) 82 | { 83 | if(!is_null($value)) $this->value[0] = new rfc1155_Integer($value); 84 | return $this->value[0]->value; 85 | } 86 | 87 | /** 88 | * Get/Set Header 89 | * 90 | * @param rfc3412_Header $value 91 | * @return rfc3412_Header 92 | */ 93 | public function header($value=NULL) 94 | { 95 | if(!is_null($value)) $this->value[1] = $value; 96 | return $this->value[1]; 97 | } 98 | 99 | /** 100 | * Get/Set USM Security 101 | * 102 | * @param rfc3414_USM $value 103 | * @return rfc3414_USM 104 | */ 105 | public function usm_security($value=NULL) 106 | { 107 | if(!is_null($value)) $this->value[2] = $value; 108 | return $this->value[2]; 109 | } 110 | 111 | /** 112 | * Get/Set Scoped PDU 113 | * 114 | * @param rfc3412_ScopedPDU $value 115 | * @return rfc3412_ScopedPDU 116 | */ 117 | public function scopedPDU($value=NULL) 118 | { 119 | if(!is_null($value)) $this->value[3] = $value; 120 | return $this->value[3]; 121 | } 122 | 123 | /** 124 | * Get/Set PDU 125 | * 126 | * @param rfc1905_PDU $value 127 | * @return rfc1905_PDU 128 | */ 129 | public function pdu($value=NULL) 130 | { 131 | if(!is_null($value)) 132 | $this->value[3]->pdu($value); 133 | return $this->value[3]->pdu(); 134 | } 135 | 136 | /** 137 | * Decode Stream 138 | * 139 | * decode() an octet stream into a sequence of Asn1Objects 140 | * 141 | * @param string $stream 142 | * @return rfc3412_Message 143 | */ 144 | public function decode($stream) 145 | { 146 | $usm = $this->usm_security(); 147 | 148 | $this->value = parent::decode($stream); 149 | 150 | if(count($this->value) != 1) 151 | trigger_error('Malformed Message: More than one object decoded.', E_USER_WARNING); 152 | $this->value = $this->value[0]->value; 153 | if(count($this->value) != 4) 154 | trigger_error('Malformed Message: Incorrect sequence length ' . count($this->value), E_USER_WARNING); 155 | 156 | $header = $this->header(); 157 | 158 | $header = $this->header(new rfc3412_Header($header->value[0]->value, $header->value[1]->value, 159 | ord($header->value[2]->value), $header->value[3]->value)); 160 | 161 | $usm->decode($this->value[2]->value); 162 | $this->usm_security($usm); 163 | 164 | if($header->auth_flag()) 165 | { 166 | // authenticate 167 | $usm = $this->usm_security(); 168 | $auth = $usm->auth(); 169 | $usm->auth(str_repeat(chr(0), USM_AUTH_KEY_LEN)); 170 | $usms = new rfc1155_OctetString($usm->encode()); 171 | $contents = $this->value[0]->encode() . $header->encode() . $usms->encode() . $this->value[3]->encode(); 172 | $packet = $this->encodeIdentifier() . $this->encodeLength(strlen($contents)) . $contents; 173 | $hmac = substr(HMAC($packet, $usm->generate_key('auth'), $usm->hash_function), 0, USM_AUTH_KEY_LEN); 174 | if($hmac != $auth) 175 | { 176 | trigger_error('Message is not authentic!', E_USER_WARNING); 177 | $this->value[3] = new rfc3412_ScopedPDU(); 178 | return $this; 179 | } 180 | 181 | if($header->priv_flag()) 182 | { 183 | $clear = $usm->decrypt($this->value[3]->value); 184 | $spdu = new rfc3412_ScopedPDU(); 185 | list($len, $c) = $spdu->decodeLength(substr($clear, 1)); 186 | $len += strlen($clear) - strlen($c); 187 | $clear = substr($clear, 0, $len); 188 | $this->value[3] = $spdu->decode($clear); 189 | } 190 | else 191 | $this->value[3] = new rfc3412_ScopedPDU($this->value[3]->value[0]->value, $this->value[3]->value[1]->value, $this->value[3]->value[2]); 192 | } 193 | else 194 | $this->value[3] = new rfc3412_ScopedPDU($this->value[3]->value[0]->value, $this->value[3]->value[1]->value, $this->value[3]->value[2]); 195 | 196 | return $this; 197 | } 198 | 199 | /** 200 | * Encode Contents 201 | * 202 | * @return string 203 | */ 204 | public function encodeContents() 205 | { 206 | $version = $this->value[0]; 207 | $header = $this->header(); 208 | $usm = $this->usm_security(); 209 | $spdu = $this->scopedPDU(); 210 | 211 | if($usm->engineID() == '') 212 | { 213 | $header->flags(SNMP_REPORTABLE); 214 | $usm = new rfc3414_USM(); 215 | $pdu = $spdu->pdu(); 216 | $pdu->varBindList(array()); 217 | $spdu = new rfc3412_ScopedPDU('', '', $pdu); 218 | } 219 | 220 | $spdu = $spdu->encode(); 221 | 222 | if($header->auth_flag()) 223 | { 224 | if($header->priv_flag()) 225 | { 226 | $spdu = new rfc1155_OctetString($usm->encrypt($spdu)); 227 | $spdu = $spdu->encode(); 228 | } 229 | 230 | $usm->auth(str_repeat(chr(0), USM_AUTH_KEY_LEN)); 231 | $usms = new rfc1155_OctetString($usm->encode()); 232 | $contents = $version->encode() . $header->encode() . $usms->encode() . $spdu; 233 | $packet = $this->encodeIdentifier() . $this->encodeLength(strlen($contents)) . $contents; 234 | $hmac = HMAC($packet, $usm->generate_key('auth'), $usm->hash_function); 235 | $usm->auth($hmac); 236 | } 237 | 238 | $usms = new rfc1155_OctetString($usm->encode()); 239 | return $version->encode() . $header->encode() . $usms->encode() . $spdu; 240 | } 241 | } 242 | 243 | /** 244 | * SNMP v3 Message Header 245 | * 246 | * @package phpSNMP 247 | * @subpackage rfc3412 248 | */ 249 | class rfc3412_Header extends rfc1155_Sequence 250 | { 251 | /** 252 | * Constructor 253 | * 254 | * @param integer $msgid 255 | * @param string $flags noAuthNoPriv(0), authNoPriv(1), authPriv(3) 256 | * @param string $security any(0), v1(1), v2c(2), usm(3) 257 | */ 258 | public function __construct($msgid=0, $max_size=65507, $flags=SNMP_NOAUTH_NOPRIV, $security=SNMP_SECURITY_USM) 259 | { 260 | parent::__construct(); 261 | $this->value = array(new rfc1155_Integer($msgid), new rfc1155_Integer($max_size), 262 | new rfc1155_OctetString(chr($flags)), new rfc1155_Integer($security)); 263 | } 264 | 265 | /** 266 | * to String 267 | * 268 | * @return string 269 | */ 270 | public function toString() 271 | { 272 | $flags = array(); 273 | $f = ord($this->value[2]->value); 274 | if($f & 1) $flags[] = 'AUTH'; 275 | if($f & 2) $flags[] = 'PRIV'; 276 | if($f & 4) $flags[] = 'REPORTABLE'; 277 | $flags = join('|', $flags) . "($f)"; 278 | 279 | switch($this->value[3]->value) 280 | { 281 | case SNMP_SECURITY_ANY: $security = 'ANY'; break; 282 | case SNMP_SECURITY_V1: $security = 'V1'; break; 283 | case SNMP_SECURITY_V2C: $security = 'V2C'; break; 284 | case SNMP_SECURITY_USM: $security = 'USM'; break; 285 | default: $this->value[3]->value; 286 | } 287 | 288 | return get_class($this) . "(MsgID:{$this->value[0]->value},max_size:{$this->value[1]->value},flags:$flags,security:$security)"; 289 | } 290 | 291 | /** 292 | * Get/Set Message ID 293 | * 294 | * @param integer $value 295 | * @return integer 296 | */ 297 | public function msgid($value=NULL) 298 | { 299 | if(!is_null($value)) $this->value[0]->value = $value; 300 | return $this->value[0]->value; 301 | } 302 | 303 | /** 304 | * Get/Set Max Message Size 305 | * 306 | * @param integer $value 307 | * @return integer 308 | */ 309 | public function maxsize($value=NULL) 310 | { 311 | if(!is_null($value)) $this->value[1]->value = $value; 312 | return $this->value[1]->value; 313 | } 314 | 315 | /** 316 | * Get/Set Message Flags 317 | * 318 | * @param integer $value 319 | * @return integer 320 | */ 321 | public function flags($value=NULL) 322 | { 323 | if(!is_null($value)) $this->value[2]->value = chr($value); 324 | return ord($this->value[2]->value); 325 | } 326 | 327 | /** 328 | * Get/Set Auth Flag 329 | * 330 | * @param boolean $value 331 | * @return boolean 332 | */ 333 | public function auth_flag($value=NULL) 334 | { 335 | if(!is_null($value)) 336 | { 337 | if($value) 338 | $this->value[2]->value |= chr(1); // set SNMP_AUTH; 339 | else 340 | $this->value[2]->value &= chr(254); // unset SNMP_AUTH 341 | } 342 | return (($this->value[2]->value & chr(1)) == chr(1)) ? true : false; 343 | } 344 | 345 | /** 346 | * Get/Set Priv Flag 347 | * 348 | * @param boolean $value 349 | * @return boolean 350 | */ 351 | public function priv_flag($value=NULL) 352 | { 353 | if(!is_null($value)) 354 | { 355 | if($value) 356 | $this->value[2]->value |= chr(3); // set SNMP_AUTH_PRIV; 357 | else 358 | $this->value[2]->value &= chr(253); // unset PRIV 359 | } 360 | return (($this->value[2]->value & chr(2)) == chr(2)) ? true : false; 361 | } 362 | 363 | /** 364 | * Get/Set Reportable Flag 365 | * 366 | * @param boolean $value 367 | * @return boolean 368 | */ 369 | public function reportable_flag($value=NULL) 370 | { 371 | if(!is_null($value)) 372 | { 373 | if($value) 374 | $this->value[2]->value |= chr(4); // set SNMP_REPORTABLE; 375 | else 376 | $this->value[2]->value &= chr(251); // unset SNMP_REPORTABLE 377 | } 378 | return ($this->value[2]->value & chr(4) == chr(4)) ? true : false; 379 | } 380 | 381 | /** 382 | * Get/Set Security Mode 383 | * 384 | * @param integer $value SNMP_SECURITY_ANY, SNMP_SECURITY_V1, SNMP_SECURITY_V2C, or SNMP_SECURITY_USM 385 | * @return integer 386 | */ 387 | public function security($value=NULL) 388 | { 389 | if(!is_null($value)) $this->value[3]->value = $value; 390 | return $this->value[3]->value; 391 | } 392 | 393 | /** 394 | * Decode Stream 395 | * 396 | * decode() an octet stream into a sequence of Asn1Objects 397 | * 398 | * @param string $stream 399 | * @return rfc3412_Header 400 | */ 401 | public function decode($stream) 402 | { 403 | parent::decode($stream); 404 | if(count($this->value) != 1) 405 | trigger_error('Malformed Message: More than one object decoded.', E_USER_WARNING); 406 | if(count($this->value[0]->value) != 4) 407 | trigger_error('Malformed Message: Incorrect sequence length ' . count($this->value[0]->value), E_USER_WARNING); 408 | return $this; 409 | } 410 | } 411 | 412 | /** 413 | * SNMP v3 Scoped PDU 414 | * 415 | * @package phpSNMP 416 | * @subpackage rfc3412 417 | */ 418 | class rfc3412_ScopedPDU extends rfc1155_Sequence 419 | { 420 | /** 421 | * Constructor 422 | * 423 | * @param string $engineid 424 | * @param string $name 425 | * @param rfc1905_PDU $pdu 426 | */ 427 | public function __construct($engineid='', $name='', $pdu=NULL) 428 | { 429 | parent::__construct(); 430 | if(is_null($pdu)) $pdu = new rfc1905_PDU(); 431 | $this->value = array(new rfc3411_EngineID($engineid), new rfc1155_OctetString($name), $pdu); 432 | } 433 | 434 | /** 435 | * Get/Set Context Engine ID 436 | * 437 | * @param string $value 438 | * @return string 439 | */ 440 | public function engineID($value=NULL) 441 | { 442 | if(!is_null($value)) $this->value[0]->value = $value; 443 | return $this->value[0]->value; 444 | } 445 | 446 | /** 447 | * Get/Set Context Name 448 | * 449 | * @param string $value 450 | * @return string 451 | */ 452 | public function name($value=NULL) 453 | { 454 | if(!is_null($value)) $this->value[1]->value = $value; 455 | return $this->value[1]->value; 456 | } 457 | 458 | /** 459 | * Get/Set PDU 460 | * 461 | * @param rfc1905_PDU $value 462 | * @return rfc1905_PDU 463 | */ 464 | public function pdu($value=NULL) 465 | { 466 | if(!is_null($value)) $this->value[2] = $value; 467 | return $this->value[2]; 468 | } 469 | 470 | /** 471 | * To String 472 | * 473 | * @return string 474 | */ 475 | public function toString() 476 | { 477 | $eid = $this->value[0]->toString(); 478 | $name = $this->value[1]->toString(); 479 | $pdu = $this->pdu(); 480 | $pdu = $pdu->toString(); 481 | return get_class($this) . "(engineID:$eid,Name:$name,pdu:$pdu)"; 482 | } 483 | 484 | /** 485 | * Decode Stream 486 | * 487 | * decode() an octet stream into a sequence of Asn1Objects 488 | * 489 | * @param string $stream 490 | * @return rfc3412_ScopedPDU 491 | */ 492 | public function decode($stream) 493 | { 494 | $this->value = parent::decode($stream); 495 | if(count($this->value) != 1) 496 | trigger_error('Malformed Message: More than one object decoded.', E_USER_WARNING); 497 | $this->value = $this->value[0]->value; 498 | if(count($this->value) != 3) 499 | trigger_error('Malformed Message: Incorrect sequence length ' . count($this->value), E_USER_WARNING); 500 | 501 | $this->value[0] = new rfc3411_EngineID($this->value[0]->value); 502 | 503 | return $this; 504 | } 505 | } 506 | ?> 507 | -------------------------------------------------------------------------------- /rfc3414.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @subpackage rfc3414 28 | * @version .7 29 | */ 30 | 31 | /** 32 | */ 33 | 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 35 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc3411.php'); 36 | 37 | define('USM_AUTH_KEY_LEN', 12); 38 | define('USM_SALT_LEN', 8); 39 | 40 | /** 41 | * User-based Security Model (USM) 42 | * 43 | * @package phpSNMP 44 | * @subpackage rfc3414 45 | */ 46 | class rfc3414_USM extends rfc1155_Sequence 47 | { 48 | var $auth_password = ''; 49 | var $priv_password = ''; 50 | var $hash_function = 'md5'; 51 | var $crypt_algorithm = 'des'; 52 | var $crypt_mode = 'cbc'; 53 | 54 | /** 55 | * Constructor 56 | * 57 | * @param string $engine_id 58 | * @param integer $engine_boots 59 | * @param integer $engine_time 60 | * @param string $user 61 | * @param string $auth MD5 or SHA hash sum 62 | * @param string $priv DES salt 63 | */ 64 | public function __construct($engine_id='', $engine_boots=0, $engine_time=0, $user='', $auth='', $priv='') 65 | { 66 | parent::__construct(); 67 | if(strlen($user) > 32) 68 | trigger_error('user must be at most 32 characters', E_USER_WARNING); 69 | $this->value = array(new rfc3411_EngineID($engine_id), new rfc1155_Integer($engine_boots), 70 | new rfc1155_Integer($engine_time), new rfc1155_OctetString($user), 71 | new rfc1155_OctetString($auth), new rfc1155_OctetString($priv)); 72 | } 73 | 74 | /** 75 | * Get/Set engine ID 76 | * 77 | * @param string $value 78 | * @return string 79 | */ 80 | public function engineID($value=NULL) 81 | { 82 | if(!is_null($value)) $this->value[0]->value = $value; 83 | return $this->value[0]->value; 84 | } 85 | 86 | /** 87 | * Get/Set engine boots 88 | * 89 | * @param integer $value 90 | * @return integer 91 | */ 92 | public function engineBoots($value=NULL) 93 | { 94 | if(!is_null($value)) $this->value[1]->value = $value; 95 | return $this->value[1]->value; 96 | } 97 | 98 | /** 99 | * Get/Set engine time 100 | * 101 | * @param integer $value 102 | * @return integer 103 | */ 104 | public function engineTime($value=NULL) 105 | { 106 | if(!is_null($value)) $this->value[2]->value = $value; 107 | return $this->value[2]->value; 108 | } 109 | 110 | /** 111 | * Get/Set usm user 112 | * 113 | * @param string $value 114 | * @return string 115 | */ 116 | public function user($value=NULL) 117 | { 118 | if(!is_null($value)) $this->value[3]->value = $value; 119 | return $this->value[3]->value; 120 | } 121 | 122 | /** 123 | * Get/Set auth parameters 124 | * 125 | * @param string $value 126 | * @return string 127 | */ 128 | public function auth($value=NULL) 129 | { 130 | if(!is_null($value)) $this->value[4]->value = substr($value, 0, USM_AUTH_KEY_LEN); 131 | return $this->value[4]->value; 132 | } 133 | 134 | /** 135 | * Get/Set priv parameters 136 | * 137 | * @param string $value - a value of 'salt' generates a new priv parameter 138 | * @return string 139 | */ 140 | public function priv($value=NULL) 141 | { 142 | static $salt = NULL; 143 | 144 | if(!is_null($value)) 145 | { 146 | if($value == 'salt') 147 | { 148 | if(is_null($salt)) for($i = 0; $i < USM_SALT_LEN; $i++) $salt .= chr(rand(0, 255)); 149 | 150 | $i = USM_SALT_LEN - 1; 151 | while($i) 152 | { 153 | if($salt{$i} == chr(255)) 154 | { 155 | $salt{$i} = chr(0); 156 | $i--; 157 | } 158 | else 159 | { 160 | $salt{$i} = chr(ord($salt{$i}) + 1); 161 | $i = 0; 162 | } 163 | } 164 | $this->value[5]->value = $salt; 165 | } 166 | else 167 | $this->value[5]->value = $value; 168 | } 169 | return $this->value[5]->value; 170 | } 171 | 172 | /** 173 | * Decode Stream 174 | * 175 | * decode() an octet stream into a sequence of Asn1Objects 176 | * 177 | * @param string $stream 178 | * @return rfc3411_USM 179 | */ 180 | public function decode($stream) 181 | { 182 | $this->value = parent::decode($stream); 183 | if(count($this->value) != 1) 184 | trigger_error('Malformed Message: More than one object decoded.', E_USER_WARNING); 185 | $this->value = $this->value[0]->value; 186 | if(count($this->value) != 6) 187 | trigger_error('Malformed Message: Incorrect sequence length ' . count($this->value), E_USER_WARNING); 188 | return $this; 189 | } 190 | 191 | /** 192 | * Generate a key 193 | * 194 | * @param string $password - 'auth' for auth_password, 'priv' for priv_password, anything else will be treated as a password 195 | * @return string key 196 | */ 197 | public function generate_key($password) 198 | { 199 | if($password == 'auth') 200 | $password = $this->auth_password; 201 | elseif($password == 'priv') 202 | $password = $this->priv_password; 203 | 204 | $hashfn = $this->hash_function; 205 | $key = substr(str_repeat($password, ceil(1048576 / strlen($password))), 0, 1048576); 206 | $key = pack('H*', $hashfn($key)); 207 | return pack('H*', $hashfn($key . $this->engineID() . $key)); 208 | } 209 | 210 | /** 211 | * Generate initialization vector for DES 212 | * 213 | * @param string $key 214 | * @return string iv 215 | */ 216 | public function generate_iv($key=NULL) 217 | { 218 | if(is_null($key)) $key = $this->generate_key('priv'); 219 | $salt = $this->priv(); 220 | return substr($key, strlen($key) - strlen($salt)) ^ $salt; 221 | } 222 | 223 | /** 224 | * Encrypt using crypt_algorithm and crypt_mode 225 | * 226 | * @param string $data 227 | * @return string 228 | */ 229 | public function encrypt($data) 230 | { 231 | if(!(function_exists('mcrypt_module_open') && function_exists('mcrypt_generic'))) 232 | { 233 | trigger_error('Mcrypt must be installed', E_USER_WARNING); 234 | return $data; 235 | } 236 | $key = $this->generate_key('priv'); 237 | $this->priv('salt'); 238 | $iv = $this->generate_iv($key); 239 | $td = mcrypt_module_open($this->crypt_algorithm, '', $this->crypt_mode, ''); 240 | $ks = mcrypt_enc_get_key_size($td); 241 | $key = substr($key, 0, $ks); 242 | mcrypt_generic_init($td, $key, $iv); 243 | $ret = mcrypt_generic($td, $data); 244 | mcrypt_generic_deinit($td); 245 | mcrypt_module_close($td); 246 | return $ret; 247 | } 248 | 249 | /** 250 | * Decrypt using crypt_algorithm and crypt_mode 251 | * 252 | * @param string $data 253 | * @return string 254 | */ 255 | public function decrypt($data) 256 | { 257 | if(!(function_exists('mcrypt_module_open') && function_exists('mdecrypt_generic'))) 258 | { 259 | trigger_error('Mcrypt must be installed', E_USER_WARNING); 260 | return $data; 261 | } 262 | $key = $this->generate_key('priv'); 263 | $iv = $this->generate_iv($key); 264 | $td = mcrypt_module_open($this->crypt_algorithm, '', $this->crypt_mode, ''); 265 | $ks = mcrypt_enc_get_key_size($td); 266 | $key = substr($key, 0, $ks); 267 | mcrypt_generic_init($td, $key, $iv); 268 | $ret = mdecrypt_generic($td, $data); 269 | mcrypt_generic_deinit($td); 270 | mcrypt_module_close($td); 271 | return $ret; 272 | } 273 | } 274 | ?> 275 | -------------------------------------------------------------------------------- /snmp.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * Based on snmp - a Python SNMP library 8 | * Copyright (C) 2003 Unicity Pty Ltd 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 25 | * @copyright 2004 David Eder 26 | * @package phpSNMP 27 | * @version .7 28 | */ 29 | 30 | /** 31 | */ 32 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1155.php'); 33 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1157.php'); 34 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1902.php'); 35 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc1905.php'); 36 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc2104.php'); 37 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc3411.php'); 38 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc3412.php'); 39 | require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rfc3414.php'); 40 | 41 | define('SNMP_VERSION_1', 0); 42 | define('SNMP_VERSION_2', 1); 43 | define('SNMP_VERSION_2C', 1); 44 | define('SNMP_VERSION_2U', 2); // doesn't work yet 45 | define('SNMP_VERSION_3', 3); // doesn't work yet 46 | 47 | /** 48 | * SNMP 49 | * 50 | * @package phpSNMP 51 | */ 52 | class snmp 53 | { 54 | var $version = SNMP_VERSION_1; // version can be SNMP_VERSION_1, SNMP_VERSION_2C, SNMP_VERSION_3 55 | var $timeout = 10.0; // timeout in seconds for waiting for a return packet 56 | var $default_security; // default security parameters 57 | 58 | /** 59 | * Constructor 60 | */ 61 | public function __construct() 62 | { 63 | $this->default_security = array('community'=>'public', 'v3_max_size'=>65507, 'v3_flags'=>SNMP_AUTH_NOPRIV, 64 | 'v3_security_model'=>SNMP_SECURITY_USM, 'v3_engine_id'=>'', 'v3_engine_boots'=>0, 65 | 'v3_engine_time'=>0, 'v3_user'=>'', 'v3_auth'=>'', 'v3_priv'=>'', 66 | 'v3_context_engine_id'=>'', 'v3_context_name'=>'', 'v3_hash'=>'md5', 67 | 'v3_crypt_algorithm'=>'des', 'v3_crypt_mode'=>'cbc'); 68 | } 69 | 70 | /** 71 | * get an oid from a single host 72 | * 73 | * @param string $host hostnames or ip addresses 74 | * @param mixed $target varbind array or oid (oids must be numeric) 75 | * @param array $security parameters 76 | * @return array in the format $oid=>$value 77 | */ 78 | public function get($host, $target, $security=NULL) 79 | { 80 | if(is_array($target)) 81 | $varbind = $target; 82 | else 83 | $varbind = $this->build_varbind($target); 84 | 85 | $ret = $this->exec($host, 'get', $varbind, $security); 86 | 87 | return array_shift($ret); 88 | } 89 | 90 | /** 91 | * get an oid from multiple hosts 92 | * 93 | * @param array $hosts hostnames or ip addresses 94 | * @param mixed $target varbind array or oid (oids must be numeric) 95 | * @param array $security parameters 96 | * @return array in the format $ip=>array($oid=>$value) 97 | */ 98 | public function multi_get($hosts, $target, $security=NULL) 99 | { 100 | if(is_array($target)) 101 | $varbind = $target; 102 | else 103 | $varbind = $this->build_varbind($target); 104 | return $this->exec($hosts, 'get', $varbind, $security); 105 | } 106 | 107 | /** 108 | * bulk get oids from a single host 109 | * 110 | * @param string $host hostname or ip address 111 | * @param array $oids (oids must be numeric) 112 | * @param array $security parameters 113 | * @return array in the format $oid=>$value 114 | */ 115 | public function bulk_get($host, $oids, $security=NULL) 116 | { 117 | $ret = $this->exec($host, 'getbulk', $this->build_varbind($oids), $security); 118 | 119 | return array_shift($ret); 120 | } 121 | 122 | /** 123 | * bulk get oids from a mulitple hosts 124 | * 125 | * @param string $hosts hostnames or ip addresses 126 | * @param array $oids (oids must be numeric) 127 | * @param array $security parameters 128 | * @return array in the format $oid=>$value 129 | */ 130 | public function multi_bulk_get($hosts, $oids, $security=NULL) 131 | { 132 | return $this->exec($hosts, 'getbulk', $this->build_varbind($oids), $security); 133 | } 134 | 135 | /** 136 | * walk an oid 137 | * 138 | * @param string $host hostnames or ip addresses 139 | * @param string $oid (oids must be numeric) 140 | * @param array $security parameters 141 | * @return array in the format $ip=>array($oid=>$value) 142 | */ 143 | public function walk($host, $oid, $security=NULL) 144 | { 145 | $ret = $this->exec($host, 'getnext', $this->build_varbind($oid), $security, $oid); 146 | 147 | return array_shift($ret); 148 | } 149 | 150 | /** 151 | * walk an oid on multiple hosts 152 | * 153 | * @param array $hosts hostnames or ip addresses 154 | * @param sring $oid (oids must be numeric) 155 | * @param array $security parameters 156 | * @return array in the format $ip=>array($oid=>$value) 157 | */ 158 | public function multi_walk($hosts, $oid, $security=NULL) 159 | { 160 | return $this->exec($hosts, 'getnext', $this->build_varbind($oid), $security, $oid); 161 | } 162 | 163 | /** 164 | * set a variable 165 | * 166 | * @param string $host hostname or ip address 167 | * @param mixed $target varbind array or oid (oids must be numeric) 168 | * @param mixed $value to set 169 | * @param string $type 'i' = integer; 't' = time ticks; 'x' = hex string; 's' = string; 'a' = IP address; 'o' = object ID; 'n' = null value 170 | * @param array $security parameters 171 | */ 172 | public function set($host, $target, $value=0, $type='i', $security=NULL) 173 | { 174 | if(is_array($target)) 175 | $varbind = $target; 176 | else 177 | $varbind = $this->build_varbind($target, $value, $type); 178 | $this->exec($host, 'set', $varbind, $security); 179 | } 180 | 181 | /** 182 | * set a variable 183 | * 184 | * @param array $hosts hostnames or ip addresses 185 | * @param mixed $target varbind array or oid (oids must be numeric) 186 | * @param mixed $value to set 187 | * @param string $type 'i' = integer; 't' = time ticks; 'x' = hex string; 's' = string; 'a' = IP address; 'o' = object ID; 'n' = null value 188 | * @param array $security parameters 189 | */ 190 | public function multi_set($hosts, $target, $value=0, $type='i', $security=NULL) 191 | { 192 | $this->set($hosts, $target, $value, $type, $security); 193 | } 194 | 195 | /** 196 | * send a trap 197 | * 198 | * @param string $manager hostname or ip address of the manager 199 | * @param array $security parameters 200 | * @param array $varbinds created by build_varbind 201 | * @param string $enterprise oid (oids must be numeric) of the object generating the trap (this is only for version 1) 202 | * @param string $agent hostname or ip address of the agent generating the trap (this is only for version 1) 203 | * @param integer $trap_type from TRAP_COLDSTART, TRAP_WARMSTART, TRAP_LINKDOWN, TRAP_LINKUP, 204 | * TRAP_AUTH_FAIL, TRAP_EGP_NEIGHBOR_LOSS, TRAP_ENTERPRISE_SPECIFIC 205 | * (this is only for version 1) 206 | * @param integer $specific_trap_type (this is only for version 1) 207 | * @param integer $timestamp time since last restart (this is only for version 1) 208 | */ 209 | public function trap($manager, $security, $varbind, $enterprise='', $agent='', $trap_type=0, $specific_trap_type=0, $timestamp=0) 210 | { 211 | if(is_null($security)) 212 | $security = $this->default_security; 213 | elseif(!is_array($security)) 214 | { 215 | $s = $this->default_security; 216 | $s['community'] = $security; 217 | $security = $s; 218 | } 219 | 220 | if($this->version == SNMP_VERSION_1) 221 | { 222 | $pdu = new rfc1157_TrapPDU($enterprise, $agent, $trap_type, $specific_trap_type, $timestamp, $varbind); 223 | $msg = new rfc1157_Message(SNMP_VERSION_1, $security['community'], $pdu); 224 | $packet = $msg->encode(); 225 | } 226 | elseif($this->version == SNMP_VERSION_2C || $this->version == SNMP_VERSION_3) 227 | $packet = $this->build_packet($varbind, $security, 'trap'); 228 | else 229 | { 230 | trigger_error("Unknown SNMP version [{$this->version}]", E_USER_WARNING); 231 | return; 232 | } 233 | 234 | $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 235 | @socket_sendto($socket, $packet, strlen($packet), 0, $manager, 162); 236 | } 237 | 238 | /** 239 | * build a variable binding 240 | * 241 | * @param string $oid (oids must be numeric) 242 | * @param mixed $value to set 243 | * @param string $type 'i' = integer; 't' = time ticks; 'x' = hex string; 's' = string; 'a' = IP address; 'o' = object ID; 'n' = null value 244 | * @return array varbind 245 | */ 246 | public function build_varbind($oid, $value=0, $type='n') 247 | { 248 | if(!is_array($oid)) $oid = array($oid); 249 | 250 | if(!is_array($value)) 251 | { 252 | $val = $value; 253 | $value = array(); 254 | foreach(array_keys($oid) as $i) 255 | $value[$i] = $val; 256 | } 257 | if(!is_array($type)) 258 | { 259 | $t = $type; 260 | $type = array(); 261 | foreach(array_keys($oid) as $i) 262 | $type[$i] = $t; 263 | } 264 | 265 | $varbind = array(); 266 | foreach($oid as $i=>$o) 267 | { 268 | switch($type[$i]) 269 | { 270 | case 'i': // integer 271 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_Integer($value[$i])); 272 | break; 273 | case 't': // time ticks 274 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_TimeTicks($value[$i])); 275 | break; 276 | case 'x': // hex string 277 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_OctetString(hexbin($value[$i]))); 278 | break; 279 | case 's': // string 280 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_OctetString($value[$i])); 281 | break; 282 | case 'a': // ip address 283 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_IPAddress($value[$i])); 284 | break; 285 | case 'o': // object id 286 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_ObjectID($value[$i])); 287 | break; 288 | case 'n': // null value 289 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_Null()); 290 | break; 291 | default: 292 | trigger_error("Unknown type $type", E_USER_WARNING); 293 | $varbind[] = new rfc1157_VarBind(new rfc1155_ObjectID($o), new rfc1155_Null()); 294 | } 295 | } 296 | return $varbind; 297 | } 298 | 299 | /** 300 | * execute a poll on hosts 301 | * 302 | * @param mixed $target 303 | * @param string $community string 304 | * @param string $type is either get, getnext, or set 305 | * @param string $value to use for set 306 | * @param string $value_type to use for set 307 | * @return string packet 308 | */ 309 | public function build_packet($varbind, $security=NULL, $type='get') 310 | { 311 | if(is_null($security)) 312 | $security = $this->default_security; 313 | elseif(!is_array($security)) 314 | { 315 | $s = $this->default_security; 316 | $s['community'] = $security; 317 | $security = $s; 318 | } 319 | 320 | if($this->version == SNMP_VERSION_1) 321 | { 322 | if($type == 'get') 323 | $pdu = new rfc1157_Get($this->assignRequestID(), 0, 0, $varbind); 324 | elseif($type == 'getnext') 325 | $pdu = new rfc1157_GetNext($this->assignRequestID(), 0, 0, $varbind); 326 | elseif($type == 'set') 327 | $pdu = new rfc1157_Set($this->assignRequestID(), 0, 0, $varbind); 328 | else 329 | { 330 | trigger_error("Unknown request type: $type", E_USER_WARNING); 331 | return ''; 332 | } 333 | $msg = new rfc1157_Message(SNMP_VERSION_1, $security['community'], $pdu); 334 | } 335 | elseif($this->version == SNMP_VERSION_2C || $this->version == SNMP_VERSION_3) 336 | { 337 | $request_id = $this->assignRequestID(); 338 | $reportable = SNMP_REPORTABLE; 339 | if($type == 'get') 340 | $pdu = new rfc1905_Get($request_id, 0, 0, $varbind); 341 | elseif($type == 'getnext') 342 | $pdu = new rfc1905_GetNext($request_id, 0, 0, $varbind); 343 | elseif($type == 'set') 344 | $pdu = new rfc1905_Set($request_id, 0, 0, $varbind); 345 | elseif($type == 'getbulk') 346 | $pdu = new rfc1905_GetBulk($request_id, count($varbind), 1, $varbind); 347 | elseif($type == 'inform') 348 | $pdu = new rfc1905_Inform($request_id, 0, 0, $varbind); 349 | elseif($type == 'trap') 350 | { 351 | $pdu = new rfc1905_Trap($request_id, 0, 0, $varbind); 352 | $reportable = 0; 353 | } 354 | elseif($type == 'report') 355 | { 356 | $pdu = new rfc1905_Report($request_id, 0, 0, $varbind); 357 | $reportable = 0; 358 | } 359 | else 360 | { 361 | trigger_error("Unknown request type: $type", E_USER_WARNING); 362 | return ''; 363 | } 364 | if($this->version == SNMP_VERSION_2C) 365 | $msg = new rfc1905_Message(SNMP_VERSION_2C, $security['community'], $pdu); 366 | else 367 | { 368 | foreach($this->default_security as $key=>$value) if(!isset($security[$key])) $security[$key] = $value; 369 | 370 | $header = new rfc3412_Header($request_id, $security['v3_max_size'], 371 | $security['v3_flags'] | $reportable, $security['v3_security_model']); 372 | 373 | $usm = new rfc3414_USM($security['v3_engine_id'], $security['v3_engine_boots'], 374 | $security['v3_engine_time'], $security['v3_user']); 375 | $usm->auth_password = $security['v3_auth']; 376 | $usm->priv_password = $security['v3_priv']; 377 | $usm->hash_function = $security['v3_hash']; 378 | $usm->crypt_algorithm = $security['v3_crypt_algorithm']; 379 | $usm->crypt_mode = $security['v3_crypt_mode']; 380 | 381 | $scopedpdu = new rfc3412_ScopedPDU($security['v3_context_engine_id'], $security['v3_context_name'], $pdu); 382 | $msg = new rfc3412_Message(SNMP_VERSION_3, $header, $usm, $scopedpdu); 383 | } 384 | } 385 | else 386 | { 387 | trigger_error("Unknown SNMP version {$this->version}", E_USER_WARNING); 388 | return ''; 389 | } 390 | 391 | return $msg->encode(); 392 | } 393 | 394 | /** 395 | * execute a poll on hosts 396 | * 397 | * @param array $hosts hostnames or ip addresses 398 | * @param string $type is either get, getnext, or set 399 | * @param string $packet to send 400 | * @param array $security parameters 401 | * @param string $stop 402 | * @return array in the format $ip=>array($oid=>$value) 403 | */ 404 | public function exec($hosts, $type, $varbind, $security=NULL, $stop='') 405 | { 406 | $queue = array(); 407 | $buffer = $port = NULL; 408 | $ret = array(); 409 | 410 | foreach($this->default_security as $key=>$value) if(!isset($security[$key])) $security[$key] = $value; 411 | 412 | $packet = $this->build_packet($varbind, $security, $type); 413 | 414 | // add each host to the queue 415 | if(!is_array($hosts)) $hosts = array($hosts); 416 | foreach($hosts as $host) 417 | { 418 | $h = ip2long($host); 419 | if($h == -1 || $h === false) $host = gethostbyname($host); // we don't like hostnames 420 | $queue[] = array($packet, $host); 421 | $ret[$host] = array(); 422 | } 423 | 424 | // create a message to decode with 425 | if($this->version == SNMP_VERSION_1) 426 | $msg = new rfc1157_Message(); 427 | elseif($this->version == SNMP_VERSION_2C) 428 | $msg = new rfc1905_Message(); 429 | elseif($this->version == SNMP_VERSION_3) 430 | { 431 | $usm = new rfc3414_USM(); 432 | $usm->auth_password = $security['v3_auth']; 433 | $usm->priv_password = $security['v3_priv']; 434 | $usm->hash_function = $security['v3_hash']; 435 | $usm->crypt_algorithm = $security['v3_crypt_algorithm']; 436 | $usm->crypt_mode = $security['v3_crypt_mode']; 437 | $msg = new rfc3412_Message(SNMP_VERSION_3, new rfc3412_Header(), $usm); 438 | } 439 | else 440 | { 441 | trigger_error("Unknown SNMP version {$this->version}", E_USER_WARNING); 442 | return array(); 443 | } 444 | 445 | $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 446 | if($socket === false) 447 | { 448 | trigger_error('Unable to create socket.', E_USER_WARNING); 449 | return array(); 450 | } 451 | if(!socket_set_nonblock($socket)) 452 | trigger_error('Unable to set socket to nonblocking.', E_USER_WARNING); 453 | 454 | $sent = 0; 455 | $received = 0; 456 | $t = $this->microtime(); 457 | $block_state = 0; // 0 = nonblock, 1 = block, 2 = failed block 458 | while(count($queue)) 459 | { 460 | do 461 | { 462 | if(count($queue)) 463 | { 464 | // send next queue entry 465 | $entry = array_shift($queue); 466 | if(strlen($entry[0])) 467 | { 468 | if($block_state == 1) 469 | { 470 | socket_set_nonblock($socket); 471 | $block_state = 0; 472 | } 473 | 474 | if(@socket_sendto($socket, $entry[0], strlen($entry[0]), 0, $entry[1], 161) === false) 475 | trigger_error('Unable to send packet.', E_USER_WARNING); 476 | else 477 | $sent++; 478 | $t = $this->microtime(); 479 | } 480 | } 481 | elseif($block_state == 0) 482 | { 483 | // we are done sending, try to set state to blocking I/O with a timeout 484 | if(@socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>floor($this->timeout), 'usec'=>0))) 485 | { 486 | socket_set_block($socket); 487 | $block_state = 1; 488 | } 489 | else 490 | $block_state = 2; 491 | } 492 | elseif($block_state == 2) // sleep if we failed to set a timeout 493 | { 494 | usleep(10000); 495 | } 496 | 497 | $buffer = $rhost = NULL; 498 | @socket_recvfrom($socket, $buffer, 4096, 0, $rhost, $port); 499 | if($buffer != '' && isset($ret[$rhost])) 500 | { 501 | $received++; 502 | 503 | $msg = $msg->decode($buffer); 504 | 505 | if($security['v3_context_engine_id'] == '' && $msg->version() == SNMP_VERSION_3) 506 | { 507 | $usm = $msg->usm_security(); 508 | $security['v3_engine_id'] = $usm->engineID(); 509 | $security['v3_engine_boots'] = $usm->engineBoots(); 510 | $security['v3_engine_time'] = $usm->engineTime(); 511 | 512 | $spdu = $msg->scopedPDU(); 513 | $security['v3_context_engine_id'] = $spdu->engineID(); 514 | $security['v3_context_name'] = $spdu->name(); 515 | 516 | $queue[] = array($this->build_packet($varbind, $security, $type), $rhost); 517 | } 518 | else 519 | { 520 | $pdu = $msg->pdu(); 521 | 522 | if($pdu->errorStatus()) trigger_error($pdu->errorString(), E_USER_WARNING); 523 | 524 | foreach($pdu->varBindList() as $val) 525 | { 526 | $oid = $val->value[0]->toString(); 527 | if(($stop == '' || strpos(' '. $oid, $stop) != 0) && !isset($ret[$rhost][$oid])) 528 | { 529 | if($type == 'getnext') 530 | $queue[] = array($this->build_packet($this->build_varbind($oid), $security, 'getnext'), $rhost); 531 | $ret[$rhost][$oid] = $val->value[1]->toString(); 532 | } 533 | } 534 | } 535 | } 536 | } while($sent != $received && $this->microtime() - $t <= $this->timeout); 537 | } 538 | return $ret; 539 | } 540 | 541 | /** 542 | * Assign a unique requestID 543 | * 544 | * @return integer a request id 545 | */ 546 | public function assignRequestID() 547 | { 548 | static $nextRequestID = 0; 549 | if($nextRequestID == 0 || $nextRequestID >= 2147483647) $nextRequestID = mt_rand(); 550 | return $nextRequestID++; 551 | } 552 | 553 | /** 554 | * Get microtime as a float 555 | * 556 | * @return float microtime 557 | */ 558 | public function microtime() 559 | { 560 | list($usec, $sec) = explode(' ', microtime()); 561 | return ((float)$usec + (float)$sec); 562 | } 563 | } 564 | ?> 565 | -------------------------------------------------------------------------------- /test.php: -------------------------------------------------------------------------------- 1 | $z => $zz\n"; 13 | 14 | $ip = '172.16.0.116'; // ip address or hostname 15 | $ips = array($ip, '172.16.0.64'); // array of ip addresses or hostnames 16 | $community = 'public'; // community string 17 | $oid = '.1.3.6.1.2.1.1'; // only numerical oids are supported 18 | $oids = array('.1.3.6.1.2.1.1.1', '.1.3.6.1.2.1.1.3'); 19 | 20 | $snmp = new snmp(); 21 | 22 | $snmp->version = SNMP_VERSION_2; 23 | 24 | print_r($snmp->walk($ip, $oid, ['community' => $community])); 25 | print_r($snmp->multi_walk($ips, $oid, ['community' => $community])); 26 | 27 | 28 | $snmp->version = SNMP_VERSION_3; 29 | print_r($snmp->get('localhost', '.1.3.6.1.2.1.1.3.0', array('v3_flags'=>SNMP_AUTH_PRIV, 'v3_user'=>'v3user', 30 | 'v3_auth'=>'authpassword', 'v3_priv'=>'privpassword'))); 31 | 32 | // get system uptime 33 | print_r($snmp->get($ip, '.1.3.6.1.2.1.1.3.0', ['community' => $community])); 34 | print_r($snmp->multi_get($ips, '.1.3.6.1.2.1.1.3.0', ['community' => $community])); 35 | 36 | // bulk get 37 | print_r($snmp->bulk_get($ip, $oids)); 38 | 39 | // reset cable modem(s) 40 | $oid = '.1.3.6.1.3.83.1.1.4.0.1.1.3.0'; 41 | $snmp->set($ip, $oid, 1, 'i', ['community' => 'private']); 42 | $snmp->multi_set($ips, $oid, 1, 'i', ['community' => 'private']); 43 | 44 | // send a trap 45 | $ip = '123.45.12.3'; 46 | $community = 'public'; 47 | $varbind = $snmp->build_varbind('.1.3.6.1.3.83.1.1.4.1', 17, 'i'); 48 | $enterprise = '.1.3.6.1.3.83.1.1.4.0.1.1.3.0'; 49 | $agent = '127.0.0.1'; 50 | $trap_type = TRAP_LINKUP; 51 | $specific_trap_type = 2; 52 | $uptime = 123; 53 | 54 | $snmp->trap($ip, $community, $varbind, $enterprise, $agent, $trap_type, $specific_trap_type, $uptime); 55 | ?> 56 | -------------------------------------------------------------------------------- /v3test.php: -------------------------------------------------------------------------------- 1 | timeout = 1; 7 | 8 | echo "v1: "; 9 | $snmp->version = SNMP_VERSION_1; 10 | print_r($snmp->get('localhost', '.1.3.6.1.2.1.1.3.0')); 11 | 12 | echo "v2: "; 13 | $snmp->version = SNMP_VERSION_2C; 14 | print_r($snmp->get('localhost', '.1.3.6.1.2.1.1.3.0')); 15 | 16 | echo "v3: "; 17 | $snmp->version = SNMP_VERSION_3; 18 | print_r($snmp->get('localhost', '.1.3.6.1.2.1.1.3.0', array('v3_flags'=>SNMP_AUTH_PRIV, 'v3_user'=>'jellofish', 19 | 'v3_auth'=>'qxplne45', 'v3_priv'=>'rvnsiq45'))); 20 | 21 | 22 | 23 | /* 24 | 25 | 26 | 1. Make sure the snmpd is not running and insert the following command to create a user: 27 | 28 | # net-snmp-config --create-snmpv3-user -a my_password my_user 29 | 30 | 31 | 2. Setup net-snmpd with the following command: 32 | 33 | # snmpconf -i -g basic_setup 34 | 35 | 36 | 3. Test the config 37 | 38 | # snmpget -v3 -u my_user -l authNoPriv -a MD5 -A my_password localhost sysUpTime.0 39 | 40 | */ 41 | ?> 42 | --------------------------------------------------------------------------------