📄 ospf_show_routing_table.c
字号:
/* ospf_show_routing_table.c - OSPF show routing table *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------02g,11jun03,ram SPR#88965 Separate route table and LSDB hash parameters02f,27may03,agi Replaced rw_container by ospf_container02e,14may03,agi Changed RWOS semaphores to vxWorks semaphores02d,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements02c,16jan03,smr SPR 85736 fixed printf bug.02b,06jan03,ram SPR 85432 Changes to allow more OSPF external route processing02a,08oct02,agi Fixed compiler warnings01a,25apr02,jkw Added new show routines based on routing table*//*DESCRIPTIONospf_show_routing_table.c is used for displaying the routing table.This file is used whenever the routing table needs to be displayed.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//* prototypes */static void print_destination_id(ULONG destination_id);static void print_destination_next_hop(OSPF_NEXT_HOP_BLOCK *sptr_next_hop);static void print_destination_path_cost(ULONG path_cost);static void print_destination_type(enum OSPF_ROUTE_DESTINATION_TYPE destination_type);static void print_destination_path_type(enum OSPF_ROUTE_PATH_TYPE path_type);static void print_destination_area(OSPF_AREA_ENTRY *sptr_area);/* SPR 85432 -- Begin *//******************************************************************************** ospfShowRoutingTable - show routing table**/STATUS ospfShowRoutingTable() { OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node = NULL; OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry = NULL; OSPF_ROUTING_TABLE_NODE *sptr_display_route = NULL; OSPF_ROUTING_TABLE_NODE *sptr_display_route_output = NULL; OSPF_CONTAINER_ITERATOR iterator; ULONG index; enum OSPF_ROUTE_TABLE_TYPE table_type; OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospfShowRoutingTable\r\n"); printf("\n\n========================================================================================\r\n"); printf(" OSPF ROUTING TABLE"); printf("\n==========================================================================================\r\n"); printf("Dest ID Next Hop Cost Dest Type Path Type Area "); printf("\n==========================================================================================\r\n"); semTake (ospf_global_mutex, WAIT_FOREVER); /* SPR 85050 -- Begin */ /* SPR#76812 -- Begin */ for(table_type = OSPF_ROUTE_TABLE_NETWORK; table_type < OSPF_ROUTE_TABLE_MAX; table_type++) { for(index = 0x00000000L; index < OSPF_RT_HASH_TABLE_SIZE; index++) { for (sptr_routing_table_node = ospf.sptr_routing_table_head[table_type][index]; sptr_routing_table_node != NULL; sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link) { sptr_display_route = (OSPF_ROUTING_TABLE_NODE *) table_malloc (1, sizeof (OSPF_ROUTING_TABLE_NODE)); if (sptr_display_route != NULL) { memset(sptr_display_route,0x0,sizeof(OSPF_ROUTING_TABLE_NODE)); memcpy(sptr_display_route,sptr_routing_table_node,sizeof(OSPF_ROUTING_TABLE_NODE)); if (ospf_container_add_back (ospf.sptr_table_route_print_queue, sptr_display_route) == false) { table_free ((void *)sptr_display_route); sptr_display_route = NULL; } } } } } /* SPR#76812 -- End */ semGive (ospf_global_mutex); iterator = (OSPF_CONTAINER_ITERATOR)NULL; iterator = ospf_container_create_iterator (ospf.sptr_table_route_print_queue); if (iterator == (OSPF_CONTAINER_ITERATOR)NULL) { return ERROR; } ospf_container_goto_front (iterator); while(ospf_container_is_at_end (iterator) == false) { sptr_display_route_output = ospf_container_at (iterator); if(sptr_display_route_output == NULL) { ospf_container_next (iterator); continue; } else { ospf_container_remove (iterator); if (sptr_display_route_output->sptr_routing_table_entry != NULL) { sptr_routing_table_entry = sptr_display_route_output->sptr_routing_table_entry; print_destination_id(sptr_routing_table_entry->destination_id); print_destination_next_hop(sptr_routing_table_entry->sptr_next_hop); /* SPR 84718 */ if(sptr_routing_table_entry->path_type == OSPF_ROUTE_PATH_TYPE_2_EXTERNAL) { print_destination_path_cost(sptr_routing_table_entry->type2_cost); } else { print_destination_path_cost(sptr_routing_table_entry->path_cost); } print_destination_type(sptr_routing_table_entry->destination_type); print_destination_path_type(sptr_routing_table_entry->path_type); print_destination_area(sptr_routing_table_entry->sptr_area); } table_free ((void *)sptr_display_route_output); sptr_display_route_output = NULL; } } printf("==========================================================================================\r\n"); ospf_container_free_iterator (iterator); iterator = 0; return OK;}/* SPR 85432 -- End */static void print_destination_id(ULONG destination_id){ char print_buffer[PRINT_BUFFER_SIZE]; OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_id\r\n"); OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, destination_id); printf("%-17s", print_buffer); return;}static void print_destination_next_hop(OSPF_NEXT_HOP_BLOCK *sptr_next_hop){ char print_buffer[PRINT_BUFFER_SIZE]; OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_next_hop\r\n"); if (sptr_next_hop != NULL) { /* SPR 85736 Start */ OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, sptr_next_hop->next_hop_router); /* SPR 85736 End */ printf("%-17s", print_buffer); } return;}static void print_destination_path_cost(ULONG path_cost){ OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_path_cost\r\n"); printf("%-12ld", path_cost); return;}static void print_destination_type(enum OSPF_ROUTE_DESTINATION_TYPE destination_type){ OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_type\r\n"); switch (destination_type) { case OSPF_DESTINATION_TYPE_NETWORK: printf("NETWORK "); break; case OSPF_DESTINATION_TYPE_ASBR: printf("ASBR "); break; case OSPF_DESTINATION_TYPE_ABR: printf("ABR "); break; case OSPF_DESTINATION_TYPE_VIRTUAL: printf("VIRTUAL "); break; case OSPF_DESTINATION_TYPE_ASE: printf("EXTERNAL "); break; case OSPF_DESTINATION_TYPE_WILDCARD: break; } return;}static void print_destination_path_type(enum OSPF_ROUTE_PATH_TYPE path_type){ OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_path_type\r\n"); switch (path_type) { case OSPF_ROUTE_PATH_TYPE_INTRA: printf("INTRA "); break; case OSPF_ROUTE_PATH_TYPE_INTER: printf("INTER "); break; case OSPF_ROUTE_PATH_TYPE_1_EXTERNAL: printf("E1 "); break; case OSPF_ROUTE_PATH_TYPE_2_EXTERNAL: printf("E2 "); break; case OSPF_ROUTE_PATH_TYPE_WILDCARD: break; } return;}static void print_destination_area(OSPF_AREA_ENTRY *sptr_area){ char print_buffer[PRINT_BUFFER_SIZE]; OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering print_destination_area\r\n"); if (sptr_area != NULL) { OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, sptr_area->area_id); printf("%-15s\r\n", print_buffer); } return;}/* This function is to include the show routines when the project is built. This function is called by ospfInitialize*/void ospf_show_routing_stub(){ return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -