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

📄 ospf_dynamic_config.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
     * interface     */    I_was_an_area_border_router = ospf_check_if_area_border_router();    /* SPR 84478, 84485, 84486 -- End */    /* first rigger the interface state machine to bring down the interface */    ospf_execute_interface_state_machine( OSPF_INTERFACE_DOWN, sptr_interface->state,                                          sptr_interface );    sptr_interface->sptr_area->build_router = TRUE;    ospf_generate_network_and_router_link_state_advertisements (sptr_interface);    /* reinitialize all timers and couter associated with this interface */    sptr_interface->periodic_hello_time_counter = 0x00000000L;    sptr_interface->hello_timer_enabled = TRUE;    sptr_interface->periodic_retransmit_time_counter = 0x00000000L;    sptr_interface->retransmit_timer_enabled = TRUE;    sptr_interface->delayed_acknowledgement_timer_enabled = FALSE;    /* explicitly initialize the acknowledgement list */    sptr_interface->sptr_head_of_delayed_acknowledgement_list = NULL;    sptr_interface->number_of_acknowledgements_on_delayed_acknowledgement_list = 0x00000000L;    /* reset (backup) designated variables */    sptr_interface->designated_router.address = 0x00000000L;    sptr_interface->designated_router.id = 0x00000000L;    sptr_interface->backup_designated_router.address = 0x00000000L;    sptr_interface->backup_designated_router.id = 0x00000000L;    /* SPR 84478, 84485, 84486 -- Begin */    /* interface has been brought down. Check if the area border router status has     * changed     */    I_am_an_area_border_router = ospf_check_if_area_border_router();    if ( I_was_an_area_border_router != I_am_an_area_border_router )    {        /* notify all other areas that our area border router status has changed. Skip         * the area where the interface is brought down since the area has gone through         * the link state database exchange process when the interface is first         * brought down in that area         */        ospf_notify_areas_for_abr_change( sptr_interface->area_id );    }    /* SPR 84478, 84485, 84486 -- END */    return;}/***************************************************************************************** ospf_dynamic_reinit_interface - dynamically reinitialize an interface** This routine dynamically reinitialize an interface. The interface will first be brought* down and all pending acknowledgement (if any) will be freed. The timers and counters* associated with the interface will be reset and the interface will be brought up again.** <sptr_new_area> OSPF new area associated with interface** <sptr_interface> OSPF interface** <reset_interface> Boolean to determine whether or not to reset the interface** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_reinit_interface( OSPF_AREA_ENTRY *sptr_new_area,                                      OSPF_INTERFACE *sptr_interface,                                      enum BOOLEAN  reset_interface ){    /* SPR 84478, 84485, 84486 -- Begin */    enum BOOLEAN  I_was_an_area_border_router;    enum BOOLEAN  I_am_an_area_border_router;    I_was_an_area_border_router = FALSE;    I_am_an_area_border_router = FALSE;    /* SPR 84478, 84485, 84486 -- End */    if ( sptr_interface == NULL )        return ERROR;    if ( sptr_interface->sptr_area == NULL )    {        OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                           "ospf_dynamic_reinit_interface:Invalid area pointer!\r\n");        return ERROR;    }    /* reset the interface variables. Notice that it is not necessary to add/join the     * multicast address for this interface because that has been done when this     * interface is first created. Reseting the interface variables doesn't do anything     * to the multicast group join/leave at all...     */    if ( reset_interface == TRUE )        ospf_dynamic_reset_interface( sptr_interface );    /* SPR 86531 - move this line to after interface reset */    /* SPR 84478, 84485, 84486 -- Begin */    /* remember if we are currently the area border router before the area changes */    I_was_an_area_border_router = ospf_check_if_area_border_router();    /* SPR 84478, 84485, 84486 -- End */    /* SPR 84478, 84485, 84486 -- Begin */    /* remove this interface from the current area if the area has changed */    if ( (sptr_new_area != NULL) &&         (sptr_interface->sptr_area->area_id != sptr_new_area->area_id) )    /* SPR 84478, 84485, 84486 -- End */    {        /* re-correlate the interface to the new area */        sptr_interface->sptr_area = sptr_new_area;        /* now put the interface on the area list */        ospf_put_an_interface_on_areas_interface_list( sptr_new_area, sptr_interface );    }    /* now bring up the interface */    sptr_interface->state = OSPF_INTERFACE_IS_DOWN;    ospf_execute_interface_state_machine( OSPF_INTERFACE_UP, OSPF_INTERFACE_IS_DOWN,                                          sptr_interface );    sptr_interface->sptr_area->build_router = TRUE;    ospf_generate_network_and_router_link_state_advertisements (sptr_interface);    /* SPR 84478, 84485, 84486 -- Begin */    /* interface is up now, determine if there is any change to the area border router     * status     */    I_am_an_area_border_router = ospf_check_if_area_border_router();    /* if the area border router status has changed, notify all other areas about     * the changes. Skip the new area that the interface is now connected since     * interface(s) in the new area has gone through the link state database exchange     * process     */    /* SPR 86274 -- Begin */    if ( I_am_an_area_border_router != I_was_an_area_border_router )        ospf_notify_areas_for_abr_change( sptr_interface->sptr_area->area_id );    /* SPR 86274 -- End */    /* SPR 84478, 84485, 84486 -- End */    /* SPR#86625 - if the interface is attached to a stub area and if     * the stub area is configured to send area summary, originate a     * default summary lsa into the stub area.     */    if ( I_am_an_area_border_router == TRUE )    {        if ( (sptr_interface->sptr_area->flags._bit.stub == TRUE) &&             (sptr_interface->sptr_area->inject_summary_lsa_into_stub_area == TRUE) )        {            ospf_originate_default_summary_link_into_the_area(                                          sptr_interface->sptr_area, FALSE );        }    }    return OK;}/***************************************************************************************** ospf_dynamic_init_unnumbered_interface - dynamically initialize unnumbered interface** This routine initialize the unnumbered interface dynamically at run-time.** <sptr_interface> OSPF interface** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_init_unnumbered_interface( OSPF_INTERFACE *sptr_interface ){#if defined(__UNNUMBERED_LINK__)    char               ifName[IFNAMSIZ];    char               theAddr[24];            /* address space holder*/    ULONG              ifindex;    struct ifnet       *p_interface;    p_interface = (struct ifnet *)NULL;    if( (sptr_interface->address == 0) && (sptr_interface->type == OSPF_POINT_TO_POINT))    {        ifindex = sptr_interface->interface_index;        if (ifIndexToIfName (ifindex, ifName) == ERROR)        {            OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                  "ospf_dynamic_init_unnumbered_interface:ifIndexToIfName failed!\n");            return ERROR;        }        if (ifDstAddrGet(ifName, theAddr) == ERROR)        {            OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                  "ospf_dynamic_init_unnumbered_interface:Unnumbered Interface does not exist\n");            return ERROR;        }        /* let's initialize the unnumbered dest ip for this interface */        sptr_interface->unnumbered_dest_ip = net_to_host_long(inet_addr(theAddr));        if (ifAddrGet(ifName, theAddr) == ERROR)        {            OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                  "ospf_dynamic_init_unnumbered_interface:ifAddrGet failed\n");            return ERROR;        }        /* initialize the unnumbered router id or borrow id  of this interface */        sptr_interface->unnumbered_router_id = net_to_host_long(inet_addr(theAddr));        p_interface = ifunit(ifName);        if (p_interface == NULL)        {             OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                  "ospf_dynamic_init_unnumbered_interface:dstaddr_to_ifp failed\n");             return ERROR;        }        /* save the pointer to the interface, if it exist!! */        sptr_interface->vx_ospf_interface = p_interface;    }#endif /* __UNNUMBERED_LINK__ */    return OK;}/********************************************************************************* ospf_dynamic_create_interface - dynamically create an OSPF Interface** This routine dynamically create an OSPF Interface at runtime. It register the interface* for the OSPF_ADDR_ALLSPF and OSPF_ADDR_ALLDR multicast group, correlate the interface* to a well known OSPF Area, and then invoked the ospf_initialize_interface() routine* to initialize the interface state machine** <sptr_interface> OSPF interface** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_create_interface( OSPF_INTERFACE *sptr_interface ){    OSPF_AREA_ENTRY  *sptr_area;    OSPF_AREA_ENTRY *sptr_next_area = NULL;    struct in_addr   ip_address;    struct ifnet     *p_interface;    ULONG            interface_address;    ULONG            ospf_addr_allspf;    ULONG            ospf_addr_alldr;    int              spl_value;    BOOL             flag;    BOOL dynamic;#if defined(__UNNUMBERED_LINK__)    struct in_ifaddr *sptr_interface_address;#endif /* __UNNUMBERED_LINK__ *//* Fix TSR# 291665 Start */    enum BOOLEAN I_was_an_area_border_router;    enum BOOLEAN I_am_an_area_border_router;/* Fix TSR# 291665 End */    dynamic = TRUE;    flag = FALSE;    sptr_area = NULL;    p_interface = (struct ifnet *)NULL;    interface_address = 0x00000000;    ospf_addr_allspf = 0x00000000;    ospf_addr_alldr = 0x00000000;    if ( sptr_interface == NULL )        return ERROR;/* Fix TSR# 291665 Start */    /* first check and remember if the router is an area border router before the     * new interface is added     */    I_was_an_area_border_router = ospf_check_if_area_border_router ();/* Fix TSR# 291665 End */    /* asr: set virtual stack context */#if defined (VIRTUAL_STACK)    virtualStackNumTaskIdSet (ospf.ospf_vsid);#endif /* VIRTUAL_STACK */#if defined(__UNNUMBERED_LINK__)    if ( ospf_dynamic_init_unnumbered_interface( sptr_interface ) == ERROR )        return ERROR;#endif /* __UNNUMBERED_LINK__ */    /* if interface type is virtual link, do not obtain the low-level interface     *  handler and to add multicast membership for virtual link.     */    if ( sptr_interface->type == OSPF_VIRTUAL_LINK  )    {        sptr_interface->vx_ospf_interface = NULL;        sptr_interface->ifnet_index = 0;        sptr_interface->ifnet_flags = 0;    }    else    {        /* first obejct the low-level interface info from the os */        if ( sptr_interface->address != 0 )        {            interface_address = sptr_interface->address;            interface_address = host_to_net_long(interface_address);            ip_address.s_addr = interface_address;            spl_value = splnet();            INADDR_TO_IFP (ip_address, p_interface);            splx( spl_value );            if ( p_interface == NULL )            {                OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                        "ospf_dynamic_create_interface:INADDR_TO_IFP failed\n");                return ERROR;            }            /* save the low-level interface handler */            sptr_interface->vx_ospf_interface = p_interface;            /* retrieve the if_index and if_flags from ifnet strucutre for later use */            sptr_interface->ifnet_index = p_interface->if_index;            sptr_interface->ifnet_flags = p_interface->if_flags;        }        else        {#if defined(__UNNUMBERED_LINK__)            /* if we are here, this is an unnumbered interface */            interface_address = sptr_interface->unnumbered_dest_ip;            interface_address = host_to_net_long(interface_address);            ip_address.s_addr = interface_address;            p_interface = dstaddr_to_ifp(ip_address);            if ( p_interface == NULL )            {                OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,                "ospf_dynamic_create_interface:INADDR_TO_IFP failed for unnumbered interface\n");                return ERROR;            }            sptr_interface->vx_ospf_interface = p_interface;            /* retrieve the if_index and if_flags from ifnet strucutre for later use */            sptr_interface->ifnet_index = p_interface->if_index;            sptr_interface->ifnet_flags = p_interface->if_flags;

⌨️ 快捷键说明

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