net-snmp 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -87,7 +87,8 @@ An SNMPv3 synchronous AuthPriv (encrypted) SNMP-GET
87
87
  :auth_protocol => :sha1,
88
88
  :priv_protocol => :des,
89
89
  :username => "myuser",
90
- :password => "mypassword"
90
+ :auth_password => "mypassword",
91
+ :priv_password => "myprivpasswd"
91
92
  ) {|session|
92
93
  begin
93
94
  pdu = session.get("sysDescr.0")
@@ -36,7 +36,8 @@ module Net
36
36
  # * +priv_protocol+ - SNMPv3 only. default is nil (usmNoPrivProtocol). Possible values include :des, :aes, and nil
37
37
  # * +context+ - SNMPv3 only.
38
38
  # * +username+ - SNMPv3 only.
39
- # * +password+ - SNMPv3 only.
39
+ # * +auth_password+ - SNMPv3 only.
40
+ # * +priv_password+ - SNMPv3 only.
40
41
  # Returns:
41
42
  # Net::SNMP::Session
42
43
  def open(options = {})
@@ -113,6 +114,7 @@ module Net
113
114
  @sess.securityPrivProtoLen = 10
114
115
  @sess.securityPrivKeyLen = Constants::USM_PRIV_KU_LEN
115
116
 
117
+
116
118
  if options[:context]
117
119
  @sess.contextName = FFI::MemoryPointer.from_string(options[:context])
118
120
  @sess.contextNameLen = options[:context].length
@@ -120,7 +122,8 @@ module Net
120
122
 
121
123
  # Do not generate_Ku, unless we're Auth or AuthPriv
122
124
  unless @sess.securityLevel == Constants::SNMP_SEC_LEVEL_NOAUTH
123
- if options[:username].nil? or options[:password].nil?
125
+ options[:auth_password] ||= options[:password] # backward compatability
126
+ if options[:username].nil? or options[:auth_password].nil?
124
127
  raise Net::SNMP::Error.new "SecurityLevel requires username and password"
125
128
  end
126
129
  if options[:username]
@@ -132,8 +135,8 @@ module Net
132
135
  auth_len_ptr.write_int(Constants::USM_AUTH_KU_LEN)
133
136
  auth_key_result = Wrapper.generate_Ku(@sess.securityAuthProto,
134
137
  @sess.securityAuthProtoLen,
135
- options[:password],
136
- options[:password].length,
138
+ options[:auth_password],
139
+ options[:auth_password].length,
137
140
  @sess.securityAuthKey,
138
141
  auth_len_ptr)
139
142
  @sess.securityAuthKeyLen = auth_len_ptr.read_int
@@ -146,10 +149,10 @@ module Net
146
149
  # key for encryption, and using PrivProto does not.
147
150
  priv_key_result = Wrapper.generate_Ku(@sess.securityAuthProto,
148
151
  @sess.securityAuthProtoLen,
149
- options[:password],
150
- options[:password].length,
152
+ options[:priv_password],
153
+ options[:priv_password].length,
151
154
  @sess.securityPrivKey,
152
- auth_len_ptr)
155
+ priv_len_ptr)
153
156
  @sess.securityPrivKeyLen = priv_len_ptr.read_int
154
157
  end
155
158
 
@@ -267,9 +270,9 @@ module Net
267
270
 
268
271
  Wrapper.snmp_sess_select_info(@struct, num_fds, fdset, tval.pointer, block )
269
272
  tv = (timeout == false ? nil : tval)
270
- debug "Calling select #{Time.now}"
273
+ #debug "Calling select #{Time.now}"
271
274
  num_ready = FFI::LibC.select(num_fds.read_int, fdset, nil, nil, tv)
272
- debug "Done select #{Time.now}"
275
+ #debug "Done select #{Time.now}"
273
276
  if num_ready > 0
274
277
  Wrapper.snmp_sess_read(@struct, fdset)
275
278
  elsif num_ready == 0
@@ -1,5 +1,5 @@
1
1
  module Net
2
2
  module SNMP
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ describe "synchronous calls" do
28
28
  end
29
29
 
30
30
  it "set should succeed" do
31
- Net::SNMP::Session.open(:peername => '127.0.0.1', :version => 1) do |sess|
31
+ Net::SNMP::Session.open(:peername => '127.0.0.1', :version => 1, :community => 'private') do |sess|
32
32
  result = sess.set([['sysContact.0', Net::SNMP::Constants::ASN_OCTET_STR, 'yomama']])
33
33
  result.varbinds.first.value.should match(/yomama/)
