?? ospf_dynamic_config.c
字號(hào):
spl_value = splnet(); IFP_TO_IA (p_interface, sptr_interface_address); splx( spl_value ); /* save the borrow ip or the unnumbered router id ip */ sptr_interface->unnumbered_router_id = sptr_interface_address->ia_addr.sin_addr.s_addr; interface_address = sptr_interface->unnumbered_router_id; interface_address = host_to_net_long(interface_address); ip_address.s_addr = interface_address;#else /* __UNNUMBERED_LINK__ is not defined */ ip_address.s_addr = host_to_net_long(sptr_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;#endif /* __UNNUMBERED_LINK__ */ } /* now configure the interface for the multicast group */ ospf_addr_allspf = OSPF_ADDR_ALLSPF; ospf_addr_allspf = host_to_net_long(ospf_addr_allspf); ospf_multicast_group_request( ip_address.s_addr, ospf_addr_allspf, IP_ADD_MEMBERSHIP ); if (sptr_interface->type != OSPF_POINT_TO_POINT) { ospf_addr_alldr = OSPF_ADDR_ALLDR; ospf_addr_alldr = host_to_net_long( ospf_addr_alldr ); ospf_multicast_group_request( ip_address.s_addr, ospf_addr_alldr, IP_ADD_MEMBERSHIP ); } } /* insert the instance to sptr_interface_list used by ospf */ if ( ospf.sptr_interface_list == NULL ) { ospf.sptr_interface_list = sptr_interface; } else { ospf_add_node_to_end_of_list((OSPF_GENERIC_NODE *)sptr_interface, (OSPF_GENERIC_NODE *) ospf.sptr_interface_list); } /* keep track the number of interfaces that have been configured */ ospf.number_of_interfaces++; /* so far so good. Correlate the interface to an well known OSPF area */ if ( sptr_interface->type == OSPF_VIRTUAL_LINK ) { if ( ospf.sptr_backbone_area != NULL ) { sptr_interface->sptr_area = ospf.sptr_backbone_area; /* Fix for SPR# 86153 - Begin */ sptr_interface->area_id = sptr_interface->sptr_area->area_id; /* Fix for SPR# 86153 - End */ ospf_put_an_interface_on_areas_interface_list( ospf.sptr_backbone_area, sptr_interface); } else { sptr_area = ospf_create_pseudo_area_for_virtual_link( sptr_interface ); if ( sptr_area != NULL ) { sptr_interface->sptr_area = sptr_area; /* Fix for SPR# 86153 - Begin */ sptr_interface->area_id = sptr_area->area_id; /* Fix for SPR# 86153 - End */ ospf_put_an_interface_on_areas_interface_list( sptr_area, sptr_interface ); } } } else if ( (sptr_interface->area_id == OSPF_BACKBONE) && (ospf.sptr_backbone_area != NULL) ) { sptr_interface->sptr_area = ospf.sptr_backbone_area; ospf_put_an_interface_on_areas_interface_list (ospf.sptr_backbone_area, sptr_interface); } else { for ( sptr_area = ospf.sptr_area_list; sptr_area != NULL; sptr_area = sptr_next_area ) { sptr_next_area = sptr_area->sptr_forward_link; if ( sptr_interface->area_id == sptr_area->area_id) { sptr_interface->sptr_area = sptr_area; /* now register this interface to the area */ ospf_put_an_interface_on_areas_interface_list(sptr_area, sptr_interface); break; } } } /* REVISIT: for now, we made a duplicate copy of the interface and queue it to * the host/virtual queue. The appropriate approach is to separate it * from the sptr_interface_list. */ if ( sptr_interface->netmask == OSPF_HOST_NET_MASK ) { /* * Tell 'em that this is a dynamically created host instance so that * ospf will not turn around to try to create a similar instance in the * MIB Management Database ospfHostTable */ ospf_add_entry_to_hosts_list (sptr_interface, dynamic); } /* tell 'em to initialize this interface */ ospf_initialize_interface (sptr_interface, dynamic);/* Fix TSR# 291665 Start */ /* New interface has been added. Check if router is the area border * router now. */ I_am_an_area_border_router = ospf_check_if_area_border_router (); /* * If the area border router status has changed, propagate the * router lsa to all other areas that OSPF is configured for */ if (I_am_an_area_border_router != I_was_an_area_border_router) /* SPR 84478, 84485, 84486 -- Begin */ { /* notify all other areas that our area border router status has changed. * Skip the area where the new interface is connected since the area has * gone through the link state database exchange process when the interface * is first brought up in that area */ ospf_notify_areas_for_abr_change( sptr_interface->area_id ); } /* 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 ) { sptr_area = sptr_interface->sptr_area; 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); } } return OK; }/********************************************************************************* ospf_dynamic_destroy_interface - dynamically destroy an OSPF Interface** This routine dynamically destroy an OSPF Interface at runtime. It destroy all* adjacencies with the neighbors, remove the interface from the area, and* de-register the multicast group.** <sptr_interface> OSPF interface** <sptr_area> OSPF area associated with interface** RETURNS: OK or ERROR** ERRNO: N/A** NOMANUAL*/STATUS ospf_dynamic_destroy_interface( OSPF_INTERFACE *sptr_interface, OSPF_AREA_ENTRY *sptr_area ){ OSPF_NEIGHBOR *sptr_neighbor =NULL; OSPF_NEIGHBOR *sptr_next_neighbor = NULL; OSPF_AREA_ENTRY *sptr_next_area = NULL; bool delete_first_node; ULONG interface_address = 0x00000000; ULONG ospf_addr_allspf = 0x00000000; ULONG ospf_addr_alldr = 0x00000000; ULONG area_id;/* Fix TSR# 291665 Start */ enum BOOLEAN I_was_an_area_border_router; enum BOOLEAN I_am_an_area_border_router;/* Fix TSR# 291665 Start */ if ( sptr_interface == NULL ) { OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "ospf_dynamic_destroy_interface:Invalid interface handler!\n"); return ERROR; } /* SPR 84478, 84485, 84486 -- Begin */ /* flush the self-originated network link state advertisement if necessary */ ospf_flush_network_link_advertisement( sptr_interface ); /* SPR 84478, 84485, 84486 -- End *//* Fix TSR# 291665 Start */ /* first remember if we are now the area border router */ I_was_an_area_border_router = ospf_check_if_area_border_router ();/* Fix TSR# 291665 End */ area_id = sptr_interface->area_id; /* first check if the interface node to be deleted is the first node on the * interface list */ if ( ospf.sptr_interface_list == sptr_interface ) delete_first_node = TRUE; else delete_first_node = FALSE; /* NOTE: it seems easier to simply force the state machine for this interface to * execute with the interface down event to bring down the interface and to * destroy all neighbors associated with this interface. However, that is * not quite appropriate since the interface state machine will trigger the * ospf2Mapi_request() to provide MIB API the statistic and operational status * update which is something that we don't want. */ /* explicitly reinitialze all timer and counter associated with this * interface */ sptr_interface->state = OSPF_INTERFACE_IS_DOWN; sptr_interface->wait_timer_enabled = FALSE; sptr_interface->flags._bit.network_scheduled = FALSE; sptr_interface->hello_timer_enabled = TRUE; sptr_interface->periodic_retransmit_time_counter = 0x00000000L; sptr_interface->periodic_retransmit_time_counter = 0x00000000L; sptr_interface->retransmit_timer_enabled = TRUE; sptr_interface->delayed_acknowledgement_timer_enabled = FALSE; /* reset (backup) desigated router variables */ sptr_interface->potential_neighbor.designated_router = 0x00000000L; sptr_interface->potential_neighbor.backup_designated_router = 0x00000000L; sptr_interface->designated_router.address = 0x00000000L; sptr_interface->backup_designated_router.address = 0x00000000L; ospf_free_interface_acknowledgement_list (sptr_interface, FALSE); for ( sptr_neighbor = sptr_interface->sptr_neighbor; sptr_neighbor != NULL; sptr_neighbor = sptr_next_neighbor) { sptr_next_neighbor = sptr_neighbor->sptr_forward_link; ospf_flush_lsdb_of_external_lsas_associated_with_neighbor ( sptr_neighbor); ospf_execute_neighbor_state_machine ( OSPF_KILL_NEIGHBOR, sptr_neighbor->state, sptr_interface, sptr_neighbor); } if ( sptr_interface->type == OSPF_VIRTUAL_LINK ) { if ( sptr_interface->sptr_transit_area != NULL ) { OSPF_INTERFACE_NODE *sptr_virtual_interface_node; OSPF_INTERFACE_NODE *sptr_virtual_interface_forward_node; OSPF_INTERFACE *sptr_virtual_interface; ULONG transit_area_id; ULONG neighbor_router_id; for ( sptr_virtual_interface_node = ospf.sptr_configured_virtual_links; sptr_virtual_interface_node != NULL; sptr_virtual_interface_node = sptr_virtual_interface_forward_node) { sptr_virtual_interface_forward_node = sptr_virtual_interface_node->sptr_forward_link; sptr_virtual_interface = sptr_virtual_interface_node->sptr_interface; if ( sptr_virtual_interface == NULL ) continue; transit_area_id = sptr_virtual_interface->sptr_transit_area->area_id; neighbor_router_id = sptr_virtual_interface->virtual_neighbor_rid; if ( (transit_area_id == sptr_interface->sptr_transit_area->area_id) && (neighbor_router_id == sptr_interface->virtual_neighbor_rid) ) { sptr_interface->sptr_transit_area->flags._bit.virtual_up = FALSE; --ospf.number_of_virtual_links_in_Up_state; ospf.number_of_virtual_links--; ospf_remove_node_from_list( (OSPF_GENERIC_NODE **)&sptr_virtual_interface, (OSPF_GENERIC_NODE *)ospf.sptr_configured_virtual_links); if ( ospf.number_of_virtual_links == 0 ) ospf.sptr_configured_virtual_links = NULL; break; } } } } sptr_area->number_of_interfaces_in_up_state--; if ( sptr_area->number_of_interfaces_in_up_state == 0 ) { /* if there is no more active interface operates in the area to which the * deleted interface connected, flush all lsas associated with the area */ ospf_free_areas_link_state_database( sptr_area ); } /* generate router lsa for the area */ sptr_interface->sptr_area->build_router = TRUE; ospf_generate_network_and_router_link_state_advertisements (sptr_interface); /* now de-register this interface from the multicast group(s) so that the lower * layer will stop forwarding multicast packets to this interface */ if ((sptr_interface->type == OSPF_BROADCAST) || (sptr_interface->type == OSPF_NBMA) || (sptr_interface->type == OSPF_POINT_TO_POINT) ) { interface_address = sptr_interface->address; interface_address = host_to_net_long(interface_address); ospf_addr_allspf = OSPF_ADDR_ALLSPF; ospf_add
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -