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

📄 ospf_dynamic_config.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
** <sptr_area> OSPF area** <delete_stub> Boolean to delete stub or not** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_reinit_area( OSPF_AREA_ENTRY *sptr_area, enum BOOLEAN delete_stub ){    if ( sptr_area == NULL )        return ERROR;    /* reinitialize all the area parameters */    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;    sptr_area->mib_number_of_type10_lsa = 0x00000000L;    sptr_area->mib_type10_checksum_sum = 0x00000000L;    /* clean up all allocated memory associated with the given area */    ospf_dynamic_cleanup_area( sptr_area );    /* explicitly reintialize the hash table list for this area */    ospf_dynamic_init_area_hash_list( sptr_area );    if ( delete_stub == TRUE )    {        OSPF_STUB_AREA_ENTRY *sptr_stub_area;        enum BOOLEAN found_stub;        found_stub = FALSE;        /* check if this was a stub area */        for ( sptr_stub_area = ospf.sptr_stub_area_list; sptr_stub_area != NULL;              sptr_stub_area = sptr_stub_area->sptr_forward_link )        {            if ( sptr_stub_area->sptr_area->area_id == sptr_area->area_id )            {                found_stub = TRUE;                ospf_remove_node_from_list(                                         (OSPF_GENERIC_NODE **)&ospf.sptr_stub_area_list,                                         (OSPF_GENERIC_NODE *)sptr_stub_area);                table_free( (void *)sptr_stub_area );                /* tell 'em that we have one less stub area configured */                ospf.number_of_stub_areas--;                if ( ospf.number_of_stub_areas == 0 )                    ospf.sptr_stub_area_list = NULL;                break;            }        }#if defined(__NSSA__)        if ( found_stub == FALSE )        {            OSPF_NSSA_AREA_ENTRY *sptr_nssa_area;            /* can't find it in the stub area list, try the nssa list */            for ( sptr_nssa_area = ospf.sptr_nssa_area_list; sptr_nssa_area != NULL;                  sptr_nssa_area = sptr_nssa_area->sptr_forward_link )            {                if ( sptr_nssa_area->sptr_area->area_id == sptr_area->area_id )                {                    found_stub = TRUE;                    ospf_remove_node_from_list(                                          (OSPF_GENERIC_NODE **)&ospf.sptr_nssa_area_list,                                          (OSPF_GENERIC_NODE *)sptr_nssa_area);                    table_free( (void *)sptr_nssa_area );                    /* tell 'em that we have one less nssa area configured */                    ospf.number_of_nssa_areas--;                    if ( ospf.number_of_nssa_areas == 0 )                        ospf.sptr_nssa_area_list = NULL;                    break;                }            }        }#endif /* __NSSA__ */        return OK;    }    /* if we are here, area is now configured as stub/nssa. Need to create a new     * stub/nssa instance     */    if (sptr_area->flags._bit.stub == TRUE)    {        OSPF_STUB_AREA_ENTRY *sptr_stub_area;        int size;        /* check if the stub area already exist */        for ( sptr_stub_area = ospf.sptr_stub_area_list; sptr_stub_area != NULL;              sptr_stub_area = sptr_stub_area->sptr_forward_link )        {            if ( sptr_stub_area->sptr_area->area_id == sptr_area->area_id )                break;        }        if ( sptr_stub_area == NULL )        {            /* stub not found, create a new one */            size = sizeof(OSPF_STUB_AREA_ENTRY);            sptr_stub_area = (OSPF_STUB_AREA_ENTRY *) table_malloc (1, size);            if ( sptr_stub_area == NULL )            {                OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                                   "ospf_dynamic_create_area:stub create failed!\n");                return ERROR;            }        }        memset (sptr_stub_area, 0x00, sizeof (OSPF_STUB_AREA_ENTRY));        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 configured */        ospf.number_of_stub_areas++;    }#if defined(__NSSA__)    else if (sptr_area->flags._bit.nssa == TRUE )    {        OSPF_NSSA_AREA_ENTRY *sptr_nssa_area;        int size;        /* check if the stub area already exist */        for ( sptr_nssa_area = ospf.sptr_nssa_area_list; sptr_nssa_area != NULL;              sptr_nssa_area = sptr_nssa_area->sptr_forward_link )        {            if ( sptr_nssa_area->sptr_area->area_id == sptr_area->area_id )                break;        }        if ( sptr_nssa_area == NULL )        {            /* nssa not found, create a new one */            size = sizeof(OSPF_NSSA_AREA_ENTRY);            sptr_nssa_area = (OSPF_NSSA_AREA_ENTRY *)table_malloc(1, size);            if ( sptr_nssa_area == NULL )            {                OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                                   "ospf_dynamic_create_area:nssa create failed!\n");                return ERROR;            }        }        memset (sptr_nssa_area, 0x00, sizeof (OSPF_NSSA_AREA_ENTRY));        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 stub areas configured */        ospf.number_of_nssa_areas++;    }#endif /* __NSSA__ */    /* check for are border status */    return OK;}/***************************************************************************************** ospf_dynamic_destroy_area - dynamically destroy an OSPF Area** This routine dynamically destroy an OSPF Area at runtime. All interface connects to* this area will be destroyed. If this area is also a transit area, all virtual links* that traverse through this area will also be brought down** <sptr_area> OSPF area** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_destroy_area( OSPF_AREA_ENTRY *sptr_area ){    if ( sptr_area == NULL )        return ERROR;    /* if area is configured as stub, free the stub entry */    if ( sptr_area->flags._bit.stub == TRUE )    {        OSPF_STUB_AREA_ENTRY *sptr_stub_area;        /* look for the stub entry */        for ( sptr_stub_area = ospf.sptr_stub_area_list; sptr_stub_area != NULL;              sptr_stub_area = sptr_stub_area->sptr_forward_link )        {            if ( sptr_stub_area->sptr_area != NULL )            {                if ( sptr_stub_area->sptr_area->area_id == sptr_area->area_id )                {                    ospf_remove_node_from_list(                                         (OSPF_GENERIC_NODE **)&ospf.sptr_stub_area_list,                                         (OSPF_GENERIC_NODE *)sptr_stub_area);                    table_free( (void *)sptr_stub_area );                    /* tell 'em that we have one less stub area configured */                    ospf.number_of_stub_areas--;                    if ( ospf.number_of_stub_areas == 0 )                        ospf.sptr_stub_area_list = NULL;                    break;                }            }        }    }#if defined(__NSSA__)    /* if area is configured as nssa, free the nssa entry */    else if ( sptr_area->flags._bit.nssa == TRUE )    {        OSPF_NSSA_AREA_ENTRY *sptr_nssa_area;        /* look for the nssa entry */        for ( sptr_nssa_area = ospf.sptr_nssa_area_list; sptr_nssa_area != NULL;                  sptr_nssa_area = sptr_nssa_area->sptr_forward_link )        {            if ( sptr_nssa_area->sptr_area != NULL )            {                if ( sptr_nssa_area->sptr_area->area_id == sptr_area->area_id )                {                    ospf_remove_node_from_list(                                          (OSPF_GENERIC_NODE **)&ospf.sptr_nssa_area_list,                                          (OSPF_GENERIC_NODE *)sptr_nssa_area);                    table_free( (void *)sptr_nssa_area );                    /* tell 'em that we have one less nssa area configured */                    ospf.number_of_nssa_areas--;                    if ( ospf.number_of_nssa_areas == 0 )                        ospf.sptr_nssa_area_list = NULL;                    break;                }            }        }    }#endif /* __NSSA__ */    /* free all the memory associated with this area instance */    ospf_free_all_the_associated_area_pointers(sptr_area);    /* if the area that is deleted is the backbone ospf area, reset the pointer to     * the backbone area     */    if ( sptr_area->area_id == OSPF_BACKBONE )        ospf.sptr_backbone_area = NULL;    /* tell 'em that we have one less area configured */    ospf.number_of_areas--;    /* remove the area node from the area list */    /* SPR#76812 */    semTake (ospf_config_mutex, WAIT_FOREVER);    ospf_remove_node_from_list( (OSPF_GENERIC_NODE **)&(ospf.sptr_area_list),                                (OSPF_GENERIC_NODE *)sptr_area );	semGive (ospf_config_mutex);    if ( ospf.number_of_areas == 0 )        ospf.sptr_area_list = NULL;    /* free the memory allocated for the area */    table_free( (void *)sptr_area );    sptr_area = NULL;    return OK;}/**************************************************************************************** ospf_dynamic_config_metric - dynamically reconfigure the interface metric** This routine dynamically reconfigure the interface metric. Regenerate the router* link state advertisement so that the metric changes can be populated to others.**<sptr_interface> OSPF interface** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_config_metric( OSPF_INTERFACE *sptr_interface ){    if ( sptr_interface == NULL )        return ERROR;    /* make sure we have a valid area */    if ( sptr_interface->sptr_area == NULL )        return ERROR;    /* force the router LSA for the area to which the interface connects to be rebuilt */    sptr_interface->sptr_area->build_router = TRUE;    ospf_generate_network_and_router_link_state_advertisements( sptr_interface );    return OK;}/***************************************************************************************** ospf_dynamic_reset_interface - dynamically reset the interface** This routine dynamically reset the interface. The interface will be brought down. All* timers and counters associated with the interface will be reset and pending* acknowledgement (if any) will be freed.**<sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_dynamic_reset_interface( OSPF_INTERFACE *sptr_interface ){    /* SPR 84478, 84485, 84486 -- Begin */    enum BOOLEAN I_was_an_area_border_router;    enum BOOLEAN I_am_an_area_border_router;    if ( sptr_interface == NULL )        return;    /* before bringing down the interface, flush the self-originated network-LSA     * if necessary     */    ospf_flush_network_link_advertisement( sptr_interface );    /* remember our current area border router status before bringing down the

⌨️ 快捷键说明

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