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 ); }
static void after_subscribed( void *user_data ) { assert( user_data != NULL ); // Get all ports' status // init_second_stage() will be called add_callback_port_status_updated( port_status_updated, user_data ); get_all_port_status( init_second_stage, user_data ); }
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 ); }
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 ); }