示例#1
0
static VALUE
pack_eth_dst( VALUE self, VALUE actions, VALUE options ) {
  VALUE r_mac_address = HASH_REF( options, mac_address );
  uint8_t *dl_addr = ( uint8_t * ) xmalloc( sizeof( uint8_t ) * OFP_ETH_ALEN );

  if ( rb_obj_is_kind_of( actions, basic_action_eval ) ) {
    append_action_set_field_eth_dst( openflow_actions_ptr( actions ), dl_addr_to_a( r_mac_address, dl_addr ) );
  }
  else if ( rb_obj_is_kind_of( actions, flexible_action_eval ) ) {
    uint8_t eth_dst_mask[ OFP_ETH_ALEN ] = { 0 };
    append_oxm_match_eth_dst( oxm_match_ptr( actions ), dl_addr_to_a( r_mac_address, dl_addr ), eth_dst_mask );
  }
  xfree( dl_addr );

  return self;
}
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 );
}