Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vsa lookup failure #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -4,4 +4,5 @@ coverage
doc
pkg
*.gem
**/.DS_Store
**/.DS_Store
nbproject
4 changes: 4 additions & 0 deletions lib/radiustar/dictionary/values.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ def initialize(name, id)
@id = id.to_i
end

def to_s
"#{id}:#{name}"
end

end

end
30 changes: 25 additions & 5 deletions lib/radiustar/packet.rb
Original file line number Diff line number Diff line change
@@ -158,10 +158,19 @@ def unpack
attribute_type = attribute_type.to_i

if attribute_type == 26 # Vendor Specific Attribute
vid, attribute_type, attribute_value = attribute_data.unpack("xxNCxa#{length-6}")
vendor = @dict.vendors.find_by_id(vid)
attribute = vendor.find_attribute_by_id(attribute_type)
else
vid, vsa_attribute_type, vsa_attribute_value = attribute_data.unpack("xxNCxa#{length-6}")
vendor = @dict.vendors.find_by_id(vid)
if vendor
attribute = vendor.find_attribute_by_id(attribute_type)
attribute_type = vsa_attribute_type
attribute_value = vsa_attribute_value
else
puts "Failed to find a vendor using id: #{vid}"
end
end

#unless the VSA attribute lookup worked, get it from the dict
unless attribute
vendor = nil
attribute = @dict.find_attribute_by_id(attribute_type)
end
@@ -170,7 +179,18 @@ def unpack
when 'string'
attribute_value
when 'integer'
attribute.has_values? ? attribute.find_values_by_id(attribute_value.unpack("N")[0]).name : attribute_value.unpack("N")[0]
if attribute.has_values?
val_id = attribute_value.unpack("N")[0]
val = attribute.find_values_by_id(val_id)
if val
val.name
else
puts "Failed to find a value with id: #{val_id} (unpacked from #{attribute_value}) in attribute value list: #{attribute.values.join("\n")}"
nil
end
else
attribute_value.unpack("N")[0]
end
when 'ipaddr'
attribute_value.unpack("N")[0].to_ip.to_s
when 'time'