netsnmp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c004123f79a4628eecef5b4c2c60098fdd33a590
4
- data.tar.gz: 03b6c15380d50856b23ce63b0266585ddb9637f3
3
+ metadata.gz: 1dcad05ae1ce9ca55fc653ab0f11d97887229b2e
4
+ data.tar.gz: e3bdc4c01e957884fea362c5b6a9c0ba79221ee0
5
5
  SHA512:
6
- metadata.gz: 2f1285f2b2e2cccca87af9c5b2d228c55bace8e5104cfcd526ed6bfd153efc5965c73ab040d7fedf710b9c1c84614c0417d2e76c3cf73a29eb3978e2da89efca
7
- data.tar.gz: 9a69fe9f2a75054b53ce636ac52f08537a4db45eea114e0ccec5100be1f27125cea460c57fdc755f15f99d6d96423f3294814b12c4388897602692fa195383ad
6
+ metadata.gz: 6557ae719bc1492de34849ed911aee5c5d7bdb246eefec39295ec6cc6e61d42dc39f6fc561d375e7edb76c6cf34f0dc5fcbec9d83fd22955a02e290caf7cb13e
7
+ data.tar.gz: 1a3599d249d30381276e0aea4c8317ab0e288a97bc5b8cff7fba787d7f8e0dc5f09148f05e9ac40bdf7ae8018d5d8741316d3eacd333dce90de245e984140fc4
data/lib/netsnmp/pdu.rb CHANGED
@@ -140,6 +140,8 @@ module NETSNMP
140
140
  when 16 then "Authorization Error"
141
141
  when 17 then "Not Writable"
142
142
  when 18 then "Inconsistent Name"
143
+ else
144
+ "Unknown Error: (#{status})"
143
145
  end
144
146
  raise Error, message
145
147
  end
@@ -5,13 +5,9 @@ module NETSNMP
5
5
 
6
6
  attr_reader :engine_id
7
7
 
8
- def initialize(type: , headers:,
9
- request_id: nil,
10
- error_status: 0,
11
- error_index: 0,
12
- varbinds: [])
8
+ def initialize(type: , headers:, **options)
13
9
  @engine_id, @context = headers
14
- super(type: type, headers: [3, nil], request_id: request_id, varbinds: varbinds)
10
+ super(type: type, headers: [3, nil], **options)
15
11
  end
16
12
 
17
13
  def encode_headers_asn
@@ -6,7 +6,7 @@ module NETSNMP
6
6
 
7
7
  attr_reader :oid, :value
8
8
 
9
- def initialize(oid , value: nil, type: nil)
9
+ def initialize(oid , value: nil, type: nil, **opts)
10
10
  @oid = OID.build(oid)
11
11
  @type = type
12
12
  @value = convert_val(value) if value
@@ -47,6 +47,19 @@ module NETSNMP
47
47
 
48
48
  def convert_val(asn_value)
49
49
  case asn_value
50
+ when OpenSSL::ASN1::OctetString
51
+ # yes, we are forcing all output to UTF-8
52
+ # it's kind of common in snmp, some stuff can't be converted,
53
+ # like Hexa Strings. Parse them into a readable format a la netsnmp
54
+ val = asn_value.value
55
+ begin
56
+ val.encode("UTF-8")
57
+ rescue Encoding::UndefinedConversionError,
58
+ Encoding::ConverterNotFoundError,
59
+ Encoding::InvalidByteSequenceError
60
+ # hexdump me!
61
+ val.unpack("H*")[0].upcase.scan(/../).join(" ")
62
+ end
50
63
  when OpenSSL::ASN1::Primitive
51
64
  val = asn_value.value
52
65
  val = val.to_i if val.is_a?(OpenSSL::BN)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NETSNMP
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsnmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-01 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake