-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathclassbench
executable file
·51 lines (42 loc) · 1.35 KB
/
classbench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby
require_relative "lib/classbench"
require "pp"
require "docopt"
doc = <<DOCOPT
Classbench utility
Firewall/openflow rule generator.
Usage:
#{__FILE__} analyse FILE
#{__FILE__} generate v4 <seed> [--count=<n>] [--db-generator=<path>]
#{__FILE__} generate v6 <seed> [--count=<n>]
#{__FILE__} -h | --help
#{__FILE__} version
Options:
--db-generator=<path> Path to binary of original db_generator [default: ./vendor/db_generator/db_generator]
--count=<n> Count of rules to generate [default: 100]
-h --help Show this screen.
Analyser accept's as input ovs-ofctl dump.
Fields extracted from dump are:
- dl_dst, dl_src, dl_type, (dl_vlan, dl_vlan_pcp,)
- eth_type, in_port,
- nw_dst, nw_proto, nw_src, nw_tos,
- tp_dst, tp_src
Output is original Classbench seed
with openflow YAML structure as last section.
Generator accept's Classbench seed with openflow section.
Output's one rule per line in format "attribute=value", joined by ", ".
DOCOPT
begin
opts = Docopt::docopt(doc)
if opts["analyse"]
Classbench::analyse(opts["FILE"])
elsif opts["generate"]
#pp opts
Classbench::generate(opts["<seed>"], (opts["--count"].to_i), opts["--db-generator"])
elsif opts["version"]
puts "Version: #{Classbench::VERSION}"
end
# TODO: --version
rescue Docopt::Exit => e
STDERR.puts e.message
end