?? ospf_dijkstra.c
字號:
OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: ADDING NETWORK VERTEX TO SPT PROBABLES LIST. VERTEX IS %lx DR is %lx \r\n", vertex_V, vertex_V); sptr_database_node = (OSPF_LS_DATABASE_NODE *) table_malloc (1, sizeof (OSPF_LS_DATABASE_NODE)); if (sptr_database_node != NULL) { memset (sptr_database_node, 0x00, sizeof (OSPF_LS_DATABASE_NODE)); sptr_database_node->sptr_ls_database_entry = sptr_database_entry; if (sptr_first_database_node == NULL) { sptr_first_database_node = sptr_database_node; } else { ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_database_node, (OSPF_GENERIC_NODE *) sptr_first_database_node); } } else { ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *)NULL , "OSPF_LS_DATABASE_NODE"); } } /* else if */ } } } return (sptr_first_database_node);}/**************************************************************************************** ospf_examine_router_link_advertisement_for_vertex_V - examine the router lsa associated with the vertex** This routine will examine the router link state advertisement for the associated vertex.* This routine will examine the links associated with the router link advertisement and* add nodes to the shortest path node.** <sptr_router_link_advertisement> Advertisement OSPF is examining** <sptr_area> OSPF area** <sptr_vertex_V> Shortest path node for vertex on router OSPF is examining** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_examine_router_link_advertisement_for_vertex_V (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_router_link_advertisement, OSPF_AREA_ENTRY *sptr_area,OSPF_SHORTEST_PATH_NODE *sptr_vertex_V){ UNION_OSPF_ROUTER_LINK_BIT_OPTIONS bit_options; USHORT number_of_links =0; OSPF_ROUTER_LINK_PIECE *sptr_link =NULL; ULONG link_id =0; BYTE_ENUM (OSPF_LS_TYPE) link_type; OSPF_LS_DATABASE_ENTRY *sptr_database_entry_for_vertex_W =NULL; USHORT age =0; enum TEST test_return_type; ULONG cost_D =0; USHORT tos0_metric =0; OSPF_SHORTEST_PATH_NODE *sptr_vertex_W =NULL; OSPF_NEXT_HOP_BLOCK *sptr_next_hop =NULL; ULONG vertex =0; char print_buffer[PRINT_BUFFER_SIZE]; char print_buffer_1[PRINT_BUFFER_SIZE]; int i = 0; OSPF_ROUTER_LINK_PIECE *sptr_router_link; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_examine_router_link_advertisement_for_vertex_V\r\n"); bit_options = sptr_router_link_advertisement->bit_options; /*UNH 4.2 start */ /* if the vertex is a virtual link locate the area in which the virtual link resides and mark it as transit area */ /* Cisco does not set the V bit (not mandatory according to RFC). Therefore to pass UNH 4.2, we need to determine which areas are transit (include the virtual link). Virtual links are advertised in router LSAs of the backbone area 0. If the current vertex is a virtual link, determine which is the area it actually resides in and mark that area as transit area: Examine router LSAs in other areas to locate what is the area in which the interface for the virtual link is advertised */ /*if (bit_options._bit.bit_V == TRUE)*/ /* SPR 86188 Begin */ number_of_links = sptr_router_link_advertisement->number_of_links; number_of_links = net_to_host_short (number_of_links); sptr_router_link = (OSPF_ROUTER_LINK_PIECE*)&sptr_router_link_advertisement->link; if (sptr_area->area_id == OSPF_BACKBONE) { for (i = 0; i < number_of_links; i++) { if (sptr_router_link->type == OSPF_ROUTER_LINK_TYPE_VIRTUAL) { /* Determine area where the transit link resides */ /* walk the router LSAs for this router to find which one (for which area) advertises this interface */ /* Pseudocode: for every non backbone area find if there is a router LSA for this router in the non-backbone area for every link of the router lsa if link == the end of virtual link found area whwre the virtual link resides: mark area as transit */ OSPF_AREA_ENTRY *sptr_area_current = NULL; OSPF_LS_DATABASE_ENTRY *sptr_router_lsa_other_area = NULL; OSPF_ROUTER_LINK_PIECE *sptr_router_link_other_area; USHORT num_links =0; int j; for (sptr_area_current = ospf.sptr_area_list; sptr_area_current != NULL; sptr_area_current = sptr_area_current->sptr_forward_link) { if (sptr_area_current->area_id == OSPF_BACKBONE) { continue; } link_id = sptr_router_link_advertisement->ls_header.advertising_router; link_id = net_to_host_long (link_id); /* SPR#76812 -- Begin */ sptr_router_lsa_other_area = ospf_find_LSA(sptr_area_current,link_id,link_id,OSPF_LS_ROUTER); /* SPR#76812 -- End */ if (sptr_router_lsa_other_area != NULL) { /* found router LSA for same router in other area */ /* for every link of the router lsa */ num_links = sptr_router_lsa_other_area->advertisement.sptr_router->number_of_links; num_links = net_to_host_short (num_links); sptr_router_link_other_area = (OSPF_ROUTER_LINK_PIECE*)&(sptr_router_lsa_other_area->advertisement.sptr_router->link); for (j = 0; j < num_links; j++) { /* if link == the end of virtual link */ if (sptr_router_link_other_area->link_data == sptr_router_link->link_data) { /* mark area as transit area */ sptr_area_current->flags._bit.transit = TRUE; } sptr_router_link_other_area = (OSPF_ROUTER_LINK_PIECE *) ((ULONG) sptr_router_link_other_area + OSPF_ROUTER_LINK_PIECE_SIZE + (sptr_router_link_other_area->number_of_metrics * OSPF_ROUTER_LINK_METRIC_PIECE_SIZE)); } /* for every link */ } /* if found router LSA in other area */ } /* for every area */ } /* if virtual link */ sptr_router_link = (OSPF_ROUTER_LINK_PIECE *) ((ULONG) sptr_router_link + OSPF_ROUTER_LINK_PIECE_SIZE + (sptr_router_link->number_of_metrics * OSPF_ROUTER_LINK_METRIC_PIECE_SIZE)); } /* for every router link */ /*SPR 86188 End */ } /* if backbone */ /*UNH 4.2 end */ OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "------------------------------>>>>>>>>>>>>>>>>>IN EXAMINE ROUTER LINK ADVERTISEMENTS: \r\n"); for (sptr_link = &sptr_router_link_advertisement->link; number_of_links > 0x0000; --number_of_links, sptr_link = (OSPF_ROUTER_LINK_PIECE *) ((ULONG) sptr_link + OSPF_ROUTER_LINK_PIECE_SIZE + ((sptr_link->number_of_metrics) * OSPF_ROUTER_LINK_METRIC_PIECE_SIZE))) { if (sptr_link->type == OSPF_ROUTER_LINK_TYPE_STUB_NETWORK) /* skip stub nets for now, they will be added later */ { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: !!!!!!!!!!!!!!!!!! SKIP link_id (HEX) %lx, which is a STUB FOR NOW and advertising router is: %lx\r\n", sptr_link->link_id, sptr_router_link_advertisement->ls_header.advertising_router); continue; /* section 16.1, item (2)(a) page (151) */ } link_id = sptr_link->link_id; link_id = net_to_host_long (link_id); switch (sptr_link->type) { case OSPF_ROUTER_LINK_TYPE_PPP: case OSPF_ROUTER_LINK_TYPE_VIRTUAL: { link_type = OSPF_LS_ROUTER; break; } default: { link_type = OSPF_LS_NETWORK; break; } } /* SPR#76812 -- Begin */ sptr_database_entry_for_vertex_W = ospf_find_LSA(sptr_area, link_id, 0x00000000L, link_type); /* SPR#76812 -- End */ if (sptr_database_entry_for_vertex_W == NULL) { continue; /* section 16.1, item (2)(b) page (152) */ } age = sptr_database_entry_for_vertex_W->advertisement.sptr_router->ls_header.age; age = net_to_host_short (age); if (age == OSPF_MAXIMUM_AGE) { continue; /* section 16.1, item (2)(b) page (152) */ } vertex = sptr_router_link_advertisement->ls_header.advertising_router; vertex = net_to_host_long (vertex); test_return_type = ospf_check_if_link_exists (&sptr_database_entry_for_vertex_W->advertisement, vertex, sptr_area); if (test_return_type == FAIL) { OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, link_id); OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer_1, vertex); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Link does not exist from %s back to %s (router link's advertising router)\r\n", print_buffer, print_buffer_1); continue; /* section 16.1, item (2)(b) page (152) */ } test_return_type = ospf_check_if_vertex_W_is_already_on_the_shortest_path_tree (sptr_area, link_id, link_type); if (test_return_type == PASS) { continue; /* section 16.1, item (2)(c) page (152) */ } cost_D = sptr_vertex_V->cost; tos0_metric = sptr_link->tos0_metric; tos0_metric = net_to_host_short (tos0_metric); if (tos0_metric == 0xFFFF) { cost_D = (ULONG) OSPF_LSInfinity; } else { cost_D += tos0_metric; } sptr_vertex_W = ospf_find_vertex_W_on_candidate_list (sptr_area->sptr_candidate, link_id, link_type /*#$-NOTE:note33-$#*/); if (sptr_vertex_W == NULL) /* section 16.1, item (2)(d), third bullet item, page (152) */ { sptr_vertex_W = (OSPF_SHORTEST_PATH_NODE *) table_malloc (1, sizeof (OSPF_SHORTEST_PATH_NODE)); if (sptr_vertex_W == NULL) { ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_SHORTEST_PATH_NODE"); continue; } memset (sptr_vertex_W, 0x00, sizeof (OSPF_SHORTEST_PATH_NODE)); sptr_vertex_W->vertex = sptr_link->link_id; /* if not PPP and virtual link, this is DR's address */ sptr_vertex_W->vertex = net_to_host_long (sptr_vertex_W->vertex); sptr_vertex_W->vertex_type = link_type; /*#$-NOTE:note 19-$#*/ sptr_vertex_W->sptr_database_entry = sptr_database_entry_for_vertex_W; sptr_vertex_W->cost = cost_D; OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "IN EXAMINE ROUTER LINK ADVERTISEMENTS: PARENT vertex_V:%lx type:%x cost:%d vertex_W:%lx type:%x cost:%d \r\n", sptr_vertex_V->vertex, sptr_vertex_V->vertex_type, sptr_vertex_V->cost, sptr_vertex_W->vertex, sptr_vertex_W->vertex_type, sptr_vertex_W->cost); ospf_set_intervening_router (sptr_vertex_V, sptr_vertex_W, sptr_area, sptr_link); sptr_vertex_W->sptr_next_hop = ospf_calculate_the_set_of_next_hops (sptr_vertex_W, sptr_vertex_V, sptr_link, sptr_area); if (sptr_area->sptr_candidate == NULL) { sptr_area->sptr_candidate = sptr_vertex_W; } else { ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_vertex_W, (OSPF_GENERIC_NODE *) sptr_area->sptr_candidate); } } else if (cost_D > sptr_vertex_W->cost) /* section 16.1, item (2)(d), first bullet item, page (152) */ { continue; } else if (cost_D == sptr_vertex_W->cost) /* section 16.1, item (2)(d), second bullet item, page (152) */ { ospf_set_intervening_router (sptr_vertex_V, sptr_vertex_W, sptr_area, sptr_link); sptr_next_hop = ospf_calculate_the_set_of_next_hops (sptr_vertex_W, sptr_vertex_V, sptr_link, sptr_area); if (sptr_vertex_W->sptr_next_hop == NULL) { sptr_vertex_W->sptr_next_hop = sptr_next_hop; } else if ( (sptr_next_hop != NULL) && (sptr_link->type == OSPF_ROUTER_LINK_TYPE_VIRTUAL) ) { /* do nothing */ /*#$-NOTE:note32-$#*/ } else if ( sptr_next_hop != NULL ) { ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_next_hop, (OSPF_GENERIC_NODE *) sptr_vertex_W->sptr_next_hop); } } else /* section 16.1, item (2)(d), third bullet item, page (152) */ { sptr_vertex_W->sptr_database_entry = sptr_database_entry_for_vertex_W; sptr_vertex_W->cost = cost_D; ospf_set_intervening_router (sptr_vertex_V, sptr_vertex_W, sptr_area, sptr_link); sptr_vertex_W->sptr_next_hop = ospf_calculate_the_set_of_next_hops (sptr_vertex_W, sptr_vertex_V, sptr_link, sptr_area); } } return;}/**************************************************************************************** ospf_examine_network_link_advertisement_for_vertex_V - examine the network lsa associated with the vertex** This routine will examine the network link state advertisement for the associated vertex.* This routine will examine the links associated with the network link advertisement and* add nodes to the shortest path node.** <sptr_network_link_advertisement> Advertisement OSPF is examining** <sptr_area> OSPF area** <sptr_vertex_V> Shortest path node for vertex on router OSPF is examining** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_examine_network_link_advertisement_for_vertex_V (OSPF_NETWORK_LINK_ADVERTISEMENT_HEADER *sptr_network_link_advertisement,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -