📄 ospf_mib_helper_update.c
字号:
case EmApiOspfImportAsExtern_importNssa: pOspfArea->flags._bit.nssa = TRUE; break; } /* SPR 78381: configure area summary option. This option is only applicable * to stub area. If noAreaSummary is needed or if this is not a stub area, set * inject_summary_lsa_into_stub_area boolean flag to FALSE. */ if ( pMibArea->ospfImportAsExtern != EmApiOspfImportAsExtern_importExternal ) { switch( pMibArea->ospfAreaSummary ) { case EmApiOspfAreaSummary_noAreaSummary: /* no summary LSAs into stub area. Must setup the default route */ pOspfArea->inject_summary_lsa_into_stub_area = FALSE; break; case EmApiOspfAreaSummary_sendAreaSummary: pOspfArea->inject_summary_lsa_into_stub_area = TRUE; break; } if ( pMibStub == NULL ) pOspfArea->stub_default_cost = pMibArea->defaultStubMetric; else { /* SPR#86625 - 0the stubDefaultCost defined by the ospfStubMetric * is configured valid only if the rowStatus object is set to * active. If stub rowStatus is not active, apply the predefined * mib api default metric. */ if ( pMibStub->ospfStubStatus != EmApiOspfRowStatus_active ) pOspfArea->stub_default_cost = pMibArea->defaultStubMetric; else pOspfArea->stub_default_cost = pMibStub->ospfStubMetric; } } else { /* AreaSummary is only applicable to stub area. By default, the * ospfAreaSummary object is set to sendNoAreaSummary */ pOspfArea->inject_summary_lsa_into_stub_area = FALSE; /* SPR#86625 - explicitly reset the stub default cost */ pOspfArea->stub_default_cost = 0; } size = sizeof(OSPF_ADDRESS_RANGE_LIST_ENTRY); for ( pAttachedClient = (mApiOspfClient_t *)lstFirst( &pMibArea->listAreaAggregate ); pAttachedClient != NULL; pAttachedClient = (mApiOspfClient_t *)lstNext( &pAttachedClient->node ) ) { pMibAreaAg = (mApiOspfAreaAggregate_t *)pAttachedClient->pClient; /* SPR 81808 */ pOspfAddrRange = (OSPF_ADDRESS_RANGE_LIST_ENTRY *)table_malloc( 1, size ); if ( pOspfAddrRange == NULL ) { mApiOspfError(("mApi2Ospf_createArea:ospf_dynamic_create_area failed\n")); if ( thisMapi->ospfRfcProto == EospfProtoType_rfc2328 ) { if ( pOspfArea->sptr_address_ranges != NULL ) { ospf_free_entire_list( (OSPF_GENERIC_NODE*)pOspfArea->sptr_address_ranges); } } else { if ( pOspfArea->sptr_address_ranges != NULL) { /* SPR 81808 */ table_free( (void *)pOspfArea->sptr_address_ranges ); pOspfArea->sptr_address_ranges = NULL; } } /* SPR 81808 */ table_free( pOspfArea ); pOspfArea = NULL; return ERROR; } /* fill in the OSPF_ADDRESS_RANGE_LIST_ENTRY */ memset( pOspfAddrRange, 0, sizeof(OSPF_ADDRESS_RANGE_LIST_ENTRY) ); pOspfAddrRange->network = pMibAreaAg->ospfAreaAggregateNet; pOspfAddrRange->mask = pMibAreaAg->ospfAreaAggregateMask; pOspfAddrRange->advertise = mApi2Ospf_aggregateEffect2BoolGet( pMibAreaAg->ospfAreaAggregateEffect ); pOspfAddrRange->cost = 1; /* set to default */ pOspfAddrRange->active = (BYTE_ENUM (BOOLEAN))FALSE; if ( thisMapi->ospfRfcProto == EospfProtoType_rfc2328 ) { if ( pOspfArea->sptr_address_ranges == NULL ) pOspfArea->sptr_address_ranges = pOspfAddrRange; else ospf_add_node_to_end_of_list((OSPF_GENERIC_NODE *)pOspfAddrRange, (OSPF_GENERIC_NODE *)pOspfArea->sptr_address_ranges ); /* keep track the number of address range that we got */ pOspfArea->number_of_address_ranges++; } else { if ( pOspfArea->sptr_address_ranges != NULL) { /* SPR 81808 */ table_free( (void *)pOspfArea->sptr_address_ranges ); pOspfArea->sptr_address_ranges = NULL; } else pOspfArea->number_of_address_ranges++; /* apply the new address range configuration */ pOspfArea->sptr_address_ranges = pOspfAddrRange; } } if ( ospf_dynamic_create_area( pOspfArea ) != OK ) { mApiOspfError(("mApi2Ospf_createArea:ospf_dynamic_create_area failed\n")); /* SPR 81808 */ table_free( pOspfArea ); pOspfArea = NULL; return ERROR; } mApiOspfPrintf(("mApi2Ospf_createArea:interface created\n")); return OK;}/***************************************************************************************** mApi2Ospf_updateStub - update an existing OSPF Stub parameters** This routine reconfigure the stub area with the metric type and metric value applied* to the stub area. No stub area is actually created here. The stub area is created in* mApi2Ospf_createArea(). This routine is called when an instance in the* ospfStubTable is created or modified.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_updateStub( OSPF_AREA_ENTRY *pOspfArea, mApiOspfStub_t *pMibStub ){ mApiOspfArea_t *pMibArea; /* get the area associated with this stub */ pMibArea = pMibStub->pArea; if ( pMibArea == NULL ) { mApiOspfError(("mApi2Ospf_updateStub:Invalid pArea pointer!\n")); return ERROR; } /* make sure the area is configured as stub at the first place */ if ( (pOspfArea->flags._bit.stub != TRUE) && (pOspfArea->flags._bit.nssa != TRUE) ) { mApiOspfError(("mApi2Ospf_updateStub:Area not configured as stub!\n")); return ERROR; } /* SPR#86625 - if the stub row status has been set to notInService(2) or * notReady(3), the stubDefaultCost previously configured is considered * invalid. The router must originate a new default summary lsa using * the predefined mib api stub default cost. */ if ( (pMibStub->ospfStubStatus == EmApiOspfRowStatus_notInService) || (pMibStub->ospfStubStatus == EmApiOspfRowStatus_notReady) ) { pOspfArea->stub_default_cost = pMibArea->defaultStubMetric; ospf_dynamic_send_default_summary_lsa( pOspfArea, FALSE ); return OK; } /* if we are here, the stub row status is active. Check if the stub * area cost has changed. SPR#86625 - changing the stub default cost * doesn't require the stub area to be reinitialized. The router simply * need to reoriginates a new default summary lsa into the stub area * if the stub area is configured to receive summary lsa. */ if ( pOspfArea->stub_default_cost != pMibStub->ospfStubMetric ) { pOspfArea->stub_default_cost = pMibStub->ospfStubMetric; if ( pMibArea->ospfAreaSummary == EmApiOspfAreaSummary_sendAreaSummary ) ospf_dynamic_send_default_summary_lsa( pOspfArea, FALSE ); } return OK;}/*************************************************************************************** mApi2Ospf_createHost - instantiates an OSPF Host Interface** This routine instantiates an OSPF Host Interface. The instance will be created and added* to the ospf.sptr_interface_list as well as ospf.sptr_host_list. An attempt will be made* to bring up such interface immediately. If the interface is failed to be brought up for* any reason, it will be destroyed and an error will be returned.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_createHost( mApiOspfHost_t *pMibHost ){ OSPF_INTERFACE *pOspfIf; /* allocate an OSPF_INTERFACE instance from ospf memory pool */ /* SPR 81808 */ pOspfIf = (OSPF_INTERFACE *)table_malloc( 1, sizeof(OSPF_INTERFACE) ); if ( pOspfIf == NULL ) { mApiOspfError(("mApi2Ospf_createHost:ospf memory pool allocation failed!\n")); return ERROR; } /* fill in the OSPF_INTERFACE structure */ memset( pOspfIf, 0, sizeof(OSPF_INTERFACE) ); pOspfIf->address = pMibHost->ospfHostIpAddress; pOspfIf->interface_index = 0; /* always */ pOspfIf->area_id = pMibHost->ospfHostAreaId; pOspfIf->cost = (ushort_t)pMibHost->ospfHostMetric; /* set initial interface state to down */ pOspfIf->state = OSPF_INTERFACE_IS_DOWN; /* NOTE: windnet ospf implements the host interface just as a regular interface. * This somewhat complicates the dynamic configuration of an host interface. * This is because most of the interface specific parameters are not defined * in the ospfHostTable in the ospf-mib. To workaround this problem, set all * the interface specific parameters to its default value as specified by the * ospfIfTable in the ospf-mib. */ pOspfIf->port_enabled = (enum BOOLEAN)TRUE; pOspfIf->type = (enum OSPF_INTERFACE_TYPE)OSPF_BROADCAST; /* set the netmask and mtu size for this interface */ pOspfIf->netmask = pMibHost->defaultNetmask; pOspfIf->mtu = pMibHost->defaultMtu; pOspfIf->priority = (ushort_t)OSPF_DEFAULT_PRIORITY; pOspfIf->transmit_delay = OSPF_DEFAULT_TRANSMIT_DELAY; pOspfIf->retransmit_interval = OSPF_DEFAULT_RETRANSMIT_INTERVAL; pOspfIf->hello_interval = OSPF_BROADCAST_DEFAULT_HELLO; pOspfIf->router_dead_interval = OSPF_DEFAULT_ROUTER_DEAD_INTERVAL; pOspfIf->poll_interval = OSPF_DEFAULT_POLL_INTERVAL; pOspfIf->authentication.type = OSPF_AUTHENTICATION_NONE; /* no authentication */ pOspfIf->passive = (enum BOOLEAN)FALSE; /* call ospf_dynamic_bring_up_interface() to perform the next step of the interface * initialization. The routine will configure multicast group for the interface, * correlate the interface to an ospf area and to init the state machine for this * interface */ if ( ospf_dynamic_create_interface( pOspfIf ) != OK ) { mApiOspfError(("mApi2Ospf_createHost:ospf_dynamic_create_interface failed\n")); /* SPR 81808 */ table_free( pOspfIf ); pOspfIf = NULL; return ERROR; } mApiOspfPrintf(("mApi2Ospf_createHost:interface created\n")); return OK;}/*************************************************************************************** mApi2Ospf_createIf - instantiates an OSPF Interface** This routine instantiates an OSPF Interface. The instance will be created and added* to the ospf.sptr_interface_list and an attempt will be made to bring up such interface* immediately. If the interface is failed to be brought up for any reason, it will be* destroyed and an error will be returned.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_createIf( mApiOspfIf_t *pMibIf ){ OSPF_INTERFACE *pOspfIf; mApiOspfIfMetric_t *pMibIfm; /* if interface administrative status is not enabled, do not continue */ if ( pMibIf->ospfIfAdminStat == EmApiOspf_disabled ) ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -