Exemple #1
0
static void
init_last_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  routing_switch *routing_switch = user_data;

  // Initialize outbound ports
  init_outbound_ports( &routing_switch->switches, n_entries, s );

  // Initialize aging FDB
  init_age_fdb( routing_switch->fdb );

  // Finally, set asynchronous event handlers
  // (0) Set features_request_reply handler
  set_features_reply_handler( receive_features_reply, routing_switch );

  // (1) Set switch_ready handler
  set_switch_ready_handler( handle_switch_ready, routing_switch );

  // (2) Set port status update callback
  add_callback_port_status_updated( port_status_updated, routing_switch );

  // (3) Set packet-in handler
  set_packet_in_handler( handle_packet_in, routing_switch );
}
Exemple #2
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );
  set_packet_in_handler( handle_packet_in, NULL );
  start_trema();
  return 0;
}
Exemple #3
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  hash_table *forwarding_db = create_hash( compare_forwarding_entry, hash_forwarding_entry );
  add_periodic_event_callback( AGING_INTERVAL, update_forwarding_db, forwarding_db );
  set_packet_in_handler( handle_packet_in, forwarding_db );

  start_trema();

  return 0;
}
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  hash_table *switch_db = create_hash( compare_datapath_id, hash_datapath_id );
  add_periodic_event_callback( AGING_INTERVAL, update_all_switches, switch_db );
  set_switch_ready_handler( handle_switch_ready, switch_db );
  set_switch_disconnected_handler( handle_switch_disconnected, switch_db );
  set_packet_in_handler( handle_packet_in, switch_db );

  start_trema();

  return 0;
}
Exemple #5
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  services services;
  if ( !set_match_type( argc, argv, &services ) ) {
    usage();
    exit( EXIT_FAILURE );
  }

  set_packet_in_handler( handle_packet_in, &services );

  start_trema();

  return 0;
}
Exemple #6
0
/*
 * Starts this controller. Usually you do not need to invoke
 * explicitly, because this is called implicitly by "trema run"
 * command.
 */
static VALUE
controller_run( VALUE self ) {
  setenv( "TREMA_HOME", STR2CSTR( rb_funcall( mTrema, rb_intern( "home" ), 0 ) ), 1 );

  VALUE name = rb_funcall( self, rb_intern( "name" ), 0 );
  rb_gv_set( "$PROGRAM_NAME", name );

  int argc = 3;
  char **argv = xmalloc( sizeof( char * ) * ( uint32_t ) ( argc + 1 ) );
  argv[ 0 ] = STR2CSTR( name );
  argv[ 1 ] = ( char * ) ( uintptr_t ) "--name";
  argv[ 2 ] = STR2CSTR( name );
  argv[ 3 ] = NULL;
  init_trema( &argc, &argv );
  xfree( argv );

  set_switch_ready_handler( handle_switch_ready, ( void * ) self );
  set_features_reply_handler( handle_features_reply, ( void * ) self );
  set_packet_in_handler( handle_packet_in, ( void * ) self );
  set_flow_removed_handler( handle_flow_removed, ( void * ) self );
  set_switch_disconnected_handler( handle_switch_disconnected, ( void * ) self );
  set_port_status_handler( handle_port_status, ( void * ) self );
  set_stats_reply_handler( handle_stats_reply, ( void * ) self );
  set_error_handler( handle_openflow_error, ( void * ) self );
  set_get_config_reply_handler( handle_get_config_reply, ( void * ) self );
  set_barrier_reply_handler( handle_barrier_reply, ( void * ) self );
  set_vendor_handler( handle_vendor, ( void * ) self );
  set_queue_get_config_reply_handler( handle_queue_get_config_reply, ( void * ) self );
  set_list_switches_reply_handler( handle_list_switches_reply );

  struct itimerspec interval;
  interval.it_interval.tv_sec = 1;
  interval.it_interval.tv_nsec = 0;
  interval.it_value.tv_sec = 0;
  interval.it_value.tv_nsec = 0;
  add_timer_event_callback( &interval, handle_timer_event, ( void * ) self );

  if ( rb_respond_to( self, rb_intern( "start" ) ) == Qtrue ) {
    rb_funcall( self, rb_intern( "start" ), 0 );
  }

  rb_funcall( self, rb_intern( "start_trema" ), 0 );

  return self;
}
Exemple #7
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  traffic db;
  db.counter = create_counter();
  db.fdb = create_fdb();

  add_periodic_event_callback( 10, show_counter, &db );

  set_packet_in_handler( handle_packet_in, &db );
  set_flow_removed_handler( handle_flow_removed, &db );

  start_trema();

  delete_fdb( db.fdb );
  delete_counter( db.counter );

  return 0;
}
Exemple #8
0
static void
init_second_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  broadcast_helper *broadcast_helper = user_data;

  // Initialize ports
  init_ports( &broadcast_helper->switches, n_entries, s );

  // Set asynchronous event handlers

  // (1) Set port status update callback
  add_callback_port_status_updated( port_status_updated, broadcast_helper );

  // (2) Set packet-in handler
  set_packet_in_handler( handle_packet_in, broadcast_helper );

  // (3) Get all link status
  get_all_link_status( init_last_stage, broadcast_helper );
}
Exemple #9
0
static void
init_second_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  routing_switch *routing_switch = user_data;
  routing_switch->second_stage_down = true;

  // Initialize ports
  init_ports( &routing_switch->switches, n_entries, s );

  // Initialize aging FDB
  init_age_fdb( routing_switch->fdb );

  // Set packet-in handler
  set_packet_in_handler( handle_packet_in, routing_switch );

  // Get all link status
  add_callback_link_status_updated( link_status_updated, routing_switch );
  get_all_link_status( init_last_stage, routing_switch );
}
Exemple #10
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  init_match_table();

  // built-in packetin-filter-rule
  if ( !set_match_type( argc, argv ) ) {
    usage();
    finalize_match_table();
    exit( EXIT_FAILURE );
  }

  set_packet_in_handler( handle_packet_in, NULL );

  start_trema();

  finalize_match_table();

  return 0;
}
static void
init_second_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  sliceable_switch *sliceable_switch = user_data;
  sliceable_switch->second_stage_down = true;

  // Initialize ports
  init_ports( &sliceable_switch->switches, n_entries, s );

  // Initialize aging FDB
  init_age_fdb( sliceable_switch->fdb );

  // Set asynchronous event handlers

  // (1) Set packet-in handler
  set_packet_in_handler( handle_packet_in, sliceable_switch );

  // (2) Get all link status
  add_callback_link_status_updated( link_status_updated, sliceable_switch );
  get_all_link_status( init_last_stage, sliceable_switch );
}
Exemple #12
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  init_packetin_match_table();

  // built-in packetin-filter-rule
  if ( !set_match_type( argc, argv ) ) {
    usage();
    finalize_packetin_match_table();
    exit( EXIT_FAILURE );
  }

  set_packet_in_handler( handle_packet_in, NULL );
  add_message_requested_callback( PACKETIN_FILTER_MANAGEMENT_SERVICE, handle_request );

  start_trema();

  finalize_packetin_match_table();

  return 0;
}
static void
init_second_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  routing_switch *routing_switch = user_data;

  // Initialize ports
  init_ports( &routing_switch->switches, n_entries, s );

  // Initialize aging FDB
  init_age_fdb( routing_switch->fdb );

  // Set asynchronous event handlers

  // (1) Set port status update callback
  add_callback_port_status_updated( port_status_updated, routing_switch );

  // (2) Set packet-in handler
  set_packet_in_handler( handle_packet_in, routing_switch );

  // (3) Get all link status
  get_all_link_status( init_last_stage, routing_switch );
}