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 ); }
bool start_topology_management( void ) { init_openflow_application_interface( get_trema_name() ); set_switch_ready_handler( handle_switch_ready, NULL ); set_switch_disconnected_handler( switch_disconnected, NULL ); set_features_reply_handler( switch_features_reply, NULL ); set_port_status_handler( port_status, NULL ); return true; }
int main( int argc, char *argv[] ) { init_trema( &argc, &argv ); set_switch_ready_handler( send_features_request, NULL ); set_features_reply_handler( handle_features_reply, NULL ); start_trema(); return 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; }
int main( int argc, char *argv[] ) { init_trema( &argc, &argv ); show_desc show_desc; show_desc.db = create_hash( compare_datapath_id, hash_datapath_id ); show_desc.count = 0; set_list_switches_reply_handler( handle_list_switches_reply ); #ifdef TREMA_EDGE set_multipart_reply_handler( handle_stats_reply, &show_desc ); #else set_stats_reply_handler( handle_stats_reply, &show_desc ); set_features_reply_handler( handle_features_reply, &show_desc ); #endif add_periodic_event_callback( 10, timed_out, NULL ); send_list_switches_request( &show_desc ); start_trema(); return 0; }