spacepaste

  1.  
  2. section\<open>Example: Executing an Iptables ruleset in Isabelle\<close>
  3. theory Executable_Iptables
  4. imports Alternative_Semantics "Primitive_Matchers/Common_Primitive_Matcher"
  5. (* arbitrarily: *) "Examples/SQRL_Shorewall/SQRL_2015_nospoof"
  6. begin
  7. text\<open>This is just a little example theory that demonstrates that one can directly
  8. execute a loaded ruleset on an inductively defined semantics.
  9. Unfortunately, doing so is only possible with the \textbf{values} command and we cannot
  10. extract or document its result automatically.
  11. This makes for an interesting toy example, but nothing more.\<close>
  12. code_pred iptables_bigstep_r .
  13. print_theorems
  14. definition "some_p \<equiv> \<lparr>p_iiface = ''lmd'', p_oiface = ''lup'',
  15. p_src = ipv4addr_of_dotdecimal (10,13,42,130), p_dst= ipv4addr_of_dotdecimal (80,237,132,143),
  16. p_proto=TCP, p_sport=51065, p_dport=80, p_tcp_flags = {},
  17. p_payload = '''', p_tag_ctstate = CT_New\<rparr>"
  18. (*values "{t. (\<lambda>_. None),(\<lambda>m p. the (ternary_to_bool (common_matcher m p))),some_p\<turnstile> \<langle>[],Undecided\<rangle> \<Rightarrow> t}"
  19. This won't work. I have no idea if one somehow can make it work\<dots> *)
  20. term "map_of_string_ipv4 filter_fw1"
  21. definition "entry_rs \<equiv> [Rule MatchAny (Call ''FORWARD''), Rule MatchAny filter_fw1_FORWARD_default_policy]"
  22. values "{t.
  23. (map_of_string_ipv4 filter_fw1),(\<lambda>m p. the (ternary_to_bool (common_matcher m p))),some_p \<turnstile>
  24. entry_rs \<Rightarrow>\<^sub>r t}"
  25. end
  26.