#580 nic constructor simplification
This commit is contained in:
parent
250db00794
commit
4a38ca7dd1
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
local comms = require("scada-common.comms")
|
local comms = require("scada-common.comms")
|
||||||
local log = require("scada-common.log")
|
local log = require("scada-common.log")
|
||||||
|
local ppm = require("scada-common.ppm")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local md5 = require("lockbox.digest.md5")
|
local md5 = require("lockbox.digest.md5")
|
||||||
@ -77,10 +78,11 @@ end
|
|||||||
|
|
||||||
-- NIC: Network Interface Controller<br>
|
-- NIC: Network Interface Controller<br>
|
||||||
-- utilizes HMAC-MD5 for message authentication, if enabled and this is wireless
|
-- 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(iface, modem)
|
function network.nic(modem)
|
||||||
local self = {
|
local self = {
|
||||||
|
-- modem interface name
|
||||||
|
iface = ppm.get_iface(modem),
|
||||||
-- used to quickly return out of tx/rx functions if there is nothing to do
|
-- used to quickly return out of tx/rx functions if there is nothing to do
|
||||||
connected = true,
|
connected = true,
|
||||||
-- used to avoid costly MAC calculations if not required
|
-- used to avoid costly MAC calculations if not required
|
||||||
@ -195,7 +197,7 @@ function network.nic(iface, 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 and side == iface then
|
if self.connected and side == self.iface then
|
||||||
local s_packet = comms.scada_packet()
|
local s_packet = comms.scada_packet()
|
||||||
|
|
||||||
if self.use_hash then
|
if self.use_hash then
|
||||||
|
|||||||
@ -76,7 +76,7 @@ function pcie_bus.init(config, println)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
bus.wd_nic = network.nic(bus.wired_modem, wired_modem)
|
bus.wd_nic = network.nic(wired_modem)
|
||||||
pcie_bus.nic.cards[bus.wired_modem] = bus.wd_nic
|
pcie_bus.nic.cards[bus.wired_modem] = bus.wd_nic
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ function pcie_bus.init(config, println)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
bus.wl_nic = network.nic(wireless_iface, wireless_modem)
|
bus.wl_nic = network.nic(wireless_modem)
|
||||||
pcie_bus.nic.cards[wireless_iface] = bus.wl_nic
|
pcie_bus.nic.cards[wireless_iface] = bus.wl_nic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ local log = require("scada-common.log")
|
|||||||
local mqueue = require("scada-common.mqueue")
|
local mqueue = require("scada-common.mqueue")
|
||||||
local types = require("scada-common.types")
|
local types = require("scada-common.types")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
local pcie = require("supervisor.pcie")
|
|
||||||
|
|
||||||
local databus = require("supervisor.databus")
|
local databus = require("supervisor.databus")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user