2022-08-28 16:12:30 +00:00
|
|
|
local comms = require("scada-common.comms")
|
|
|
|
local log = require("scada-common.log")
|
|
|
|
local util = require("scada-common.util")
|
2022-05-04 17:37:01 +00:00
|
|
|
|
2022-05-11 15:31:02 +00:00
|
|
|
local svsessions = require("supervisor.session.svsessions")
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
local supervisor = {}
|
2022-04-22 15:07:59 +00:00
|
|
|
|
2023-02-21 16:05:57 +00:00
|
|
|
local PROTOCOL = comms.PROTOCOL
|
|
|
|
local DEVICE_TYPE = comms.DEVICE_TYPE
|
2022-11-13 19:13:30 +00:00
|
|
|
local ESTABLISH_ACK = comms.ESTABLISH_ACK
|
2023-02-21 16:05:57 +00:00
|
|
|
local SCADA_MGMT_TYPE = comms.SCADA_MGMT_TYPE
|
2022-04-22 15:07:59 +00:00
|
|
|
|
2022-04-29 02:41:08 +00:00
|
|
|
local println = util.println
|
|
|
|
|
2022-03-25 16:18:33 +00:00
|
|
|
-- supervisory controller communications
|
2023-02-25 04:36:16 +00:00
|
|
|
---@nodiscard
|
2023-02-07 22:31:22 +00:00
|
|
|
---@param version string supervisor version
|
|
|
|
---@param num_reactors integer number of reactors
|
|
|
|
---@param cooling_conf table cooling configuration table
|
|
|
|
---@param modem table modem device
|
|
|
|
---@param dev_listen integer listening port for PLC/RTU devices
|
|
|
|
---@param coord_listen integer listening port for coordinator
|
|
|
|
---@param range integer trusted device connection range
|
|
|
|
function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen, coord_listen, range)
|
2022-03-25 16:18:33 +00:00
|
|
|
local self = {
|
2023-02-25 04:36:16 +00:00
|
|
|
last_est_acks = {}
|
2022-03-25 16:18:33 +00:00
|
|
|
}
|
2022-04-18 15:07:16 +00:00
|
|
|
|
2023-02-07 22:31:22 +00:00
|
|
|
comms.set_trusted_range(range)
|
|
|
|
|
2022-04-18 15:07:16 +00:00
|
|
|
-- PRIVATE FUNCTIONS --
|
|
|
|
|
2022-09-23 00:42:06 +00:00
|
|
|
-- configure modem channels
|
|
|
|
local function _conf_channels()
|
2023-02-25 04:36:16 +00:00
|
|
|
modem.closeAll()
|
|
|
|
modem.open(dev_listen)
|
|
|
|
modem.open(coord_listen)
|
2022-04-18 15:07:16 +00:00
|
|
|
end
|
|
|
|
|
2022-09-23 00:42:06 +00:00
|
|
|
_conf_channels()
|
2022-04-23 01:44:33 +00:00
|
|
|
|
2022-04-23 16:12:33 +00:00
|
|
|
-- link modem to svsessions
|
2023-02-25 04:36:16 +00:00
|
|
|
svsessions.init(modem, num_reactors, cooling_conf)
|
2022-04-23 16:12:33 +00:00
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
-- send an establish request response to a PLC/RTU
|
2022-05-11 16:31:19 +00:00
|
|
|
---@param dest integer
|
|
|
|
---@param msg table
|
2022-11-13 19:13:30 +00:00
|
|
|
local function _send_dev_establish(seq_id, dest, msg)
|
2022-05-13 13:45:11 +00:00
|
|
|
local s_pkt = comms.scada_packet()
|
|
|
|
local m_pkt = comms.mgmt_packet()
|
|
|
|
|
2023-02-21 16:05:57 +00:00
|
|
|
m_pkt.make(SCADA_MGMT_TYPE.ESTABLISH, msg)
|
|
|
|
s_pkt.make(seq_id, PROTOCOL.SCADA_MGMT, m_pkt.raw_sendable())
|
2022-04-23 01:44:33 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
modem.transmit(dest, dev_listen, s_pkt.raw_sendable())
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
|
2022-07-07 04:34:42 +00:00
|
|
|
-- send coordinator connection establish response
|
|
|
|
---@param seq_id integer
|
|
|
|
---@param dest integer
|
2022-11-13 19:13:30 +00:00
|
|
|
---@param msg table
|
|
|
|
local function _send_crdn_establish(seq_id, dest, msg)
|
2022-07-07 04:34:42 +00:00
|
|
|
local s_pkt = comms.scada_packet()
|
2022-11-13 19:13:30 +00:00
|
|
|
local c_pkt = comms.mgmt_packet()
|
2022-07-07 04:34:42 +00:00
|
|
|
|
2023-02-21 16:05:57 +00:00
|
|
|
c_pkt.make(SCADA_MGMT_TYPE.ESTABLISH, msg)
|
|
|
|
s_pkt.make(seq_id, PROTOCOL.SCADA_MGMT, c_pkt.raw_sendable())
|
2022-07-07 04:34:42 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
modem.transmit(dest, coord_listen, s_pkt.raw_sendable())
|
2022-07-07 04:34:42 +00:00
|
|
|
end
|
|
|
|
|
2022-04-18 15:07:16 +00:00
|
|
|
-- PUBLIC FUNCTIONS --
|
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
---@class superv_comms
|
|
|
|
local public = {}
|
|
|
|
|
2022-04-18 15:07:16 +00:00
|
|
|
-- reconnect a newly connected modem
|
2023-02-25 04:36:16 +00:00
|
|
|
---@param new_modem table
|
|
|
|
function public.reconnect_modem(new_modem)
|
|
|
|
modem = new_modem
|
|
|
|
svsessions.relink_modem(new_modem)
|
2022-09-23 00:42:06 +00:00
|
|
|
_conf_channels()
|
2022-04-18 15:07:16 +00:00
|
|
|
end
|
|
|
|
|
2022-04-22 15:07:59 +00:00
|
|
|
-- parse a packet
|
2023-02-25 04:36:16 +00:00
|
|
|
---@nodiscard
|
2022-05-11 16:31:19 +00:00
|
|
|
---@param side string
|
|
|
|
---@param sender integer
|
|
|
|
---@param reply_to integer
|
|
|
|
---@param message any
|
|
|
|
---@param distance integer
|
2022-07-07 04:34:42 +00:00
|
|
|
---@return modbus_frame|rplc_frame|mgmt_frame|crdn_frame|nil packet
|
2022-05-31 19:36:17 +00:00
|
|
|
function public.parse_packet(side, sender, reply_to, message, distance)
|
2022-04-22 15:07:59 +00:00
|
|
|
local pkt = nil
|
2022-04-26 01:00:50 +00:00
|
|
|
local s_pkt = comms.scada_packet()
|
2022-04-22 15:07:59 +00:00
|
|
|
|
|
|
|
-- parse packet as generic SCADA packet
|
2022-04-25 19:49:04 +00:00
|
|
|
s_pkt.receive(side, sender, reply_to, message, distance)
|
2022-04-22 15:07:59 +00:00
|
|
|
|
|
|
|
if s_pkt.is_valid() then
|
|
|
|
-- get as MODBUS TCP packet
|
2023-02-21 16:05:57 +00:00
|
|
|
if s_pkt.protocol() == PROTOCOL.MODBUS_TCP then
|
2022-04-22 15:07:59 +00:00
|
|
|
local m_pkt = comms.modbus_packet()
|
|
|
|
if m_pkt.decode(s_pkt) then
|
|
|
|
pkt = m_pkt.get()
|
|
|
|
end
|
|
|
|
-- get as RPLC packet
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif s_pkt.protocol() == PROTOCOL.RPLC then
|
2022-04-22 15:07:59 +00:00
|
|
|
local rplc_pkt = comms.rplc_packet()
|
|
|
|
if rplc_pkt.decode(s_pkt) then
|
|
|
|
pkt = rplc_pkt.get()
|
|
|
|
end
|
|
|
|
-- get as SCADA management packet
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif s_pkt.protocol() == PROTOCOL.SCADA_MGMT then
|
2022-04-22 15:07:59 +00:00
|
|
|
local mgmt_pkt = comms.mgmt_packet()
|
|
|
|
if mgmt_pkt.decode(s_pkt) then
|
2022-05-02 21:43:23 +00:00
|
|
|
pkt = mgmt_pkt.get()
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
-- get as coordinator packet
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif s_pkt.protocol() == PROTOCOL.SCADA_CRDN then
|
2022-07-07 04:34:42 +00:00
|
|
|
local crdn_pkt = comms.crdn_packet()
|
|
|
|
if crdn_pkt.decode(s_pkt) then
|
|
|
|
pkt = crdn_pkt.get()
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
else
|
2022-05-04 17:37:01 +00:00
|
|
|
log.debug("attempted parse of illegal packet type " .. s_pkt.protocol(), true)
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return pkt
|
|
|
|
end
|
|
|
|
|
2022-05-11 16:31:19 +00:00
|
|
|
-- handle a packet
|
2022-09-21 19:53:51 +00:00
|
|
|
---@param packet modbus_frame|rplc_frame|mgmt_frame|crdn_frame|nil
|
2022-05-31 19:36:17 +00:00
|
|
|
function public.handle_packet(packet)
|
2022-04-22 15:07:59 +00:00
|
|
|
if packet ~= nil then
|
2022-04-26 01:00:50 +00:00
|
|
|
local l_port = packet.scada_frame.local_port()
|
|
|
|
local r_port = packet.scada_frame.remote_port()
|
2022-04-22 15:07:59 +00:00
|
|
|
local protocol = packet.scada_frame.protocol()
|
|
|
|
|
|
|
|
-- device (RTU/PLC) listening channel
|
2023-02-25 04:36:16 +00:00
|
|
|
if l_port == dev_listen then
|
2023-02-21 16:05:57 +00:00
|
|
|
if protocol == PROTOCOL.MODBUS_TCP then
|
2023-02-25 04:36:16 +00:00
|
|
|
---@cast packet modbus_frame
|
2022-05-13 15:38:56 +00:00
|
|
|
-- look for an associated session
|
|
|
|
local session = svsessions.find_rtu_session(r_port)
|
|
|
|
|
2022-04-22 15:07:59 +00:00
|
|
|
-- MODBUS response
|
2022-05-13 13:45:11 +00:00
|
|
|
if session ~= nil then
|
|
|
|
-- pass the packet onto the session handler
|
|
|
|
session.in_queue.push_packet(packet)
|
|
|
|
else
|
|
|
|
-- any other packet should be session related, discard it
|
|
|
|
log.debug("discarding MODBUS_TCP packet without a known session")
|
|
|
|
end
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif protocol == PROTOCOL.RPLC then
|
2023-02-25 04:36:16 +00:00
|
|
|
---@cast packet rplc_frame
|
2022-05-13 15:38:56 +00:00
|
|
|
-- look for an associated session
|
|
|
|
local session = svsessions.find_plc_session(r_port)
|
|
|
|
|
2022-04-22 15:07:59 +00:00
|
|
|
-- reactor PLC packet
|
2022-05-11 16:31:19 +00:00
|
|
|
if session ~= nil then
|
2022-11-13 19:13:30 +00:00
|
|
|
-- pass the packet onto the session handler
|
|
|
|
session.in_queue.push_packet(packet)
|
2022-04-22 15:07:59 +00:00
|
|
|
else
|
2022-11-13 19:13:30 +00:00
|
|
|
-- unknown session, force a re-link
|
2023-02-16 00:59:58 +00:00
|
|
|
log.debug("PLC_ESTABLISH: no session but not an establish, forcing relink")
|
|
|
|
_send_dev_establish(packet.scada_frame.seq_num() + 1, r_port, { ESTABLISH_ACK.DENY })
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif protocol == PROTOCOL.SCADA_MGMT then
|
2023-02-25 04:36:16 +00:00
|
|
|
---@cast packet mgmt_frame
|
2022-05-13 15:38:56 +00:00
|
|
|
-- look for an associated session
|
|
|
|
local session = svsessions.find_device_session(r_port)
|
|
|
|
|
2022-04-22 15:07:59 +00:00
|
|
|
-- SCADA management packet
|
2022-05-11 16:31:19 +00:00
|
|
|
if session ~= nil then
|
2022-05-02 15:42:24 +00:00
|
|
|
-- pass the packet onto the session handler
|
|
|
|
session.in_queue.push_packet(packet)
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif packet.type == SCADA_MGMT_TYPE.ESTABLISH then
|
2022-11-13 19:13:30 +00:00
|
|
|
-- establish a new session
|
|
|
|
local next_seq_id = packet.scada_frame.seq_num() + 1
|
2022-05-19 14:21:04 +00:00
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
-- validate packet and continue
|
|
|
|
if packet.length >= 3 and type(packet.data[1]) == "string" and type(packet.data[2]) == "string" then
|
|
|
|
local comms_v = packet.data[1]
|
|
|
|
local firmware_v = packet.data[2]
|
|
|
|
local dev_type = packet.data[3]
|
|
|
|
|
|
|
|
if comms_v ~= comms.version then
|
2023-02-25 04:36:16 +00:00
|
|
|
if self.last_est_acks[r_port] ~= ESTABLISH_ACK.BAD_VERSION then
|
|
|
|
log.info(util.c("dropping device establish packet with incorrect comms version v", comms_v, " (expected v", comms.version, ")"))
|
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.BAD_VERSION
|
|
|
|
end
|
2022-05-13 13:45:11 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.BAD_VERSION })
|
|
|
|
elseif dev_type == DEVICE_TYPE.PLC then
|
2022-11-13 19:13:30 +00:00
|
|
|
-- PLC linking request
|
|
|
|
if packet.length == 4 and type(packet.data[4]) == "number" then
|
|
|
|
local reactor_id = packet.data[4]
|
|
|
|
local plc_id = svsessions.establish_plc_session(l_port, r_port, reactor_id, firmware_v)
|
2022-10-20 17:53:39 +00:00
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
if plc_id == false then
|
|
|
|
-- reactor already has a PLC assigned
|
2023-02-25 04:36:16 +00:00
|
|
|
if self.last_est_acks[r_port] ~= ESTABLISH_ACK.COLLISION then
|
|
|
|
log.warning(util.c("PLC_ESTABLISH: assignment collision with reactor ", reactor_id))
|
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.COLLISION
|
|
|
|
end
|
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.COLLISION })
|
|
|
|
else
|
|
|
|
-- got an ID; assigned to a reactor successfully
|
2023-02-07 22:31:22 +00:00
|
|
|
println(util.c("PLC (", firmware_v, ") [:", r_port, "] \xbb reactor ", reactor_id, " connected"))
|
|
|
|
log.info(util.c("PLC_ESTABLISH: PLC (", firmware_v, ") [:", r_port, "] reactor unit ", reactor_id, " PLC connected with session ID ", plc_id))
|
2023-02-25 04:36:16 +00:00
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.ALLOW })
|
2023-02-25 04:36:16 +00:00
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.ALLOW
|
2022-11-13 19:13:30 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
log.debug("PLC_ESTABLISH: packet length mismatch/bad parameter type")
|
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
|
|
|
end
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif dev_type == DEVICE_TYPE.RTU then
|
2022-11-13 19:13:30 +00:00
|
|
|
if packet.length == 4 then
|
|
|
|
-- this is an RTU advertisement for a new session
|
|
|
|
local rtu_advert = packet.data[4]
|
|
|
|
local s_id = svsessions.establish_rtu_session(l_port, r_port, rtu_advert, firmware_v)
|
|
|
|
|
|
|
|
println(util.c("RTU (", firmware_v, ") [:", r_port, "] \xbb connected"))
|
2023-02-07 22:31:22 +00:00
|
|
|
log.info(util.c("RTU_ESTABLISH: RTU (",firmware_v, ") [:", r_port, "] connected with session ID ", s_id))
|
2023-02-25 04:36:16 +00:00
|
|
|
|
2022-11-13 19:13:30 +00:00
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.ALLOW })
|
|
|
|
else
|
|
|
|
log.debug("RTU_ESTABLISH: packet length mismatch")
|
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
|
|
|
end
|
|
|
|
else
|
|
|
|
log.debug(util.c("illegal establish packet for device ", dev_type, " on PLC/RTU listening channel"))
|
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
|
|
|
end
|
2022-05-13 13:45:11 +00:00
|
|
|
else
|
2022-11-13 19:13:30 +00:00
|
|
|
log.debug("invalid establish packet (on PLC/RTU listening channel)")
|
|
|
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
2022-05-13 13:45:11 +00:00
|
|
|
end
|
2022-05-19 14:21:04 +00:00
|
|
|
else
|
|
|
|
-- any other packet should be session related, discard it
|
2022-07-07 04:34:42 +00:00
|
|
|
log.debug(util.c(r_port, "->", l_port, ": discarding SCADA_MGMT packet without a known session"))
|
2022-05-02 15:42:24 +00:00
|
|
|
end
|
2022-04-22 15:07:59 +00:00
|
|
|
else
|
2022-05-04 17:37:01 +00:00
|
|
|
log.debug("illegal packet type " .. protocol .. " on device listening channel")
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
-- coordinator listening channel
|
2023-02-25 04:36:16 +00:00
|
|
|
elseif l_port == coord_listen then
|
2022-05-13 15:38:56 +00:00
|
|
|
-- look for an associated session
|
|
|
|
local session = svsessions.find_coord_session(r_port)
|
|
|
|
|
2023-02-21 16:05:57 +00:00
|
|
|
if protocol == PROTOCOL.SCADA_MGMT then
|
2023-02-25 04:36:16 +00:00
|
|
|
---@cast packet mgmt_frame
|
2022-04-22 15:07:59 +00:00
|
|
|
-- SCADA management packet
|
2022-07-07 04:34:42 +00:00
|
|
|
if session ~= nil then
|
|
|
|
-- pass the packet onto the session handler
|
|
|
|
session.in_queue.push_packet(packet)
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif packet.type == SCADA_MGMT_TYPE.ESTABLISH then
|
2022-11-13 19:13:30 +00:00
|
|
|
-- establish a new session
|
|
|
|
local next_seq_id = packet.scada_frame.seq_num() + 1
|
|
|
|
|
|
|
|
-- validate packet and continue
|
|
|
|
if packet.length >= 3 and type(packet.data[1]) == "string" and type(packet.data[2]) == "string" then
|
|
|
|
local comms_v = packet.data[1]
|
|
|
|
local firmware_v = packet.data[2]
|
|
|
|
local dev_type = packet.data[3]
|
|
|
|
|
|
|
|
if comms_v ~= comms.version then
|
2023-02-25 04:36:16 +00:00
|
|
|
if self.last_est_acks[r_port] ~= ESTABLISH_ACK.BAD_VERSION then
|
|
|
|
log.info(util.c("dropping coordinator establish packet with incorrect comms version v", comms_v, " (expected v", comms.version, ")"))
|
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.BAD_VERSION
|
|
|
|
end
|
|
|
|
|
2023-02-16 00:59:58 +00:00
|
|
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.BAD_VERSION })
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif dev_type ~= DEVICE_TYPE.CRDN then
|
2022-11-13 19:13:30 +00:00
|
|
|
log.debug(util.c("illegal establish packet for device ", dev_type, " on CRDN listening channel"))
|
|
|
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
2023-02-25 04:36:16 +00:00
|
|
|
else
|
|
|
|
-- this is an attempt to establish a new session
|
|
|
|
local s_id = svsessions.establish_coord_session(l_port, r_port, firmware_v)
|
|
|
|
|
|
|
|
if s_id ~= false then
|
|
|
|
local config = { num_reactors }
|
|
|
|
for i = 1, #cooling_conf do
|
|
|
|
table.insert(config, cooling_conf[i].BOILERS)
|
|
|
|
table.insert(config, cooling_conf[i].TURBINES)
|
|
|
|
end
|
2022-11-13 19:13:30 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
println(util.c("CRD (",firmware_v, ") [:", r_port, "] \xbb connected"))
|
|
|
|
log.info(util.c("CRDN_ESTABLISH: coordinator (",firmware_v, ") [:", r_port, "] connected with session ID ", s_id))
|
2022-07-07 04:34:42 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.ALLOW, config })
|
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.ALLOW
|
|
|
|
else
|
|
|
|
if self.last_est_acks[r_port] ~= ESTABLISH_ACK.COLLISION then
|
|
|
|
log.info("CRDN_ESTABLISH: denied new coordinator due to already being connected to another coordinator")
|
|
|
|
self.last_est_acks[r_port] = ESTABLISH_ACK.COLLISION
|
|
|
|
end
|
2022-11-13 19:13:30 +00:00
|
|
|
|
2023-02-25 04:36:16 +00:00
|
|
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.COLLISION })
|
|
|
|
end
|
2022-10-20 17:53:39 +00:00
|
|
|
end
|
2022-07-07 04:34:42 +00:00
|
|
|
else
|
|
|
|
log.debug("CRDN_ESTABLISH: establish packet length mismatch")
|
2022-11-13 19:13:30 +00:00
|
|
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
2022-07-07 04:34:42 +00:00
|
|
|
end
|
2022-11-13 19:13:30 +00:00
|
|
|
else
|
|
|
|
-- any other packet should be session related, discard it
|
|
|
|
log.debug(r_port .. "->" .. l_port .. ": discarding SCADA_MGMT packet without a known session")
|
|
|
|
end
|
2023-02-21 16:05:57 +00:00
|
|
|
elseif protocol == PROTOCOL.SCADA_CRDN then
|
2023-02-25 04:36:16 +00:00
|
|
|
---@cast packet crdn_frame
|
2022-11-13 19:13:30 +00:00
|
|
|
-- coordinator packet
|
|
|
|
if session ~= nil then
|
|
|
|
-- pass the packet onto the session handler
|
|
|
|
session.in_queue.push_packet(packet)
|
2022-07-07 04:34:42 +00:00
|
|
|
else
|
|
|
|
-- any other packet should be session related, discard it
|
2022-10-20 17:53:39 +00:00
|
|
|
log.debug(r_port .. "->" .. l_port .. ": discarding SCADA_CRDN packet without a known session")
|
2022-07-07 04:34:42 +00:00
|
|
|
end
|
2022-04-22 15:07:59 +00:00
|
|
|
else
|
2022-05-04 17:37:01 +00:00
|
|
|
log.debug("illegal packet type " .. protocol .. " on coordinator listening channel")
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
else
|
2022-09-23 00:42:06 +00:00
|
|
|
log.warning("received packet on unconfigured channel " .. l_port)
|
2022-04-22 15:07:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-11 16:31:19 +00:00
|
|
|
return public
|
2022-03-25 16:18:33 +00:00
|
|
|
end
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
return supervisor
|