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

📄 v3mt_usr.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
            case LM_userStorage:                getproc_got_int32(pktp, vbp, SNMP_User_Get_Storage(user));                break;            case LM_userStatus:                getproc_got_int32(pktp, vbp, SNMP_User_Get_Status(user));                break;            }        }#if INSTALL_SNMP_V3_DIFFIE_HELLMAN    /* Is this a Diffie-Hellman object? */    if (STRCMP (VB_TO_COOKIE (vbp), "_usmDHKeyTable") == 0)    {        switch(vbp->vb_ml.ml_last_match) {            int pubKeySize;            bits8_t *pubKeyVal;            case LM_userDHAuthKeyChange:            case LM_userDHOwnAuthKeyChange:                /* If the public auth key is not valid, generate a new one */                if (!(user -> flags & ETC_USER_VALID_AUTHKEY)) {                    DH *DHauth = user -> DH_keys.DHauthValues;                    /* Start with a fresh DH structure */                    DH_free (DHauth);                    if ((DHauth = DH_new()) == NULL) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                                        user -> DH_keys.DHauthValues = DHauth;                    if (((DHauth -> p = BN_new()) == 0) ||                        ((DHauth -> g = BN_new()) == 0)) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    /* Copy the parameters to the DH structure.  Generate the keys. */                    BN_copy (DHauth -> p, SNMP_DH_params.prime);                    BN_copy (DHauth -> g, SNMP_DH_params.base);                                        if (DH_generate_key (DHauth) == 0) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    pubKeySize = BN_num_bytes (DHauth -> pub_key);                    if  ((pubKeyVal = SNMP_memory_alloc (pubKeySize)) == NULL) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    if (BN_bn2bin (DHauth -> pub_key, pubKeyVal) != pubKeySize) {                        if (pubKeyVal) SNMP_memory_free (pubKeyVal);                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    EBufferClean (&(user -> DH_keys.DHpubAuthKey));                    EBufferPreLoad (BFL_IS_DYNAMIC,                                    &(user -> DH_keys.DHpubAuthKey),                                    pubKeyVal,                                    pubKeySize);                    user -> flags |= ETC_USER_VALID_AUTHKEY;                }                getproc_got_string (pktp, vbp,                                    SNMP_Get_DHauthKey_len (user),                                    SNMP_Get_DHauthKey (user),                                    BFL_IS_STATIC, VT_STRING);                break;            case LM_userDHPrivKeyChange:            case LM_userDHOwnPrivKeyChange:                /* If the public privacy key is not valid, generate a new one */                if (!(user -> flags & ETC_USER_VALID_PRIVKEY)) {                    DH *DHpriv = user -> DH_keys.DHprivValues;                    /* Start with a fresh DH structure */                    DH_free (DHpriv);                    if ((DHpriv = DH_new()) == NULL) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                                        user -> DH_keys.DHprivValues = DHpriv;                     if (((DHpriv -> p = BN_new()) == 0) ||                        ((DHpriv -> g = BN_new()) == 0)) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    /* Copy the parameters to the DH structure.  Generate the keys. */                    BN_copy (DHpriv -> p, SNMP_DH_params.prime);                    BN_copy (DHpriv -> g, SNMP_DH_params.base);                                        if (DH_generate_key (DHpriv) == 0) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    pubKeySize = BN_num_bytes (DHpriv -> pub_key);                    if  ((pubKeyVal = SNMP_memory_alloc (pubKeySize)) == NULL) {                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    if (BN_bn2bin (DHpriv -> pub_key, pubKeyVal) != pubKeySize) {                        if (pubKeyVal) SNMP_memory_free (pubKeyVal);                        getproc_error(pktp, vbp, GEN_ERR);                        break;                    }                    EBufferClean (&(user -> DH_keys.DHpubPrivKey));                    EBufferPreLoad (BFL_IS_DYNAMIC,                                    &(user -> DH_keys.DHpubPrivKey),                                    pubKeyVal,                                    pubKeySize);                    user -> flags |= ETC_USER_VALID_PRIVKEY;                }                getproc_got_string (pktp, vbp,                                    SNMP_Get_DHprivKey_len (user),                                    SNMP_Get_DHprivKey (user),                                    BFL_IS_STATIC, VT_STRING);                break;            default:                break;            }        }#endif /* INSTALL_SNMP_V3_DIFFIE_HELLMAN */    }return;}/****************************************************************************NAME:  usertable_getPURPOSE:  Find the appropriate entry in the user table and attach information          from it to the vbp using the getproc_got_* functions.          If we can't find an entry indicate that by calling getproc_nosuchins.PARAMETERS:        OIDC_T          Last component of the object id leading to                        the leaf node in the MIB.  This is usually                        the identifier for the particular attribute                        in the table.        int             Number of components in the unused part of the                        object identifier        OIDC_T     *    Unused part of the object identifier        SNMP_PKT_T *    SNMP packet currently being processed.        VB_T       *    Variable being processed.RETURNS: void****************************************************************************/void  usertable_get(OIDC_T           last_match,                int              tcount,                OIDC_T          *tlist,                SNMP_PKT_T      *pktp,                VB_T            *vbp){SNMP_USER_T *user = 0;bits8_t name[ETC_USER_USER_MAX], engineid[ETC_USER_ENGINE_MAX];ALENGTH_T namelen = ETC_USER_USER_MAX, idlen = ETC_USER_ENGINE_MAX;/* group the vbs that are touching the given entry */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* gather the indexing information, the index will be of the form:   <len> <engineid> <len> <name>   first we do some minor checks then we attempt to find the group */if ((tcount > 4 ) && (tlist[0] != 0) &&    (oid_to_string(tcount, tlist, &idlen, engineid, 0) == 0) &&    ((bits32_t)(idlen + 1) < (bits32_t)tcount) &&    (oid_to_string(tcount - ((int)(idlen + 1)), tlist + idlen + 1,                   &namelen, name, 0) == 0) &&    (namelen != 0) &&    ((bits32_t)(idlen + namelen + 2) == (bits32_t)tcount)) {    user = SNMP_User_Lookup(engineid, idlen, name, namelen);    }/* install the right info into the vbps */if (user == 0)    for(; vbp; vbp = vbp->vb_link)        getproc_nosuchins(pktp,vbp);else    get_user_data(pktp, vbp, user);return;}/****************************************************************************NAME:  usertable_nextPURPOSE:  Find the appropriate entry in the user table and attach information          from it to the vbp using the getproc_got_* functions.          If we can't find an entry indicate that by calling nextproc_no_nextPARAMETERS:        OIDC_T          Last component of the object id leading to                        the leaf node in the MIB.  This is usually                        the identifier for the particular attribute                        in the table.        int             Number of components in the unused part of the                        object identifier        OIDC_T     *    Unused part of the object identifier        SNMP_PKT_T *    SNMP packet currently being processed.        VB_T       *    Variable being processed.RETURNS: void****************************************************************************/void  usertable_next(OIDC_T          last_match,                 int             tcount,                 OIDC_T         *tlist,                 SNMP_PKT_T     *pktp,                 VB_T           *vbp){SNMP_USER_T *user = 0;bits8_t name[ETC_USER_USER_MAX], engineid[ETC_USER_ENGINE_MAX];ALENGTH_T namelen = 0, idlen = 0;int rcount;OIDC_T *rlist;/* group the vbs that are touching the given entry */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);user = SNMP_User_Next(tcount, tlist);/* install the right info into the vbps */if (user == 0)    for(; vbp; vbp = vbp->vb_link)        nextproc_no_next(pktp,vbp);else {    /* determine and insert instance information */    namelen = ETC_USER_USER_MAX;    idlen = ETC_USER_ENGINE_MAX;    SNMP_User_Name(user, engineid, &idlen, name, &namelen);    rcount = 2 + idlen + namelen;    rlist = SNMP_memory_alloc((unsigned int)(rcount * sizeof(OIDC_T)));    if (rlist == 0)        nextproc_error(pktp, vbp, GEN_ERR);    else {        /* insert the data */        get_user_data(pktp, vbp, user);        /* then build and insert the instance info */        (void) string_to_oid(idlen, engineid, (int)(idlen + 1), rlist, 0);        (void) string_to_oid(namelen, name, (int)(namelen + 1),                             rlist + idlen + 1, 0);        for(; vbp; vbp = vbp->vb_link)            nextproc_next_instance(pktp, vbp, rcount, rlist);        SNMP_memory_free(rlist);        }    }return;}/****************************************************************************NAME: usertable_destroy_cleanupPURPOSE: Cleanup after a user test (delete) succeeded but some other test         failed.  We merely call the DESTROY_BACKOUT macro to allow         the customer to restore any changed state.         Expects the pointer to point to a VB_TPARAMETERS:         ptr_t   A pointer to the vb that points to the user                that we were going to delete, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  usertable_destroy_cleanup(ptr_t userptr){SNMP_V3_USER_DESTROY_BACKOUT(((VB_T *)userptr)->vb_priv, 0);}/****************************************************************************NAME: usertable_create_cleanupPURPOSE: Cleanup after a user create test succeeded but some         other test failed.  As this is a create the state         pointer points to a structure that is installed,         we need to deinstall it, call the backout routine,         and cleanup the state.         Expects the pointer to point to a VB_TPARAMETERS:         ptr_t   A pointer to the vb that points to the user                that we were going to create, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  usertable_create_cleanup(ptr_t userptr){SNMP_USER_T *user;user = (SNMP_USER_T *)(((VB_T *)userptr)->vb_priv);SNMP_V3_USER_CREATE_BACKOUT(0, user);SNMP_User_Deinstall(user);SNMP_User_Destroy(user);}/****************************************************************************NAME: usertable_update_cleanupPURPOSE: Cleanup after a user update test succeeded but some         other test failed.  As this is an update the state         pointer points to a structure that isn't installed.         The next pointer of that structure points to the         installed copy.  We call the backout routine and         cleanup the state.PARAMETERS:         ptr_t   A pointer to the vb that points to the user                that contained the update information,                cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  usertable_update_cleanup(ptr_t userptr){SNMP_USER_T *user;user = (SNMP_USER_T *)(((VB_T *)userptr)->vb_priv);SNMP_V3_USER_UPDATE_BACKOUT(user->next, user);

⌨️ 快捷键说明

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