check interface side in network logic before handling packets
This commit is contained in:
parent
c319039a4e
commit
c6143934d8
@ -76,11 +76,16 @@ local function compute_hmac(message)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- NIC: Network Interface Controller<br>
|
-- NIC: Network Interface Controller<br>
|
||||||
-- utilizes HMAC-MD5 for message authentication, if enabled
|
-- utilizes HMAC-MD5 for message authentication, if enabled and this is wireless
|
||||||
|
---@param iface string peripheral interface name
|
||||||
---@param modem Modem modem to use
|
---@param modem Modem modem to use
|
||||||
function network.nic(modem)
|
function network.nic(iface, modem)
|
||||||
local self = {
|
local self = {
|
||||||
connected = true, -- used to avoid costly MAC calculations if modem isn't even present
|
-- used to quickly return out of tx/rx functions if there is nothing to do
|
||||||
|
connected = true,
|
||||||
|
-- used to avoid costly MAC calculations if not required
|
||||||
|
use_hash = c_eng.hmac and modem.isWireless(),
|
||||||
|
-- open channels
|
||||||
channels = {}
|
channels = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +170,7 @@ function network.nic(modem)
|
|||||||
if self.connected then
|
if self.connected then
|
||||||
local tx_packet = packet ---@type authd_packet|scada_packet
|
local tx_packet = packet ---@type authd_packet|scada_packet
|
||||||
|
|
||||||
if c_eng.hmac ~= nil then
|
if self.use_hash then
|
||||||
-- local start = util.time_ms()
|
-- local start = util.time_ms()
|
||||||
tx_packet = comms.authd_packet()
|
tx_packet = comms.authd_packet()
|
||||||
|
|
||||||
@ -190,10 +195,10 @@ function network.nic(modem)
|
|||||||
function public.receive(side, sender, reply_to, message, distance)
|
function public.receive(side, sender, reply_to, message, distance)
|
||||||
local packet = nil
|
local packet = nil
|
||||||
|
|
||||||
if self.connected then
|
if self.connected and side == iface then
|
||||||
local s_packet = comms.scada_packet()
|
local s_packet = comms.scada_packet()
|
||||||
|
|
||||||
if c_eng.hmac ~= nil then
|
if self.use_hash then
|
||||||
-- parse packet as an authenticated SCADA packet
|
-- parse packet as an authenticated SCADA packet
|
||||||
local a_packet = comms.authd_packet()
|
local a_packet = comms.authd_packet()
|
||||||
a_packet.receive(side, sender, reply_to, message, distance)
|
a_packet.receive(side, sender, reply_to, message, distance)
|
||||||
|
|||||||
@ -24,7 +24,7 @@ local t_pack = table.pack
|
|||||||
local util = {}
|
local util = {}
|
||||||
|
|
||||||
-- scada-common version
|
-- scada-common version
|
||||||
util.version = "1.5.2"
|
util.version = "1.5.3"
|
||||||
|
|
||||||
util.TICK_TIME_S = 0.05
|
util.TICK_TIME_S = 0.05
|
||||||
util.TICK_TIME_MS = 50
|
util.TICK_TIME_MS = 50
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user