static void dump_filter_strict( void ) { oxm_matches *match = create_oxm_matches(); append_oxm_match_in_port( match, 1 ); append_oxm_match_eth_type( match, 0x0800 ); append_oxm_match_vlan_vid( match, 0, 0 ); append_oxm_match_ipv4_src( match, 0x0a000001, 0 ); append_oxm_match_ipv4_dst( match, 0x0a000002, 0 ); append_oxm_match_ip_dscp( match, 0 ); append_oxm_match_ip_ecn( match, 0 ); append_oxm_match_ip_proto( match, 0x6 ); append_oxm_match_tcp_src( match, 1024 ); append_oxm_match_tcp_dst( match, 2048 ); static handler_data data; data.match = match; snprintf( data.service_name, sizeof( data.service_name ), "dumper" ); data.service_name[ sizeof( data.service_name ) - 1 ] = '\0'; data.strict = true; bool ret = dump_packetin_filter( data.match, OFP_HIGH_PRIORITY, data.service_name, data.strict, dump_filters, &data ); if ( ret == false ) { error( "Failed to dump packetin filters ( ret = %d ).", ret ); } else { add_periodic_event_callback( 5, timeout, &data ); } }
static VALUE pack_ether_type( VALUE self, VALUE actions, VALUE options ) { VALUE r_ether_type = HASH_REF( options, ether_type ); if ( rb_obj_is_kind_of( actions, basic_action_eval ) ) { append_action_set_field_eth_type( openflow_actions_ptr( actions ), ( const uint16_t ) NUM2UINT( r_ether_type ) ); } else if ( rb_obj_is_kind_of( actions, flexible_action_eval ) ) { append_oxm_match_eth_type( oxm_match_ptr( actions ), ( uint16_t ) NUM2UINT( r_ether_type ) ); } return self; }
static void test_map_entry_if_match_set_nw_src() { add_all_exact_entry(); add_all_wildcards_entry(); oxm_matches *match = create_oxm_matches(); append_oxm_match_eth_type( match, ETHERTYPE_IP ); append_oxm_match_ipv4_src( match, 0x0a000101, 0 ); char *user_data = xstrdup( USER_DATA ); count = 0; map_match_table( match, test_map_entry_if_match_set_nw_src_helper, user_data ); assert_int_equal( count, 2 ); XFREE( user_data ); delete_oxm_matches( match ); }
static void alloc_MATCH() { uint8_t dst_mac[6] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; uint8_t src_mac[6] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; uint8_t nomask[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; MATCH = create_oxm_matches(); append_oxm_match_in_port( MATCH, 1 ); append_oxm_match_eth_dst( MATCH, dst_mac, nomask ); append_oxm_match_eth_src( MATCH, src_mac, nomask ); append_oxm_match_vlan_vid( MATCH, 1, 0 ); append_oxm_match_vlan_pcp( MATCH, 1 ); append_oxm_match_eth_type( MATCH, 0x0800 ); append_oxm_match_ip_proto( MATCH, 0x6 ); append_oxm_match_ipv4_src( MATCH, 0x0a090807, 0x00000000 ); append_oxm_match_ipv4_dst( MATCH, 0x0a090807, 0x00000000 ); append_oxm_match_tcp_src( MATCH, 1024 ); append_oxm_match_tcp_dst( MATCH, 2048 ); }
static void set_alice_match_entry( oxm_matches *match ) { append_oxm_match_eth_type( match, ETHERTYPE_IP ); append_oxm_match_ipv4_src( match, 0x0a000101, 0 ); append_oxm_match_ipv4_dst( match, 0x0a000202, 0 ); }
static void set_carol_wildcards_entry( oxm_matches *match ) { append_oxm_match_eth_type( match, ETHERTYPE_IP ); append_oxm_match_ipv4_src( match, 0x0a000303, 0 ); }
static void set_lldp_wildcards_entry( oxm_matches *match ) { append_oxm_match_eth_type( match, ETH_ETHTYPE_LLDP ); }
static void set_nw_prefix_28_wildcards_entry( oxm_matches *match ) { append_oxm_match_eth_type( match, ETHERTYPE_IP ); append_oxm_match_ipv4_src( match, 0x0a000200, 0xfffffff0 ); append_oxm_match_ipv4_dst( match, 0x0a000100, 0xfffffff0 ); }
static void handle_switch_ready( uint64_t datapath_id, void *user_data ) { UNUSED( user_data ); openflow_actions *actions = create_actions(); append_action_output( actions, OFPP_CONTROLLER, OFPCML_NO_BUFFER ); openflow_instructions *insts = create_instructions(); append_instructions_apply_actions( insts, actions ); buffer *flow_mod = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_LOW_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, NULL, insts ); send_openflow_message( datapath_id, flow_mod ); free_buffer( flow_mod ); delete_instructions( insts ); // sleep(2000); info("sending ARP config to %d",datapath_id); uint32_t dest = OFPP_ALL; oxm_matches *match2 = create_oxm_matches(); append_oxm_match_eth_type( match2, 0x0806); openflow_actions *actions2 = create_actions(); append_action_output( actions2, dest, OFPCML_NO_BUFFER ); openflow_instructions *insts2 = create_instructions(); append_instructions_apply_actions( insts2, actions2 ); buffer *flow_mod2 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match2, insts2 ); send_openflow_message( datapath_id, flow_mod2 ); free_buffer( flow_mod2 ); delete_oxm_matches( match2 ); delete_instructions( insts2 ); // sleep(2000); info("sending second config: ipv4"); oxm_matches *match3 = create_oxm_matches(); append_oxm_match_eth_type( match3, 0x0800); // append_oxm_match_in_port( match2, 2); // dest = 1; openflow_actions *actions3 = create_actions(); append_action_push_mpls(actions3,0x8847); append_action_set_field_mpls_label(actions3,4120955); append_action_output( actions3, dest, OFPCML_NO_BUFFER ); openflow_instructions *insts3 = create_instructions(); append_instructions_apply_actions( insts3, actions3 ); buffer *flow_mod3 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match3, insts3 ); send_openflow_message( datapath_id, flow_mod3 ); free_buffer( flow_mod3 ); delete_oxm_matches( match3 ); delete_instructions( insts3 ); info("done sending"); // sleep(2000); info("sending third config"); oxm_matches *match4 = create_oxm_matches(); append_oxm_match_eth_type( match4, 0x8847); append_oxm_match_mpls_label(match4, 4120955); openflow_actions *actions4 = create_actions(); append_action_pop_mpls(actions4, 0x0800); append_action_output( actions4, dest, OFPCML_NO_BUFFER ); openflow_instructions *insts4 = create_instructions(); append_instructions_apply_actions( insts4, actions4 ); buffer *flow_mod4 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match4, insts4 ); send_openflow_message( datapath_id, flow_mod4); free_buffer( flow_mod4 ); delete_oxm_matches( match4 ); delete_instructions( insts4 ); info("done sending"); }
static void handle_switch_ready( uint64_t datapath_id, void *user_data ) { UNUSED( user_data ); openflow_actions *actions = create_actions(); append_action_output( actions, OFPP_CONTROLLER, OFPCML_NO_BUFFER ); openflow_instructions *insts = create_instructions(); append_instructions_apply_actions( insts, actions ); buffer *flow_mod = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_LOW_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, NULL, insts ); send_openflow_message( datapath_id, flow_mod ); free_buffer( flow_mod ); delete_instructions( insts ); // sleep(2000); info("sending ARP config: flood - %d",datapath_id); uint32_t dest = OFPP_ALL; oxm_matches *match2 = create_oxm_matches(); append_oxm_match_eth_type( match2, 0x0806); openflow_actions *actions2 = create_actions(); append_action_output( actions2, dest, OFPCML_NO_BUFFER ); openflow_instructions *insts2 = create_instructions(); append_instructions_apply_actions( insts2, actions2 ); buffer *flow_mod2 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match2, insts2 ); send_openflow_message( datapath_id, flow_mod2 ); free_buffer( flow_mod2 ); delete_oxm_matches( match2 ); delete_instructions( insts2 ); // sleep(2000); info("sending second config: match on eth src"); uint8_t eth_src[ OFP_ETH_ALEN ] = {0x0,0x24,0xe8,0x77,0xa5,0x32}; uint8_t set_src[ OFP_ETH_ALEN ] = {0x0,0x10,0x18,0x56,0xab,0xc2}; uint8_t eth_mask[ OFP_ETH_ALEN ] = {0xff,0xff,0xff,0xff,0xff,0xff}; oxm_matches *match3 = create_oxm_matches(); append_oxm_match_eth_type( match3, 0x0800); append_oxm_match_eth_src( match3,eth_src,eth_mask); // append_oxm_match_in_port( match2, 2); // dest = 1; openflow_actions *actions3 = create_actions(); append_action_set_field_eth_src( actions3, set_src ); append_action_push_mpls(actions3,0x8847); append_action_set_field_mpls_label(actions3,412095); append_action_output( actions3, 3, OFPCML_NO_BUFFER ); openflow_instructions *insts3 = create_instructions(); append_instructions_apply_actions( insts3, actions3 ); buffer *flow_mod3 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match3, insts3 ); send_openflow_message( datapath_id, flow_mod3 ); free_buffer( flow_mod3 ); delete_oxm_matches( match3 ); delete_instructions( insts3 ); info("done sending"); // sleep(2000); info("sending config:match mpls label -> pop mpls, set dest eth"); oxm_matches *match4 = create_oxm_matches(); append_oxm_match_eth_type( match4, 0x8847); append_oxm_match_mpls_label(match4, 412095); uint8_t set_src2[ OFP_ETH_ALEN ] = {0x0,0x24,0xe8,0x77,0xa5,0x32}; openflow_actions *actions4 = create_actions(); append_action_pop_mpls(actions4, 0x0800); append_action_output( actions4, 1, OFPCML_NO_BUFFER ); append_action_set_field_eth_src( actions4, set_src2 ); openflow_instructions *insts4 = create_instructions(); append_instructions_apply_actions( insts4, actions4 ); buffer *flow_mod4 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match4, insts4 ); send_openflow_message( 0x00101856ab98 , flow_mod4); free_buffer( flow_mod4 ); delete_oxm_matches( match4 ); delete_instructions( insts4 ); info("sending second config: match on eth src"); uint8_t set_src3[ OFP_ETH_ALEN ] = {0x0,0x10,0x18,0x56,0xab,0xc2}; oxm_matches *match5 = create_oxm_matches(); append_oxm_match_eth_type( match5, 0x0800); // append_oxm_match_eth_src( match3,eth_src,eth_mask); // append_oxm_match_in_port( match2, 2); // dest = 1; openflow_actions *actions5 = create_actions(); append_action_set_field_eth_src( actions5, set_src3 ); append_action_push_mpls(actions5,0x8847); append_action_set_field_mpls_label(actions5,442095); append_action_output( actions5, 3, OFPCML_NO_BUFFER ); openflow_instructions *insts5 = create_instructions(); append_instructions_apply_actions( insts5, actions5 ); buffer *flow_mod5 = create_flow_mod( get_transaction_id(), get_cookie(), 0, 0, OFPFC_ADD, 0, 0, OFP_HIGH_PRIORITY, OFP_NO_BUFFER, 0, 0, OFPFF_SEND_FLOW_REM, match5, insts5 ); send_openflow_message( datapath_id, flow_mod5 ); free_buffer( flow_mod5 ); delete_oxm_matches( match5 ); delete_instructions( insts5 ); info("done sending"); }