📄 usmdhuserkeytable_interface.c
字号:
var_usmUserEngineID.type = ASN_OCTET_STR; memset(&var_usmUserName, 0x00, sizeof(var_usmUserName)); var_usmUserName.type = ASN_OCTET_STR; /* * chain temp index varbinds together */ var_usmUserEngineID.next_variable = &var_usmUserName; var_usmUserName.next_variable = NULL; DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_usmUserEngineID); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, usmUserEngineID_len might not be */ if (var_usmUserEngineID.val_len > sizeof(mib_idx->usmUserEngineID)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->usmUserEngineID, var_usmUserEngineID.val.string, var_usmUserEngineID.val_len); mib_idx->usmUserEngineID_len = var_usmUserEngineID.val_len / sizeof(mib_idx->usmUserEngineID[0]); } /* * NOTE: val_len is in bytes, usmUserName_len might not be */ if (var_usmUserName.val_len > sizeof(mib_idx->usmUserName)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->usmUserName, var_usmUserName.val.string, var_usmUserName.val_len); mib_idx->usmUserName_len = var_usmUserName.val_len / sizeof(mib_idx->usmUserName[0]); } } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_usmUserEngineID); return err;} /* usmDHUserKeyTable_index_from_oid *//* ********************************************************************* * @internal * allocate resources for a usmDHUserKeyTable_rowreq_ctx */usmDHUserKeyTable_rowreq_ctx *usmDHUserKeyTable_allocate_rowreq_ctx(usmDHUserKeyTable_data * data){ usmDHUserKeyTable_rowreq_ctx *rowreq_ctx = SNMP_MALLOC_TYPEDEF(usmDHUserKeyTable_rowreq_ctx); DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_allocate_rowreq_ctx", "called\n")); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "Couldn't allocate memory for a " "usmDHUserKeyTable_rowreq_ctx.\n"); } else { if (NULL != data) { /* * for non-transient data, track when we got data from user */ rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; rowreq_ctx->data = data; } else if (NULL == (rowreq_ctx->data = usmDHUserKeyTable_allocate_data())) { SNMP_FREE(rowreq_ctx); return NULL; } } /* * undo context will be allocated when needed (in *_undo_setup) */ rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; rowreq_ctx->usmDHUserKeyTable_data_list = NULL; rowreq_ctx->usmDHUserKeyTable_reg = usmDHUserKeyTable_if_ctx.user_ctx; return rowreq_ctx;} /* usmDHUserKeyTable_allocate_rowreq_ctx *//* * @internal * release resources for a usmDHUserKeyTable_rowreq_ctx */voidusmDHUserKeyTable_release_rowreq_ctx(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_release_rowreq_ctx", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * for non-transient data, don't free data we got from the user */ if ((rowreq_ctx->data) && !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) usmDHUserKeyTable_release_data(rowreq_ctx->data); if (rowreq_ctx->undo) { usmDHUserKeyTable_release_data(rowreq_ctx->undo); rowreq_ctx->undo = NULL; } /* * free index oid pointer */ if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) free(rowreq_ctx->oid_idx.oids); SNMP_FREE(rowreq_ctx);} /* usmDHUserKeyTable_release_rowreq_ctx *//** * @internal * wrapper */static int_mfd_usmDHUserKeyTable_pre_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc = usmDHUserKeyTable_pre_request(usmDHUserKeyTable_if_ctx.user_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from " "usmDHUserKeyTable_pre_request\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR;} /* _mfd_usmDHUserKeyTable_pre_request *//** * @internal * wrapper */static int_mfd_usmDHUserKeyTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ usmDHUserKeyTable_rowreq_ctx *rowreq_ctx; int rc = usmDHUserKeyTable_post_request(usmDHUserKeyTable_if_ctx.user_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from " "usmDHUserKeyTable_post_request\n", rc)); } /* * if it was set, clear row created flag. */ rowreq_ctx = netsnmp_container_table_row_extract(requests); if ((NULL != rowreq_ctx) && (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; return SNMP_ERR_NOERROR;} /* _mfd_usmDHUserKeyTable_post_request *//** * @internal * wrapper */static int_mfd_usmDHUserKeyTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ usmDHUserKeyTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_object_lookup", "called\n")); /* * get our context from mfd * usmDHUserKeyTable_interface_ctx *if_ctx = * (usmDHUserKeyTable_interface_ctx *)reginfo->my_reg_void; */ if (NULL == rowreq_ctx) { netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); } else { usmDHUserKeyTable_row_prep(rowreq_ctx); } return SNMP_ERR_NOERROR;} /* _mfd_usmDHUserKeyTable_object_lookup *//*********************************************************************** * * GET processing * ***********************************************************************//* * @internal * Retrieve the value for a particular column */NETSNMP_STATIC_INLINE int_usmDHUserKeyTable_get_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */ case COLUMN_USMDHUSERAUTHKEYCHANGE: var->type = ASN_OCTET_STR; rc = usmDHUserAuthKeyChange_get(rowreq_ctx, (char **) &var->val.string, &var->val_len); break; /* * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */ case COLUMN_USMDHUSEROWNAUTHKEYCHANGE: var->type = ASN_OCTET_STR; rc = usmDHUserOwnAuthKeyChange_get(rowreq_ctx, (char **) &var->val.string, &var->val_len); break; /* * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */ case COLUMN_USMDHUSERPRIVKEYCHANGE: var->type = ASN_OCTET_STR; rc = usmDHUserPrivKeyChange_get(rowreq_ctx, (char **) &var->val.string, &var->val_len); break; /* * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */ case COLUMN_USMDHUSEROWNPRIVKEYCHANGE: var->type = ASN_OCTET_STR; rc = usmDHUserOwnPrivKeyChange_get(rowreq_ctx, (char **) &var->val.string, &var->val_len); break; default: snmp_log(LOG_ERR, "unknown column %d in _usmDHUserKeyTable_get_column\n", column); break; } return rc;} /* _usmDHUserKeyTable_get_column */int_mfd_usmDHUserKeyTable_get_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ usmDHUserKeyTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info *tri; u_char *old_string; void (*dataFreeHook) (void *); int rc; DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_values", "called\n")); netsnmp_assert(NULL != rowreq_ctx); for (; requests; requests = requests->next) { /* * save old pointer, so we can free it if replaced */ old_string = requests->requestvb->val.string; dataFreeHook = requests->requestvb->dataFreeHook; if (NULL == requests->requestvb->val.string) { requests->requestvb->val.string = requests->requestvb->buf; requests->requestvb->val_len = sizeof(requests->requestvb->buf); } else if (requests->requestvb->buf == requests->requestvb->val.string) { if (requests->requestvb->val_len != sizeof(requests->requestvb->buf)) requests->requestvb->val_len = sizeof(requests->requestvb->buf); } /* * get column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _usmDHUserKeyTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); if (rc) { if (MFD_SKIP == rc) { requests->requestvb->type = ASN_PRIV_RETRY; rc = SNMP_ERR_NOERROR; } } else if (NULL == requests->requestvb->val.string) { snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); rc = SNMP_ERR_GENERR; } if (rc) netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); /* * if the buffer wasn't used previously for the old data (i.e. it * was allcoated memory) and the get routine replaced the pointer, * we need to free the previous pointer. */ if (old_string && (old_string != requests->requestvb->buf) && (requests->requestvb->val.string != old_string)) { if (dataFreeHook) (*dataFreeHook) (old_string); else free(old_string); } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_usmDHUserKeyTable_get_values *//*********************************************************************** * * SET processing * ***********************************************************************//*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*//* * @internal * Check the syntax for a particular column */NETSNMP_STATIC_INLINE int_usmDHUserKeyTable_check_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -