Skip to content

Commit

Permalink
Merge snabbco#970 branch 'snabbco/kbara-next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Jul 22, 2016
2 parents f9e8307 + 16c72ae commit 946e266
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
16 changes: 7 additions & 9 deletions src/apps/bridge/flooding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@ function bridge:new (arg)
end

function bridge:push()
local src_ports = self._src_ports
local ports = self._ports
local dst_ports = self._dst_ports
local output = self.output
local i = 1
while src_ports[i] do
local src_port = src_ports[i]
local l_in = self.input[src_port]
while ports[i] do
local l_in = ports[i].l_in
while not empty(l_in) do
local ports = dst_ports[src_port]
local dst = dst_ports[i]
local p = receive(l_in)
transmit(output[ports[1]], p)
transmit(ports[dst[1]].l_out, p)
local j = 2
while ports[j] do
transmit(output[ports[j]], clone(p))
while dst[j] do
transmit(ports[dst[j]].l_out, clone(p))
j = j + 1
end
end
Expand Down
6 changes: 0 additions & 6 deletions src/core/packet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ function free (p)
free_internal(p)
end

-- Return pointer to packet data.
function data (p) return p.data end

-- Return packet data length.
function length (p) return p.length end

-- Set packet data length.
function resize (p, len)
assert(len <= max_payload, "packet payload overflow")
Expand Down
16 changes: 8 additions & 8 deletions src/lib/ipsec/esp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ
local p_min = packet.from_string("012345678901234567890123456789012345678901234567890123")
p_min.data[18] = 0 -- Set IPv6 payload length to zero
p_min.data[19] = 0 -- ...
assert(packet.length(p_min) == PAYLOAD_OFFSET)
print("original", lib.hexdump(ffi.string(packet.data(p_min), packet.length(p_min))))
assert(p_min.length == PAYLOAD_OFFSET)
print("original", lib.hexdump(ffi.string(p_min.data, p_min.length)))
local e_min = packet.clone(p_min)
assert(enc:encapsulate(e_min))
print("encrypted", lib.hexdump(ffi.string(packet.data(e_min), packet.length(e_min))))
assert(packet.length(e_min) == dec.MIN_SIZE+PAYLOAD_OFFSET)
print("encrypted", lib.hexdump(ffi.string(e_min.data, e_min.length)))
assert(e_min.length == dec.MIN_SIZE+PAYLOAD_OFFSET)
assert(dec:decapsulate(e_min))
print("decrypted", lib.hexdump(ffi.string(packet.data(e_min), packet.length(e_min))))
assert(packet.length(e_min) == PAYLOAD_OFFSET)
assert(packet.length(p_min) == packet.length(e_min)
and C.memcmp(p_min, e_min, packet.length(p_min)) == 0,
print("decrypted", lib.hexdump(ffi.string(e_min.data, e_min.length)))
assert(e_min.length == PAYLOAD_OFFSET)
assert(p_min.length == e_min.length
and C.memcmp(p_min, e_min, p_min.length) == 0,
"integrity check failed")
-- Check transmitted Sequence Number wrap around
enc.seq:low(0)
Expand Down

0 comments on commit 946e266

Please sign in to comment.