Skip to content

Instantly share code, notes, and snippets.

@shun159
Created March 11, 2015 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shun159/9c7e4ea87b9f282354c3 to your computer and use it in GitHub Desktop.
Save shun159/9c7e4ea87b9f282354c3 to your computer and use it in GitHub Desktop.
flow_mod_with_nomatch_and_inst() ->
Actions = [ #ofp_action_output{ port = 2 },
#ofp_action_group{ group_id = 1 },
#ofp_action_set_queue{ queue_id = 2 },
#ofp_action_meter{ meter_id = 3 },
#ofp_action_set_mpls_ttl{ ttl = 127 },
#ofp_action_set_nw_ttl{ ttl = 127 },
#ofp_action_copy_ttl_out{},
#ofp_action_copy_ttl_in{},
#ofp_action_dec_mpls_ttl{},
#ofp_action_dec_nw_ttl{},
#ofp_action_push_vlan{ ethertype = 1 },
#ofp_action_push_mpls{ ethertype = 2 },
#ofp_action_push_pbb{ ethertype = 3 },
#ofp_action_pop_vlan{},
#ofp_action_pop_mpls{ ethertype = 4 },
#ofp_action_pop_pbb{},
#ofp_action_set_field{ field = #oxm_field{ class = packet_regs,
field = 1,
value = <<1234:32>> }},
#ofp_action_copy_field{ n_bits = 32,
src_ofs = 0,
dst_ofs = 0,
oxm_ids = [#oxm_header{ class = openflow_basic,
field = arp_spa },
#oxm_header{ class = openflow_basic,
field = ipv4_dst }]}],
StatsFields = [#oxs_ofb_duration{ sec = 1, n_sec = 1000 },
#oxs_ofb_idle_time{ sec = 20, n_sec = 20000 },
#oxs_ofb_flow_count{ count = 10 },
#oxs_ofb_packet_count{ count = 100 },
#oxs_ofb_byte_count{ count = 800 }],
Thres = #ofp_stats{ oxs_fields = StatsFields },
Instructions = [#ofp_instruction_goto_table{ table_id = 2 },
#ofp_instruction_write_metadata{ metadata = <<1:64>>,
metadata_mask = <<0:64>> },
#ofp_instruction_apply_actions{ actions = Actions },
#ofp_instruction_write_actions{ actions = Actions },
#ofp_instruction_clear_actions{},
#ofp_instruction_stat_trigger{ flags = [periodic],
thresholds = Thres }],
Msg = #ofp_flow_mod{ xid = 123,
cookie = <<0:64>>,
cookie_mask = <<0:64>>,
table_id = 1,
command = add,
idle_timeout = 0,
hard_timeout = 0,
priority = 65534,
buffer_id = no_buffer,
instructions = Instructions },
Bin = ?ENCODE(Msg),
EMsg = ?DECODE(Bin),
Msg = EMsg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment