static void make_path( routing_switch *routing_switch, uint64_t in_datapath_id, uint16_t in_port, uint64_t out_datapath_id, uint16_t out_port, const buffer *packet ) { dlist_element *hops = resolve_path( routing_switch->pathresolver, in_datapath_id, in_port, out_datapath_id, out_port ); if ( hops == NULL ) { warn( "No available path found ( %#" PRIx64 ":%u -> %#" PRIx64 ":%u ).", in_datapath_id, in_port, out_datapath_id, out_port ); discard_packet_in( in_datapath_id, in_port, packet ); return; } // count elements uint32_t hop_count = count_hops( hops ); // send flow entry from tail switch for ( dlist_element *e = get_last_element( hops ); e != NULL; e = e->prev, hop_count-- ) { uint16_t idle_timer = ( uint16_t ) ( routing_switch->idle_timeout + hop_count ); modify_flow_entry( e->data, packet, idle_timer ); } // for(;;) // send packet out for tail switch dlist_element *e = get_last_element( hops ); pathresolver_hop *last_hop = e->data; output_packet_from_last_switch( last_hop, packet ); // free them free_hop_list( hops ); }
static void resolve_path_replied( void *user_data, dlist_element *hops ) { assert( user_data != NULL ); resolve_path_replied_params *param = user_data; routing_switch *routing_switch = param->routing_switch; buffer *original_packet = param->original_packet; if ( hops == NULL ) { warn( "No available path found." ); free_buffer( original_packet ); xfree( param ); return; } original_packet->user_data = NULL; if ( !parse_packet( original_packet ) ) { warn( "Received unsupported packet" ); free_packet( original_packet ); free_hop_list( hops ); xfree( param ); return; } // count elements uint32_t hop_count = count_hops( hops ); // send flow entry from tail switch for ( dlist_element *e = get_last_element( hops ); e != NULL; e = e->prev, hop_count-- ) { uint16_t idle_timer = ( uint16_t ) ( routing_switch->idle_timeout + hop_count ); modify_flow_entry( e->data, original_packet, idle_timer ); } // for(;;) // send packet out for tail switch dlist_element *e = get_last_element( hops ); pathresolver_hop *last_hop = e->data; output_packet_from_last_switch( last_hop, original_packet ); // free them free_hop_list( hops ); free_packet( original_packet ); xfree( param ); }