diff --git a/shard.yml b/shard.yml index 2968816..7e315aa 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: bacnet -version: 0.10.4 +version: 0.10.5 crystal: ">= 0.36.1" dependencies: diff --git a/src/bacnet/client/ipv4.cr b/src/bacnet/client/ipv4.cr index 9bd097a..ab58801 100644 --- a/src/bacnet/client/ipv4.cr +++ b/src/bacnet/client/ipv4.cr @@ -88,6 +88,8 @@ class BACnet::Client::IPv4 def received(message : BACnet::Message::IPv4, address : Socket::IPAddress) Log.trace { "received #{message.data_link.request_type} message from #{address.inspect} - #{message.application.class}" } + address = message.data_link.forwarded_address if message.data_link.request_type.forwarded_npdu? + app = message.application case app in Nil diff --git a/src/bacnet/virtual_link_control/ipv4_bvlci.cr b/src/bacnet/virtual_link_control/ipv4_bvlci.cr index ec6d625..d416438 100644 --- a/src/bacnet/virtual_link_control/ipv4_bvlci.cr +++ b/src/bacnet/virtual_link_control/ipv4_bvlci.cr @@ -1,5 +1,6 @@ require "../../bacnet" require "./ipv4_message" +require "socket/address" module BACnet # BACnet Virtual Link Control Interface @@ -51,12 +52,19 @@ module BACnet Request::DeleteForeignDeviceTableEntry, }.includes? request_type }) do - uint32 :ip + uint8 :ip1 + uint8 :ip2 + uint8 :ip3 + uint8 :ip4 uint16 :port end uint16 :register_ttl, onlyif: ->{ request_type.register_foreign_device? } enum_field UInt16, result_code : Result = Result::Success, onlyif: ->{ request_type.bvcl_result? } + + def forwarded_address + Socket::IPAddress.new("#{address.ip1}.#{address.ip2}.#{address.ip3}.#{address.ip4}", address.port.to_i) + end end end