#225 PLC/RTUs drop incoming packets from devices other than the configured supervisor while linked

This commit is contained in:
Mikayla Fischler
2023-06-05 19:12:43 -04:00
parent b20d42ff38
commit c536b823e7
4 changed files with 17 additions and 7 deletions

View File

@@ -778,6 +778,7 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
-- print a log message to the terminal as long as the UI isn't running
local function println_ts(message) if not plc_state.fp_ok then util.println_ts(message) end end
local protocol = packet.scada_frame.protocol()
local l_chan = packet.scada_frame.local_channel()
local src_addr = packet.scada_frame.src_addr()
@@ -789,6 +790,9 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
elseif self.linked and ((self.r_seq_num + 1) ~= packet.scada_frame.seq_num()) then
log.warning("sequence out-of-order: last = " .. self.r_seq_num .. ", new = " .. packet.scada_frame.seq_num())
return
elseif self.linked and src_addr ~= self.sv_addr then
log.debug("received packet from unknown computer " .. src_addr .. " while linked; channel in use by another system?")
return
else
self.r_seq_num = packet.scada_frame.seq_num()
end
@@ -796,8 +800,6 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
-- feed the watchdog first so it doesn't uhh...eat our packets :)
conn_watchdog.feed()
local protocol = packet.scada_frame.protocol()
-- handle packet
if protocol == PROTOCOL.RPLC then
---@cast packet rplc_frame