Class: Dap::Filter::FilterDecodeNATPMPExternalAddressResponse

Inherits:
Object
  • Object
show all
Includes:
BaseDecoder
Defined in:
lib/dap/filter/udp.rb

Overview

Decode a NAT-PMP External Address response

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from BaseDecoder

#process

Methods included from Base

#initialize, #process

Instance Method Details

#decode(data) ⇒ Object



165
166
167
168
169
170
171
172
173
174
# File 'lib/dap/filter/udp.rb', line 165

def decode(data)
  return unless (data && data.size == Dap::Proto::NATPMP::REQUIRED_SIZE)
  info = Dap::Proto::NATPMP::ExternalAddressResponse.new(data)
  {}.tap do |h|
    info.fields.each do |f|
      name = f.name
      h[name] = info.send(name).to_s
    end
  end
end