📄 ospf_initialization.c
字号:
/* ospf_initialization.c - initialization file for OSPF *//* Copyright 1998 - 2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03n,17jul03,agi Fixed compilation with __OPAQUE_LSA__ flag turned on03m,11jun03,ram SPR#88965 Separate route table and LSDB hash parameters03l,11jun03,agi fixed if statements comparisons for ospf.protocol_enabled03k,11jun03,agi fixed SPR#88958, ospfShutdown(), ospfRestart()03j,30may03,agi removed #include "ospf_configuration.h"03i,30may03,agi removed RWOS calls03h,30may03,asr Changes to make OSPF virtual stack compatible03g,27may03,kc Fixed SPR#86625 - Modified ospf_initialize_protocol() to send default summary lsa only if the stub area is configured to do so.03n,21may03,htm Fixed SPR 86153 - Commented usage of source_area_id_for_virtual_link since the concept of source area is not mentioned in RFC 2328.03m,24may03,agi Removed debug statements03l,14may03,agi Changed RWOS semaphores to vxWorks semaphores03k,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements03j,20feb03,kc Fixed SPR#86319 - modified ospf_create_areas_based_on_configured_information to rename inject_default_route_if_stub_area variable to inject_summary_lsa_into_stub_area.03i,17feb02,ram SPR 81808 Added OSPF memory partition support03h,06jan03,ram SPR 85432 Changes to allow more OSPF external route processing03g,24dec02,agi Fixed SPR#75194, ANVL 27.1503f,10feb03,kc Fixed SPR#86175 - moved all ospf_xxx_stub() calls from ospf_init.c to ospf_initialize_router().03e,19nov02,mwv Merge TMS code SPR 8428403d,16oct02,kkz Moved call to ospf_sysctl_rtableWalk to after initialization.03c,08oct02,agi Fixed compiler warning03b,24jun02,kc Do not save the low-level interface handler in the routine ospf_assign_vx_interface_to_port_numbers().03a,30may02,kc Modified ospf_initialize_router() to invoke the routine ospf_sysctl_rtableWalk() if configured as ASBR.02z,24may02,kc Modified ospf_assign_vx_interface_to_port_numbers() to save a local copy of the if_flags and if_index (retrieve from ifnet structure) to the OSPF_INTERFACE data structure.02y,23apr02,kc Fixed ospf_assign_vx_interface_to_port_numbers() for virtual interface support. Properly keep track the number of stub areas and nssa that have been configured.02x,16apr02,jkw One copy of external and type 11 lsa02w,24mar02,kc Fixed ospf_initialize_router() to check for return status for ospf2Mapi_proto_register().02v,14feb02,kc Changed printf statement to OSPF_PRINTF_DEBUG in ospf_initializa_router02u,06feb02,bt look for changes in comment __UNNUMBERED_LINK__ver1.002t,22jan02,kc Removed the redundant ospf_add_node_to_end_of_list() call from the ospf_put_an_interface_on_areas_interface_list. Also changed it so that the sptr_area->sptr_interfaces will always point to the ospf.sptr_interface_list.02s,14jan02,kc Fixed ospf_initialize_protocol() and ospf_initialize_global_parameters() so that interfaces will not be initialized twice if mixing dynamic and static configurations.02r,20dec01,jkw Removed sptr_area->sptr_interfaces structure.02q,19dec01,kc Simplified callout to ospf2Mapi_proto_register().02p,19dec01,kc Change ospf_create_areas_based_on_configured_information() to setup area address range only after all area configurations have completed.02o,19dec01,jkw If virtual links are configured in stub network do not initialize neighbor for virtual.02n,11dec01,kc Set interface poll interval to default (120 seconds) in ospf_create_interfaces_based_on_configured_information().02m,28nov01,jkw Virtual link updates.02l,13nov01,jkw Change number of address ranges to ULONG02k,12nov01,jkw Remove __RFC_2328__ preproc around number of area addreess ranges.02j,25oct01,kc Added dynamic configuration changes for address range.02i,15oct01,jkw Renamed ospfExit to ospfShutdown and ospfReboot to ospfRestart.02h,13oct01,kc Dynamic configuration changes.02g,11oct01,jkw Set pointer to NULL after table_free.02f,29sep01,kc Called in_delmulti() to undo previously added multicast group if the second in_addmulti() failed.02e,29sep01,kc Changed ospf_assign_vx_interface_to_port_numbers() to save the M_BLK_ID for each multicast group added using in_addmulti().02d,29sep01,kc Made the following functions public: 1) ospf_add_entry_to_hosts_list(), 2) ospf_add_entry_to_virtual_link_list() 3) ospf_put_an_interface_on_areas_interface_list02c,24sep01,kc Cleaned up non-raw socket receive task related handling02b,22sep01,kc Put all interfaces on sptr_interface_list.02a,21sep01,kc Added ospf_multicast_group_request() for joining/leaving multicast group. Modified ospf_assign_vx_interface_to_port_numbers() to use ospf_multicast_group_request() for raw socket.01z,17sep01,kc Added virtual stack and raw socket initization to ospf_initialize_protocol().01y,23aug01,jkw Fixed compiler warnings.01x,14aug01,kc Corrected problems with ospfVirtIfTable update.01w,13Aug01,aos Added ospfExit (), ospfTaskDelete(),ospfHardwareReboot() and ospfReboot() hook functions;01v,20jun01,jkw Added unnumbered link support01u,03may01,jkw Added checks for NULL pointers and alarm messages01t,26sep00,reshma Added WindRiver CopyRight01s,25sep00,reshma RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL.01r,11jul00,reshma OSPF-MIB: OSPF-Authentication related changes.01q,07jul00,reshma Unix compatibility related changes.01p,04apr00,reshma Added some MIB support (Read only).Passed all important ANVL OSPF tests.01o,23dec99,reshma Compatibility with VxWorks-IP and VxWorks RTM-interface01n,06jun99,jack Changed setting of address range from TRUE to FALSE on init. This should be set at the run time01m,28dec98,jack Compiled and added some comments01l,03dec98,jack Removed C++ comments01k,13nov98,jack Changes related to introducing queuing in OSPF to RTM interface and bug fix on the external route additions path (to RTM)01j,11nov98,jack Config changes, linted and big endian changes01i,30oct98,jack Incorporate changes for compilation on Vxworks01h,23aug98,jack ANVL tested OSPF with PATRICIA tree route table and no recursion01g,10aug98,jack PATRICIA Route Table Based OSPF Code Base01f,04jun98,jack Integration with RTM and BGP01e,24apr98,jack RTM changes01d,10jul97,cindy Pre-release v1.52b01c,02oct97,cindy Release Version 1.5201b,22oct96,cindy Release Version 1.5001a,05jun96,cindy First Beta Release*//*DESCRIPTIONospf_initialization.c is used for creating and initialization data structures used by OSPF. Thisfile will create spawn the timer and receive tasks for sending and receiving OSPF packets. Thisfile will create interfaces and areas for OSPF.This file is used at the startup of OSPF.*/#define GLOBAL_FILE#include <vxWorks.h>#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ */#include <in.h>#include <sockLib.h>#include <ioLib.h>#include <netinet/in_var.h>/* Added for Task Spawn for the "tOspfRecv" task*//* Added change as per TMS PR # 1652 */#include <taskLib.h>static BOOL readStaticConfig;/**********************************************************************************************************************************/static void ospf_initialize_protocol (ULONG clock_ticks_per_second);static void ospf_create_areas_based_on_configured_information (void);static void ospf_set_address_ranges_for_the_area (OSPF_AREA_ENTRY *sptr_area, ULONG address_range_number);static void ospf_create_interfaces_based_on_configured_information (void);static void ospf_correlate_interface_to_area (OSPF_INTERFACE *sptr_interface,ULONG number_of_ports);static void ospf_initialize_global_parameters (ULONG clock_ticks_per_second);static void ospf_initialize_interfaces (void);static void ospf_initialize_interfaces_md5_authentication_information (OSPF_INTERFACE *sptr_interface, ULONG port_number);static void ospf_configure_neighbor_for_interface (OSPF_INTERFACE *sptr_interface, ULONG number_of_ports);extern void ospfShutdown (void);extern void ospfRestart(void);#if defined (__OSPF_FTP__)extern void ospf_init (const char* p_configuration_file, const char* p_ftp_server_address, const char* p_directory, const char* p_user, const char* p_password);#elseextern void ospf_init (void);#endifstatic void ospf_configure_nbma_ptmp_neighbor_for_interface (OSPF_INTERFACE *sptr_interface, ULONG number_of_ports); /* __NBMA_PTMP__ *//*************************************************************************** ospf_multicast_group_request - add or drop an interface from a multicast group** This routine is called when an interface is enabled/disabled for ospf. The interface* specified by <ipAddr> will join or leave the multicast group with the address* specified by <multicastAddr> depending on the <request> type.** <ipAddr> Interface identifier** <multicastAddr> Multicast address** <request> Add or drop request** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_multicast_group_request( ULONG ipAddr, ULONG multicastAddr, int request ){ struct ip_mreq mcastReq; UCHAR loopback; STATUS rc; /* construct the ip_mreq structure */ mcastReq.imr_interface.s_addr = ipAddr; mcastReq.imr_multiaddr.s_addr = multicastAddr; if (request == IP_ADD_MEMBERSHIP ) { rc = setsockopt(ipSock, IPPROTO_IP, request, (char *)&mcastReq, sizeof(mcastReq)); if ( rc == ERROR ) { OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "failed to join multicast group\n"); return; } /* we do not want to listen to our own transmission, so we need to disable this * feature so that the multicast packets will not oopback */ loopback = 0; rc = setsockopt(ipSock, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&loopback, sizeof(loopback)); if ( rc == ERROR ) { OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,"failed to disable loopback for self\n"); ospf_multicast_group_request(ipAddr, multicastAddr, IP_DROP_MEMBERSHIP); return; } } else if (request == IP_DROP_MEMBERSHIP) /* leave a multicast group */ { /* since we are leaving the multicast group, don't care if the setsockopts * returns error */ rc = setsockopt(ipSock, IPPROTO_IP, request, (char *)&mcastReq, sizeof(mcastReq)); if ( rc == ERROR ) OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF,"failed to leave multicast group\n"); } return;}/*************************************************************************** ospf_raw_socket_init - initialize raw sockets for OSPF transmit and receive** This routine intialize raw sockets for OSPF transmit and receive. For Interface* with multicast capability, ospf_multicast_group_request() function must be called* to join/leave a multicast group.** RETURNS: PASS or FAIL** ERRNO: N/A** NOMANUAL*/enum TEST ospf_raw_socket_init( void ){ int optval = (64*1024); if ((ipSock = socket (AF_INET, SOCK_RAW, IPPROTO_OSPF)) == ERROR) { printf ("ospf_raw_socket_init: Failed to create input socket. \n\r"); return (FAIL); } /* SPR 85432 -- Begin */ if(setsockopt(ipSock,SOL_SOCKET, SO_RCVBUF, (char*) &optval,sizeof(optval)) == ERROR) { OSPF_PRINTF_DEBUG(OSPF_DEBUG_PRINTF, "OSPF: Failed to set raw socket rcv buffer\r\n"); } /* SPR 85432 -- End */ return( PASS );}/*************************************************************************** ospf_put_an_interface_on_areas_interface_list - register interface to an area** This routine registers an OSPF Interface to a well known OSPF Area** <sptr_area> OSPF area** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_put_an_interface_on_areas_interface_list ( OSPF_AREA_ENTRY * sptr_area, OSPF_INTERFACE * sptr_interface ) { /* make the interface pointer in the area to always point to the head of the interface * linked list found in the ospf data structure. That way we always guarantee that * all the interfaces associated with that area will always be included when we need * to traverse the interfaces using the sptr_area->sptr_interfaces. */ PARAMETER_NOT_USED (sptr_interface); /* SPR#76812 */ semTake (ospf_config_mutex, WAIT_FOREVER); if (sptr_area->sptr_interfaces == NULL) { sptr_area->sptr_interfaces = ospf.sptr_interface_list; } semGive (ospf_config_mutex); }/*************************************************************************** ospf_add_entry_to_hosts_list - add host interface to host list** This routine adds the host interface to the host 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_hosts_list (OSPF_INTERFACE *sptr_interface, BOOL dynamic )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -