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

📄 ospf_initialization.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
            area_address_ranges->area_id = sptr_area->area_id;                /*Mistral- added the 'if' prior to the area assignment to the MIB variable*/                        sptr_area->number_of_address_ranges++;                    if (sptr_area->sptr_address_ranges == NULL)                                {                                sptr_area->sptr_address_ranges = area_address_ranges;                                }                        else                                {                                ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) area_address_ranges, (OSPF_GENERIC_NODE *) sptr_area->sptr_address_ranges);                                }#if defined (__OSPF_MIB__)            ospf2Mapi_request( (void *)area_address_ranges, ospfAreaAggregateCreateReq );#endif /* __OSPF_MIB__ */                        }                }        else if (ospf.area_address_range[address_range_number].config.area_id == sptr_area->area_id)                {            area_address_ranges = (OSPF_ADDRESS_RANGE_LIST_ENTRY *) table_malloc (1, sizeof (OSPF_ADDRESS_RANGE_LIST_ENTRY));                if (area_address_ranges != NULL)                        {                memset (area_address_ranges, 0x00, sizeof (OSPF_ADDRESS_RANGE_LIST_ENTRY));            area_address_ranges->area_id = sptr_area->area_id;                    area_address_ranges->network = ospf.area_address_range[address_range_number].config.network;                        area_address_ranges->mask = ospf.area_address_range[address_range_number].config.mask;                area_address_ranges->advertise = ospf.area_address_range[address_range_number].config.advertise;                    area_address_ranges->active = (BYTE_ENUM (BOOLEAN)) FALSE;                        area_address_ranges->cost = ospf.area_address_range[address_range_number].config.cost;                /*Mistral- added the 'if' prior to the area assignment to the MIB variable*/                        sptr_area->number_of_address_ranges++;                    if (sptr_area->sptr_address_ranges == NULL)                                {                                sptr_area->sptr_address_ranges = area_address_ranges;                                }                        else                                {                                ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) area_address_ranges, (OSPF_GENERIC_NODE *) sptr_area->sptr_address_ranges);                                }#if defined (__OSPF_MIB__)            ospf2Mapi_request( (void *)area_address_ranges, ospfAreaAggregateCreateReq );#endif /* __OSPF_MIB__ */                        }                }        return;}/*************************************************************************** ospf_create_interfaces_based_on_configured_information - create and initialize interfaces** This routine creates and initializes all* the interfaces used in OSPF based on the* configuration.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_create_interfaces_based_on_configured_information (void){        ULONG number_of_ports;        OSPF_INTERFACE *sptr_interface;            BOOL dynamic;#if defined(__UNNUMBERED_LINK__)        /*  __UNNUMBERED_LINK__ver1.0 */        struct ifnet *pIp_interface;                ULONG interface_address;        struct in_addr ip_address;#endif /*  __UNNUMBERED_LINK__ver1.0 */        OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_create_interfaces_based_on_configured_information\r\n");        ospf.number_of_interfaces = 0x00000000L;        ospf.number_of_virtual_links = 0x00000000L;        ospf.number_of_virtual_links_in_Up_state = 0x00000000L;        ospf.sptr_configured_virtual_links = NULL;        ospf.sptr_host_list = NULL;        for (number_of_ports = 0x00000000L; number_of_ports < ospf.number_of_ports; ++number_of_ports)                    {            if (ospf.port[number_of_ports].config.port_enabled == FALSE)                            {                continue;                }            sptr_interface = (OSPF_INTERFACE *) table_malloc (1, sizeof (OSPF_INTERFACE));            if (sptr_interface != NULL)                {                ++ospf.number_of_interfaces;                memset (sptr_interface, 0x00, sizeof (OSPF_INTERFACE));                    sptr_interface->area_id = ospf.port[number_of_ports].config.area_id;                        sptr_interface->port_enabled = ospf.port[number_of_ports].config.port_enabled;                sptr_interface->address = ospf.port[number_of_ports].config.ip_address;                sptr_interface->netmask = ospf.port[number_of_ports].config.subnetmask;                sptr_interface->mtu = MAXIMUM_ETHERNET_DATA_SIZE;                sptr_interface->type = (enum OSPF_INTERFACE_TYPE) ospf.port[number_of_ports].config.type;                sptr_interface->hello_interval = ospf.port[number_of_ports].config.hello_interval;                sptr_interface->router_dead_interval = ospf.port[number_of_ports].config.router_dead_interval;                sptr_interface->transmit_delay = ospf.port[number_of_ports].config.transmit_delay;                sptr_interface->priority = ospf.port[number_of_ports].config.priority;                sptr_interface->cost = ospf.port[number_of_ports].config.cost;                sptr_interface->authentication.type = ospf.port[number_of_ports].config.authentication_type;                sptr_interface->source_area_id_for_virtual_link = ospf.port[number_of_ports].config.source_area_id_for_virtual_link;                sptr_interface->port_number = number_of_ports;#if defined(__UNNUMBERED_LINK__)        /* __UNNUMBERED_LINK__ver1.0 */                           /* On interface with IP Address, the interface index takes the value 0.                                * On Interface having no IP Address, the value of IfIndex will be used.                                */                                if((sptr_interface->address == 0) && (sptr_interface->type == OSPF_POINT_TO_POINT))                                {                                        /* with the unnumbered destination IP find the Ifindex from the IP interface*/                        sptr_interface->unnumbered_dest_ip = ospf.port[number_of_ports].config.unnumbered_dest_ip;                    interface_address = sptr_interface->unnumbered_dest_ip;                    interface_address = host_to_net_long(interface_address);                    ip_address.s_addr = interface_address;                    pIp_interface = dstaddr_to_ifp(ip_address);                                        if(pIp_interface == NULL)                                        {                                                OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: Configuration Error - Cannot find Unnumbered Interface!!\n");                                                return;                                        }                                        sptr_interface->interface_index = pIp_interface->if_index;                                }                                else                                {                                        /* numbered interface has index value of 0 */                                        sptr_interface->interface_index = 0;                                }#else /* __UNNUMBERED_LINK__ver1.0 */                                /*      if unnumbered interface is not support then every interface will have an                                 *      index of ZERO                                 */                                sptr_interface->interface_index = 0;#endif /* __UNNUMBERED_LINK__ver1.0 */                if (sptr_interface->authentication.type == OSPF_AUTHENTICATION_SIMPLE)                                        {                    memset (sptr_interface->authentication.key_or_plain_text_passwd, 0x0, OSPF_AUTHENTICATION_SIMPLE_SIZE);                    memcpy (sptr_interface->authentication.key_or_plain_text_passwd, ospf.port[number_of_ports].config.simple_plain_text_or_md5_password, OSPF_AUTHENTICATION_SIMPLE_SIZE);                    }                else if (sptr_interface->authentication.type == OSPF_AUTHENTICATION_MD5)                    {                    ospf_initialize_interfaces_md5_authentication_information (sptr_interface, number_of_ports);                    }                                sptr_interface->poll_interval = ospf.port[number_of_ports].config.poll_interval;                sptr_interface->retransmit_interval = ospf.port[number_of_ports].config.retransmit_interval;                sptr_interface->passive = ospf.port[number_of_ports].config.passive;                sptr_interface->sptr_forward_link = NULL;                sptr_interface->sptr_backward_link = NULL;                                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);                    }                ospf_correlate_interface_to_area (sptr_interface, number_of_ports);                if (sptr_interface->netmask == OSPF_HOST_NET_MASK)                                        {                                        dynamic = FALSE;                    ospf_add_entry_to_hosts_list (sptr_interface, dynamic);                    }                if (sptr_interface->type == OSPF_VIRTUAL_LINK)                                        {                    if ((sptr_interface->sptr_area != NULL) && (sptr_interface->sptr_transit_area != NULL))                                                {                        if ((sptr_interface->sptr_area->flags._bit.stub == TRUE) || (sptr_interface->sptr_transit_area->flags._bit.stub == TRUE))                                                        {                                                        OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: Configuration Error - Cannot configure virtual link in stub area!\n");                            }                        else                            {                                                        ospf_configure_neighbor_for_interface (sptr_interface, number_of_ports);                            }                        }                    }				if((sptr_interface->type == OSPF_NBMA) || (sptr_interface->type == OSPF_POINT_TO_MULTIPOINT))	/*	__NBMA_PTMP__ */					{					ospf_configure_nbma_ptmp_neighbor_for_interface (sptr_interface, number_of_ports);					}				}			else				{                ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_INTERFACE");                }#if defined (__OSPF_MIB__)#if defined(__UNNUMBERED_LINK__)        /* __UNNUMBERED_LINK__ver1.0 */            /* create an instance in the ospfIfTable and ospfIfMetricTable only if             * this is not a virtual interface. Virtual interface is taken care by             * ospf_configure_neighbor_for_interface() above             */            if ( sptr_interface != NULL )                                {                        if (sptr_interface->type != OSPF_VIRTUAL_LINK)                                        {                        if((sptr_interface->type == OSPF_POINT_TO_POINT) && (sptr_interface->address == 0))                                        {                                                ospf2Mapi_request ((void *)sptr_interface, wrnOspfIfCreateReqType);                        }                                ospf2Mapi_request ((void *)sptr_interface, ospfIfCreateReqType);                                    ospf2Mapi_request ((void *)sptr_interface, ospfIfMetricCreateReqType);                }                        }#else   /* __UNNUMBERED_LINK__ver1.0 */            /* create an instance in the ospfIfTable and ospfIfMetricTable only if             * this is not a virtual interface. Virtual interface is taken care by             * ospf_configure_neighbor_for_interface() above             */            if ( sptr_interface != NULL )                                {                        if (sptr_interface->type != OSPF_VIRTUAL_LINK)                                        {                                ospf2Mapi_request ((void *)sptr_interface, ospfIfCreateReqType);                                    ospf2Mapi_request ((void *)sptr_interface, ospfIfMetricCreateReqType);                    }                }#endif /* __UNNUMBERED_LINK__ver1.0 */#endif /*__OSPF_MIB__*/        }        return;}/*************************************************************************** ospf_correlate_interface_to_area - correlate interfaces to areas data structure** This routine correlates interface data structures* to area data structures.** <sptr_interface> OSPF interface** <number_of_ports> Number of OSPF interfaces** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_correlate_interface_to_area (OSPF_INTERFACE *sptr_interface,ULONG number_of_ports){        OSPF_AREA_ENTRY *sptr_area = NULL;        OSPF_AREA_ENTRY *sptr_next_area = NULL;        OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_correlate_interface_to_area\r\n");        if ( sptr_interface->type == OSPF_VIRTUAL_LINK  )                        {            if (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                                {                sptr_area = ospf_create_pseudo_area_for_virtual_link (sptr_interface);                                if ( sptr_area != NULL )                                        {                                        sptr_interface->sptr_area = sptr_area;                                        ospf_put_an_interface_on_areas_interface_list (sptr_area, sptr_interface);#if defined (__OSPF_VIRTUAL_LINK__)                    sptr_interface->area_id = sptr_area->area_id;#endif /* __OSPF_VIRTUAL_LINK__ */                                        }                                }            }                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;                                        ospf_put_an_interface_on_areas_interface_list (sptr_area, sptr_interface);

⌨️ 快捷键说明

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