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

📄 ospf_initialization.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
{        OSPF_HOSTS *sptr_host_entry;#if !defined (__OSPF_MIB__)                PARAMETER_NOT_USED(dynamic);#endif /* __OSPF_MIB__ */        sptr_host_entry = (OSPF_HOSTS *) table_malloc (1, sizeof (OSPF_HOSTS));        if (sptr_host_entry == NULL)                        {                        ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_HOST_TABLE_ENTRY");                        return (FAIL);                        }        sptr_host_entry->sptr_forward_link = NULL;        sptr_host_entry->sptr_backward_link = NULL;        sptr_host_entry->interface_address = sptr_interface->address;                sptr_host_entry->type_of_service = 0;        sptr_host_entry->cost = sptr_interface->cost;        sptr_host_entry->status = TRUE;        sptr_host_entry->area_id = sptr_interface->sptr_area->area_id;        if (ospf.sptr_host_list == NULL)                        {            ospf.sptr_host_list = sptr_host_entry;                        }        else                        {            ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_host_entry, (OSPF_GENERIC_NODE *) ospf.sptr_host_list);                        }#if defined(__OSPF_MIB__)    if ( dynamic == FALSE )                {        /* this is a statically configured host interface, tell MIB API to create an         * instance of host entry in ospfHostTable         */            ospf2Mapi_request( (void *)sptr_interface, ospfHostCreateReqType );                }#endif /*__OSPF_MIB__*/        return (PASS);}/*************************************************************************** ospf_add_entry_to_virtual_link_list - add virtual interface to virtual interface list** This routine adds the virutal interface to the virtual interface list** <sptr_interface> OSPF interface** <dynamic> Boolean for dynamically configured or not** RETURNS: PASS or FAIL** ERRNO: N/A** NOMANUAL*/enum TEST ospf_add_entry_to_virtual_link_list (OSPF_INTERFACE *sptr_interface, BOOL dynamic){    OSPF_INTERFACE_NODE *sptr_interface_node;    int node_size;#if !defined (__OSPF_MIB__)                PARAMETER_NOT_USED(dynamic);#endif /* __OSPF_MIB__ */        node_size = sizeof(OSPF_INTERFACE_NODE);    sptr_interface_node = (OSPF_INTERFACE_NODE*) table_malloc (1, node_size);    if (sptr_interface_node == NULL )                {        ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_INTERFACE_ENTRY");        return (FAIL);                }    sptr_interface_node->sptr_interface = sptr_interface;    sptr_interface_node->sptr_forward_link = NULL;    sptr_interface_node->sptr_backward_link = NULL;    ospf.number_of_virtual_links++;    if (ospf.sptr_configured_virtual_links == NULL)                {        ospf.sptr_configured_virtual_links = sptr_interface_node;                }    else                {        ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_interface_node , (OSPF_GENERIC_NODE *) ospf.sptr_configured_virtual_links);                }#if defined (__OSPF_MIB__)    if ( dynamic == FALSE )                {        /* this is a statically configured virtual interface. Tell MIB API to create an         * instance of virtual interface in ospfVirtIfTable         */        ospf2Mapi_request ((void *)sptr_interface, ospfVirtIfCreateReq);                }#endif /*__OSPF_MIB__*/    return (PASS);}/*************************************************************************** ospf_initialize_router - calls functions to initialize router** This routine calls the appropriate functions to* intialize the OSPF router.  This routine will* initializes the sockets for input and output.** <clock_ticks_per_second> Ticks per second** RETURNS: PASS or FAIL** ERRNO: N/A** NOMANUAL*/enum TEST ospf_initialize_router     (    ULONG clock_ticks_per_second    )    {    OSPF_PRINTF_DEBUG (        OSPF_DEBUG_PRINTF,         "OSPF: Entering ospf_initialize_router\r\n");    if (ospf.protocol_enabled == FALSE)        {        printf("ospf_initialize_router: ERROR: ");        printf("OSPF protocol is not enabled, exiting\n");        return (FAIL);        }#if defined (__OSPF_VIRTUAL_STACK__)    /* Initialize support for virtual stacks. */    if (ospfVirtualStackLibInit() == ERROR)        {        printf ("ospfInitialize: unable to initialize ospf virtual stack support.\n");        return (FAIL);        }    /* set the startup task to create the ospf management stack */    if (ospfVirtualStackCreate (&mgmtStackId) == ERROR)        {        printf ("ospf_initialize_router:failed to setup stack0.\n");        return (FAIL);        }    /* Start the initial ("management") ospf virtual stack. */        ospfVirtualStackInit (mgmtStackId);#endif /* __OSPF_VIRTUAL_STACK__ */    if (ospf_raw_socket_init() == FAIL)        {        printf("ospf_initialize_router: failed to initialize raw socket.\n");#if defined(__OSPF_VIRTUAL_STACK__)        (void)ospfVirtualStackDelete (mgmtStackId);#endif /* __OSPF_VIRTUAL_STACK__ */        return (FAIL);        }#if defined(__OSPF_MIB__)    if ( ospf2Mapi_proto_register() == ERROR )        {        printf("ospf_initialize_router:failed to register OSPF to mib api.\n");#if defined(__OSPF_VIRTUAL_STACK__)        (void)ospfVirtualStackDelete (mgmtStackId);#endif /* __OSPF_VIRTUAL_STACK__ */        /* close the raw socket */        close( ipSock );        return FAIL;        }    /* query MIB API for any previously saved OSPF configuration */    if ( ospf2Mapi_query_config ( &readStaticConfig ) == ERROR )       {        printf("ospf_initialize_router:failed to retrieve ospf configuration.\n");        /* de-register ourself from MIB API */        ospf2Mapi_proto_deregister();#if defined(__OSPF_VIRTUAL_STACK__)        (void)ospfVirtualStackDelete(mgmtStackId);#endif /* __OSPF_VIRTUAL_STACK__ */        /* close the raw socket */        close( ipSock );        return FAIL;        }#else    /* if MIB API is not included, always read static configuration */    readStaticConfig = TRUE;#endif /* __OSPF_MIB__ */    ospf_initialize_protocol (clock_ticks_per_second);    ospf_register_with_ip (NULL, NULL);    /* if ospf is configured as autonomous system border router, walk the kernel routing     * table to retrieve any external routes that may need to be exported     * This MUST be done after all initialization is complete.     */    if ( ospf.autonomous_system_border_router == TRUE )        {        ospf_sysctl_rtableWalk(                   ospf.autonomous_system_border_router,                   ospf.ospf_redistribution_configuration.redistribute_all_static,                   ospf.ospf_redistribution_configuration.redistribute_all_rip,                   ospf.ospf_redistribution_configuration.redistribute_all_bgp,                   ospf.ospf_redistribution_configuration.redistribute_ip_default_route);        }#if defined (__KY_DRIVER__)	ospf_ky_stub();#endif /* __KY_DRIVER__ */#if defined (__OPAQUE_LSA__)	ospf_opaque_stub();#endif /* __OPAQUE_LSA__ */    return PASS;    }/*************************************************************************** ospf_initialize_protocol - initializes data structures for OSPF** This routine calls the appropriate functions to* create all the data structures used for OSPF.** <clock_ticks_per_second> Ticks per second** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_initialize_protocol (ULONG clock_ticks_per_second)    {    enum BOOLEAN I_am_an_area_border_router;    OSPF_AREA_ENTRY *sptr_area = NULL;    OSPF_INTERFACE *sptr_interface;    OSPF_INTERFACE_NODE *sptr_interface_node = NULL;    BOOL dynamic = FALSE;    OSPF_PRINTF_PROLOGUE (        OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_initialize_protocol\r\n");    if ( readStaticConfig == TRUE )    {    ospf_create_areas_based_on_configured_information ();    ospf_create_interfaces_based_on_configured_information ();    ospf_assign_vx_interface_to_port_numbers ();    ospf_initialize_interfaces ();    }    ospf_initialize_global_parameters (clock_ticks_per_second);    I_am_an_area_border_router = ospf_check_if_area_border_router ();    if (I_am_an_area_border_router == TRUE)                    {        for (sptr_area = ospf.sptr_area_list;              sptr_area != NULL;              sptr_area = sptr_area->sptr_forward_link)            {                /* SPR#86625 - originate a default summary lsa into the stub                 * area only if it is configured to sendAreaSummary.                 */                if ((sptr_area->flags._bit.stub == TRUE) &&                    (sptr_area->inject_summary_lsa_into_stub_area == TRUE) )                    {                    ospf_originate_default_summary_link_into_the_area (sptr_area, FALSE);                                                                  /* section 12.4.3.1 */                    }                }        if(readStaticConfig == TRUE)           {            /* Set timers for virtual links */            for (sptr_interface_node = ospf.sptr_configured_virtual_links;                  sptr_interface_node != NULL;                   sptr_interface_node = sptr_interface_node->sptr_forward_link)                {                sptr_interface = sptr_interface_node->sptr_interface;                if (sptr_interface == NULL)                    {                    continue;                    }                 ospf_initialize_interface (sptr_interface, dynamic);                 }            }        }    ospf.timer_enabled = TRUE;    }/*************************************************************************** ospf_create_areas_based_on_configured_information - create and initialize areas** This routine creates and initializes all* the areas used in OSPF based on the* configuration.** RETURNS: N/A

⌨️ 快捷键说明

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