/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiSensorThdNegHysteresisTable_set_reserve1 (netsnmp_request_group * rg) { saHpiSensorThdNegHysteresisTable_context *row_ctx = (saHpiSensorThdNegHysteresisTable_context *) rg->existing_row; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc = 0; DEBUGMSGTL ((AGENT, "saHpiSensorThdNegHysteresisTable_set_reserve1. Entry.\n")); for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISREADABLE: case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISWRITABLE: case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALISFIXED: case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALVALUESPRESENT: rc = SNMP_ERR_NOTWRITABLE; break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALRAW: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiSensorThdNegHysteresisRaw)); break; case COLUMN_SAHPISENSORTHDNEGHYSTERESISICALINTERPRETED: /** OCTETSTR = ASN_OCTET_STR */ if (var->type != ASN_OCTET_STR) { rc = SNMP_ERR_WRONGTYPE; } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log (LOG_ERR, "unknown column in " "saHpiSensorThdNegHysteresisTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX (rg->status, current->ri->status); } DEBUGMSGTL ((AGENT, "saHpiSensorThdNegHysteresisTable_set_reserve1. Exit. (rc:%d) \n", rc)); }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiSensorThdUpMinorTable_set_reserve1( netsnmp_request_group *rg ) { saHpiSensorThdUpMinorTable_context *row_ctx = (saHpiSensorThdUpMinorTable_context *)rg->existing_row; // saHpiSensorThdUpMinorTable_context *undo_ctx = // (saHpiSensorThdUpMinorTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiSensorThdUpMinorTable_set_reserve1, called\n")); /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for ( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPISENSORTHDUPMINORVALUE: /** SaHpiSensorReadingValue = ASN_OCTET_STR */ rc = netsnmp_check_vb_type(var, ASN_OCTET_STR); if (rc == SNMP_ERR_NOERROR ) { rc = check_sensor_reading_value( var->val_len, row_ctx->saHpiSensorThdUpMinorType); if (rc != SNMP_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "COLUMN_SAHPISENSORTHDUPMINORVALUE ERROR: %d\n", rc)); } } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiSensorThdUpMinorTable_set_reserve1\n"); } if (rc) netsnmp_request_set_error( current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiCtrlAnalogTable_set_reserve1( netsnmp_request_group *rg ) { saHpiCtrlAnalogTable_context *row_ctx = (saHpiCtrlAnalogTable_context *)rg->existing_row; // saHpiCtrlAnalogTable_context *undo_ctx = // (saHpiCtrlAnalogTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiCtrlAnalogTable_set_reserve1, called\n")); /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for ( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPICTRLANALOGMODE: /** SaHpiCtrlMode = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiCtrlAnalogMode)); break; case COLUMN_SAHPICTRLANALOGSTATE: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiCtrlAnalogState)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiCtrlAnalogTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiAutoInsertTimeoutTable_set_reserve1( netsnmp_request_group *rg ) { // saHpiAutoInsertTimeoutTable_context *row_ctx = // (saHpiAutoInsertTimeoutTable_context *)rg->existing_row; // saHpiAutoInsertTimeoutTable_context *undo_ctx = // (saHpiAutoInsertTimeoutTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_SAHPIAUTOINSERTTIMEOUTFORINSERT: /** SafUnsigned64 = ASN_OPAQUE */ rc = netsnmp_check_vb_type(var, ASN_OPAQUE); if (rc == SNMP_ERR_NOERROR ) { if (var->val_len > SAF_UNSIGNED_64_LEN) { rc = SNMP_ERR_WRONGLENGTH; DEBUGMSGTL ((AGENT, "COLUMN_SAHPIAUTOINSERTTIMEOUTFORINSERT" " SNMP_ERR_WRONGLENGTH\n", rc)); } } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiAutoInsertTimeoutTable_set_reserve1\n"); } if (rc) netsnmp_request_set_error( current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/** register a given data_set at a given oid (specified in the netsnmp_handler_registration pointer). The reginfo->handler->access_method *may* be null if the call doesn't ever want to be called for SNMP operations. */ int netsnmp_register_table_data_set(netsnmp_handler_registration *reginfo, netsnmp_table_data_set *data_set, netsnmp_table_registration_info *table_info) { int ret; if (NULL == table_info) { /* * allocate the table if one wasn't allocated */ table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (table_info == NULL) return SNMP_ERR_GENERR; } if (NULL == table_info->indexes && data_set->table->indexes_template) { /* * copy the indexes in */ table_info->indexes = snmp_clone_varbind(data_set->table->indexes_template); } if ((!table_info->min_column || !table_info->max_column) && (data_set->default_row)) { /* * determine min/max columns */ unsigned int mincol = 0xffffffff, maxcol = 0; netsnmp_table_data_set_storage *row; for (row = data_set->default_row; row; row = row->next) { mincol = SNMP_MIN(mincol, row->column); maxcol = SNMP_MAX(maxcol, row->column); } if (!table_info->min_column) table_info->min_column = mincol; if (!table_info->max_column) table_info->max_column = maxcol; } netsnmp_inject_handler(reginfo, netsnmp_get_table_data_set_handler(data_set)); ret = netsnmp_register_table_data(reginfo, data_set->table, table_info); if (reginfo->handler) netsnmp_handler_owns_table_info(reginfo->handler->next); return ret; }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void pwrTable_set_reserve1(netsnmp_request_group * rg) { pwrTable_context *row_ctx = (pwrTable_context *) rg->existing_row; pwrTable_context *undo_ctx = (pwrTable_context *) rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_PWRSYSTEM: /** OCTETSTR = ASN_OCTET_STR */ rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR, sizeof(row_ctx-> pwrSystem)); break; default:/** We shouldn't get here */ rc = SNMP_ERR_GENERR; log_print(LOGN_CRI, "unknown column in " "pwrTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX(rg->status, current->ri->status); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiSensorReadingNormalMaxTable_set_reserve1( netsnmp_request_group *rg ) { // saHpiSensorReadingNormalMaxTable_context *row_ctx = // (saHpiSensorReadingNormalMaxTable_context *)rg->existing_row; // saHpiSensorReadingNormalMaxTable_context *undo_ctx = // (saHpiSensorReadingNormalMaxTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiSensorReadingNormalMaxTable_set_reserve1, called\n")); /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for ( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiSensorReadingNormalMaxTable_set_reserve1\n"); } if (rc) netsnmp_request_set_error( current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/* * Large parts of this function have been auto-generated. The functions purpose * is to check to make sure all SNMP set values for the given row, have been * valid. If not, then the process is supposed to be aborted. Otherwise, we * pass on to the *_reserve2 function. * * For our purposes, our only check is to make sure that either of the following * conditions are true: * * 1) If this row already exists, then the SET request is setting the rowStatus * column to 'destroy'. * * 2) If this row does not already exist, then the SET request is setting the * rowStatus to 'createAndGo'. * * Since the MIB specified there are to be no other modifications to the row, * any other condition is considered illegal, and will result in an SNMP error * being returned. */ void openserSIPStatusCodesTable_set_reserve1( netsnmp_request_group *rg ) { openserSIPStatusCodesTable_context *row_ctx = (openserSIPStatusCodesTable_context *)rg->existing_row; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* Loop through the specified columns, and make sure that all values are * valid. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_OPENSERSIPSTATUSCODEROWSTATUS: /** RowStatus = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof( row_ctx->openserSIPStatusCodeRowStatus)); /* Want to make sure that if it already exists that it * is setting it to 'destroy', or if it doesn't exist, * that it is setting it to 'createAndGo' */ if (row_ctx->openserSIPStatusCodeRowStatus == 0 && *var->val.integer != TC_ROWSTATUS_CREATEANDGO) { rc = SNMP_ERR_BADVALUE; } else if (row_ctx->openserSIPStatusCodeRowStatus == TC_ROWSTATUS_ACTIVE && *var->val.integer != TC_ROWSTATUS_DESTROY) { rc = SNMP_ERR_BADVALUE; } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in openserSIP" "StatusCodesTable_set_reserve1\n"); } if (rc) { netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc ); } rg->status = SNMP_MAX(rg->status, current->ri->status); } }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiSensorTable_set_reserve1 (netsnmp_request_group * rg) { netsnmp_variable_list *var; netsnmp_request_group_item *current; saHpiSensorTable_context *row_ctx = (saHpiSensorTable_context *) rg->existing_row; int rc = SNMP_ERR_NOERROR; DEBUGMSGTL ((AGENT, "saHpiSensorTable_set_reserve1. Entry\n")); for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPISENSORSTATUS: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiSensorStatus)); break; case COLUMN_SAHPISENSORASSERTEVENTS: /** OCTETSTR = ASN_OCTET_STR */ if (var->type != ASN_OCTET_STR) { rc = SNMP_ERR_WRONGTYPE; } else if (var->val_len > SENSOR_EVENTS_SUPPORTED_MAX) { rc = SNMP_ERR_WRONGLENGTH; } else if (var->val_len < 0) { rc = SNMP_ERR_WRONGLENGTH; } break; case COLUMN_SAHPISENSORDEASSERTEVENTS: /** OCTETSTR = ASN_OCTET_STR */ if (var->type != ASN_OCTET_STR) { rc = SNMP_ERR_WRONGTYPE; } else if (var->val_len > SENSOR_EVENTS_SUPPORTED_MAX) { rc = SNMP_ERR_WRONGLENGTH; } else if (var->val_len < 0) { rc = SNMP_ERR_WRONGLENGTH; } break; case COLUMN_SAHPISENSORINDEX: case COLUMN_SAHPISENSORTYPE: case COLUMN_SAHPISENSORCATEGORY: case COLUMN_SAHPISENSOREVENTSCATEGORYCONTROL: case COLUMN_SAHPISENSOREVENTSSUPPORTED: case COLUMN_SAHPISENSORIGNORE: case COLUMN_SAHPISENSORREADINGFORMATS: case COLUMN_SAHPISENSORISNUMERIC: case COLUMN_SAHPISENSORSIGNFORMAT: case COLUMN_SAHPISENSORBASEUNITS: case COLUMN_SAHPISENSORMODIFIERUNITS: case COLUMN_SAHPISENSORMODIFIERUSE: case COLUMN_SAHPISENSORFACTORSSTATIC: case COLUMN_SAHPISENSORFACTORS: case COLUMN_SAHPISENSORFACTORSLINEARIZATION: case COLUMN_SAHPISENSORPERCENTAGE: case COLUMN_SAHPISENSORRANGEFLAGS: case COLUMN_SAHPISENSORHASTHRESHOLDS: case COLUMN_SAHPISENSORTHRESHOLDCAPABILITIES: case COLUMN_SAHPISENSOROEM: case COLUMN_SAHPISENSORRDR: rc = SNMP_ERR_NOTWRITABLE; break; default: // Trying to write to read-only objects or to unknown columns? rc = SNMP_ERR_GENERR; break; } if (rc) netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX (rg->status, current->ri->status); } for (current = rg->list; current; current = current->next) { // The nice thing about this API is that _row_copy() is called // for this row - if the API has matched the index with an // already existing entry. We check the 'hash' value. If its // 0 the API couldn't find the right context. if (((saHpiSensorTable_context *) rg->existing_row)->hash == 0) { rc = SNMP_ERR_NOSUCHNAME; netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc); } } DEBUGMSGTL ((AGENT, "saHpiSensorTable_set_reserve1: Exit (rc:%d)\n", rc)); }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiHotSwapTable_set_reserve1 (netsnmp_request_group * rg) { saHpiHotSwapTable_context *row_ctx = (saHpiHotSwapTable_context *) rg->existing_row; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_reserve1: Entry.\n")); for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPIHOTSWAPINDICATOR: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiHotSwapIndicator)); break; case COLUMN_SAHPIHOTSWAPPOWERSTATE: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiHotSwapPowerState)); break; case COLUMN_SAHPIHOTSWAPRESETSTATE: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiHotSwapResetState)); break; case COLUMN_SAHPIHOTSWAPSTATE: /** INTEGER = ASN_INTEGER */ case COLUMN_SAHPIHOTSWAPPREVIOUSSTATE: /** INTEGER = ASN_INTEGER */ case COLUMN_SAHPIHOTSWAPEVENTSEVERITY: rc = SNMP_ERR_NOTWRITABLE; break; case COLUMN_SAHPIHOTSWAPINSERTTIMEOUT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiHotSwapInsertTimeout)); break; case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiHotSwapExtractTimeout)); break; case COLUMN_SAHPIHOTSWAPACTIONREQUEST: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiHotSwapActionRequest)); break; case COLUMN_SAHPIHOTSWAPRTP: rc = SNMP_ERR_NOTWRITABLE; break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log (LOG_ERR, "unknown column in " "saHpiHotSwapTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX (rg->status, current->ri->status); } for (current = rg->list; current; current = current->next) { // The nice thing about this API is that _row_copy() is called // for this row - if the API has matched the index with an // already existing entry. We check the 'hash' value. If its // 0 the API couldn't find the right context. if (row_ctx->hash == 0) { netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, SNMP_ERR_NOSUCHNAME); } } DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_reserve1: Exit.\n")); }
/** @internal */ void netsnmp_config_parse_table_set(const char *token, char *line) { oid name[MAX_OID_LEN], table_name[MAX_OID_LEN]; size_t name_length = MAX_OID_LEN, table_name_length = MAX_OID_LEN; struct tree *tp, *indexnode; netsnmp_table_data_set *table_set; data_set_tables *tables; struct index_list *index; unsigned int mincol = 0xffffff, maxcol = 0; u_char type; char *pos; /* * instatiate a fake table based on MIB information */ DEBUGMSGTL(("9:table_set_add_table", "processing '%s'\n", line)); if (NULL != (pos = strchr(line,' '))) { config_pwarn("ignoring extra tokens on line"); snmp_log(LOG_WARNING," ignoring '%s'\n", pos); *pos = '\0'; } /* * check for duplicate table */ tables = (data_set_tables *) netsnmp_get_list_data(auto_tables, line); if (NULL != tables) { config_pwarn("duplicate table definition"); return; } /* * parse oid and find tree structure */ if (!snmp_parse_oid(line, table_name, &table_name_length)) { config_pwarn ("can't instatiate table since I can't parse the table name"); return; } if(NULL == (tp = get_tree(table_name, table_name_length, get_tree_head()))) { config_pwarn("can't instatiate table since " "I can't find mib information about it"); return; } if (NULL == (tp = tp->child_list) || NULL == tp->child_list) { config_pwarn("can't instatiate table since it doesn't appear to be " "a proper table (no children)"); return; } /* * check for augments indexes */ if (NULL != tp->augments) { if (!snmp_parse_oid(tp->augments, table_name, &table_name_length)) { config_pwarn("I can't parse the augment tabel name"); snmp_log(LOG_WARNING, " can't parse %s\n", tp->augments); return; } if(NULL == (tp = get_tree(table_name, table_name_length, get_tree_head()))) { config_pwarn("can't instatiate table since " "I can't find mib information about augment table"); snmp_log(LOG_WARNING, " table %s not found in tree\n", tp->augments); return; } table_set = netsnmp_create_table_data_set(line); /* * loop through indexes and add types */ for (index = tp->indexes; index; index = index->next) { if (!snmp_parse_oid(index->ilabel, name, &name_length) || (NULL == (indexnode = get_tree(name, name_length, get_tree_head())))) { config_pwarn("can't instatiate table since " "I don't know anything about one index"); snmp_log(LOG_WARNING, " index %s not found in tree\n", index->ilabel); return; /* xxx mem leak */ } type = mib_to_asn_type(indexnode->type); if (type == (u_char) - 1) { config_pwarn("unknown index type"); return; /* xxx mem leak */ } if (index->isimplied) /* if implied, mark it as such */ type |= ASN_PRIVATE; DEBUGMSGTL(("table_set_add_row", "adding default index of type %d\n", type)); netsnmp_table_dataset_add_index(table_set, type); } } else table_set = netsnmp_create_table_data_set(line); /* * loop through indexes and add types */ for (index = tp->indexes; index; index = index->next) { if (!snmp_parse_oid(index->ilabel, name, &name_length) || (NULL == (indexnode = get_tree(name, name_length, get_tree_head())))) { config_pwarn("can't instatiate table since " "I don't know anything about one index"); snmp_log(LOG_WARNING, " index %s not found in tree\n", index->ilabel); return; /* xxx mem leak */ } type = mib_to_asn_type(indexnode->type); if (type == (u_char) - 1) { config_pwarn("unknown index type"); return; /* xxx mem leak */ } if (index->isimplied) /* if implied, mark it as such */ type |= ASN_PRIVATE; DEBUGMSGTL(("table_set_add_row", "adding default index of type %d\n", type)); netsnmp_table_dataset_add_index(table_set, type); } /* * loop through children and add each column info */ for (tp = tp->child_list; tp; tp = tp->next_peer) { int canwrite = 0; type = mib_to_asn_type(tp->type); if (type == (u_char) - 1) { config_pwarn("unknown column type"); return; /* xxx mem leak */ } DEBUGMSGTL(("table_set_add_row", "adding column %s(%d) of type %d (access %d)\n", tp->label, tp->subid, type, tp->access)); switch (tp->access) { case MIB_ACCESS_CREATE: table_set->allow_creation = 1; case MIB_ACCESS_READWRITE: case MIB_ACCESS_WRITEONLY: canwrite = 1; case MIB_ACCESS_READONLY: DEBUGMSGTL(("table_set_add_row", "adding column %d of type %d\n", tp->subid, type)); netsnmp_table_set_add_default_row(table_set, tp->subid, type, canwrite, NULL, 0); mincol = SNMP_MIN(mincol, tp->subid); maxcol = SNMP_MAX(maxcol, tp->subid); break; case MIB_ACCESS_NOACCESS: case MIB_ACCESS_NOTIFY: break; default: config_pwarn("unknown column access type"); break; } } /* * register the table */ netsnmp_register_table_data_set(netsnmp_create_handler_registration (line, NULL, table_name, table_name_length, HANDLER_CAN_RWRITE), table_set, NULL); netsnmp_register_auto_data_table(table_set, NULL); }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiWatchdogTable_set_reserve1( netsnmp_request_group *rg ) { saHpiWatchdogTable_context *row_ctx = (saHpiWatchdogTable_context *)rg->existing_row; saHpiWatchdogTable_context *undo_ctx = (saHpiWatchdogTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_SAHPIWATCHDOGLOG: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogLog)); break; case COLUMN_SAHPIWATCHDOGRUNNING: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogRunning)); break; case COLUMN_SAHPIWATCHDOGTIMERUSE: /** SaHpiWatchdogTimerUse = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogTimerUse)); break; case COLUMN_SAHPIWATCHDOGTIMERACTION: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogTimerAction)); break; case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT: /** SaHpiWatchdogPreTimerAction = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogPretimerInterrupt)); break; case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx->saHpiWatchdogPreTimeoutInterval)); break; case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS: /** OCTETSTR = ASN_OCTET_STR */ rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR, sizeof(row_ctx->saHpiWatchdogTimerUseExpFlags)); break; case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx->saHpiWatchdogTimerInitialCount)); break; case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx->saHpiWatchdogTimerPresentCount)); break; case COLUMN_SAHPIWATCHDOGTIMERRESET: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogTimerReset)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiWatchdogTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiUserEventTable_set_reserve1( netsnmp_request_group *rg ) { saHpiUserEventTable_context *row_ctx = (saHpiUserEventTable_context *)rg->existing_row; saHpiUserEventTable_context *undo_ctx = (saHpiUserEventTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_SAHPIUSEREVENTTIMESTAMP: /** SaHpiTime = ASN_COUNTER64 */ rc = netsnmp_check_vb_type_and_size(var, ASN_COUNTER64, sizeof(row_ctx->saHpiUserEventTimestamp)); break; case COLUMN_SAHPIUSEREVENTTEXTTYPE: /** SaHpiTextType = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiUserEventTextType)); break; case COLUMN_SAHPIUSEREVENTTEXTLANGUAGE: /** SaHpiTextLanguage = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiUserEventTextLanguage)); break; case COLUMN_SAHPIUSEREVENTTEXT: /** SaHpiText = ASN_OCTET_STR */ rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR, sizeof(row_ctx->saHpiUserEventText)); break; case COLUMN_SAHPIUSEREVENTROWSTATUS: /** RowStatus = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiUserEventRowStatus)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiUserEventTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void netSnmpIETFWGTable_set_reserve1(netsnmp_request_group * rg) { netSnmpIETFWGTable_context *row_ctx = (netSnmpIETFWGTable_context *) rg->existing_row; netSnmpIETFWGTable_context *undo_ctx = (netSnmpIETFWGTable_context *) rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL((AGENT,"netSnmpIETFWGTable_set_reserve1")); /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; DEBUGMSGTL((AGENT,"Length of char1: %d ", sizeof(row_ctx->nsIETFWGChair1))); switch (current->tri->colnum) { case COLUMN_NSIETFWGCHAIR1: /** OCTETSTR = ASN_OCTET_STR */ rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR, sizeof(row_ctx-> nsIETFWGChair1)); break; case COLUMN_NSIETFWGCHAIR2: /** OCTETSTR = ASN_OCTET_STR */ rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR, sizeof(row_ctx-> nsIETFWGChair2)); break; default:/** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "netSnmpIETFWGTable_set_reserve1\n"); } DEBUGMSGTL((AGENT,"rc: %d", rc)); if (rc == SNMP_ERR_WRONGLENGTH) rc = SNMP_ERR_NOERROR; if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX(rg->status, current->ri->status); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiHotSwapTable_set_reserve1( netsnmp_request_group *rg ) { saHpiHotSwapTable_context *row_ctx = (saHpiHotSwapTable_context *)rg->existing_row; saHpiHotSwapTable_context *undo_ctx = (saHpiHotSwapTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_SAHPIHOTSWAPINDICATOR: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiHotSwapIndicator)); break; case COLUMN_SAHPIHOTSWAPSTATE: /** SaHpiHotSwapState = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiHotSwapState)); break; case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT: /** SaHpiTime = ASN_COUNTER64 */ rc = netsnmp_check_vb_type_and_size(var, ASN_COUNTER64, sizeof(row_ctx->saHpiHotSwapExtractTimeout)); break; case COLUMN_SAHPIHOTSWAPACTIONREQUEST: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiHotSwapActionRequest)); break; case COLUMN_SAHPIHOTSWAPPOLICYCANCEL: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiHotSwapPolicyCancel)); break; case COLUMN_SAHPIHOTSWAPRESOURCEREQUEST: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiHotSwapResourceRequest)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiHotSwapTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/* * Large parts of this function have been auto-generated. The functions purpose * is to check to make sure all SNMP set values for the given row, have been * valid. If not, then the process is supposed to be aborted. Otherwise, we * pass on to the *_reserve2 function. * * For our purposes, our only check is to make sure that either of the following * conditions are true: * * 1) If this row already exists, then the SET request is setting the rowStatus * column to 'destroy'. * * 2) If this row does not already exist, then the SET request is setting the * rowStatus to 'createAndGo'. * * Since the MIB specified there are to be no other modifications to the row, * any other condition is considered illegal, and will result in an SNMP error * being returned. */ void kamailioSIPRegUserLookupTable_set_reserve1( netsnmp_request_group *rg ) { kamailioSIPRegUserLookupTable_context *row_ctx = (kamailioSIPRegUserLookupTable_context *)rg->existing_row; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch(current->tri->colnum) { case COLUMN_KAMAILIOSIPREGUSERLOOKUPURI: if (row_ctx->kamailioSIPRegUserLookupRowStatus == 0 || row_ctx->kamailioSIPRegUserLookupRowStatus == TC_ROWSTATUS_NOTREADY) { } else { rc = SNMP_ERR_BADVALUE; } break; case COLUMN_KAMAILIOSIPREGUSERLOOKUPROWSTATUS: /** RowStatus = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof( row_ctx->kamailioSIPRegUserLookupRowStatus)); /* Want to make sure that if it already exists that it * is setting it to 'destroy', or if it doesn't exist, * that it is setting it to 'createAndGo' */ if (row_ctx->kamailioSIPRegUserLookupRowStatus == 0 && *var->val.integer != TC_ROWSTATUS_CREATEANDGO) { rc = SNMP_ERR_BADVALUE; } else if (row_ctx->kamailioSIPRegUserLookupRowStatus == TC_ROWSTATUS_ACTIVE && *var->val.integer != TC_ROWSTATUS_DESTROY) { rc = SNMP_ERR_BADVALUE; } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in kamailioSIPReg" "UserLookupTable_set_reserve1\n"); } if (rc) { netsnmp_set_mode_request_error( MODE_SET_BEGIN, current->ri, rc ); } rg->status = SNMP_MAX( rg->status, current->ri->status ); } }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiCtrlStreamTable_set_reserve1( netsnmp_request_group *rg ) { saHpiCtrlStreamTable_context *row_ctx = (saHpiCtrlStreamTable_context *)rg->existing_row; // saHpiCtrlStreamTable_context *undo_ctx = // (saHpiCtrlStreamTable_context *)rg->undo_info; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiCtrlStreamTable_set_reserve1, called\n")); /* * TODO: loop through columns, check syntax and lengths. For * columns which have no dependencies, you could also move * the value/range checking here to attempt to catch error * cases as early as possible. */ for ( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPICTRLSTREAMMODE: /** SaHpiCtrlMode = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiCtrlStreamMode)); break; case COLUMN_SAHPICTRLSTREAMREPEAT: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiCtrlStreamRepeat)); break; case COLUMN_SAHPICTRLSTREAMSTATE: /** SaHpiText = ASN_OCTET_STR */ rc = netsnmp_check_vb_type(var, ASN_OCTET_STR); if (rc == SNMP_ERR_NOERROR ) { if (var->val_len > sizeof(row_ctx->saHpiCtrlStreamState)) { rc = SNMP_ERR_WRONGLENGTH; } } if (rc == SNMP_ERR_NOERROR) DEBUGMSGTL ((AGENT, "COLUMN_SAHPICTRLSTREAMSTATE NO ERROR: %d\n", rc)); else DEBUGMSGTL ((AGENT, "COLUMN_SAHPICTRLSTREAMSTATE ERROR: %d\n", rc)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiCtrlStreamTable_set_reserve1\n"); } if (rc) netsnmp_request_set_error( current->ri, rc ); rg->status = SNMP_MAX( rg->status, current->ri->status ); } /* * done with all the columns. Could check row related * requirements here. */ }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiWatchdogTable_set_reserve1(netsnmp_request_group * rg) { saHpiWatchdogTable_context *row_ctx = (saHpiWatchdogTable_context *) rg->existing_row; /* saHpiWatchdogTable_context *undo_ctx = (saHpiWatchdogTable_context *) rg->undo_info;*/ netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve1.Entry\n")); for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPIWATCHDOGLOG: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx-> saHpiWatchdogLog)); break; case COLUMN_SAHPIWATCHDOGRUNNING: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx->saHpiWatchdogRunning)); break; case COLUMN_SAHPIWATCHDOGTIMERUSE: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx-> saHpiWatchdogTimerUse)); break; case COLUMN_SAHPIWATCHDOGTIMERACTION: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx-> saHpiWatchdogTimerAction)); break; case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(row_ctx-> saHpiWatchdogPretimerInterrupt)); break; case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx-> saHpiWatchdogPreTimeoutInterval)); break; case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx-> saHpiWatchdogTimerUseExpFlags)); break; case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx-> saHpiWatchdogTimerInitialCount)); break; case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size(var, ASN_UNSIGNED, sizeof(row_ctx-> saHpiWatchdogTimerPresentCount)); break; default:/** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column in " "saHpiWatchdogTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX(rg->status, current->ri->status); } DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve1. Exit\n")); }
/************************************************************ * RESERVE is used to check the syntax of all the variables * provided, that the values being set are sensible and consistent, * and to allocate any resources required for performing the SET. * After this stage, the expectation is that the set ought to * succeed, though this is not guaranteed. (In fact, with the UCD * agent, this is done in two passes - RESERVE1, and * RESERVE2, to allow for dependancies between variables). * * BEFORE calling this routine, the agent will call duplicate_row * to create a copy of the row (unless this is a new row; i.e. * row_created == 1). * * next state -> SET_RESERVE2 || SET_FREE */ void saHpiWatchdogTable_set_reserve1 (netsnmp_request_group * rg) { saHpiWatchdogTable_context *row_ctx = (saHpiWatchdogTable_context *) rg->existing_row; netsnmp_variable_list *var; netsnmp_request_group_item *current; int rc; DEBUGMSGTL ((AGENT, "saHpiWatchdogTable_set_reserve1.Entry\n")); for (current = rg->list; current; current = current->next) { var = current->ri->requestvb; rc = SNMP_ERR_NOERROR; switch (current->tri->colnum) { case COLUMN_SAHPIWATCHDOGNUM: case COLUMN_SAHPIWATCHDOGOEM: case COLUMN_SAHPIWATCHDOGRDR: rc = SNMP_ERR_NOTWRITABLE; break; case COLUMN_SAHPIWATCHDOGLOG: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogLog)); break; case COLUMN_SAHPIWATCHDOGRUNNING: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogRunning)); break; case COLUMN_SAHPIWATCHDOGTIMERUSE: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogTimerUse)); break; case COLUMN_SAHPIWATCHDOGTIMERACTION: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogTimerAction)); break; case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT: /** INTEGER = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogPretimerInterrupt)); break; case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiWatchdogPreTimeoutInterval)); break; case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiWatchdogTimerUseExpFlags)); break; case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiWatchdogTimerInitialCount)); break; case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT: /** UNSIGNED32 = ASN_UNSIGNED */ rc = netsnmp_check_vb_type_and_size (var, ASN_UNSIGNED, sizeof (row_ctx-> saHpiWatchdogTimerPresentCount)); break; case COLUMN_SAHPIWATCHDOGTIMERRESET: /** TruthValue = ASN_INTEGER */ rc = netsnmp_check_vb_type_and_size (var, ASN_INTEGER, sizeof (row_ctx-> saHpiWatchdogTimerReset)); break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log (LOG_ERR, "unknown column in " "saHpiWatchdogTable_set_reserve1\n"); } if (rc) netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc); rg->status = SNMP_MAX (rg->status, current->ri->status); } for (current = rg->list; current; current = current->next) { // The nice thing about this API is that _row_copy() is called // for this row - if the API has matched the index with an // already existing entry. We check the 'hash' value. If its // 0 the API couldn't find the right context. if (((saHpiWatchdogTable_context *) rg->existing_row)->hash == 0) { netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, SNMP_ERR_NOSUCHNAME); } } DEBUGMSGTL ((AGENT, "saHpiWatchdogTable_set_reserve1. Exit\n")); }