?? ospf_dijkstra.c
字號(hào):
link_state_id_for_vertex_V = sptr_vertex_V->sptr_database_entry->advertisement.sptr_network->ls_header.id; link_state_id_for_vertex_V = net_to_host_long (link_state_id_for_vertex_V); address_mask_for_vertex_V = sptr_vertex_V->sptr_database_entry->advertisement.sptr_network->network_mask; address_mask_for_vertex_V = net_to_host_long (address_mask_for_vertex_V); destination_id_for_vertex_V = link_state_id_for_vertex_V & address_mask_for_vertex_V; sptr_routing_table_entry = ospf_find_routing_table_entry (destination_id_for_vertex_V, OSPF_DESTINATION_TYPE_NETWORK, OSPF_ROUTE_PATH_TYPE_WILDCARD, NULL); /* NEWRT LOOKUP */ if (sptr_routing_table_entry != NULL ) /* sptr_routing_table_node is not NULL */ { if ((sptr_vertex_V->cost <= sptr_routing_table_entry->path_cost) && (link_state_id_for_vertex_V > sptr_routing_table_entry->link_state_id) /* check this condiion in RFC ### JACK ??? */ ) { sptr_routing_table_entry->destination_id = destination_id_for_vertex_V; sptr_routing_table_entry->address_mask = address_mask_for_vertex_V; sptr_routing_table_entry->optional_capabilities = sptr_vertex_V->sptr_database_entry->advertisement.sptr_network->ls_header.options; sptr_routing_table_entry->sptr_area = sptr_area; sptr_routing_table_entry->path_cost = sptr_vertex_V->cost; sptr_routing_table_entry->type2_cost = 0x00; sptr_routing_table_entry->sptr_link_state_origin = &sptr_vertex_V->sptr_database_entry->advertisement; sptr_routing_table_entry->link_state_id = net_to_host_long ( sptr_vertex_V->sptr_database_entry->advertisement.sptr_router->ls_header.id); sptr_routing_table_entry->link_type = sptr_vertex_V->sptr_database_entry->advertisement.sptr_router->ls_header.type; if (sptr_routing_table_entry->sptr_next_hop != NULL) { ospf_free_entire_list ((OSPF_GENERIC_NODE *) sptr_routing_table_entry->sptr_next_hop); /* Jack July 7/31 ### inher rt_entry not mallocked */ } sptr_routing_table_entry->sptr_next_hop = ospf_inherit_the_set_of_next_hops_from_node_X (sptr_vertex_V->sptr_next_hop); } } else { ospf_add_fields_to_ospf_route_entry (destination_id_for_vertex_V, address_mask_for_vertex_V, sptr_vertex_V, sptr_area, OSPF_DESTINATION_TYPE_NETWORK); } return;}/**************************************************************************************** ospf_set_intervening_router - set intervening router for shortest path node** This routine will set the intervening router for the shortest path node.** <sptr_vertex_V> Shortest path node parent** <sptr_vertex_W> Shortest path node for intervening router** <sptr_area> OSPF area** <sptr_link> Link of lsa** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_set_intervening_router (OSPF_SHORTEST_PATH_NODE *sptr_vertex_V, OSPF_SHORTEST_PATH_NODE *sptr_vertex_W, OSPF_AREA_ENTRY* sptr_area, OSPF_ROUTER_LINK_PIECE *sptr_link){ OSPF_INTERFACE *sptr_interface = NULL; OSPF_INTERFACE *sptr_next_interface = NULL; OSPF_INTERFACE_NODE *sptr_virtual_interface_node =NULL; OSPF_NEIGHBOR *sptr_neighbor = NULL; OSPF_NEIGHBOR *sptr_next_neighbor = NULL; OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_BR =NULL; ULONG area_id =0; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_set_intervening_router\r\n"); area_id = 0x00000000L; if ( sptr_area != NULL) { area_id = sptr_area->area_id; } OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "----->>>>>FUNCTION ospf_set_intervening_router Vertex_V:%lx vertex_Vs cost:%d vertex_Vs intervening router:%lx vertex_V type:%x VertexW:%lx Vertex_Wcost:%d vertex_W type:%x, area_id:%lx\r\n", sptr_vertex_V->vertex, sptr_vertex_V->cost, sptr_vertex_V->intervening_router, sptr_vertex_V->vertex_type, sptr_vertex_W->vertex, sptr_vertex_W->cost, sptr_vertex_W->vertex_type, area_id ); /* SPR 85572 -- Begin */ sptr_vertex_W->intervening_router = 0; /* SPR 85572 -- End */ PARAMETER_NOT_USED (sptr_link); if (sptr_vertex_V->intervening_router != 0x00000000L ) { sptr_vertex_W->intervening_router = sptr_vertex_V->intervening_router; } else if ((sptr_vertex_V->vertex != ospf.router_id) && (sptr_vertex_V->sptr_database_entry != NULL) && (sptr_vertex_V->sptr_database_entry->advertisement.sptr_router->ls_header.type == OSPF_LS_ROUTER) ) { /* * if directly connected, return */ for (sptr_interface = sptr_area->sptr_interfaces; sptr_interface != NULL; sptr_interface = sptr_next_interface) { sptr_next_interface = sptr_interface->sptr_forward_link; if (sptr_interface->area_id == sptr_area->area_id) { if (sptr_interface->type == OSPF_VIRTUAL_LINK ) { continue; } for (sptr_neighbor = sptr_interface->sptr_neighbor; sptr_neighbor != NULL; sptr_neighbor = sptr_next_neighbor) { sptr_next_neighbor = sptr_neighbor->sptr_forward_link; if ( (sptr_neighbor->address == sptr_vertex_W->vertex) || (sptr_vertex_W->vertex == sptr_interface->address )) /* directly attached OR myself */ { sptr_vertex_W->intervening_router = 0x00000000L; /* directly connected */ return; } } } } sptr_vertex_W->intervening_router = sptr_vertex_V->vertex; } else if (sptr_vertex_V->vertex == ospf.router_id) { for ( sptr_virtual_interface_node = ospf.sptr_configured_virtual_links; sptr_virtual_interface_node != NULL; /* Set intervening router for virtual links */ sptr_virtual_interface_node = sptr_virtual_interface_node->sptr_forward_link) { sptr_interface = sptr_virtual_interface_node->sptr_interface; if (sptr_interface != NULL) { if (sptr_interface->sptr_neighbor !=NULL) { if (sptr_interface->sptr_neighbor->id == sptr_vertex_W->vertex) { sptr_routing_table_entry_for_BR = ospf_find_routing_table_entry (sptr_vertex_W->vertex, OSPF_DESTINATION_TYPE_ABR, OSPF_ROUTE_PATH_TYPE_WILDCARD, sptr_area); if (sptr_routing_table_entry_for_BR != NULL && sptr_routing_table_entry_for_BR->sptr_next_hop != NULL) { sptr_vertex_W->intervening_router = sptr_routing_table_entry_for_BR->sptr_next_hop->next_hop_router; } else { sptr_vertex_W->intervening_router = sptr_interface->sptr_neighbor->id; /*#$-NOTE:note30-$#*/ } } } } } }#if defined (__UNNUMBERED_LINK__) else { /* dsk: Fix for PNE1.0 ping failure across chain of OSPF routers connected by ethernets: This code is reachable not only for unnumbered links but also if the following are true: the vertexV is of type broadcast the vertexV is directly connected to this router this router is designated router the vertexV's IP address does not match the router ID (only one of the interfaces can match the router ID. In such case, there is no intervening router to reach the other end of the vertex. Verify if the vertex is truly unnumberd and Only set sptr_vertex_W->intervening_router to the local IP address for unnumbered links */ /* dsk SPR: 84284: find if the vertex is directly attached to this router and if it is truly unnumbered link */ for (sptr_interface = sptr_area->sptr_interfaces; sptr_interface != NULL; sptr_interface = sptr_next_interface) { sptr_next_interface = sptr_interface->sptr_forward_link; if (sptr_interface->address == sptr_vertex_V->vertex) { /* Found local interface: vertex is directly attached to this router */ break; } } /* for */ if ((sptr_interface!= NULL) && (sptr_interface->address == sptr_vertex_V->vertex)) /* vertex is directly connected */ { if ((sptr_interface->address == 0x00000000L) && (sptr_interface->type == OSPF_POINT_TO_POINT)) { /* interface is unnumbered link */ sptr_vertex_W->intervening_router = sptr_vertex_V->vertex; } } /* dsk SPR 84284: end of fix */ }#endif /* __UNNUMBERED_LINK__ */ OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "---------->>>>>>>>>>FUNCTION ospf_set_intervening_router AFTTER SET: VERTEX_W:%lx Ws intervening router:%lx \r\n", sptr_vertex_W->vertex, sptr_vertex_W->intervening_router); return; }/**************************************************************************************** ospf_set_next_hop_for_abr_or_asbr - set next hop for area border router or autonomous system boundary router** This routine will set the next hop for the area border router or the autonomous* system boundary router.** <sptr_routing_table_entry> Routing table entry for ABR or ASBR** <sptr_vertex_W> Shortest path node for intervening router** <sptr_area> OSPF area** <sptr_vertex_V> Vertex that is being examined** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static enum TEST ospf_set_next_hop_for_abr_or_asbr (OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry, OSPF_AREA_ENTRY *sptr_area, OSPF_SHORTEST_PATH_NODE *sptr_vertex_V){ OSPF_INTERFACE *sptr_interface = NULL; OSPF_INTERFACE *sptr_next_interface = NULL; OSPF_NEIGHBOR *sptr_neighbor = NULL; OSPF_NEIGHBOR *sptr_next_neighbor = NULL; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_set_next_hop_for_abr_or_asbr\r\n"); if (sptr_routing_table_entry->sptr_next_hop != NULL) { ospf_free_entire_list ((OSPF_GENERIC_NODE *) sptr_routing_table_entry->sptr_next_hop); /* Jack July 7/31 ### inher rt_entry not mallocked */ } sptr_routing_table_entry->sptr_next_hop = ospf_inherit_the_set_of_next_hops_from_node_X (sptr_vertex_V->sptr_next_hop); if (sptr_routing_table_entry->sptr_next_hop != NULL && sptr_routing_table_entry->sptr_next_hop->next_hop_router != 0x00000000L) { return (PASS); } 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->area_id == sptr_area->area_id) { if (sptr_interface->type == OSPF_VIRTUAL_LINK) { continue; } for (sptr_neighbor = sptr_interface->sptr_neighbor; sptr_neighbor != NULL; sptr_neighbor = sptr_next_neighbor) { sptr_next_neighbor = sptr_neighbor->sptr_forward_link; if (sptr_neighbor->id == sptr_vertex_V->vertex) { if (sptr_routing_table_entry->sptr_next_hop == NULL) { sptr_routing_table_entry->sptr_next_hop = (OSPF_NEXT_HOP_BLOCK *) table_malloc (1, sizeof (OSPF_NEXT_HOP_BLOCK)); } if (sptr_routing_table_entry->sptr_next_hop == NULL) { ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_NEXT_HOP_BLOCK"); return (FAIL); } memset (sptr_routing_table_entry->sptr_next_hop, 0x00, sizeof (OSPF_NEXT_HOP_BLOCK)); if (sptr_vertex_V->cost != sptr_interface->cost) { /* * Parallel interfaces to same neighbor, found one but * with worse cost than the one used for best path, * keep looking for the interface that connects to the * neighbor sptr_vertex_V with cost as considered for * SPF */ continue; } sptr_routing_table_entry->sptr_next_hop->next_hop_router = sptr_neighbor->address;#if defined (__UNNUMBERED_LINK__) if (sptr_interface->address == 0x00000000) /* unnumbered link */ { sptr_routing_table_entry->sptr_next_hop->outgoing_router_interface = sptr_interface->port_number; } else { sptr_routing_table_entry->sptr_next_hop->outgoing_router_interface = sptr_interface->address; }#else /* __UNNUMBERED_LINK__ */ sptr_routing_table_entry->sptr_next_hop->outgoing_router_interface = sptr_interface->address;#endif /* __UNNUMBERED_LINK__ */ return (PASS); } } } } if (sptr_routing_table_entry->sptr_next_hop != NULL ) { ospf_free_entire_list ( (OSPF_GENERIC_NODE *) sptr_routing_table_entry->sptr_next_hop); } return (FAIL);}/**************************************************************************************** ospf_add_fields_to_ospf_route_entry - add fields to ospf route entry** This routine will create a new routing table entry for the routing* table. It will assign the values for the new routing table entry* and add it to the routing table.** <destination_id_for_vertex_V> New destination for route** <address_mask_for_vertex_V> New address mask for route** <sptr_vertex_V> Shortest path node associated with route** <sptr_area> OSPF area** <ospf_route_destination_type> Destination type of route** RETURNS: OSPF_ROUTING_TABLE_NODE * or NULL** ERRNO: N/A** NOMANUAL*/static OSPF_ROUTING_TABLE_NODE* ospf_add_fields_to_ospf_route_entry (ULONG destination_id_for_vertex_V, ULONG address_mask_for_vertex
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -