supported translation of the X.690 OID representation.
More useful for SNMP than for LDAP.
This commit is contained in:
parent
8dfbf21302
commit
6860965651
1 changed files with 18 additions and 1 deletions
|
@ -88,7 +88,7 @@ module Net
|
|||
2 => :integer,
|
||||
4 => :string,
|
||||
5 => :null,
|
||||
6 => :string, # (OID)
|
||||
6 => :oid,
|
||||
10 => :integer,
|
||||
13 => :string # (relative OID)
|
||||
},
|
||||
|
@ -147,6 +147,23 @@ module Net
|
|||
j = 0
|
||||
newobj.each_byte {|b| j = (j << 8) + b}
|
||||
j
|
||||
elsif objtype == :oid
|
||||
# cf X.690 pgh 8.19 for an explanation of this algorithm.
|
||||
# Potentially not good enough. We may need a BerIdentifiedOid
|
||||
# as a subclass of BerIdentifiedArray, to get the ber identifier
|
||||
# and also a to_s method that produces the familiar dotted notation.
|
||||
oid = newobj.unpack("w*")
|
||||
f = oid.shift
|
||||
g = if f < 40
|
||||
[0, f]
|
||||
elsif f < 80
|
||||
[1, f-40]
|
||||
else
|
||||
[2, f-80] # f-80 can easily be > 80. What a weird optimization.
|
||||
end
|
||||
oid.unshift g.last
|
||||
oid.unshift g.first
|
||||
oid
|
||||
elsif objtype == :array
|
||||
#seq = []
|
||||
seq = BerIdentifiedArray.new
|
||||
|
|
Loading…
Reference in a new issue