snmp 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/README +193 -0
  2. data/Rakefile +52 -0
  3. data/data/ruby/snmp/mibs/ACCOUNTING-CONTROL-MIB.yaml +44 -0
  4. data/data/ruby/snmp/mibs/ADSL-LINE-EXT-MIB.yaml +66 -0
  5. data/data/ruby/snmp/mibs/ADSL-LINE-MIB.yaml +238 -0
  6. data/data/ruby/snmp/mibs/ADSL-TC-MIB.yaml +2 -0
  7. data/data/ruby/snmp/mibs/AGENTX-MIB.yaml +40 -0
  8. data/data/ruby/snmp/mibs/APM-MIB.yaml +98 -0
  9. data/data/ruby/snmp/mibs/APPC-MIB.yaml +295 -0
  10. data/data/ruby/snmp/mibs/APPLETALK-MIB.yaml +284 -0
  11. data/data/ruby/snmp/mibs/APPLICATION-MIB.yaml +161 -0
  12. data/data/ruby/snmp/mibs/APPN-DLUR-MIB.yaml +41 -0
  13. data/data/ruby/snmp/mibs/APPN-MIB.yaml +356 -0
  14. data/data/ruby/snmp/mibs/APPN-TRAP-MIB.yaml +8 -0
  15. data/data/ruby/snmp/mibs/APS-MIB.yaml +62 -0
  16. data/data/ruby/snmp/mibs/ATM-ACCOUNTING-INFORMATION-MIB.yaml +37 -0
  17. data/data/ruby/snmp/mibs/ATM-MIB.yaml +112 -0
  18. data/data/ruby/snmp/mibs/ATM-TC-MIB.yaml +19 -0
  19. data/data/ruby/snmp/mibs/ATM2-MIB.yaml +182 -0
  20. data/data/ruby/snmp/mibs/BGP4-MIB.yaml +56 -0
  21. data/data/ruby/snmp/mibs/BLDG-HVAC-MIB.yaml +35 -0
  22. data/data/ruby/snmp/mibs/BRIDGE-MIB.yaml +63 -0
  23. data/data/ruby/snmp/mibs/CHARACTER-MIB.yaml +48 -0
  24. data/data/ruby/snmp/mibs/CIRCUIT-IF-MIB.yaml +21 -0
  25. data/data/ruby/snmp/mibs/CLNS-MIB.yaml +116 -0
  26. data/data/ruby/snmp/mibs/COFFEE-POT-MIB.yaml +13 -0
  27. data/data/ruby/snmp/mibs/COPS-CLIENT-MIB.yaml +54 -0
  28. data/data/ruby/snmp/mibs/DECNET-PHIV-MIB.yaml +237 -0
  29. data/data/ruby/snmp/mibs/DIAL-CONTROL-MIB.yaml +84 -0
  30. data/data/ruby/snmp/mibs/DIFFSERV-CONFIG-MIB.yaml +15 -0
  31. data/data/ruby/snmp/mibs/DIFFSERV-DSCP-TC.yaml +2 -0
  32. data/data/ruby/snmp/mibs/DIFFSERV-MIB.yaml +171 -0
  33. data/data/ruby/snmp/mibs/DIRECTORY-SERVER-MIB.yaml +52 -0
  34. data/data/ruby/snmp/mibs/DISMAN-EVENT-MIB.yaml +110 -0
  35. data/data/ruby/snmp/mibs/DISMAN-EXPRESSION-MIB.yaml +55 -0
  36. data/data/ruby/snmp/mibs/DISMAN-NSLOOKUP-MIB.yaml +23 -0
  37. data/data/ruby/snmp/mibs/DISMAN-PING-MIB.yaml +57 -0
  38. data/data/ruby/snmp/mibs/DISMAN-SCHEDULE-MIB.yaml +32 -0
  39. data/data/ruby/snmp/mibs/DISMAN-SCRIPT-MIB.yaml +80 -0
  40. data/data/ruby/snmp/mibs/DISMAN-TRACEROUTE-MIB.yaml +72 -0
  41. data/data/ruby/snmp/mibs/DLSW-MIB.yaml +193 -0
  42. data/data/ruby/snmp/mibs/DNS-RESOLVER-MIB.yaml +87 -0
  43. data/data/ruby/snmp/mibs/DNS-SERVER-MIB.yaml +73 -0
  44. data/data/ruby/snmp/mibs/DOCS-BPI-MIB.yaml +101 -0
  45. data/data/ruby/snmp/mibs/DOCS-CABLE-DEVICE-MIB.yaml +107 -0
  46. data/data/ruby/snmp/mibs/DOCS-IF-MIB.yaml +143 -0
  47. data/data/ruby/snmp/mibs/DOT12-IF-MIB.yaml +33 -0
  48. data/data/ruby/snmp/mibs/DS0-MIB.yaml +18 -0
  49. data/data/ruby/snmp/mibs/DS0BUNDLE-MIB.yaml +17 -0
  50. data/data/ruby/snmp/mibs/DS1-MIB.yaml +118 -0
  51. data/data/ruby/snmp/mibs/DS3-MIB.yaml +106 -0
  52. data/data/ruby/snmp/mibs/DSA-MIB.yaml +44 -0
  53. data/data/ruby/snmp/mibs/DSMON-MIB.yaml +219 -0
  54. data/data/ruby/snmp/mibs/EBN-MIB.yaml +47 -0
  55. data/data/ruby/snmp/mibs/ENTITY-MIB.yaml +51 -0
  56. data/data/ruby/snmp/mibs/ENTITY-SENSOR-MIB.yaml +16 -0
  57. data/data/ruby/snmp/mibs/ETHER-CHIPSET-MIB.yaml +79 -0
  58. data/data/ruby/snmp/mibs/ETHER-WIS.yaml +28 -0
  59. data/data/ruby/snmp/mibs/EtherLike-MIB.yaml +58 -0
  60. data/data/ruby/snmp/mibs/FDDI-SMT73-MIB.yaml +128 -0
  61. data/data/ruby/snmp/mibs/FIBRE-CHANNEL-FE-MIB.yaml +122 -0
  62. data/data/ruby/snmp/mibs/FLOW-METER-MIB.yaml +112 -0
  63. data/data/ruby/snmp/mibs/FR-ATM-PVC-SERVICE-IWF-MIB.yaml +45 -0
  64. data/data/ruby/snmp/mibs/FR-MFR-MIB.yaml +52 -0
  65. data/data/ruby/snmp/mibs/FRAME-RELAY-DTE-MIB.yaml +54 -0
  66. data/data/ruby/snmp/mibs/FRNETSERV-MIB.yaml +109 -0
  67. data/data/ruby/snmp/mibs/FRSLD-MIB.yaml +82 -0
  68. data/data/ruby/snmp/mibs/Finisher-MIB.yaml +53 -0
  69. data/data/ruby/snmp/mibs/GSMP-MIB.yaml +82 -0
  70. data/data/ruby/snmp/mibs/HC-ALARM-MIB.yaml +32 -0
  71. data/data/ruby/snmp/mibs/HC-PerfHist-TC-MIB.yaml +2 -0
  72. data/data/ruby/snmp/mibs/HC-RMON-MIB.yaml +193 -0
  73. data/data/ruby/snmp/mibs/HCNUM-TC.yaml +2 -0
  74. data/data/ruby/snmp/mibs/HDSL2-SHDSL-LINE-MIB.yaml +115 -0
  75. data/data/ruby/snmp/mibs/HOST-RESOURCES-MIB.yaml +98 -0
  76. data/data/ruby/snmp/mibs/HOST-RESOURCES-TYPES.yaml +56 -0
  77. data/data/ruby/snmp/mibs/HPR-IP-MIB.yaml +24 -0
  78. data/data/ruby/snmp/mibs/HPR-MIB.yaml +81 -0
  79. data/data/ruby/snmp/mibs/IF-INVERTED-STACK-MIB.yaml +9 -0
  80. data/data/ruby/snmp/mibs/IF-MIB.yaml +73 -0
  81. data/data/ruby/snmp/mibs/IGMP-STD-MIB.yaml +33 -0
  82. data/data/ruby/snmp/mibs/INET-ADDRESS-MIB.yaml +2 -0
  83. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-GUARANTEED-MIB.yaml +13 -0
  84. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-MIB.yaml +44 -0
  85. data/data/ruby/snmp/mibs/INTERFACETOPN-MIB.yaml +29 -0
  86. data/data/ruby/snmp/mibs/IP-FORWARD-MIB.yaml +42 -0
  87. data/data/ruby/snmp/mibs/IP-MIB.yaml +66 -0
  88. data/data/ruby/snmp/mibs/IPATM-IPMC-MIB.yaml +203 -0
  89. data/data/ruby/snmp/mibs/IPMROUTE-STD-MIB.yaml +64 -0
  90. data/data/ruby/snmp/mibs/IPOA-MIB.yaml +85 -0
  91. data/data/ruby/snmp/mibs/IPV6-FLOW-LABEL-MIB.yaml +2 -0
  92. data/data/ruby/snmp/mibs/IPV6-ICMP-MIB.yaml +42 -0
  93. data/data/ruby/snmp/mibs/IPV6-MIB.yaml +88 -0
  94. data/data/ruby/snmp/mibs/IPV6-MLD-MIB.yaml +30 -0
  95. data/data/ruby/snmp/mibs/IPV6-TCP-MIB.yaml +14 -0
  96. data/data/ruby/snmp/mibs/IPV6-UDP-MIB.yaml +11 -0
  97. data/data/ruby/snmp/mibs/ISDN-MIB.yaml +71 -0
  98. data/data/ruby/snmp/mibs/Job-Monitoring-MIB.yaml +43 -0
  99. data/data/ruby/snmp/mibs/L2TP-MIB.yaml +156 -0
  100. data/data/ruby/snmp/mibs/MALLOC-MIB.yaml +83 -0
  101. data/data/ruby/snmp/mibs/MAU-MIB.yaml +110 -0
  102. data/data/ruby/snmp/mibs/MIOX25-MIB.yaml +38 -0
  103. data/data/ruby/snmp/mibs/MIP-MIB.yaml +180 -0
  104. data/data/ruby/snmp/mibs/MPLS-FTN-STD-MIB.yaml +44 -0
  105. data/data/ruby/snmp/mibs/MPLS-LDP-ATM-STD-MIB.yaml +35 -0
  106. data/data/ruby/snmp/mibs/MPLS-LDP-FRAME-RELAY-STD-MIB.yaml +28 -0
  107. data/data/ruby/snmp/mibs/MPLS-LDP-GENERIC-STD-MIB.yaml +15 -0
  108. data/data/ruby/snmp/mibs/MPLS-LDP-STD-MIB.yaml +118 -0
  109. data/data/ruby/snmp/mibs/MPLS-LSR-STD-MIB.yaml +98 -0
  110. data/data/ruby/snmp/mibs/MPLS-TC-STD-MIB.yaml +3 -0
  111. data/data/ruby/snmp/mibs/MPLS-TE-STD-MIB.yaml +120 -0
  112. data/data/ruby/snmp/mibs/MTA-MIB.yaml +64 -0
  113. data/data/ruby/snmp/mibs/Modem-MIB.yaml +106 -0
  114. data/data/ruby/snmp/mibs/NETWORK-SERVICES-MIB.yaml +33 -0
  115. data/data/ruby/snmp/mibs/NHRP-MIB.yaml +163 -0
  116. data/data/ruby/snmp/mibs/NOTIFICATION-LOG-MIB.yaml +51 -0
  117. data/data/ruby/snmp/mibs/OPT-IF-MIB.yaml +431 -0
  118. data/data/ruby/snmp/mibs/OSPF-MIB.yaml +150 -0
  119. data/data/ruby/snmp/mibs/OSPF-TRAP-MIB.yaml +11 -0
  120. data/data/ruby/snmp/mibs/P-BRIDGE-MIB.yaml +51 -0
  121. data/data/ruby/snmp/mibs/PARALLEL-MIB.yaml +24 -0
  122. data/data/ruby/snmp/mibs/PIM-MIB.yaml +66 -0
  123. data/data/ruby/snmp/mibs/PINT-MIB.yaml +51 -0
  124. data/data/ruby/snmp/mibs/POWER-ETHERNET-MIB.yaml +36 -0
  125. data/data/ruby/snmp/mibs/PPP-BRIDGE-NCP-MIB.yaml +25 -0
  126. data/data/ruby/snmp/mibs/PPP-IP-NCP-MIB.yaml +13 -0
  127. data/data/ruby/snmp/mibs/PPP-LCP-MIB.yaml +47 -0
  128. data/data/ruby/snmp/mibs/PPP-SEC-MIB.yaml +20 -0
  129. data/data/ruby/snmp/mibs/PTOPO-MIB.yaml +39 -0
  130. data/data/ruby/snmp/mibs/PerfHist-TC-MIB.yaml +2 -0
  131. data/data/ruby/snmp/mibs/Printer-MIB.yaml +209 -0
  132. data/data/ruby/snmp/mibs/Q-BRIDGE-MIB.yaml +99 -0
  133. data/data/ruby/snmp/mibs/RADIUS-ACC-CLIENT-MIB.yaml +26 -0
  134. data/data/ruby/snmp/mibs/RADIUS-ACC-SERVER-MIB.yaml +35 -0
  135. data/data/ruby/snmp/mibs/RADIUS-AUTH-CLIENT-MIB.yaml +28 -0
  136. data/data/ruby/snmp/mibs/RADIUS-AUTH-SERVER-MIB.yaml +37 -0
  137. data/data/ruby/snmp/mibs/RDBMS-MIB.yaml +82 -0
  138. data/data/ruby/snmp/mibs/RFC1065-SMI.yaml +9 -0
  139. data/data/ruby/snmp/mibs/RFC1155-SMI.yaml +9 -0
  140. data/data/ruby/snmp/mibs/RFC1158-MIB.yaml +202 -0
  141. data/data/ruby/snmp/mibs/RFC1213-MIB.yaml +202 -0
  142. data/data/ruby/snmp/mibs/RFC1269-MIB.yaml +29 -0
  143. data/data/ruby/snmp/mibs/RFC1271-MIB.yaml +214 -0
  144. data/data/ruby/snmp/mibs/RFC1285-MIB.yaml +104 -0
  145. data/data/ruby/snmp/mibs/RFC1316-MIB.yaml +42 -0
  146. data/data/ruby/snmp/mibs/RFC1381-MIB.yaml +60 -0
  147. data/data/ruby/snmp/mibs/RFC1382-MIB.yaml +169 -0
  148. data/data/ruby/snmp/mibs/RFC1414-MIB.yaml +10 -0
  149. data/data/ruby/snmp/mibs/RIPv2-MIB.yaml +34 -0
  150. data/data/ruby/snmp/mibs/RMON-MIB.yaml +219 -0
  151. data/data/ruby/snmp/mibs/RMON2-MIB.yaml +282 -0
  152. data/data/ruby/snmp/mibs/ROHC-MIB.yaml +64 -0
  153. data/data/ruby/snmp/mibs/ROHC-RTP-MIB.yaml +29 -0
  154. data/data/ruby/snmp/mibs/ROHC-UNCOMPRESSED-MIB.yaml +11 -0
  155. data/data/ruby/snmp/mibs/RS-232-MIB.yaml +54 -0
  156. data/data/ruby/snmp/mibs/RSVP-MIB.yaml +156 -0
  157. data/data/ruby/snmp/mibs/RTP-MIB.yaml +57 -0
  158. data/data/ruby/snmp/mibs/SFLOW-MIB.yaml +22 -0
  159. data/data/ruby/snmp/mibs/SIP-MIB.yaml +70 -0
  160. data/data/ruby/snmp/mibs/SLAPM-MIB.yaml +144 -0
  161. data/data/ruby/snmp/mibs/SMON-MIB.yaml +63 -0
  162. data/data/ruby/snmp/mibs/SNA-NAU-MIB.yaml +137 -0
  163. data/data/ruby/snmp/mibs/SNA-SDLC-MIB.yaml +147 -0
  164. data/data/ruby/snmp/mibs/SNMP-COMMUNITY-MIB.yaml +22 -0
  165. data/data/ruby/snmp/mibs/SNMP-FRAMEWORK-MIB.yaml +14 -0
  166. data/data/ruby/snmp/mibs/SNMP-MPD-MIB.yaml +11 -0
  167. data/data/ruby/snmp/mibs/SNMP-NOTIFICATION-MIB.yaml +25 -0
  168. data/data/ruby/snmp/mibs/SNMP-PROXY-MIB.yaml +17 -0
  169. data/data/ruby/snmp/mibs/SNMP-REPEATER-MIB.yaml +135 -0
  170. data/data/ruby/snmp/mibs/SNMP-TARGET-MIB.yaml +29 -0
  171. data/data/ruby/snmp/mibs/SNMP-USER-BASED-SM-MIB.yaml +35 -0
  172. data/data/ruby/snmp/mibs/SNMP-USM-DH-OBJECTS-MIB.yaml +21 -0
  173. data/data/ruby/snmp/mibs/SNMP-VIEW-BASED-ACM-MIB.yaml +37 -0
  174. data/data/ruby/snmp/mibs/SNMPv2-MIB.yaml +58 -0
  175. data/data/ruby/snmp/mibs/SNMPv2-SMI.yaml +17 -0
  176. data/data/ruby/snmp/mibs/SNMPv2-TM.yaml +9 -0
  177. data/data/ruby/snmp/mibs/SNMPv2-USEC-MIB.yaml +19 -0
  178. data/data/ruby/snmp/mibs/SONET-MIB.yaml +131 -0
  179. data/data/ruby/snmp/mibs/SOURCE-ROUTING-MIB.yaml +30 -0
  180. data/data/ruby/snmp/mibs/SYSAPPL-MIB.yaml +81 -0
  181. data/data/ruby/snmp/mibs/TCP-MIB.yaml +27 -0
  182. data/data/ruby/snmp/mibs/TCPIPX-MIB.yaml +24 -0
  183. data/data/ruby/snmp/mibs/TN3270E-MIB.yaml +105 -0
  184. data/data/ruby/snmp/mibs/TN3270E-RT-MIB.yaml +43 -0
  185. data/data/ruby/snmp/mibs/TOKEN-RING-RMON-MIB.yaml +183 -0
  186. data/data/ruby/snmp/mibs/TOKENRING-MIB.yaml +58 -0
  187. data/data/ruby/snmp/mibs/TOKENRING-STATION-SR-MIB.yaml +12 -0
  188. data/data/ruby/snmp/mibs/TRANSPORT-ADDRESS-MIB.yaml +19 -0
  189. data/data/ruby/snmp/mibs/TUNNEL-MIB.yaml +23 -0
  190. data/data/ruby/snmp/mibs/UDP-MIB.yaml +14 -0
  191. data/data/ruby/snmp/mibs/UPS-MIB.yaml +117 -0
  192. data/data/ruby/snmp/mibs/VDSL-LINE-MIB.yaml +173 -0
  193. data/data/ruby/snmp/mibs/VRRP-MIB.yaml +50 -0
  194. data/data/ruby/snmp/mibs/WWW-MIB.yaml +91 -0
  195. data/examples/dump.rb +15 -0
  196. data/examples/get.rb +7 -0
  197. data/examples/iftable.rb +14 -0
  198. data/examples/log_traps.rb +23 -0
  199. data/examples/set.rb +8 -0
  200. data/examples/walk.rb +9 -0
  201. data/lib/snmp.rb +10 -0
  202. data/lib/snmp/agent.rb +74 -0
  203. data/lib/snmp/ber.rb +332 -0
  204. data/lib/snmp/manager.rb +502 -0
  205. data/lib/snmp/mib.rb +259 -0
  206. data/lib/snmp/pdu.rb +363 -0
  207. data/lib/snmp/varbind.rb +520 -0
  208. data/setup.rb +1360 -0
  209. data/test/test_ber.rb +236 -0
  210. data/test/test_manager.rb +192 -0
  211. data/test/test_mib.rb +66 -0
  212. data/test/test_pdu.rb +184 -0
  213. data/test/test_varbind.rb +270 -0
  214. metadata +251 -0
@@ -0,0 +1,50 @@
1
+ ---
2
+ vrrpOperVirtualMacAddr: 1.3.6.1.2.1.68.1.3.1.2
3
+ vrrpOperPrimaryIpAddr: 1.3.6.1.2.1.68.1.3.1.8
4
+ vrrpRouterVersionErrors: 1.3.6.1.2.1.68.2.2
5
+ vrrpRouterStatsTable: 1.3.6.1.2.1.68.2.4
6
+ vrrpRouterStatsEntry: 1.3.6.1.2.1.68.2.4.1
7
+ vrrpStatsAdvertiseIntervalErrors: 1.3.6.1.2.1.68.2.4.1.3
8
+ vrrpStatsIpTtlErrors: 1.3.6.1.2.1.68.2.4.1.5
9
+ vrrpMIBGroups: 1.3.6.1.2.1.68.3.2
10
+ vrrpMIB: 1.3.6.1.2.1.68
11
+ vrrpOperPriority: 1.3.6.1.2.1.68.1.3.1.5
12
+ vrrpAssoIpAddrRowStatus: 1.3.6.1.2.1.68.1.4.1.2
13
+ vrrpTrapAuthErrorType: 1.3.6.1.2.1.68.1.6
14
+ vrrpStatsAdvertiseRcvd: 1.3.6.1.2.1.68.2.4.1.2
15
+ vrrpStatsPacketLengthErrors: 1.3.6.1.2.1.68.2.4.1.12
16
+ vrrpOperVrId: 1.3.6.1.2.1.68.1.3.1.1
17
+ vrrpOperState: 1.3.6.1.2.1.68.1.3.1.3
18
+ vrrpOperAdvertisementInterval: 1.3.6.1.2.1.68.1.3.1.11
19
+ vrrpStatsAddressListErrors: 1.3.6.1.2.1.68.2.4.1.9
20
+ vrrpNotifications: 1.3.6.1.2.1.68.0
21
+ vrrpOperEntry: 1.3.6.1.2.1.68.1.3.1
22
+ vrrpOperPreemptMode: 1.3.6.1.2.1.68.1.3.1.12
23
+ vrrpTrapPacketSrc: 1.3.6.1.2.1.68.1.5
24
+ vrrpStatsPriorityZeroPktsRcvd: 1.3.6.1.2.1.68.2.4.1.6
25
+ vrrpStatsPriorityZeroPktsSent: 1.3.6.1.2.1.68.2.4.1.7
26
+ vrrpStatsAuthTypeMismatch: 1.3.6.1.2.1.68.2.4.1.11
27
+ vrrpOperIpAddrCount: 1.3.6.1.2.1.68.1.3.1.6
28
+ vrrpOperProtocol: 1.3.6.1.2.1.68.1.3.1.14
29
+ vrrpAssoIpAddr: 1.3.6.1.2.1.68.1.4.1.1
30
+ vrrpStatsAuthFailures: 1.3.6.1.2.1.68.2.4.1.4
31
+ vrrpMIBCompliances: 1.3.6.1.2.1.68.3.1
32
+ vrrpNodeVersion: 1.3.6.1.2.1.68.1.1
33
+ vrrpOperTable: 1.3.6.1.2.1.68.1.3
34
+ vrrpOperMasterIpAddr: 1.3.6.1.2.1.68.1.3.1.7
35
+ vrrpRouterChecksumErrors: 1.3.6.1.2.1.68.2.1
36
+ vrrpAssoIpAddrTable: 1.3.6.1.2.1.68.1.4
37
+ vrrpAssoIpAddrEntry: 1.3.6.1.2.1.68.1.4.1
38
+ vrrpStatistics: 1.3.6.1.2.1.68.2
39
+ vrrpStatsBecomeMaster: 1.3.6.1.2.1.68.2.4.1.1
40
+ vrrpNotificationCntl: 1.3.6.1.2.1.68.1.2
41
+ vrrpOperAuthKey: 1.3.6.1.2.1.68.1.3.1.10
42
+ vrrpOperRowStatus: 1.3.6.1.2.1.68.1.3.1.15
43
+ vrrpOperVirtualRouterUpTime: 1.3.6.1.2.1.68.1.3.1.13
44
+ vrrpRouterVrIdErrors: 1.3.6.1.2.1.68.2.3
45
+ vrrpStatsInvalidTypePktsRcvd: 1.3.6.1.2.1.68.2.4.1.8
46
+ vrrpStatsInvalidAuthType: 1.3.6.1.2.1.68.2.4.1.10
47
+ vrrpConformance: 1.3.6.1.2.1.68.3
48
+ vrrpOperations: 1.3.6.1.2.1.68.1
49
+ vrrpOperAdminState: 1.3.6.1.2.1.68.1.3.1.4
50
+ vrrpOperAuthType: 1.3.6.1.2.1.68.1.3.1.9
@@ -0,0 +1,91 @@
1
+ ---
2
+ wwwDocBytesTopNLastResponseType: 1.3.6.1.2.1.65.1.3.5.1.5
3
+ wwwServiceOperStatus: 1.3.6.1.2.1.65.1.1.1.1.8
4
+ wwwMIBConformance: 1.3.6.1.2.1.65.2
5
+ wwwDocAccessTopNEntry: 1.3.6.1.2.1.65.1.3.4.1
6
+ wwwRequestInTable: 1.3.6.1.2.1.65.1.2.2
7
+ wwwRequestInEntry: 1.3.6.1.2.1.65.1.2.2.1
8
+ wwwServiceLastChange: 1.3.6.1.2.1.65.1.1.1.1.9
9
+ wwwDocBytesTopNName: 1.3.6.1.2.1.65.1.3.5.1.2
10
+ wwwDocLastNRequestType: 1.3.6.1.2.1.65.1.3.2.1.4
11
+ wwwResponseOutIndex: 1.3.6.1.2.1.65.1.2.5.1.1
12
+ wwwDocBucketTable: 1.3.6.1.2.1.65.1.3.3
13
+ wwwRequestInLastTime: 1.3.6.1.2.1.65.1.2.2.1.4
14
+ wwwSummaryInResponses: 1.3.6.1.2.1.65.1.2.1.1.3
15
+ wwwDocAccessTopNBytes: 1.3.6.1.2.1.65.1.3.4.1.4
16
+ wwwServiceContact: 1.3.6.1.2.1.65.1.1.1.1.3
17
+ wwwServiceStartTime: 1.3.6.1.2.1.65.1.1.1.1.7
18
+ wwwRequestOutTable: 1.3.6.1.2.1.65.1.2.3
19
+ wwwRequestOutEntry: 1.3.6.1.2.1.65.1.2.3.1
20
+ wwwSummaryInLowBytes: 1.3.6.1.2.1.65.1.2.1.1.6
21
+ wwwDocBucketAccesses: 1.3.6.1.2.1.65.1.3.3.1.3
22
+ wwwDocLastNEntry: 1.3.6.1.2.1.65.1.3.2.1
23
+ wwwSummaryInBytes: 1.3.6.1.2.1.65.1.2.1.1.5
24
+ wwwRequestInBytes: 1.3.6.1.2.1.65.1.2.2.1.3
25
+ wwwRequestOutBytes: 1.3.6.1.2.1.65.1.2.3.1.3
26
+ wwwSummaryOutRequests: 1.3.6.1.2.1.65.1.2.1.1.2
27
+ wwwResponseOutResponses: 1.3.6.1.2.1.65.1.2.5.1.2
28
+ wwwDocLastNName: 1.3.6.1.2.1.65.1.3.2.1.2
29
+ wwwSummaryOutResponses: 1.3.6.1.2.1.65.1.2.1.1.4
30
+ wwwDocCtrlBucketTimeInterval: 1.3.6.1.2.1.65.1.3.1.1.4
31
+ wwwDocBucketDocuments: 1.3.6.1.2.1.65.1.3.3.1.4
32
+ wwwSummaryOutBytes: 1.3.6.1.2.1.65.1.2.1.1.7
33
+ wwwResponseInIndex: 1.3.6.1.2.1.65.1.2.4.1.1
34
+ wwwDocLastNBytes: 1.3.6.1.2.1.65.1.3.2.1.7
35
+ wwwDocCtrlEntry: 1.3.6.1.2.1.65.1.3.1.1
36
+ wwwDocBytesTopNIndex: 1.3.6.1.2.1.65.1.3.5.1.1
37
+ wwwService: 1.3.6.1.2.1.65.1.1
38
+ wwwProtocolStatistics: 1.3.6.1.2.1.65.1.2
39
+ wwwDocBucketTimeStamp: 1.3.6.1.2.1.65.1.3.3.1.2
40
+ wwwMIBGroups: 1.3.6.1.2.1.65.2.2
41
+ wwwSummaryTable: 1.3.6.1.2.1.65.1.2.1
42
+ wwwResponseInTable: 1.3.6.1.2.1.65.1.2.4
43
+ wwwServiceIndex: 1.3.6.1.2.1.65.1.1.1.1.1
44
+ wwwDocAccessTopNLastResponseType: 1.3.6.1.2.1.65.1.3.4.1.5
45
+ wwwSummaryInRequests: 1.3.6.1.2.1.65.1.2.1.1.1
46
+ wwwDocCtrlTopNSize: 1.3.6.1.2.1.65.1.3.1.1.5
47
+ wwwDocCtrlLastNLock: 1.3.6.1.2.1.65.1.3.1.1.2
48
+ wwwMIBCompliances: 1.3.6.1.2.1.65.2.1
49
+ wwwDocAccessTopNName: 1.3.6.1.2.1.65.1.3.4.1.2
50
+ wwwDocBytesTopNTable: 1.3.6.1.2.1.65.1.3.5
51
+ wwwDocBucketEntry: 1.3.6.1.2.1.65.1.3.3.1
52
+ wwwDocCtrlBuckets: 1.3.6.1.2.1.65.1.3.1.1.3
53
+ wwwServiceName: 1.3.6.1.2.1.65.1.1.1.1.5
54
+ wwwServiceTable: 1.3.6.1.2.1.65.1.1.1
55
+ wwwResponseInLastTime: 1.3.6.1.2.1.65.1.2.4.1.4
56
+ wwwDocLastNTimeStamp: 1.3.6.1.2.1.65.1.3.2.1.3
57
+ wwwDocAccessTopNAccesses: 1.3.6.1.2.1.65.1.3.4.1.3
58
+ wwwResponseOutTable: 1.3.6.1.2.1.65.1.2.5
59
+ wwwResponseOutEntry: 1.3.6.1.2.1.65.1.2.5.1
60
+ wwwDocBucketBytes: 1.3.6.1.2.1.65.1.3.3.1.5
61
+ wwwResponseInBytes: 1.3.6.1.2.1.65.1.2.4.1.3
62
+ wwwDocAccessTopNIndex: 1.3.6.1.2.1.65.1.3.4.1.1
63
+ wwwDocLastNStatusMsg: 1.3.6.1.2.1.65.1.3.2.1.6
64
+ wwwRequestInIndex: 1.3.6.1.2.1.65.1.2.2.1.1
65
+ wwwDocBytesTopNBytes: 1.3.6.1.2.1.65.1.3.5.1.4
66
+ wwwDocCtrlLastNSize: 1.3.6.1.2.1.65.1.3.1.1.1
67
+ wwwRequestOutIndex: 1.3.6.1.2.1.65.1.2.3.1.1
68
+ wwwResponseOutBytes: 1.3.6.1.2.1.65.1.2.5.1.3
69
+ wwwDocAccessTopNTable: 1.3.6.1.2.1.65.1.3.4
70
+ wwwDocBytesTopNAccesses: 1.3.6.1.2.1.65.1.3.5.1.3
71
+ wwwResponseInResponses: 1.3.6.1.2.1.65.1.2.4.1.2
72
+ wwwRequestOutRequests: 1.3.6.1.2.1.65.1.2.3.1.2
73
+ wwwDocLastNIndex: 1.3.6.1.2.1.65.1.3.2.1.1
74
+ wwwResponseInEntry: 1.3.6.1.2.1.65.1.2.4.1
75
+ wwwDocLastNTable: 1.3.6.1.2.1.65.1.3.2
76
+ wwwServiceDescription: 1.3.6.1.2.1.65.1.1.1.1.2
77
+ wwwServiceProtocol: 1.3.6.1.2.1.65.1.1.1.1.4
78
+ wwwSummaryEntry: 1.3.6.1.2.1.65.1.2.1.1
79
+ wwwMIBObjects: 1.3.6.1.2.1.65.1
80
+ wwwDocBytesTopNEntry: 1.3.6.1.2.1.65.1.3.5.1
81
+ wwwServiceEntry: 1.3.6.1.2.1.65.1.1.1.1
82
+ wwwRequestOutLastTime: 1.3.6.1.2.1.65.1.2.3.1.4
83
+ wwwSummaryOutLowBytes: 1.3.6.1.2.1.65.1.2.1.1.8
84
+ wwwServiceType: 1.3.6.1.2.1.65.1.1.1.1.6
85
+ wwwDocLastNResponseType: 1.3.6.1.2.1.65.1.3.2.1.5
86
+ wwwMIB: 1.3.6.1.2.1.65
87
+ wwwRequestInRequests: 1.3.6.1.2.1.65.1.2.2.1.2
88
+ wwwResponseOutLastTime: 1.3.6.1.2.1.65.1.2.5.1.4
89
+ wwwDocumentStatistics: 1.3.6.1.2.1.65.1.3
90
+ wwwDocCtrlTable: 1.3.6.1.2.1.65.1.3.1
91
+ wwwDocBucketIndex: 1.3.6.1.2.1.65.1.3.3.1.1
@@ -0,0 +1,15 @@
1
+ require 'snmp'
2
+ include SNMP
3
+
4
+ host = ARGV[0] || 'localhost'
5
+
6
+ manager = Manager.new(:Host => host, :Port => 161)
7
+ start_oid = ObjectId.new("1.3.6.1.2")
8
+ next_oid = start_oid
9
+ while next_oid.subtree_of?(start_oid)
10
+ response = manager.get_next(next_oid)
11
+ varbind = response.varbind_list.first
12
+ break if varbind.value == EndOfMibView
13
+ next_oid = varbind.name
14
+ puts "#{varbind.name.to_s} #{varbind.value.to_s} #{varbind.value.asn1_type}"
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'snmp'
2
+
3
+ host = ARGV[0] || 'localhost'
4
+
5
+ manager = SNMP::Manager.new(:Host => host, :Port => 161)
6
+ response = manager.get(["sysDescr.0", "sysName.0"])
7
+ response.each_varbind { |vb| puts vb.to_s }
@@ -0,0 +1,14 @@
1
+ require 'snmp'
2
+ include SNMP
3
+
4
+ host = ARGV[0] || 'localhost'
5
+
6
+ manager = Manager.new(:Host => host, :Port => 161)
7
+ ifTable = ObjectId.new("1.3.6.1.2.1.2.2")
8
+ next_oid = ifTable
9
+ while next_oid.subtree_of?(ifTable)
10
+ response = manager.get_next(next_oid)
11
+ varbind = response.varbind_list.first
12
+ next_oid = varbind.name
13
+ puts "#{varbind.name.to_s} #{varbind.value.to_s} #{varbind.value.asn1_type}"
14
+ end
@@ -0,0 +1,23 @@
1
+ require 'snmp'
2
+ require 'logger'
3
+
4
+ def format_v1_trap(trap)
5
+ "Trap #{trap.generic_trap} from #{trap.source_ip}"
6
+ end
7
+
8
+ def format_v2c_trap(trap)
9
+ "Trap #{trap.trap_oid} from #{trap.source_ip}"
10
+ end
11
+
12
+ log = Logger.new(STDOUT)
13
+ m = SNMP::TrapManager.new(:Port => 1062) do |manager|
14
+ manager.on_trap_v1 do |trap|
15
+ log.info format_v1_trap(trap)
16
+ end
17
+ manager.on_trap_v2c do |trap|
18
+ log.info format_v2c_trap(trap)
19
+ end
20
+ log.info "Logging started"
21
+ end
22
+ trap("INT") { log.info "Logging stopped"; m.exit }
23
+ m.join
@@ -0,0 +1,8 @@
1
+ require 'snmp'
2
+ include SNMP
3
+
4
+ host = ARGV[0] || 'localhost'
5
+
6
+ manager = Manager.new(:Host => host, :Port => 161)
7
+ varbind = VarBind.new("1.3.6.1.2.1.1.5.0", OctetString.new("System Name"))
8
+ manager.set(varbind)
@@ -0,0 +1,9 @@
1
+ require 'snmp'
2
+
3
+ host = ARGV[0] || 'localhost'
4
+
5
+ SNMP::Manager.open(:Host => host) do |manager|
6
+ manager.walk(["ifIndex", "ifDescr"]) do |index, descr|
7
+ puts "#{index.value} #{descr.value}"
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ #
2
+ # Copyright (c) 2004 David R. Halliday
3
+ # All rights reserved.
4
+ #
5
+ # This SNMP library is free software. Redistribution is permitted under the
6
+ # same terms and conditions as the standard Ruby distribution. See the
7
+ # COPYING file in the Ruby distribution for details.
8
+ #
9
+
10
+ require 'snmp/manager'
@@ -0,0 +1,74 @@
1
+ #
2
+ # Copyright (c) 2004 David R. Halliday
3
+ # All rights reserved.
4
+ #
5
+ # This SNMP library is free software. Redistribution is permitted under the
6
+ # same terms and conditions as the standard Ruby distribution. See the
7
+ # COPYING file in the Ruby distribution for details.
8
+ #
9
+
10
+ require 'snmp'
11
+ require 'socket'
12
+ require 'logger'
13
+
14
+ module SNMP
15
+
16
+ class Agent #:nodoc:all
17
+
18
+ def initialize(listen_port=161, max_packet=8000)
19
+ @log = Logger.new(STDOUT)
20
+ @log.level = Logger::DEBUG
21
+ @max_packet = max_packet
22
+ @socket = UDPSocket.open
23
+ @socket.bind(nil, listen_port)
24
+ @mib = MIB::SystemMIB.new
25
+ end
26
+
27
+ def start
28
+ @log.info "SNMP agent running"
29
+ loop do
30
+ begin
31
+ data, remote_info = @socket.recvfrom(@max_packet)
32
+ puts "Received #{data.length} bytes"
33
+ p data
34
+ message = Message.decode(data)
35
+ case message.pdu
36
+ when GetRequest
37
+ response = message.response
38
+ response.pdu.varbind_list.each do |v|
39
+ v.value = @mib.get(v.name)
40
+ end
41
+ when SetRequest
42
+ response = message.response
43
+ else
44
+ raise "invalid message #{message.to_s}"
45
+ end
46
+ puts "Responding to #{remote_info[3]}:#{remote_info[1]}"
47
+ encoded_message = response.encode
48
+ n=@socket.send(encoded_message, 0, remote_info[3], remote_info[1])
49
+ p encoded_message
50
+ rescue => e
51
+ @log.error e
52
+ shutdown
53
+ end
54
+ end
55
+ end
56
+
57
+ def shutdown
58
+ @log.info "SNMP agent stopping"
59
+ @socket.close
60
+ exit
61
+ end
62
+
63
+ alias stop :shutdown
64
+
65
+ end
66
+
67
+ end
68
+
69
+ if $0 == __FILE__
70
+ agent = SNMP::Agent.new(1061)
71
+ trap("INT") { agent.shutdown }
72
+ agent.start
73
+ end
74
+
@@ -0,0 +1,332 @@
1
+ #
2
+ # Copyright (c) 2004 David R. Halliday
3
+ # All rights reserved.
4
+ #
5
+ # This SNMP library is free software. Redistribution is permitted under the
6
+ # same terms and conditions as the standard Ruby distribution. See the
7
+ # COPYING file in the Ruby distribution for details.
8
+ #
9
+
10
+ #
11
+ # This module implements methods for encoding and decoding SNMP packets
12
+ # using the ASN.1 BER (Basic Encoding Rules).
13
+ #
14
+ module SNMP
15
+ module BER #:nodoc:all
16
+
17
+ # SNMP version codes
18
+ SNMP_V1 = 0
19
+ SNMP_V2C = 1
20
+ SNMP_V3 = 3 # not supported
21
+
22
+ # SNMP context-specific data types
23
+ # See RFC 1157 for SNMPv1
24
+ # See RFC 1905 for SNMPv2c
25
+ GetRequest_PDU_TAG = 0xa0
26
+ GetNextRequest_PDU_TAG = 0xa1
27
+ Response_PDU_TAG = 0xa2
28
+ SetRequest_PDU_TAG = 0xa3
29
+ SNMPv1_Trap_PDU_TAG = 0xa4 # Note: valid for SNMPv1 only
30
+ GetBulkRequest_PDU_TAG = 0xa5
31
+ InformRequest_PDU_TAG = 0xa6
32
+ SNMPv2_Trap_PDU_TAG = 0xa7
33
+ Report_PDU_TAG = 0xa8 # Note: Usage not defined - not supported
34
+
35
+ # Primitive ASN.1 data types
36
+ INTEGER_TAG = 0x02
37
+ OCTET_STRING_TAG = 0x04
38
+ NULL_TAG = 0x05
39
+ OBJECT_IDENTIFIER_TAG = 0x06
40
+
41
+ # Constructed ASN.1 data type
42
+ SEQUENCE_TAG = 0x30
43
+
44
+ # SNMP application data types
45
+ # See RFC 1155 for SNMPv1
46
+ # See RFC 1902 for SNMPv2c
47
+ IpAddress_TAG = 0x40
48
+ Counter32_TAG = 0x41 # Counter in SNMPv1
49
+ Gauge32_TAG = 0x42 # Gauge in SNMPv1
50
+ Unsigned32_TAG = 0x42 # Note: same as Gauge32
51
+ TimeTicks_TAG = 0x43
52
+ Opaque_TAG = 0x44
53
+ Counter64_TAG = 0x46
54
+
55
+ # VarBind response exceptions
56
+ NoSuchObject_TAG = 0x80
57
+ NoSuchInstance_TAG = 0x81
58
+ EndOfMibView_TAG = 0x82
59
+
60
+ # Exceptions thrown in this module
61
+ class OutOfData < RuntimeError; end
62
+ class InvalidLength < RuntimeError; end
63
+ class InvalidTag < RuntimeError; end
64
+ class InvalidObjectId < RuntimeError; end
65
+ class InvalidLength < RuntimeError; end
66
+
67
+ def assert_no_remainder(remainder)
68
+ raise ParseError, remainder.inspect if remainder != ""
69
+ end
70
+
71
+ #
72
+ # Decode tag-length-value data. The data is assumed to be a string of
73
+ # bytes in network byte order. This format is returned by Socket#recv.
74
+ #
75
+ # Returns a tuple containing the tag, the value, and any remaining
76
+ # unprocessed data.
77
+ #
78
+ # The data is not interpretted by this method. Use one of the other
79
+ # decoding methods to interpret the data.
80
+ #
81
+ # Note that ASN.1 supports an indefinite length format where the end of
82
+ # content is marked by a pair of 0 octets. SNMP does not support this
83
+ # format, so only the two definite forms are implemented (single byte and
84
+ # multi-byte).
85
+ #
86
+ def decode_tlv(data)
87
+ raise OutOfData if (data.length == 2 && data[1] != 0) || data.length < 2
88
+ tag = data[0]
89
+ length = data[1]
90
+ if length < 0x80
91
+ value = data[2, length]
92
+ remainder = data[length+2..-1]
93
+ else
94
+ # ASN.1 says this octet can't be 0xff
95
+ raise InvalidLength, length.to_s if length == 0xff
96
+ num_octets = length & 0x7f
97
+ length = build_integer(data, 2, num_octets)
98
+ value = data[num_octets+2, length]
99
+ remainder = data[num_octets+2+length..-1]
100
+ end
101
+ return tag, value, remainder
102
+ end
103
+
104
+ #
105
+ # Decode TLV data for an ASN.1 integer.
106
+ #
107
+ # Throws an InvalidTag exception if the tag is incorrect.
108
+ #
109
+ # Returns a tuple containing an integer and any remaining unprocessed data.
110
+ #
111
+ def decode_integer(data)
112
+ tag, value, remainder = decode_tlv(data)
113
+ raise InvalidTag, tag.to_s if tag != INTEGER_TAG
114
+ return decode_integer_value(value), remainder
115
+ end
116
+
117
+ def decode_timeticks(data)
118
+ tag, value, remainder = decode_tlv(data)
119
+ raise InvalidTag, tag.to_s if tag != TimeTicks_TAG
120
+ return decode_integer_value(value), remainder
121
+ end
122
+
123
+ def decode_integer_value(value)
124
+ result = build_integer(value, 0, value.length)
125
+ if value[0][7] == 1
126
+ result -= (1 << (8 * value.length))
127
+ end
128
+ result
129
+ end
130
+
131
+ def build_integer(data, start, num_octets)
132
+ number = 0
133
+ num_octets.times { |i| number = number<<8 | data[start+i] }
134
+ return number
135
+ end
136
+
137
+ #
138
+ # Decode TLV data for an ASN.1 octet string.
139
+ #
140
+ # Throws an InvalidTag exception if the tag is incorrect.
141
+ #
142
+ # Returns a tuple containing a string and any remaining unprocessed data.
143
+ #
144
+ def decode_octet_string(data)
145
+ tag, value, remainder = decode_tlv(data)
146
+ raise InvalidTag, tag.to_s if tag != OCTET_STRING_TAG
147
+ return value, remainder
148
+ end
149
+
150
+ def decode_ip_address(data)
151
+ tag, value, remainder = decode_tlv(data)
152
+ raise InvalidTag, tag.to_s if tag != IpAddress_TAG
153
+ raise InvalidLength, tag.to_s if value.length != 4
154
+ return value, remainder
155
+ end
156
+
157
+ #
158
+ # Decode TLV data for an ASN.1 sequence.
159
+ #
160
+ # Throws an InvalidTag exception if the tag is incorrect.
161
+ #
162
+ # Returns a tuple containing the sequence data and any remaining
163
+ # unprocessed data that follows the sequence.
164
+ #
165
+ def decode_sequence(data)
166
+ tag, value, remainder = decode_tlv(data)
167
+ raise InvalidTag, tag.to_s if tag != SEQUENCE_TAG
168
+ return value, remainder
169
+ end
170
+
171
+ #
172
+ # Unwrap TLV data for an ASN.1 object identifier. This method extracts
173
+ # the OID value as a character string but does not decode it further.
174
+ #
175
+ # Throws an InvalidTag exception if the tag is incorrect.
176
+ #
177
+ # Returns a tuple containing the object identifier (OID) and any
178
+ # remaining unprocessed data. The OID is represented as an array
179
+ # of integers.
180
+ #
181
+ def decode_object_id(data)
182
+ tag, value, remainder = decode_tlv(data)
183
+ raise InvalidTag, tag.to_s if tag != OBJECT_IDENTIFIER_TAG
184
+ return decode_object_id_value(value), remainder
185
+ end
186
+
187
+ def decode_object_id_value(value)
188
+ if value.length == 0
189
+ object_id = []
190
+ else
191
+ if value[0] == 0x2b
192
+ object_id = [1,3]
193
+ else
194
+ second = value[0] % 40
195
+ first = (value[0] - second) / 40
196
+ raise InvalidObjectId, value.to_s if first > 2
197
+ object_id = [first, second]
198
+ end
199
+ n = 0
200
+ for i in 1...value.length
201
+ n = (n<<7) + (value[i] & 0x7f)
202
+ if value[i] < 0x80
203
+ object_id << n
204
+ n = 0
205
+ end
206
+ end
207
+ end
208
+ return object_id
209
+ end
210
+
211
+ #
212
+ # Encode the length field for TLV data. Returns the length octets
213
+ # as a string.
214
+ #
215
+ def encode_length(length)
216
+ raise InvalidLength, length.to_s if length < 0
217
+ if length < 0x80
218
+ length.chr
219
+ else
220
+ data = integer_to_octets(length)
221
+ (data.size | 0x80).chr << data
222
+ end
223
+ end
224
+
225
+ #
226
+ # Encode integer
227
+ #
228
+ def encode_integer(value)
229
+ encode_tagged_integer(INTEGER_TAG, value)
230
+ end
231
+
232
+ def encode_tagged_integer(tag, value)
233
+ if value > 0 && value < 0x80
234
+ data = value.chr
235
+ else
236
+ data = integer_to_octets(value)
237
+ if value > 0 && data[0] > 0x7f
238
+ data = "\000" << data
239
+ elsif value < 0 && data[0] < 0x80
240
+ data = "\377" << data
241
+ end
242
+ end
243
+ encode_tlv(tag, data)
244
+ end
245
+
246
+ #
247
+ # Helper method for encoding integer-like things.
248
+ #
249
+ def integer_to_octets(i)
250
+ if i >= 0
251
+ done = 0
252
+ else
253
+ done = -1
254
+ end
255
+ octets = ""
256
+ begin
257
+ octets = (i & 0xff).chr << octets
258
+ i = i >> 8
259
+ end until i == done
260
+ octets
261
+ end
262
+
263
+ def encode_null
264
+ NULL_TAG.chr << "\000"
265
+ end
266
+
267
+ #
268
+ # Encode an exception. The encoding is simply the exception tag with
269
+ # no data, similar to NULL.
270
+ #
271
+ def encode_exception(tag)
272
+ tag.chr << "\000"
273
+ end
274
+
275
+ #
276
+ # Wraps value in a tag and length. This method expects an
277
+ # integer tag and a string value.
278
+ #
279
+ def encode_tlv(tag, value)
280
+ data = tag.chr << encode_length(value.length)
281
+ data = data << value if value.length > 0
282
+ data
283
+ end
284
+
285
+ #
286
+ # Wrap string in a octet string tag and length.
287
+ #
288
+ def encode_octet_string(value)
289
+ encode_tlv(OCTET_STRING_TAG, value)
290
+ end
291
+
292
+ #
293
+ # Wrap value in a sequence tag and length.
294
+ #
295
+ def encode_sequence(value)
296
+ encode_tlv(SEQUENCE_TAG, value)
297
+ end
298
+
299
+ #
300
+ # Encode an object id. The input is assumed to be an array of integers
301
+ # representing the object id.
302
+ #
303
+ def encode_object_id(value)
304
+ raise InvalidObjectId, value.to_s if value.length < 1
305
+ raise InvalidObjectId, value.to_s if value[0] > 2
306
+ data = ""
307
+ if (value.length > 1)
308
+ raise InvalidObjectId if value[0] < 2 && value[1] > 40
309
+ data << (40 * value[0] + value[1]).chr
310
+ for i in 2...value.length
311
+ if value[i] < 0x80
312
+ data << value[i].chr
313
+ else
314
+ octets = ""
315
+ n = value[i]
316
+ begin
317
+ octets = (n & 0x7f | 0x80).chr << octets
318
+ n = n >> 7
319
+ end until n == 0
320
+ octets[-1] &= 0x7f
321
+ data << octets
322
+ end
323
+ end
324
+ elsif (value.length == 1)
325
+ data << (40 * value[0]).chr
326
+ end
327
+ encode_tlv(OBJECT_IDENTIFIER_TAG, data)
328
+ end
329
+
330
+ end
331
+ end
332
+