Skip to content

Commit

Permalink
Merge pull request snabbco#52 from andywingo/checkies
Browse files Browse the repository at this point in the history
Add "check" snabb_lwaftr program
  • Loading branch information
wingo committed Sep 30, 2015
2 parents c2ec367 + ea84f09 commit 0ffec3e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/program/snabb_lwaftr/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Usage:
snabb-lwaftr run
snabb-lwaftr transient
snabb-lwaftr check

Use --help for per-command usage.
Example:
Expand Down
8 changes: 8 additions & 0 deletions src/program/snabb_lwaftr/check/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Usage: check BINDING-TABLE CONF IPV4-IN.PCAP IPV6-IN.PCAP IPV6-OUT.PCAP IPV6-OUT.PCAP

-h, --help
Print usage information.

Run the lwAFTR with input from IPV4-IN.PCAP and IPV6-IN.PCAP, and record
output to IPV6-OUT.PCAP and IPV6-OUT.PCAP. Exit when finished. This
program is used in the lwAFTR test suite.
1 change: 1 addition & 0 deletions src/program/snabb_lwaftr/check/README.inc
47 changes: 47 additions & 0 deletions src/program/snabb_lwaftr/check/check.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module(..., package.seeall)

local app = require("core.app")
local config = require("core.config")
local lib = require("core.lib")
local pcap = require("apps.pcap.pcap")
local lwaftr = require("apps.lwaftr.lwaftr")
local bt = require("apps.lwaftr.binding_table")
local conf = require("apps.lwaftr.conf")

function show_usage(code)
print(require("program.snabb_lwaftr.check.README_inc"))
main.exit(code)
end

function parse_args(args)
local handlers = {}
function handlers.h() show_usage(0) end
args = lib.dogetopt(args, handlers, "h", { help="h" })
if #args ~= 6 then show_usage(1) end
return unpack(args)
end

function run(args)
local bt_file, conf_file, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap =
parse_args(args)

-- It's essential to initialize the binding table before the aftrconf
bt.get_binding_table(bt_file)
local aftrconf = conf.get_aftrconf(conf_file)

local c = config.new()
config.app(c, "capturev4", pcap.PcapReader, inv4_pcap)
config.app(c, "capturev6", pcap.PcapReader, inv6_pcap)
config.app(c, "lwaftr", lwaftr.LwAftr, aftrconf)
config.app(c, "output_filev4", pcap.PcapWriter, outv4_pcap)
config.app(c, "output_filev6", pcap.PcapWriter, outv6_pcap)

config.link(c, "capturev4.output -> lwaftr.v4")
config.link(c, "capturev6.output -> lwaftr.v6")
config.link(c, "lwaftr.v4 -> output_filev4.input")
config.link(c, "lwaftr.v6 -> output_filev6.input")

app.configure(c)
app.main({duration=1})
print("done")
end

0 comments on commit 0ffec3e

Please sign in to comment.