section Parser theory IpRoute_Parser imports Routing_Table
IP_Addresses.IP_Address_Parser
keywords "parse_ip_route""parse_ip_6_route" :: thy_decl begin text‹This helps to read the output of the \texttt{ip route} command into a @{typ "32 routing_rule list"}.›
definition routing_action_next_hop_update :: "'a word ==> 'a routing_rule ==> ('a::len) routing_rule" where "routing_action_next_hop_update h pk = pk( routing_action := (routing_action pk)(next_hop := Some h))" lemma"routing_action_next_hop_update h pk = routing_action_update (next_hop_update (λ_. (Some h))) (pk::32 routing_rule)" by(simp add: routing_action_next_hop_update_def)
definition routing_action_oiface_update :: "string ==> 'a routing_rule ==> ('a::len) routing_rule" where "routing_action_oiface_update h pk = routing_action_update (output_iface_update (λ_. h)) (pk::'a routing_rule)" lemma"routing_action_oiface_update h pk = pk( routing_action := (routing_action pk)( output_iface := h))" by(simp add: routing_action_oiface_update_def)
(* Could be moved to Bitmagic *) definition"default_prefix = PrefixMatch 0 0" lemma default_prefix_matchall: "prefix_match_semantics default_prefix ip" unfolding default_prefix_def by (simp add: valid_prefix_00 zero_prefix_match_all)
definition"sanity_ip_route (r::('a::len) prefix_routing) ≡ correct_routing r ∧ unambiguous_routing r ∧ list_all ((≠) '''' ∘ routing_oiface) r" text‹The parser ensures that @{const sanity_ip_route} holds for any ruleset that is imported.›
(* Hide all the ugly ml in a file with the right extension *) (*Depends on the function parser_ipv4 from IP_Address_Parser*)
ML_file ‹IpRoute_Parser.ML›
ML‹
Outer_Syntax.local_theory @{command_keyword parse_ip_route}
"Load a file generated by ip route and make the routing table definition available as isabelle term"
(Parse.binding --| @{keyword "="} -- Parse.string >> register_ip_route 32) ›
ML‹
Outer_Syntax.local_theory @{command_keyword parse_ip_6_route}
"Load a file generated by ip -6 route and make the routing table definition available as isabelle term"
(Parse.binding --| @{keyword "="} -- Parse.string >> register_ip_route 128) ›
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.