📄 ospf_receive_update.c
字号:
if ((sptr_advertisement->ls_header.type == OSPF_LS_TYPE_11) && (sptr_interface->sptr_area->flags._bit.stub == TRUE)) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Opaque Type 11 Link advertisements are not flooded into/throughout stub areas\r\n"); return (GOOD_RECEIVE); /* Opaque Type 11 link advertisements are not flooded into/throughout stub areas - see section 3.6, (pages 35-36) */ }#endif /* __OPAQUE_LSA__ */#if defined (__NSSA__) if (sptr_advertisement->ls_header.type == OSPF_LS_MULTICAST) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: OSPF_LS_MULTICAST received .. \r\n"); return (GOOD_RECEIVE); } if ((sptr_advertisement->ls_header.type == OSPF_LS_AS_EXTERNAL) && (sptr_interface->sptr_area->flags._bit.nssa == TRUE)) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: AS External Link advertisements received on an NSSA area \r\n"); } /* opaque lsa flood type 11 into nssa area jkw */#if defined (__OPAQUE_LSA__) if ((sptr_advertisement->ls_header.type == OSPF_LS_TYPE_11) && (sptr_interface->sptr_area->flags._bit.nssa == TRUE)) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Type 11 Link advertisements received on an NSSA area \r\n"); }#endif /* __OPAQUE_LSA__ */#endif /*__NSSA__*/#if defined (__OPAQUE_LSA__) if (sptr_advertisement->ls_header.type == OSPF_LS_TYPE_9) { link_state_id = ((OSPF_TYPE_9_LINK_ADVERTISEMENT_HEADER *)sptr_advertisement)->ls_header.id.lsid; link_state_id = net_to_host_long(link_state_id); id.lsid = link_state_id; opaque_type = id.opaque_lsid.opaque_type; opaque_type = ((OSPF_TYPE_9_LINK_ADVERTISEMENT_HEADER *)sptr_advertisement)->ls_header.id.opaque_lsid.opaque_type; sptr_opaque_callback = ospfRetrieveOpaqueCallback(lsa_type, opaque_type); if (sptr_opaque_callback != NULL) { sptr_opaque_callback->opaque_lsa_received_hook((UNION_OSPF_LINK_STATE_ADVERTISEMENT *)sptr_advertisement); } } else if (sptr_advertisement->ls_header.type == OSPF_LS_TYPE_10) { link_state_id = ((OSPF_TYPE_10_LINK_ADVERTISEMENT_HEADER *)sptr_advertisement)->ls_header.id.lsid; link_state_id = net_to_host_long(link_state_id); id.lsid = link_state_id; opaque_type = id.opaque_lsid.opaque_type; sptr_opaque_callback = ospfRetrieveOpaqueCallback(lsa_type, opaque_type); if (sptr_opaque_callback != NULL) { sptr_opaque_callback->opaque_lsa_received_hook((UNION_OSPF_LINK_STATE_ADVERTISEMENT *)sptr_advertisement); } } else if (sptr_advertisement->ls_header.type == OSPF_LS_TYPE_11) { link_state_id = ((OSPF_TYPE_11_LINK_ADVERTISEMENT_HEADER *)sptr_advertisement)->ls_header.id.lsid; link_state_id = net_to_host_long(link_state_id); id.lsid = link_state_id; sptr_opaque_callback = ospfRetrieveOpaqueCallback(lsa_type, opaque_type); if (sptr_opaque_callback != NULL) { sptr_opaque_callback->opaque_lsa_received_hook((UNION_OSPF_LINK_STATE_ADVERTISEMENT *)sptr_advertisement); } }#endif /* __OPAQUE_LSA__ */ /* section 13, item (4) - (page 133-134) */ /* SPR#76812 -- Begin */ link_state_id = sptr_advertisement->ls_header.id; link_state_id = net_to_host_long (link_state_id); advertising_router = sptr_advertisement->ls_header.advertising_router; advertising_router = net_to_host_long (advertising_router); if(sptr_advertisement->ls_header.type == OSPF_LS_NETWORK) { sptr_database_entry = ospf_find_network_LSA(sptr_interface->sptr_area,link_state_id); } else { sptr_database_entry = ospf_find_LSA(sptr_interface->sptr_area, link_state_id, advertising_router, sptr_advertisement->ls_header.type); } if (sptr_database_entry != NULL) { database_information.found_link_state_advertisement_in_database = TRUE; } else { database_information.found_link_state_advertisement_in_database = FALSE; } age = sptr_advertisement->ls_header.age; age = net_to_host_short (age); if (((age == OSPF_MAXIMUM_AGE) && (database_information.found_link_state_advertisement_in_database == FALSE))#if defined (__RFC_2328__) && ((ospf_check_if_neighbor_exchange_or_loading(sptr_neighbor)))#endif /*__RFC_2328__*/ ) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: section 13, item (4) In file ospf_receive_update.c. Function: ospf_process_link_state_advertisement\r\n"); /* section 13, item (4a) - (page 134) */ ospf_send_direct_acknowledgement (sptr_advertisement, sptr_interface, sptr_neighbor); return (GOOD_RECEIVE); } else { /* section 13, item (5) - (page 134) */ if (database_information.found_link_state_advertisement_in_database == TRUE) { /* SPR#76812 */ database_information.sptr_database_entry = sptr_database_entry; /* SPR 84312 -- Begin */ current_time = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ database_information.time_difference = current_time - database_information.sptr_database_entry->ls_database_time_stamp; request_is_more_recent = ospf_check_if_more_recent (&sptr_advertisement->ls_header, &database_information.sptr_database_entry->advertisement.sptr_router->ls_header, database_information.time_difference); } /* if finished */ else { database_information.sptr_database_entry = NULL; request_is_more_recent = PASS; } if (request_is_more_recent == PASS) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: section 13, item (5) process_more_recent_link_state_adv\r\n"); /* section 13, items (5a-5f) - (page 134-135) */ ospf_process_more_recent_link_state_advertisement (&database_information, sptr_advertisement, sptr_interface, sptr_neighbor, source_address, destination_address); database_information.new_advertisement.sptr_router = sptr_advertisement; ospf_remove_request_from_neighbor_request_list (sptr_neighbor, &(database_information.new_advertisement)); database_information.new_advertisement.sptr_router = NULL; } else { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: section 13, item (6) NOT a more recent request\r\n"); /* section 13, item (6) - (page 135) */ database_entry.advertisement.sptr_router = sptr_advertisement; sptr_ls_request = ospf_find_advertisement_on_neighbors_ls_request_list (sptr_neighbor, &database_entry); if (sptr_ls_request != NULL) /* an error has occurred in the Database Exchange process */ { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Error in the Database Exchange process\r\n"); ospf_execute_neighbor_state_machine (OSPF_BAD_LINK_STATE_REQUEST, sptr_neighbor->state, sptr_interface, sptr_neighbor); return (OSPF_ERROR_REQUEST_BOGUS); } else { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: section 13, item (7) Check if same instance\r\n"); /* section 13, item (7) - (page 135) */ test_return_type = ospf_check_if_same_instance (&database_information.sptr_database_entry->advertisement.sptr_router->ls_header, &sptr_advertisement->ls_header, database_information.time_difference); if (test_return_type == PASS) { /* section 13, item (7a) - (page 135) */ sptr_retransmission_node = ospf_find_advertisement_on_neighbors_retransmit_list (sptr_neighbor, database_information.sptr_database_entry); if (sptr_retransmission_node != NULL) { ospf_remove_node_from_neighbors_retransmit_queue (sptr_neighbor, sptr_retransmission_node); ospf_remove_neighbor_from_advertisements_retransmit_list (database_information.sptr_database_entry, sptr_neighbor); /* section 13, item (7b) - (page 135) */ if (sptr_interface->state == OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) { /* * The folowing is decremented in function ospf_send_direct_acknowledgement when neighbor is passed as NULL (MULTICASTED) */ ospf_add_entry_to_interfaces_delayed_acknowledgement_list (sptr_interface,database_information.sptr_database_entry); } } else { ospf_send_direct_acknowledgement (sptr_advertisement, sptr_interface, sptr_neighbor); } } else { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: section 13, item (8)\r\n"); /* section 13, item (8) - (page 135) */ age = database_information.sptr_database_entry->advertisement.sptr_router->ls_header.age; age = net_to_host_short (age); sequence_number = database_information.sptr_database_entry->advertisement.sptr_router->ls_header.sequence_number; sequence_number = net_to_host_long (sequence_number); if ((age >= OSPF_MAXIMUM_AGE) && (sequence_number == OSPFMAXLSSEQ)) { return (GOOD_RECEIVE); } else { /* Refer section 13, item (8) */ /*#$-NOTE:note20-$#*/ OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: section 13, item (8) Database copy is more recent. \r\n");#if defined (__RFC_2328__) /* RFC 2178 G.4 */ if (database_information.time_difference < OSPF_MinLSArrival) { return (GOOD_RECEIVE); } else { send_database_copy_back_to_sending_neighbor(database_information.sptr_database_entry, sptr_neighbor, sptr_interface); }#else /*__RFC_2328__*/ ospf_send_direct_acknowledgement (sptr_advertisement, sptr_interface, sptr_neighbor);#endif /*__RFC_2328__*/ } } } } } return (GOOD_RECEIVE);}/****************************************************************************************//* section 13, item (5) - (page 134) */static void ospf_process_more_recent_link_state_advertisement (OSPF_DATABASE_INFORMATION_STRUCTURE *sptr_database_information, OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor, ULONG source_address,ULONG destination_address){ enum TEST test_return_type; enum BOOLEAN advertisement_was_flooded_back_out_receiving_interface; ULONG advertising_router; /* * The pointer "sptr_advertisement" points to the packet passed by the lower layer; * so, should not be used as is. Make a copy eventually. */ OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement_to_be_installed_in_lsdb; UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_union_new_advertisement; enum TEST status_of_advertisements_copy_for_installation_in_lsdb; enum TEST different_lsa; /* section 13, item (5a) - (page 134) */ OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_more_recent_link_state_advertisement\r\n"); if ((sptr_database_information->found_link_state_advertisement_in_database == TRUE) &&#if defined (__RFC_2328__) (ospf_is_lsa_self_originated (sptr_advertisement) == false) &&#endif /*__RFC_2328__*/ /* RFC 2178 G.5 */ (sptr_database_information->time_difference < OSPF_MinLSArrival)) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Discarded new advertisement because the database copy was installed less than OSPF_MinLSArrival seconds ago\r\n"); return; } else { /* section 13, item (5f) - (page 135) */ test_return_type = ospf_check_if_advertisements_link_state_id_is_equal_to_one_of_the_routers_own_IP_interface_addresses ( sptr_advertisement); advertising_router = sptr_advertisement->ls_header.advertising_router;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -