?? ospf_external_route_calculation.c
字號:
} return;}/*******************************************************************************//* section 3.5 RFC - 1587 */#if defined (__NSSA__)/*************************************************************************** ospf_calculate_type_7_as_external_routes - calculate new paths for type 7 link state advertisements** This routine will traverse through the link state database* and call the appropriate routine to create new paths for the* type 7 external routes.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_calculate_type_7_as_external_routes (void){ OSPF_LS_DATABASE_HEAD *sptr_ls_database_head = NULL; OSPF_LS_DATABASE_ENTRY *sptr_database_entry = NULL; OSPF_LS_DATABASE_ENTRY *sptr_next_database_entry = NULL; ULONG index; OSPF_AREA_ENTRY *sptr_area = NULL; OSPF_AREA_ENTRY *sptr_next_area = NULL; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_type_7_as_external_routes\r\n"); for (sptr_area = ospf.sptr_area_list; sptr_area != NULL; sptr_area = sptr_next_area) { sptr_next_area = sptr_area->sptr_forward_link; for (index = 0x00000000L, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[OSPF_LS_TYPE_7][index]); /* for each hash list */ index < OSPF_HASH_TABLE_SIZE; ++index, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[OSPF_LS_TYPE_7][index])) { if (sptr_ls_database_head == NULL) { continue; } /* SPR#76812 */ for (sptr_database_entry = sptr_ls_database_head->sptr_linear_database_entry; sptr_database_entry != NULL; sptr_database_entry = sptr_next_database_entry) { sptr_next_database_entry = sptr_database_entry->sptr_forward_link; if (sptr_database_entry->advertisement.sptr_type_7 != NULL) { ospf_calculate_type_7_routes_to_a_single_external_destination (&(sptr_database_entry->advertisement), FALSE); } } } } return;}/*************************************************************************** ospf_calculate_type_7_routes_to_a_single_external_destination - create a new routing table entry for the type 7 destination** This routine will calculate the type 7 path to the type 7* destination and call the function to create the new routing* table entry for that path.** <advertisement> Advertisement to be examined** <on_new_external_lsa_received_path> Boolean to see if external lsa was received on new path** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*******************************************************************************//* NSSA RFC-1587 Section 3.5 Similar to section 16.4 of OSPF specification */void ospf_calculate_type_7_routes_to_a_single_external_destination (UNION_OSPF_LINK_STATE_ADVERTISEMENT *advertisement, enum BOOLEAN on_new_external_lsa_received_path){ ULONG destination_N =0; ULONG autonomous_system_boundary_router =0; OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_ASBR =NULL; OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_forwarding_address=NULL; OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_N =NULL; OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node_for_N =NULL; ULONG distance_X =0; ULONG cost_Y =0; ULONG tos0_metric =0; USHORT age =0; ULONG default_network_mask =0; ULONG number_of_areas =0; BOOLEAN nssa_ABR; ULONG forwarding_address =0; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_type_7_routes_to_a_single_external_destination\r\n"); tos0_metric = net_to_host_long (advertisement->sptr_type_7->tos0_metric); tos0_metric = tos0_metric & OSPF_LSInfinity; age = net_to_host_short (advertisement->sptr_type_7->ls_header.age); autonomous_system_boundary_router = net_to_host_long (advertisement->sptr_type_7->ls_header.advertising_router); nssa_ABR = FALSE; distance_X = 0x00000000L; if ((tos0_metric == OSPF_LSInfinity) || (age == OSPF_MAXIMUM_AGE) || (autonomous_system_boundary_router == ospf.router_id)) { if ( (tos0_metric == OSPF_LSInfinity) || (age == OSPF_MAXIMUM_AGE) ) { ospf_invalidate_type_7_route_entry (advertisement->sptr_type_7); ospf_display_routing_table (); } return; /* section 3.5, items (1) RFC-1587*/ } sptr_routing_table_entry_for_ASBR = ospf_find_routing_table_entry (autonomous_system_boundary_router, OSPF_DESTINATION_TYPE_ASBR, OSPF_ROUTE_PATH_TYPE_WILDCARD, NULL); if (sptr_routing_table_entry_for_ASBR == NULL) /* ASBR is unreachable */ { OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "OSPF_ROUTING_TABLE: ---------> TYPE-7 LSA - Did not add route to ext \ destination- Destination:%lx (LSA queued) - Reason - No route to ASBR \r\n", net_to_host_long (advertisement->sptr_type_7->ls_header.id)); ospf_display_routing_table (); return; /* section 3.5, item (2) Step 1 RFC-1587*/ } destination_N = net_to_host_long (advertisement->sptr_type_7->ls_header.id); default_network_mask = net_to_host_long (advertisement->sptr_type_7->network_mask); for (number_of_areas = 0x00000000L; number_of_areas < ospf.number_of_areas; ++number_of_areas) { if ((ospf.area[number_of_areas].config.nssa_enabled == TRUE) && (ospf.number_of_areas > 1)) { nssa_ABR = TRUE; break; } } if (((destination_N == OSPF_DefaultDestination) && (default_network_mask == OSPF_DefaultMask)) && ((advertisement->sptr_type_7->ls_header.type == OSPF_LS_TYPE_7) && (nssa_ABR == TRUE))) { ospf_invalidate_type_7_route_entry (advertisement->sptr_type_7); ospf_display_routing_table (); return; /* section 3.5, item (2) Step 2 RFC-1587*/ } else /* This LSA descibes an AS External path to destination N*/ { forwarding_address = net_to_host_long (advertisement->sptr_type_7->tos0_forwarding_address); /* Packets routed to destination_N should be routed to the originating ASBR */ if (forwarding_address != 0x00000000L) /* Lookup the forwarding address in the routing table */ { /* SPR#76812 -- Begin */ sptr_routing_table_entry_for_ASBR ospf_find_routing_table_entry_1583_asbr(autonomous_system_boundary_router); /* SPR#76812 -- End */ if (sptr_routing_table_entry_for_ASBR == NULL) /* ASBR is unreachable */ { OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "OSPF_ROUTING_TABLE: ---------> EXT LSA - Did not add route to ext destination- Destinatin:%lx (LSA queued) - Reason - No route to ASBR \r\n", net_to_host_long (advertisement->sptr_external->ls_header.id)); return; /* section 16.4, item (3) (pages 160-161) */ } sptr_routing_table_entry_for_forwarding_address = ospf_get_forwarding_address (advertisement, &distance_X, sptr_routing_table_entry_for_ASBR); if ((sptr_routing_table_entry_for_forwarding_address == NULL) && (distance_X == 0x00000000L)) { return; } else if (sptr_routing_table_entry_for_forwarding_address != NULL) { if ((sptr_routing_table_entry_for_forwarding_address->path_type != OSPF_ROUTE_PATH_TYPE_INTRA) && (sptr_routing_table_entry_for_forwarding_address->path_type != OSPF_ROUTE_PATH_TYPE_INTER)) /* an intra area or inter area path must therefore exist to this forwarding adress */ { return; } } } cost_Y = tos0_metric; } /* Lookup the routing table entry for Destination N */ /* section 3.5, item (3) RFC-1587*/ /* Fix for SPR# 297651 (SPR#83274) */ sptr_routing_table_node_for_N = ospf_find_router_or_network_routing_table_node (destination_N, advertisement->sptr_type_7->ls_header.type, OSPF_ROUTE_PATH_TYPE_WILDCARD, NULL); if (sptr_routing_table_node_for_N != NULL) { sptr_routing_table_entry_for_N = sptr_routing_table_node_for_N->sptr_routing_table_entry; } else { sptr_routing_table_entry_for_N = NULL; }/* Above forwarding address is used to route the packets routed to the external destination_N using this forwarding address in the nssa area */ if (sptr_routing_table_entry_for_N == NULL) /* section 3.5, item (3) RFC-1587 continued */ { ospf_create_and_install_a_new_external_area_path_to_N (destination_N, sptr_routing_table_entry_for_N, advertisement, sptr_routing_table_entry_for_forwarding_address, sptr_routing_table_entry_for_ASBR, distance_X, /*#$-NOTE:note57-$#*/ cost_Y, on_new_external_lsa_received_path); } else if ((sptr_routing_table_entry_for_N->path_type != OSPF_ROUTE_PATH_TYPE_1_EXTERNAL) && (sptr_routing_table_entry_for_N->path_type != OSPF_ROUTE_PATH_TYPE_2_EXTERNAL)) /* section 3.5, item (4) RFC-1587 */ { return; } else /* section 3.5, item (5) RFC-1587 */ { if ( (sptr_routing_table_entry_for_forwarding_address != NULL) && (sptr_routing_table_entry_for_forwarding_address->sptr_next_hop != NULL) && (sptr_routing_table_entry_for_forwarding_address->sptr_next_hop->next_hop_router == 0x00000000L) ) { return; } ospf_install_new_external_path_based_on_cost (destination_N, sptr_routing_table_node_for_N, distance_X, cost_Y, advertisement, sptr_routing_table_entry_for_forwarding_address, sptr_routing_table_entry_for_ASBR); /*#$-NOTE:note56-$#*/ } return;}/*************************************************************************** ospf_translate_type_7_routes_into_type_5_lsa - translate a type 5 lsa to a type 7 lsa** This routine will translate the type 7 lsas to external lsas.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//**********************************************************************************************************************************/ /* Section 4.1 RFC-1587 */void ospf_translate_type_7_routes_into_type_5_lsa (void){ OSPF_INTERFACE *sptr_interface = NULL; OSPF_INTERFACE *sptr_next_interface = NULL; bool interface_found; OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node = NULL; OSPF_EXTERNAL_ROUTE *sptr_external_route_from_global_list = NULL; OSPF_EXTERNAL_ROUTE *sptr_external_route = NULL; ULONG index; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_translate_type_7_routes_into_type_5_lsa\r\n"); interface_found = FALSE; for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface) { sptr_next_interface = sptr_interface->sptr_forward_link; if (sptr_interface->designated_router.id > ospf.router_id) { interface_found = TRUE; break; } } /* SPR#76812 -- Begin */ for(index = 0x00000000L; index < OSPF_RT_HASH_TABLE_SIZE; index++) { for (sptr_routing_table_node = ospf.sptr_routing_table_head[OSPF_ROUTE_TABLE_NETWORK][index]; sptr_routing_table_node != NULL; sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link) { if (sptr_routing_table_node->sptr_routing_table_entry->link_type == OSPF_LS_TYPE_7) { if ((sptr_routing_table_node->sptr_routing_table_entry->sptr_link_state_origin->sptr_type_7->ls_header.options._bit.dont_propagate != FALSE) #if defined (MISTRAL_COMMENTED) ||(sptr_routing_table_node->sptr_routing_table_entry->sptr_link_state_origin->sptr_type_7->tos0_forwarding_address == 0x00000000L) #endif /* MISTRAL_COMMENTED */ ) { return ; } sptr_external_route = ospf_translate_routing_table_entry_to_external_route (sptr_routing_table_node->sptr_routing_table_entry, TRUE); if (sptr_external_route == NULL) { continue; } if (sptr_routing_table_node->sptr_routing_table_entry->type_5_route_originated == FALSE) /* Section 4.1 Item 3 bullet 1 RFC-1587 */ { ospf_originate_external_links_advertisement_from_type_7_route (sptr_external_route); sptr_routing_table_node->sptr_routing_table_entry->type_5_route_originated = TRUE; continue; } else { sptr_external_route_from_global_list = ospf_find_originated_external_route (ospf.sptr_originated_external_routes, sptr_external_route); if (sptr_external_route_from_global_list != NULL) { /* Section 4.1 Item 3 bullet 2 RFC-1587 */ if ((sptr_routing_table_node->sptr_routing_table_entry->sptr_link_state_origin->sptr_type_7->tos0_metric != sptr_external_route_from_global_list->metric ) || (sptr_routing_table_node->sptr_routing_table_entry->sptr_link_state_origin->sptr_type_7->tos0_forwarding_address != sptr_external_route_from_global_list->forwarding_address )) /* Section 4.1 Item 3 bullet 3 RFC-1587 */ { ospf_originate_external_links_advertisement_from_type_7_route (sptr_external_route); table_free (sptr_external_route_from_global_list); break; } else { ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_external_route_from_global_list , (OSPF_GENERIC_NODE *) ospf.sptr_originated_external_routes); table_free (sptr_external_route); sptr_external_route = NULL;#if defined (__NSSA_FIXES__) continue;#else /* __NSSA_FIXES__ */ break;#endif /* __NSSA_FIXES__ */ } } else { table_free (sptr_external_route); sptr_external_route = NULL;#if defined (__NSSA_FIXES__) continue;#else /* __NSSA_FIXES__ */ break;#endif /* __NSSA_FIXES__ */ } } }/* End of if */ }/* End of for loop*/return;}#endif /*__NSSA__*//*************************************************************************** ospf_invalidate_external_route_entry - invalidate external routing table entry** This routine will invalidate an external routing table entry.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -