⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf_initialization.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
** ERRNO: N/A** NOMANUAL*/static void ospf_create_areas_based_on_configured_information (void){    ULONG number_of_areas;    OSPF_AREA_ENTRY *sptr_area;    OSPF_STUB_AREA_ENTRY *sptr_stub_area;    ULONG number_of_address_ranges;#if defined (__NSSA__)    OSPF_NSSA_AREA_ENTRY *sptr_nssa_area;#endif/*__NSSA__*/    enum OSPF_LS_TYPE ls_type;    ULONG index;    OSPF_LS_DATABASE_HEAD *sptr_ls_database_head;    OSPF_PRINTF_PROLOGUE (        OSPF_PROLOGUE_PRINTF,         "OSPF: Entering ospf_create_areas_based_on_configured_information\r\n");    for (number_of_areas = 0x00000000L;          number_of_areas < ospf.number_of_areas;          ++number_of_areas)                {        sptr_area = (OSPF_AREA_ENTRY *) table_malloc (1, sizeof (OSPF_AREA_ENTRY));        if ( sptr_area != NULL )                        {                        memset (sptr_area, 0x00, sizeof (OSPF_AREA_ENTRY));                        sptr_area->area_id = ospf.area[number_of_areas].config.area_id;#if !defined (__NSSA__)                        if (ospf.area[number_of_areas].config.external_routing_capability_enabled == FALSE)                                {                                sptr_area->flags._bit.stub = TRUE;                                sptr_area->stub_default_cost = ospf.area[number_of_areas].config.stub_default_cost;                                sptr_stub_area = (OSPF_STUB_AREA_ENTRY *) table_malloc (1, sizeof (OSPF_STUB_AREA_ENTRY));                    if (sptr_stub_area != NULL) /*#$-NOTE:note28-$#*/                                        {                                    memset (sptr_stub_area, 0x00, sizeof (OSPF_STUB_AREA_ENTRY));                    }                else                    {                    ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) sptr_area, "OSPF_STUB_AREA_ENTRY");                    return;                    }                    sptr_stub_area->sptr_area = sptr_area;                if (ospf.sptr_stub_area_list == NULL)                        {                    ospf.sptr_stub_area_list = sptr_stub_area;                    }                else                                {                            ospf_add_node_to_end_of_list( (OSPF_GENERIC_NODE *)sptr_stub_area,                            (OSPF_GENERIC_NODE *)ospf.sptr_stub_area_list );                    }                /* keep track the number of stub areas that have been configured */                ospf.number_of_stub_areas++;#if defined (__OSPF_MIB__)                /* tell MIB API to create an instance of area in ospfAreaTable */                ospf2Mapi_request ( (void *)sptr_area, ospfAreaCreateReqType);                /* tell MIB API to create an instance of stub in ospfStubTable */                ospf2Mapi_request ( (void *)sptr_area, ospfStubCreateReqType);#endif /* __OSPF_MIB__ */                                }#else /* __NSSA__ */            if ((ospf.area[number_of_areas].config.external_routing_capability_enabled == FALSE) && (ospf.area[number_of_areas].config.nssa_enabled == FALSE))                                {                /* It is a stub area */                sptr_area->flags._bit.stub = TRUE;                sptr_area->stub_default_cost = ospf.area[number_of_areas].config.stub_default_cost;                sptr_stub_area = (OSPF_STUB_AREA_ENTRY *) table_malloc (1, sizeof (OSPF_STUB_AREA_ENTRY));                if (sptr_stub_area != NULL) /*#$-NOTE:note28-$#*/                                        {                    memset (sptr_stub_area, 0x00, sizeof (OSPF_STUB_AREA_ENTRY));                    }                else                                        {                    ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) sptr_area, "OSPF_STUB_AREA_ENTRY");                    return;                    }                sptr_stub_area->sptr_area = sptr_area;                if (ospf.sptr_stub_area_list == NULL)                                        {                    ospf.sptr_stub_area_list = sptr_stub_area;                    }                else                                        {                    ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_stub_area, (OSPF_GENERIC_NODE *) ospf.sptr_stub_area_list);                    }                /* keep track the number of stub areas that have been configured */                ospf.number_of_stub_areas++;#if defined (__OSPF_MIB__)                /* tell MIB API to create an instance of area in ospfAreaTable */                ospf2Mapi_request ( (void *)sptr_area, ospfAreaCreateReqType);                /* tell MIB API to create an instance of stub in ospfStubTable */                ospf2Mapi_request ( (void *)sptr_area, ospfStubCreateReqType);#endif /* __OSPF_MIB__ */                    }                else if ((ospf.area[number_of_areas].config.external_routing_capability_enabled == FALSE) && (ospf.area[number_of_areas].config.nssa_enabled == TRUE)) /*Now it is an NSSA */                    {                    sptr_area->flags._bit.nssa = TRUE;                    if (ospf.nssa_enabled == FALSE)                                                {                        ospf.nssa_enabled = TRUE;                        }                    sptr_nssa_area = (OSPF_NSSA_AREA_ENTRY *) table_malloc (1, sizeof (OSPF_NSSA_AREA_ENTRY));                    if (sptr_nssa_area != NULL)                                                {                        memset (sptr_nssa_area, 0x00, sizeof (OSPF_NSSA_AREA_ENTRY));                        }                    else                                                {                        ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) sptr_area, "OSPF_NSSA_AREA_ENTRY");                        return;                        }                    sptr_nssa_area->sptr_area = sptr_area;                    if (ospf.sptr_nssa_area_list == NULL)                                                {                        ospf.sptr_nssa_area_list = sptr_nssa_area;                        }                    else                        {                        ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_nssa_area, (OSPF_GENERIC_NODE *) ospf.sptr_nssa_area_list);                                                }                    /* keep track the number of nssa areas that have been configured */                    ospf.number_of_nssa_areas++;#if defined (__OSPF_MIB__)                    /* tell MIB API to create an instance of area in ospfAreaTable */                    ospf2Mapi_request ( (void *)sptr_area, ospfAreaCreateReqType);                    /* tell MIB API to create an instance of stub in ospfStubTable */                    ospf2Mapi_request ( (void *)sptr_area, ospfStubCreateReqType);#endif /* __OSPF_MIB__ */                    }#endif /*__NSSA__*/                sptr_area->shortest_path_first_tree.vertex = ospf.router_id;                sptr_area->shortest_path_first_tree.vertex_type = OSPF_LS_ROUTER;                sptr_area->shortest_path_first_tree.intervening_router = 0x00000000L;                sptr_area->run_shortest_path_calculation = FALSE;                sptr_area->shortest_path_calculation_time_counter = 0x00000000L;                sptr_area->bring_up_virtual_links = FALSE;#if !defined (__NSSA__)                for (ls_type = OSPF_LS_ROUTER; ls_type <= OSPF_LS_AS_EXTERNAL; ++ls_type)                                                       /* for each type of advertisement */#else                for (ls_type = OSPF_LS_ROUTER; ls_type <= OSPF_LS_TYPE_7; ++ls_type)                                                    /* for each type of advertisement */#endif /*__NSSA__*/                            {#if defined (__NSSA__)                    if (ls_type == OSPF_LS_MULTICAST )                                                continue;#endif /*__NSSA__*/                    for (index = 0x00000000L, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[ls_type][index]); /* for each hash list */                                                index < OSPF_HASH_TABLE_SIZE; ++index, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[ls_type][index]))                        {                        sptr_ls_database_head->sptr_linear_database_entry = NULL;                        sptr_ls_database_head->sptr_avl_database_entry = NULL;                        sptr_ls_database_head->rerun = FALSE;                        }                    }                    /* opaque lsa intialize opaque ls database head structure jkw */#if defined (__OPAQUE_LSA__)                for (ls_type = TYPE_9_LSA; ls_type <= TYPE_11_LSA; ++ls_type)                                                   /* for each type of advertisement */                    {                    for (index = 0x00000000L, sptr_ls_database_head = &(sptr_area->opaque_ls_database_hash_table[ls_type][index]);   /* for each hash list */                         index < OSPF_HASH_TABLE_SIZE;                          ++index, sptr_ls_database_head = &(sptr_area->opaque_ls_database_hash_table[ls_type][index]))                        {                        sptr_ls_database_head->sptr_linear_database_entry = NULL;                        sptr_ls_database_head->sptr_avl_database_entry = NULL;                        sptr_ls_database_head->rerun = FALSE;                        }                    }                 /* Check for type 11 lsdb */                 for (index = 0x00000000L, sptr_ls_database_head = &(ospf.type_11_database_hash_table[LS_TYPE_11_LSA][index]);   /* for each hash list */                      index < OSPF_HASH_TABLE_SIZE;                       ++index, sptr_ls_database_head = &(ospf.type_11_database_hash_table[LS_TYPE_11_LSA][index]))                    {                    sptr_ls_database_head->sptr_avl_database_entry = NULL;                    sptr_ls_database_head->sptr_linear_database_entry = NULL;                    sptr_ls_database_head->rerun = FALSE;                    }                    sptr_area->mib_number_of_type10_lsa = 0x00000000L;                    sptr_area->mib_type10_checksum_sum = 0x00000000L;#endif /* __OPAQUE_LSA__ */				/* SPR 78381 Set the ospfAreaSummary flag */                /* SPR#86319 - the variable inject_summary_lsa_into_stub_area controls                  * the import of summary LSAs into stub areas.  It has no effect on other                  * areas.                 */				sptr_area->inject_summary_lsa_into_stub_area = ospf.area[number_of_areas].config.inject_summary_lsa_into_stub_area;                sptr_area->mib_number_of_link_state_advertisements = 0x00000000L;                sptr_area->mib_checksum_sum = 0x00000000L;                if ((ospf.sptr_backbone_area == NULL) &&                     (sptr_area->area_id == OSPF_BACKBONE))                    {                    semTake (ospf_config_mutex, (UINT)WAIT_FOREVER);                    ospf.sptr_backbone_area = sptr_area;                    semGive (ospf_config_mutex);                    }                if (ospf.sptr_area_list == NULL)                    {                    semTake (ospf_config_mutex, (UINT)WAIT_FOREVER);                    ospf.sptr_area_list = sptr_area;                    semGive (ospf_config_mutex);                    }                else                    {                    semTake (ospf_config_mutex, (UINT)WAIT_FOREVER);                                        ospf_add_node_to_end_of_list (                        (OSPF_GENERIC_NODE *) sptr_area,                         (OSPF_GENERIC_NODE *) ospf.sptr_area_list);                                        semGive (ospf_config_mutex);                    }#if defined (__OSPF_MIB__)                /* create a good old ospf area in the ospfAreaTable only if this is not a                * stub. For stub area, an instance should have been created in the                * ospfAreaTable and ospfStubTable in the above                */                if ( ospf.area[number_of_areas].config.external_routing_capability_enabled == TRUE )                                        {                    /* tell MIB API to create an instance of area in ospfAreaTable */                    ospf2Mapi_request ( (void *)sptr_area, ospfAreaCreateReqType);                    }#endif /* __OSPF_MIB__*/                /* RFC 2178 G.3. Now that the area has been created and configured, setup the area                 * address range (if any)                 */                for (number_of_address_ranges = 0x00000000L; number_of_address_ranges < ospf.number_of_area_address_ranges;                                        ++number_of_address_ranges)                    {                    ospf_set_address_ranges_for_the_area (sptr_area, number_of_address_ranges);                    }                }            else                                {                ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_AREA_ENTRY");                }                        }        return;}/*************************************************************************** ospf_set_address_ranges_for_the_area - set the area address ranges for an area** This routine sets the area address ranges* for areas based on configuration.** <sptr_area> OSPF area** <address_range_number> Address range identifier** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_set_address_ranges_for_the_area (OSPF_AREA_ENTRY *sptr_area,ULONG address_range_number){        OSPF_ADDRESS_RANGE_LIST_ENTRY *area_address_ranges;        OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_set_address_ranges_for_the_area\r\n");        /* Virtual link update */        if (sptr_area->area_id == OSPF_STARTING_AREA_ID_FOR_VIRTUAL_INTERFACE)                {            area_address_ranges = (OSPF_ADDRESS_RANGE_LIST_ENTRY *) table_malloc (1, sizeof (OSPF_ADDRESS_RANGE_LIST_ENTRY));                if (area_address_ranges != NULL)                        {                memset (area_address_ranges, 0x00, sizeof (OSPF_ADDRESS_RANGE_LIST_ENTRY));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -