static void stop_switch() { if ( switch_info.secure_channel_fd >= 0 ) { close( switch_info.secure_channel_fd ); switch_info.secure_channel_fd = -1; } uint8_t state = MESSENGER_OPENFLOW_DISCONNECTED; if ( switch_info.state == SWITCH_STATE_CONNECTION_FAILED ) { state = MESSENGER_OPENFLOW_FAILD_TO_CONNECT; } service_send_state( &switch_info, &switch_info.datapath_id, state ); flush_messenger(); // free service name list iterate_list( switch_info.vendor_service_name_list, xfree_data, NULL ); delete_list( switch_info.vendor_service_name_list ); switch_info.vendor_service_name_list = NULL; iterate_list( switch_info.packetin_service_name_list, xfree_data, NULL ); delete_list( switch_info.packetin_service_name_list ); switch_info.packetin_service_name_list = NULL; iterate_list( switch_info.portstatus_service_name_list, xfree_data, NULL ); delete_list( switch_info.portstatus_service_name_list ); switch_info.portstatus_service_name_list = NULL; iterate_list( switch_info.state_service_name_list, xfree_data, NULL ); delete_list( switch_info.state_service_name_list ); switch_info.state_service_name_list = NULL; stop_trema(); }
int switch_event_disconnected( struct switch_info *sw_info ) { sw_info->state = SWITCH_STATE_DISCONNECTED; if ( sw_info->fragment_buf != NULL ) { free_buffer( sw_info->fragment_buf ); sw_info->fragment_buf = NULL; } if ( sw_info->send_queue != NULL ) { delete_message_queue( sw_info->send_queue ); sw_info->send_queue = NULL; } if ( sw_info->recv_queue != NULL ) { delete_message_queue( sw_info->recv_queue ); sw_info->recv_queue = NULL; } if ( sw_info->secure_channel_fd >= 0 ) { close( sw_info->secure_channel_fd ); sw_info->secure_channel_fd = -1; } // send secure channle disconnect state to application service_send_state( sw_info, &sw_info->datapath_id, MESSENGER_OPENFLOW_DISCONNECTED ); flush_messenger(); debug( "send disconnected state" ); stop_messenger(); return 0; }
int switch_event_disconnected( struct switch_info *sw_info ) { int old_state = sw_info->state; sw_info->state = SWITCH_STATE_DISCONNECTED; if ( old_state == SWITCH_STATE_COMPLETED ) { delete_timer_event( echo_request_interval, sw_info ); } if ( sw_info->fragment_buf != NULL ) { free_buffer( sw_info->fragment_buf ); sw_info->fragment_buf = NULL; } if ( sw_info->send_queue != NULL ) { delete_message_queue( sw_info->send_queue ); sw_info->send_queue = NULL; } if ( sw_info->recv_queue != NULL ) { delete_message_queue( sw_info->recv_queue ); sw_info->recv_queue = NULL; } if ( sw_info->secure_channel_fd >= 0 ) { set_readable( switch_info.secure_channel_fd, false ); set_writable( switch_info.secure_channel_fd, false ); delete_fd_handler( switch_info.secure_channel_fd ); close( sw_info->secure_channel_fd ); sw_info->secure_channel_fd = -1; } if ( old_state != SWITCH_STATE_COMPLETED ) { service_send_state( sw_info, &sw_info->datapath_id, MESSENGER_OPENFLOW_FAILD_TO_CONNECT ); } else { // send secure channle disconnect state to application service_send_state( sw_info, &sw_info->datapath_id, MESSENGER_OPENFLOW_DISCONNECTED ); } flush_messenger(); stop_trema(); return 0; }