Skip to content

Commit

Permalink
remove mixed tabs/space
Browse files Browse the repository at this point in the history
  • Loading branch information
javierguerragiraldez committed Jun 11, 2015
1 parent 5e8c4fa commit d6dd62c
Show file tree
Hide file tree
Showing 45 changed files with 737 additions and 737 deletions.
12 changes: 6 additions & 6 deletions src/apps/basic/basic_apps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Join:new()
return setmetatable({}, {__index=Join})
end

function Join:push ()
function Join:push ()
for _, inport in ipairs(self.input) do
for n = 1,math.min(link.nreadable(inport), link.nwritable(self.output.out)) do
transmit(self.output.out, receive(inport))
Expand Down Expand Up @@ -105,11 +105,11 @@ function Tee:push ()
for _ = 1, math.min(link.nreadable(i), maxoutput) do
local p = receive(i)
maxoutput = maxoutput - 1
do local output = self.output
for k = 1, #output do
transmit(output[k], k == #output and p or packet.clone(p))
end
end
do local output = self.output
for k = 1, #output do
transmit(output[k], k == #output and p or packet.clone(p))
end
end
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions src/apps/bridge/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
--
-- config = { ports = { <free-port1>, <free-port2>, ... },
-- split_horizon_groups = {
-- <sh_group1> = { <shg1-port1>, <shg1-port2>, ...},
-- <sh_group1> = { <shg1-port1>, <shg1-port2>, ...},
-- ...},
-- config = { <bridge-specific-config> } }
--
Expand Down Expand Up @@ -60,27 +60,27 @@ function bridge:new (arg)
local ports = {}
local function add_port(port, group)
assert(not ports[port],
self:name()..": duplicate definition of port "..port)
self:name()..": duplicate definition of port "..port)
ports[port] = group
end
for _, port in ipairs(conf.ports) do
add_port(port, '')
end
if conf.split_horizon_groups then
for group, ports in pairs(conf.split_horizon_groups) do
for _, port in ipairs(ports) do
add_port(port, group)
end
for _, port in ipairs(ports) do
add_port(port, group)
end
end
end
local src_ports, dst_ports = {}, {}
for sport, sgroup in pairs(ports) do
table.insert(src_ports, sport)
dst_ports[sport] = {}
for dport, dgroup in pairs(ports) do
if not (sport == dport or (sgroup ~= '' and sgroup == dgroup)) then
table.insert(dst_ports[sport], dport)
end
if not (sport == dport or (sgroup ~= '' and sgroup == dgroup)) then
table.insert(dst_ports[sport], dport)
end
end
end
o._src_ports = src_ports
Expand Down
16 changes: 8 additions & 8 deletions src/apps/bridge/flooding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ function bridge:push()
local src_port = src_ports[i]
local l_in = self.input[src_port]
while not empty(l_in) do
local ports = dst_ports[src_port]
local p = receive(l_in)
transmit(output[ports[1]], p)
local j = 2
while ports[j] do
transmit(output[ports[j]], clone(p))
j = j + 1
end
local ports = dst_ports[src_port]
local p = receive(l_in)
transmit(output[ports[1]], p)
local j = 2
while ports[j] do
transmit(output[ports[j]], clone(p))
j = j + 1
end
end
i = i + 1
end
Expand Down
86 changes: 43 additions & 43 deletions src/apps/bridge/learning.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- bridge" using a Bloom filter (provided by lib.bloom_filter) to
-- store the set of MAC source addresses of packets arriving on each
-- port.
--
--
-- Two Bloom storage cells called mac_table and mac_shadow are
-- allocated for each port connected to the bridge. For each packet
-- arriving on a port, the MAC source address is stored in both cells.
Expand Down Expand Up @@ -66,14 +66,14 @@ bridge = subClass(bridge_base)
bridge._name = "learning bridge"

local default_config = { mac_table_size = 1000, fp_rate = 0.001,
timeout = 60, verbose = false }
timeout = 60, verbose = false }

function bridge:new (arg)
local o = bridge:superClass().new(self, arg)
local conf = o._conf
for k, v in pairs(default_config) do
if not conf[k] then
conf[k] = v
conf[k] = v
end
end
local bf = bloom:new(conf.mac_table_size, conf.fp_rate)
Expand All @@ -84,30 +84,30 @@ function bridge:new (arg)
o._filters = {}
for _, port in ipairs(o._src_ports) do
o._filters[port] = { mac_table = bf:cell_new(),
mac_shadow = bf:cell_new(),
mac_address = bf:item_new()
}
mac_shadow = bf:cell_new(),
mac_address = bf:item_new()
}

end
o._eth_dst = bf:item_new()

timer.activate(timer.new("mac_learn_timeout",
function (t)
if conf.verbose then
print("MAC learning timeout")
print("Table usage per port:")
end
for port, filter in pairs(o._filters) do
bf:cell_copy(filter.mac_shadow, filter.mac_table)
bf:cell_clear(filter.mac_shadow)
if conf.verbose then
print(string.format("\t%s: %02.2f%%", port,
100*bf:cell_usage(filter.mac_table)))
end
end
end,
conf.timeout *1e9, 'repeating')
)
function (t)
if conf.verbose then
print("MAC learning timeout")
print("Table usage per port:")
end
for port, filter in pairs(o._filters) do
bf:cell_copy(filter.mac_shadow, filter.mac_table)
bf:cell_clear(filter.mac_shadow)
if conf.verbose then
print(string.format("\t%s: %02.2f%%", port,
100*bf:cell_usage(filter.mac_table)))
end
end
end,
conf.timeout *1e9, 'repeating')
)

-- Caches for various cdata pointer objects to avoid boxing in the
-- push() loop
Expand Down Expand Up @@ -141,7 +141,7 @@ function bridge:push()
mem[0] = packet.data(p[0])
local is_mcast = ethernet:is_mcast(mem[0])
if not is_mcast then
bf:store_value(mem, 6, eth_dst)
bf:store_value(mem, 6, eth_dst)
end

-- Store the source MAC address in the active and shadow
Expand All @@ -151,32 +151,32 @@ function bridge:push()
mem[0] = mem[0] + 6
bf:store_value(mem, 6, mac_address, filter.mac_table)
bf:store_item(mac_address, filter.mac_shadow)

local ports = dst_ports[src_port]
local copy = false
local j = 1
while ports[j] do
local dst_port = ports[j]
if is_mcast or bf:check_item(eth_dst, filters[dst_port].mac_table) then
if not copy then
transmit(self.output[dst_port], p[0])
copy = true
else
transmit(self.output[dst_port], clone(p[0]))
end
end
j = j + 1
local dst_port = ports[j]
if is_mcast or bf:check_item(eth_dst, filters[dst_port].mac_table) then
if not copy then
transmit(self.output[dst_port], p[0])
copy = true
else
transmit(self.output[dst_port], clone(p[0]))
end
end
j = j + 1
end
if not copy then
-- The source MAC address is unknown, flood the packet to
-- all ports
local output = self.output
transmit(output[ports[1]], p[0])
local j = 2
while ports[j] do
transmit(output[ports[j]], clone(p[0]))
j = j + 1
end
-- The source MAC address is unknown, flood the packet to
-- all ports
local output = self.output
transmit(output[ports[1]], p[0])
local j = 2
while ports[j] do
transmit(output[ports[j]], clone(p[0]))
j = j + 1
end
end
end -- of while not empty(l_in)
if self._port_index == self._nsrc_ports then
Expand Down
Loading

0 comments on commit d6dd62c

Please sign in to comment.