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

📄 ospf_mib_helper_update.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
    }    return nbrState;;}/***** private management method routines used by MIB API to configure OSPF *****//***************************************************************************************** mApi2Ospf_destroyAuthKey - destroy the ospf authentication** This routine destory any authentication keys that are previously configured.** RETURNS: N/A** NOMANUAL*/LOCAL void mApi2Ospf_destroyAuthKey( OSPF_INTERFACE *pOspfIf ){    if ( pOspfIf->authentication.type == OSPF_AUTHENTICATION_SIMPLE )    {        memset( pOspfIf->authentication.key_or_plain_text_passwd, 0,                OSPF_AUTHENTICATION_SIMPLE_SIZE );    }    else if ( pOspfIf->authentication.type == OSPF_AUTHENTICATION_MD5 )    {        /* free all authentication structures */        if ( pOspfIf->sptr_authentication_key != NULL )        {            ospf_free_entire_list ((OSPF_GENERIC_NODE*)pOspfIf->sptr_authentication_key);            pOspfIf->sptr_authentication_key = NULL;        }    }    pOspfIf->authentication.type = OSPF_AUTHENTICATION_NONE;    return;}/***************************************************************************************** mApi2Ospf_initAuthKey - initialize authentication key** This routine initialize the authentication key for OSPF.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_initAuthKey( ulong_t authType, uchar_t *authKey, uchar_t keyId,                                    size_t authKeyLen, OSPF_INTERFACE *pOspfIf ){    int  same;    if ( (pOspfIf == NULL) || (authKey == NULL) || (authKeyLen == 0) )    {        mApiOspfError(("mApi2Ospf_initAuthKey:Invalid parameter value.\n"));        return ERROR;    }    same = 1;    if ( (mApiOspfAuthType_t)authType == EmApiOspfAuthType_simplePasswd )    {        if ( authKeyLen > OSPF_AUTHENTICATION_SIMPLE_SIZE )        {            mApiOspfError(("mApi2Ospf_initAuthKey:bad simple authLen\n"));            return ERROR;        }        /* if existing authentication type is simple authentication, compare it */        if ( pOspfIf->authentication.type == OSPF_AUTHENTICATION_SIMPLE )        {            same = bcmp( (char *)pOspfIf->authentication.key_or_plain_text_passwd, (char *)authKey,                           authKeyLen );        }        else if ( pOspfIf->authentication.type == OSPF_AUTHENTICATION_MD5 )        {            /* simple password is to be used now. Free the entire md5 authentications             * structure that are previously configured. Note that only one type of             * authentication shall be allowed.             */            if ( pOspfIf->sptr_authentication_key != NULL )            {                ospf_free_entire_list(                                  (OSPF_GENERIC_NODE*)pOspfIf->sptr_authentication_key);                pOspfIf->sptr_authentication_key = NULL;            }        }        if ( same != 0 )        {            bzero ( (char *)pOspfIf->authentication.key_or_plain_text_passwd,                    OSPF_AUTHENTICATION_SIMPLE_SIZE);            bcopy ( (const char *)authKey, (char *)pOspfIf->authentication.key_or_plain_text_passwd,                    OSPF_AUTHENTICATION_SIMPLE_SIZE );        }    }    else if ( (mApiOspfAuthType_t)authType == EmApiOspfAuthType_md5 )    {        OSPF_AUTHENTICATION_KEY *pOspfAuthKey;        /* if we are here, we know that we need to create a new one */        if ( authKeyLen > OSPF_AUTHENTICATION_MD5_SIZE )        {            mApiOspfError(("mApi2Ospf_initAuthKey:bad md5 authKeyLen\n"));            return ERROR;        }        /* rfc2328 supports the use of multiple md5 authentication key. If the md5         * password and key id already existed, do nothing.         */        for ( pOspfAuthKey = pOspfIf->sptr_authentication_key; pOspfAuthKey != NULL;              pOspfAuthKey = pOspfAuthKey->sptr_forward_link )        {            if ( (pOspfAuthKey->key_ID == keyId) &&                 (bcmp( (char *)pOspfAuthKey->md5_16byte_password, (char *)authKey,                        OSPF_AUTHENTICATION_MD5_SIZE ) == 0 ) )            {                mApiOspfPrintf(("mApi2Ospf_initAuthKey:md5 already existed\n"));                return OK;            }        }		/* SPR 81808 */        pOspfAuthKey = (OSPF_AUTHENTICATION_KEY *)table_malloc(                                                   1, sizeof(OSPF_AUTHENTICATION_KEY) );        if ( pOspfAuthKey == NULL )        {            mApiOspfError(("mApi2Ospf_initAuthKey:md5 memory allocation failed\n"));            return ERROR;        }        /* initialize the OSPF_AUTHENTICATION_KEY */        bzero( (char *)pOspfAuthKey, sizeof(OSPF_AUTHENTICATION_KEY) );        pOspfAuthKey->key_ID = keyId;        bcopy( (const char *)authKey, (char *)pOspfAuthKey->md5_16byte_password, OSPF_AUTHENTICATION_MD5_SIZE );        pOspfAuthKey->key_start_accept = 0x00000000L;        pOspfAuthKey->key_start_generate =  0x00000000L;        pOspfAuthKey->key_stop_generate = 0x00000000L;        pOspfAuthKey->key_stop_accept = 0x00000000L;        if ( pOspfIf->sptr_authentication_key == NULL )            pOspfIf->sptr_authentication_key = pOspfAuthKey;        else        {            ospf_add_node_to_end_of_list((OSPF_GENERIC_NODE *)pOspfAuthKey,                                  (OSPF_GENERIC_NODE *)pOspfIf->sptr_authentication_key );        }        /* if this interface is previously configured to use simple password authType,         * clear the simple authentication password         */        if ( pOspfIf->authentication.type == OSPF_AUTHENTICATION_SIMPLE )        {            memset( pOspfIf->authentication.key_or_plain_text_passwd, 0,                    OSPF_AUTHENTICATION_SIMPLE_SIZE );        }    }    return OK;}/***************************************************************************************** mApi2Ospf_reinitIf - reinitialize all interfaces attached to the given area** This routine reinitialize all interfaces attached to the given area. The state* machine for each interface will be forced to execute with the InterfaceDown event* to destory the adjacencies with the neighbors. Area will then be reconfigured and* all interfaces attached to the area will be brought up again so that the adjacencies* can be reestablished.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_reinitIf( mApiOspfArea_t *pMibArea, mApiOspfTrueValue_t up ){    mApiOspfClient_t     *pAttachedClient;    mApiOspfRowStatus_t  rowStatus;    OSPF_INTERFACE       *pOspfIf;    STATUS               rc;    rc = OK;    pOspfIf = NULL;    rowStatus = EmApiOspfRowStatus_notReady; /* to satisfy the compiler */    for ( pAttachedClient = (mApiOspfClient_t *)lstFirst( &pMibArea->listIfAttached);          pAttachedClient != NULL;          pAttachedClient = (mApiOspfClient_t *)lstNext( &pAttachedClient->node ) )    {        switch( pAttachedClient->clientType )        {            case EmApiOspfClientType_intf:                {                    mApiOspfIf_t  *pMibIf;                    pMibIf = (mApiOspfIf_t *)pAttachedClient->pClient;                    rowStatus = pMibIf->ospfIfStatus;                    /* SPR#86135 - skip this interface if its administrative status                     * is not set to enabled.                     */                    if ( pMibIf->ospfIfAdminStat != EmApiOspf_enabled )                        continue;                    /* lookup the interface on the interface list */                    for ( pOspfIf = ospf.sptr_interface_list; pOspfIf != NULL;                          pOspfIf= pOspfIf->sptr_forward_link )                    {                        if ( (pOspfIf->address == pMibIf->ospfIfIpAddress) &&                             (pOspfIf->interface_index == pMibIf->ospfAddressLessIf) )                            break;  /* got it */                    }                }                break;            case EmApiOspfClientType_vintf:                {                    mApiOspfVirtIf_t  *pMibVirtIf;                    pMibVirtIf = (mApiOspfVirtIf_t *)pAttachedClient->pClient;                    rowStatus = pMibVirtIf->ospfVirtIfStatus;                    /* lookup the virtual interface on the interface list */                    for ( pOspfIf = ospf.sptr_interface_list; pOspfIf != NULL;                          pOspfIf= pOspfIf->sptr_forward_link )                    {                        if ( (pOspfIf->virtual_neighbor_rid ==                                                    pMibVirtIf->ospfVirtIfNeighbor)                             && (pOspfIf->area_id == pMibVirtIf->ospfVirtIfAreaId) )                        {                            break;  /* got it */                        }                    }                }                break;            case EmApiOspfClientType_host:                {                    mApiOspfHost_t  *pMibHost;                    pMibHost = (mApiOspfHost_t *)pAttachedClient->pClient;                    rowStatus = pMibHost->ospfHostStatus;                }                break;            case EmApiOspfClientType_nbr:            case EmApiOspfClientType_ag:                mApiOspfPrintf(("mApi2Ospf_reinitIf:Incorrect client type\n"));                pOspfIf = NULL;                rc = ERROR;                break;        }        /* it is ok if we can't find the interface, continue to the next client */        if ( pOspfIf == NULL )            continue;        if ( (rc == OK) && (rowStatus == EmApiOspfRowStatus_active) )        {            if ( up == EmApiOspf_false )            {                /* reset the interface */                ospf_dynamic_reset_interface( pOspfIf );            }            else            {                /* reinitialize the interface - tell 'em don't have to reset the                 * interface since it has been done. Set first argument (pointer                 * to ospf area entry) to NULL since the area remain unchanged...                 */                rc = ospf_dynamic_reinit_interface( NULL, pOspfIf, FALSE );                if ( rc == ERROR )                {                    mApiOspfError(("mApi2Ospf_reinitIf:reinit interface failed\n"));                    break; /* bail out */                }            }        }    }    return rc;}/**************************************************************************************** mApi2Ospf_updateArea - reconfigure an existing OSPF Area instance** This routine reconfigure an existing OSPF Area instance. Depends on the configurable* parameters, some of the changes may not required immediate action from OSPF.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS mApi2Ospf_updateArea( OSPF_AREA_ENTRY *pOspfArea, mApiOspfArea_t *pMibArea,

⌨️ 快捷键说明

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