34
34
  result.should_not be_error
@@ -84,10 +84,10 @@ describe "synchronous calls" do
84
84
  it "walk should work with multiple oids" do
85
85
  Net::SNMP::Session.open(:peername => 'localhost', :version => 1) do |sess|
86
86
  sess.walk(['system', 'ifTable']) do |results|
87
- pp results
87
+ #pp results
88
88
  results['1.3.6.1.2.1.1.1.0'].should match(/Darwin/)
89
89
  results['1.3.6.1.2.1.2.2.1.1.2'].should eql(2)
90
- results.size.should eql(186)
90
+ results.size.should eql(208)
91
91
  end
92
92
  end
93
93
  end
@@ -127,5 +127,12 @@ describe "synchronous calls" do
127
127
  result.varbinds.first.value.should match(/Darwin/)
128
128
  end
129
129
  end
130
+
131
+ it "should get using authpriv" do
132
+ Net::SNMP::Session.open(:peername => '127.0.0.1', :version => 3, :username => 'mixtli', :security_level => Net::SNMP::Constants::SNMP_SEC_LEVEL_AUTHPRIV, :auth_protocol => :md5, :priv_protocol => :des, :auth_password => 'testauth', :priv_password => 'testpass') do |sess|
133
+ result = sess.get("sysDescr.0")
134
+ result.varbinds.first.value.should match(/xenu/)
135
+ end
136
+ end
130
137
  end
131
138
  end
@@ -12,7 +12,7 @@ describe "snmp traps" do
12
12
  end
13
13
 
14
14
  it "should send a v2 inform" do
15
- #pending "still working on it"
15
+ pending "still working on it"
16
16
  did_callback = false
17
17
  Net::SNMP::TrapSession.open(:peername => '127.0.0.1', :version => '2c') do |sess|
18
18
  sess.inform(:oid => 'coldStart.0') do |op, res|
@@ -24,7 +24,7 @@ describe "snmp traps" do
24
24
  end
25
25
 
26
26
  it "should send v2 trap" do
27
- #pending "still working on it"
27
+ pending "still working on it"
28
28
  Net::SNMP::TrapSession.open(:peername => '127.0.0.1', :version => '2c') do |sess|
29
29
  res = sess.trap_v2(:oid => 'warmStart.0')
30
30
  res.should be_true
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-snmp
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 4
9
+ version: 0.2.4
6
10
  platform: ruby
7
11
  authors:
8
12
  - Ron McClain
@@ -10,7 +14,7 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-08-02 00:00:00 -05:00
17
+ date: 2012-03-16 00:00:00 -05:00
14
18
  default_executable:
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
@@ -21,6 +25,8 @@ dependencies:
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
24
30
  version: "0"
25
31
  type: :runtime
26
32
  version_requirements: *id001
@@ -32,6 +38,8 @@ dependencies:
32
38
  requirements:
33
39
  - - ">="
34
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
35
43
  version: "0"
36
44
  type: :runtime
37
45
  version_requirements: *id002
@@ -43,6 +51,8 @@ dependencies:
43
51
  requirements:
44
52
  - - ">="
45
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
46
56
  version: "0"
47
57
  type: :development
48
58
  version_requirements: *id003
@@ -54,6 +64,8 @@ dependencies:
54
64
  requirements:
55
65
  - - ">="
56
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
57
69
  version: "0"
58
70
  type: :development
59
71
  version_requirements: *id004
@@ -120,7 +132,7 @@ rdoc_options:
120
132
  - --main=README.rdoc
121
133
  - --line-numbers
122
134
  - --inline-source
123
- - --title=net-snmp-0.2.3 Documentation
135
+ - --title=net-snmp-0.2.4 Documentation
124
136
  require_paths:
125
137
  - lib
126
138
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -128,17 +140,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
140
  requirements:
129
141
  - - ">="
130
142
  - !ruby/object:Gem::Version
143
+ segments:
144
+ - 0
131
145
  version: "0"
132
146
  required_rubygems_version: !ruby/object:Gem::Requirement
133
147
  none: false
134
148
  requirements:
135
149
  - - ">="
136
150
  - !ruby/object:Gem::Version
151
+ segments:
152
+ - 0
137
153
  version: "0"
138
154
  requirements: []
139
155
 
140
156
  rubyforge_project: net-snmp
141
- rubygems_version: 1.6.2
157
+ rubygems_version: 1.3.7
142
158
  signing_key:
143
159
  specification_version: 3
144
160
  summary: Object oriented wrapper around C net-snmp libraries