📄 usmdhuserkeytable_data_set.c
字号:
a Diffie-Hellman key exchange. The right-most n bits of the shared secret 'sk', where 'n' is the number of bits required for the protocol defined by usmUserPrivProtocol, are installed as the operational privacy key for this row after a successful SET. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * * Its syntax is DHKeyChange (based on perltype OCTETSTR) * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) * This data type requires a length. (Max 32) *//** * Check that the proposed new value is potentially valid. * * @param rowreq_ctx * Pointer to the row request context. * @param usmDHUserPrivKeyChange_val_ptr * A char containing the new value. * @param usmDHUserPrivKeyChange_val_ptr_len * The size (in bytes) of the data pointed to by usmDHUserPrivKeyChange_val_ptr * * @retval MFD_SUCCESS : incoming value is legal * @retval MFD_NOT_VALID_NOW : incoming value is not valid now * @retval MFD_NOT_VALID_EVER : incoming value is never valid * * This is the place to check for requirements that are not * expressed in the mib syntax (for example, a requirement that * is detailed in the description for an object). * * You should check that the requested change between the undo value and the * new value is legal (ie, the transistion from one value to another * is legal). * *@note * This check is only to determine if the new value * is \b potentially valid. This is the first check of many, and * is one of the simplest ones. * *@note * this is not the place to do any checks for values * which depend on some other value in the mib. Those * types of checks should be done in the * usmDHUserKeyTable_check_dependencies() function. * * The following checks have already been done for you: * The syntax is ASN_OCTET_STR * * If there a no other checks you need to do, simply return MFD_SUCCESS. * */intusmDHUserPrivKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, char *usmDHUserPrivKeyChange_val_ptr, size_t usmDHUserPrivKeyChange_val_ptr_len){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_check_value", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); netsnmp_assert(NULL != usmDHUserPrivKeyChange_val_ptr); /* * TODO:441:o: |-> Check for valid usmDHUserPrivKeyChange value. */ return usmDHUserCheckValue(rowreq_ctx->data, 0, usmDHUserPrivKeyChange_val_ptr, usmDHUserPrivKeyChange_val_ptr_len);} /* usmDHUserPrivKeyChange_check_value *//** * Save old value information * * @param rowreq_ctx * Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. * * This function will be called after the table level undo setup function * usmDHUserKeyTable_undo_setup has been called. * *@note * this function will only be called if a new value is set for this column. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in this function, so it * won't be done unless it is necessary. */intusmDHUserPrivKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ struct usmUser *undouser; DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_undo_setup", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:455:o: |-> Setup usmDHUserPrivKeyChange undo. */ /* * copy usmDHUserPrivKeyChange and usmDHUserPrivKeyChange_len data * set rowreq_ctx->undo->usmDHUserPrivKeyChange from rowreq_ctx->data->usmDHUserPrivKeyChange */ undouser = rowreq_ctx->undo; undouser->privKeyLen = rowreq_ctx->data->privKeyLen; memdup(&undouser->privKey, rowreq_ctx->data->privKey, rowreq_ctx->data->privKeyLen); return MFD_SUCCESS;} /* usmDHUserPrivKeyChange_undo_setup *//** * Set the new value. * * @param rowreq_ctx * Pointer to the users context. You should know how to * manipulate the value from this object. * @param usmDHUserPrivKeyChange_val_ptr * A char containing the new value. * @param usmDHUserPrivKeyChange_val_ptr_len * The size (in bytes) of the data pointed to by usmDHUserPrivKeyChange_val_ptr */intusmDHUserPrivKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, char *usmDHUserPrivKeyChange_val_ptr, size_t usmDHUserPrivKeyChange_val_ptr_len){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_set", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); netsnmp_assert(NULL != usmDHUserPrivKeyChange_val_ptr); /* * TODO:461:M: |-> Set usmDHUserPrivKeyChange value. * set usmDHUserPrivKeyChange value in rowreq_ctx->data */ usmDHSetKey(rowreq_ctx->data, 0, usmDHUserPrivKeyChange_val_ptr, usmDHUserPrivKeyChange_val_ptr_len); return MFD_SUCCESS;} /* usmDHUserPrivKeyChange_set *//** * undo the previous set. * * @param rowreq_ctx * Pointer to the users context. */intusmDHUserPrivKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ struct usmUser *undouser; DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_undo", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:456:o: |-> Clean up usmDHUserPrivKeyChange undo. */ /* * copy usmDHUserPrivKeyChange and usmDHUserPrivKeyChange_len data * set rowreq_ctx->data->usmDHUserPrivKeyChange from rowreq_ctx->undo->usmDHUserPrivKeyChange */ undouser = rowreq_ctx->undo; /** uncopy priv key */ undouser->privKeyLen = rowreq_ctx->data->privKeyLen; SNMP_FREE(rowreq_ctx->data->privKey); rowreq_ctx->data->privKey = undouser->privKey; undouser->privKey = NULL; return MFD_SUCCESS;} /* usmDHUserPrivKeyChange_undo *//*--------------------------------------------------------------------- * SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserOwnPrivKeyChange * usmDHUserOwnPrivKeyChange is subid 4 of usmDHUserKeyEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.3.101.1.1.2.1.4 * Description:The object used to change the agent's own Privacy Key using a Diffie-Hellman key exchange. The right-most n bits of the shared secret 'sk', where 'n' is the number of bits required for the protocol defined by usmUserPrivProtocol, are installed as the operational privacy key for this row after a successful SET. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * * Its syntax is DHKeyChange (based on perltype OCTETSTR) * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) * This data type requires a length. (Max 32) *//** * Check that the proposed new value is potentially valid. * * @param rowreq_ctx * Pointer to the row request context. * @param usmDHUserOwnPrivKeyChange_val_ptr * A char containing the new value. * @param usmDHUserOwnPrivKeyChange_val_ptr_len * The size (in bytes) of the data pointed to by usmDHUserOwnPrivKeyChange_val_ptr * * @retval MFD_SUCCESS : incoming value is legal * @retval MFD_NOT_VALID_NOW : incoming value is not valid now * @retval MFD_NOT_VALID_EVER : incoming value is never valid * * This is the place to check for requirements that are not * expressed in the mib syntax (for example, a requirement that * is detailed in the description for an object). * * You should check that the requested change between the undo value and the * new value is legal (ie, the transistion from one value to another * is legal). * *@note * This check is only to determine if the new value * is \b potentially valid. This is the first check of many, and * is one of the simplest ones. * *@note * this is not the place to do any checks for values * which depend on some other value in the mib. Those * types of checks should be done in the * usmDHUserKeyTable_check_dependencies() function. * * The following checks have already been done for you: * The syntax is ASN_OCTET_STR * * If there a no other checks you need to do, simply return MFD_SUCCESS. * */intusmDHUserOwnPrivKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, char *usmDHUserOwnPrivKeyChange_val_ptr, size_t usmDHUserOwnPrivKeyChange_val_ptr_len){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_check_value", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); netsnmp_assert(NULL != usmDHUserOwnPrivKeyChange_val_ptr); /* * TODO:441:o: |-> Check for valid usmDHUserOwnPrivKeyChange value. */ return usmDHUserPrivKeyChange_check_value(rowreq_ctx, usmDHUserOwnPrivKeyChange_val_ptr, usmDHUserOwnPrivKeyChange_val_ptr_len);} /* usmDHUserOwnPrivKeyChange_check_value *//** * Save old value information * * @param rowreq_ctx * Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. * * This function will be called after the table level undo setup function * usmDHUserKeyTable_undo_setup has been called. * *@note * this function will only be called if a new value is set for this column. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in this function, so it * won't be done unless it is necessary. */intusmDHUserOwnPrivKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_undo_setup", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:455:o: |-> Setup usmDHUserOwnPrivKeyChange undo. */ /* * copy usmDHUserOwnPrivKeyChange and usmDHUserOwnPrivKeyChange_len data * set rowreq_ctx->undo->usmDHUserOwnPrivKeyChange from rowreq_ctx->data->usmDHUserOwnPrivKeyChange */ return usmDHUserPrivKeyChange_undo_setup(rowreq_ctx);} /* usmDHUserOwnPrivKeyChange_undo_setup *//** * Set the new value. * * @param rowreq_ctx * Pointer to the users context. You should know how to * manipulate the value from this object. * @param usmDHUserOwnPrivKeyChange_val_ptr * A char containing the new value. * @param usmDHUserOwnPrivKeyChange_val_ptr_len * The size (in bytes) of the data pointed to by usmDHUserOwnPrivKeyChange_val_ptr */intusmDHUserOwnPrivKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, char *usmDHUserOwnPrivKeyChange_val_ptr, size_t usmDHUserOwnPrivKeyChange_val_ptr_len){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_set", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); netsnmp_assert(NULL != usmDHUserOwnPrivKeyChange_val_ptr); /* * TODO:461:M: |-> Set usmDHUserOwnPrivKeyChange value. * set usmDHUserOwnPrivKeyChange value in rowreq_ctx->data */ return usmDHUserPrivKeyChange_set(rowreq_ctx, usmDHUserOwnPrivKeyChange_val_ptr, usmDHUserOwnPrivKeyChange_val_ptr_len);} /* usmDHUserOwnPrivKeyChange_set *//** * undo the previous set. * * @param rowreq_ctx * Pointer to the users context. */intusmDHUserOwnPrivKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_undo", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:456:o: |-> Clean up usmDHUserOwnPrivKeyChange undo. */ /* * copy usmDHUserOwnPrivKeyChange and usmDHUserOwnPrivKeyChange_len data * set rowreq_ctx->data->usmDHUserOwnPrivKeyChange from rowreq_ctx->undo->usmDHUserOwnPrivKeyChange */ return usmDHUserPrivKeyChange_undo(rowreq_ctx);} /* usmDHUserOwnPrivKeyChange_undo *//** * check dependencies * * This is useful for for tables which have dependencies between columns * (or rows, or tables). For example, two columns allocating a percentage * of something add up 100%. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the FLAG_* bits can be found in * usmDHUserKeyTable_oids.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @retval MFD_SUCCESS all the changes to the row are legal * @retval MFD_ERROR one or more changes are not legal * * (see README-table-usmDHUserKeyTable if you don't have dependencies) */intusmDHUserKeyTable_check_dependencies(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; int flags; DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_check_dependencies", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:470:o: Check usmDHUserKeyTable row dependencies. * check that all new value are legal and consistent with each other */ flags = rowreq_ctx->column_set_flags; if (flags & FLAG_USMDHUSERAUTHKEYCHANGE && flags & FLAG_USMDHUSEROWNAUTHKEYCHANGE) { return MFD_ERROR; } if (flags & FLAG_USMDHUSERPRIVKEYCHANGE && flags & FLAG_USMDHUSEROWNPRIVKEYCHANGE) { return MFD_ERROR; } return rc;} /* usmDHUserKeyTable_check_dependencies *//** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -