示例#1
0
/************************************************************
 * 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 )
{
//    saHpiSensorTable_context *row_ctx =
//            (saHpiSensorTable_context *)rg->existing_row;
//    saHpiSensorTable_context *undo_ctx =
//            (saHpiSensorTable_context *)rg->undo_info;
    netsnmp_variable_list *var;
    netsnmp_request_group_item *current;
    int rc;

    DEBUGMSGTL ((AGENT, "saHpiSensorTable_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 "
                     "saHpiSensorTable_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.
     */
}
/*
 * Auto-generated function.  The function is supposed to check for any
 * last-minute conditions not being met.  However, we don't have any such
 * conditions, so we leave the default function as is.
 */
void openserSIPStatusCodesTable_set_reserve2( netsnmp_request_group *rg )
{
	openserSIPStatusCodesTable_context *undo_ctx = 
		(openserSIPStatusCodesTable_context *)rg->undo_info;

	netsnmp_request_group_item *current;
	netsnmp_variable_list      *var;

	int rc;

	rg->rg_void = rg->list->ri;

	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_rowstatus(current->ri->requestvb,
					undo_ctx ? 
					undo_ctx->openserSIPStatusCodeRowStatus:0);

				rg->rg_void = current->ri;
				break;

			default: /** We shouldn't get here */
				netsnmp_assert(0); /** why wasn't this caught in reserve1? */
		}

		if (rc)
		{
			netsnmp_set_mode_request_error(MODE_SET_BEGIN, 
					current->ri, rc);
		}
	}

}
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void saHpiWatchdogEventLogTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
    saHpiWatchdogEventLogTable_context *row_ctx = (saHpiWatchdogEventLogTable_context *)rg->existing_row;
    saHpiWatchdogEventLogTable_context *undo_ctx = (saHpiWatchdogEventLogTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;

    int            row_err = 0;

    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for( current = rg->list; current; current = current->next ) {

        var = current->ri->requestvb;

        switch(current->tri->colnum) {

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
    if(row_err) {
        netsnmp_set_mode_request_error(MODE_SET_BEGIN,
                                       (netsnmp_request_info*)rg->rg_void,
                                       row_err);
        return;
    }

    /*
     * TODO: if you have dependencies on other tables, this would be
     * a good place to check those, too.
     */
}
示例#4
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void saHpiSensorTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
//    saHpiSensorTable_context *row_ctx = (saHpiSensorTable_context *)rg->existing_row;
//    saHpiSensorTable_context *undo_ctx = (saHpiSensorTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;

    int            row_err = 0;

    DEBUGMSGTL ((AGENT, "saHpiSensorTable_set_action, called\n"));

    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for( current = rg->list; current; current = current->next ) {

        var = current->ri->requestvb;

        switch(current->tri->colnum) {

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }
    }

    if(row_err) {
        netsnmp_set_mode_request_error(MODE_SET_BEGIN,
                                       (netsnmp_request_info*)rg->rg_void,
                                       row_err);
        return;
    }

    /*
     * TODO: if you have dependencies on other tables, this would be
     * a good place to check those, too.
     */
}
示例#5
0
void saHpiRdrTable_set_reserve2( netsnmp_request_group *rg )
{
//    saHpiRdrTable_context *row_ctx = (saHpiRdrTable_context *)rg->existing_row;
//    saHpiRdrTable_context *undo_ctx = (saHpiRdrTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int rc;

	DEBUGMSGTL ((AGENT, "saHpiRdrTable_set_reserve2, called\n"));

    rg->rg_void = rg->list->ri;

    /*
     * TODO: loop through columns, check for valid
     * values and any range constraints.
     */
    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 */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
           netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
示例#6
0
void
saHpiHotSwapTable_set_reserve2 (netsnmp_request_group * rg)
{

  netsnmp_request_group_item *current;
  netsnmp_variable_list *var;
  int rc;

  rg->rg_void = rg->list->ri;
  DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_reserve2: 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:
	  if ((*var->val.integer < 1) || (*var->val.integer > 2))
	    rc = SNMP_ERR_BADVALUE;

	  break;

	case COLUMN_SAHPIHOTSWAPPOWERSTATE:
	  if ((*var->val.integer < 1) || (*var->val.integer > 3))
	    rc = SNMP_ERR_BADVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPRESETSTATE:
	  if ((*var->val.integer < 1) || (*var->val.integer > 4))
	    rc = SNMP_ERR_BADVALUE;

	  break;

	case COLUMN_SAHPIHOTSWAPSTATE:
	    /** INTEGER = ASN_INTEGER */
	  if ((*var->val.integer < 1) || (*var->val.integer > 6))
	    rc = SNMP_ERR_BADVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPPREVIOUSSTATE:
	    /** INTEGER = ASN_INTEGER */
	  // Its  read-only object.
	  break;

	case COLUMN_SAHPIHOTSWAPINSERTTIMEOUT:
	    /** UNSIGNED32 = ASN_UNSIGNED */

	  break;

	case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT:
	    /** UNSIGNED32 = ASN_UNSIGNED */

	  break;

	case COLUMN_SAHPIHOTSWAPACTIONREQUEST:
	    /** INTEGER = ASN_INTEGER */
	  if ((*var->val.integer < 1) || (*var->val.integer > 2))
	    rc = SNMP_ERR_BADVALUE;
	  break;

	default:
		/** We shouldn't get here */
	  netsnmp_assert (0);  /** why wasn't this caught in reserve1? */
	}

      if (rc)
	netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc);
    }

  /*
   * done with all the columns. Could check row related
   * requirements here.
   */
  DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_reserve2: Exit.\n"));
}
示例#7
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void saHpiUserEventTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
    saHpiUserEventTable_context *row_ctx = (saHpiUserEventTable_context *)rg->existing_row;
    saHpiUserEventTable_context *undo_ctx = (saHpiUserEventTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;

    int            row_err = 0;

    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for( current = rg->list; current; current = current->next ) {

        var = current->ri->requestvb;

        switch(current->tri->colnum) {

        case COLUMN_SAHPIUSEREVENTTIMESTAMP:
            /** SaHpiTime = ASN_COUNTER64 */
            row_ctx->saHpiUserEventTimestamp = *var->val.integer;
        break;

        case COLUMN_SAHPIUSEREVENTTEXTTYPE:
            /** SaHpiTextType = ASN_INTEGER */
            row_ctx->saHpiUserEventTextType = *var->val.integer;
        break;

        case COLUMN_SAHPIUSEREVENTTEXTLANGUAGE:
            /** SaHpiTextLanguage = ASN_INTEGER */
            row_ctx->saHpiUserEventTextLanguage = *var->val.integer;
        break;

        case COLUMN_SAHPIUSEREVENTTEXT:
            /** SaHpiText = ASN_OCTET_STR */
            memcpy(row_ctx->saHpiUserEventText,var->val.string,var->val_len);
            row_ctx->saHpiUserEventText_len = var->val_len;
        break;

        case COLUMN_SAHPIUSEREVENTROWSTATUS:
            /** RowStatus = ASN_INTEGER */
            row_ctx->saHpiUserEventRowStatus = *var->val.integer;
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
#ifndef saHpiUserEventTable_CAN_MODIFY_ACTIVE_ROW
    if( undo_ctx && RS_IS_ACTIVE(undo_ctx->saHpiDomainAlarmRowStatus) &&
        row_ctx && RS_IS_ACTIVE(row_ctx->saHpiDomainAlarmRowStatus) ) {
            row_err = 1;
    }
#endif

    /*
     * check activation/deactivation
     */
    row_err = netsnmp_table_array_check_row_status(&cb, rg,
                                  row_ctx ? &row_ctx->saHpiDomainAlarmRowStatus : NULL,
                                  undo_ctx ? &undo_ctx->saHpiDomainAlarmRowStatus : NULL);
    if(row_err) {
        netsnmp_set_mode_request_error(MODE_SET_BEGIN,
                                       (netsnmp_request_info*)rg->rg_void,
                                       row_err);
        return;
    }

    /*
     * TODO: if you have dependencies on other tables, this would be
     * a good place to check those, too.
     */
}
示例#8
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiSensorTable_set_action (netsnmp_request_group * rg)
{
  netsnmp_variable_list *var;
  saHpiSensorTable_context *row_ctx =
    (saHpiSensorTable_context *) rg->existing_row;

  netsnmp_request_group_item *current;
  int rc = SNMP_ERR_NOERROR;
  int rc2;
  DEBUGMSGTL ((AGENT, "saHpiSensorTable_set_action: Entry\n"));
  for (current = rg->list; current; current = current->next)
    {

      var = current->ri->requestvb;

      switch (current->tri->colnum)
	{
	case COLUMN_SAHPISENSORSTATUS:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiSensorStatus = *var->val.integer;
	  rc2 = set_sensor_event (row_ctx);
	  if (rc2 != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_GENERR;
	  if (rc2 == AGENT_ERR_WRONG_DELIM)
	    rc = SNMP_ERR_BADVALUE;
	  break;

	case COLUMN_SAHPISENSORASSERTEVENTS:
	  memcpy (row_ctx->saHpiSensorAssertEvents,
		  var->val.string, var->val_len);
	  row_ctx->saHpiSensorAssertEvents_len = var->val_len;
	  rc2 = set_sensor_event (row_ctx);
	  if (rc2 != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_GENERR;
	  if (rc2 == AGENT_ERR_WRONG_DELIM)
	    rc = SNMP_ERR_BADVALUE;
	  break;

	case COLUMN_SAHPISENSORDEASSERTEVENTS:
	  memcpy (row_ctx->saHpiSensorDeassertEvents,
		  var->val.string, var->val_len);
	  row_ctx->saHpiSensorDeassertEvents_len = var->val_len;
	  rc2 = set_sensor_event (row_ctx);
	  if (rc2 != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_GENERR;
	  if (rc2 == AGENT_ERR_WRONG_DELIM)
	    rc = SNMP_ERR_BADVALUE;
	  break;

	default:
		/** We shouldn't get here */
	  netsnmp_assert (0);  /** why wasn't this caught in reserve1? */
	  break;
	}

      if (rc)
	netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc);

    }
  DEBUGMSGTL ((AGENT, "saHpiSensorTable_set_action: Exit \n"));

}
示例#9
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void saHpiWatchdogTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
    saHpiWatchdogTable_context *row_ctx = (saHpiWatchdogTable_context *)rg->existing_row;
    saHpiWatchdogTable_context *undo_ctx = (saHpiWatchdogTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;

    int            row_err = 0;

    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for( current = rg->list; current; current = current->next ) {

        var = current->ri->requestvb;

        switch(current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogLog = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogRunning = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** SaHpiWatchdogTimerUse = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerUse = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerAction = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** SaHpiWatchdogPreTimerAction = ASN_INTEGER */
            row_ctx->saHpiWatchdogPretimerInterrupt = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogPreTimeoutInterval = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** OCTETSTR = ASN_OCTET_STR */
            memcpy(row_ctx->saHpiWatchdogTimerUseExpFlags,var->val.string,var->val_len);
            row_ctx->saHpiWatchdogTimerUseExpFlags_len = var->val_len;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerInitialCount = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerPresentCount = *var->val.integer;
        break;

        case COLUMN_SAHPIWATCHDOGTIMERRESET:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerReset = *var->val.integer;
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
#ifndef saHpiWatchdogTable_CAN_MODIFY_ACTIVE_ROW
    if( undo_ctx && RS_IS_ACTIVE(undo_ctx->saHpiDomainAlarmRowStatus) &&
        row_ctx && RS_IS_ACTIVE(row_ctx->saHpiDomainAlarmRowStatus) ) {
            row_err = 1;
    }
#endif

    /*
     * check activation/deactivation
     */
    row_err = netsnmp_table_array_check_row_status(&cb, rg,
                                  row_ctx ? &row_ctx->saHpiDomainAlarmRowStatus : NULL,
                                  undo_ctx ? &undo_ctx->saHpiDomainAlarmRowStatus : NULL);
    if(row_err) {
        netsnmp_set_mode_request_error(MODE_SET_BEGIN,
                                       (netsnmp_request_info*)rg->rg_void,
                                       row_err);
        return;
    }

    /*
     * TODO: if you have dependencies on other tables, this would be
     * a good place to check those, too.
     */
}
/*
 * 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);
	}

}
示例#11
0
void saHpiCtrlTextTable_set_reserve2( netsnmp_request_group *rg )
{
	saHpiCtrlTextTable_context *row_ctx = (saHpiCtrlTextTable_context *)rg->existing_row;
//	saHpiCtrlTextTable_context *undo_ctx = (saHpiCtrlTextTable_context *)rg->undo_info;
	netsnmp_request_group_item *current;
	netsnmp_variable_list *var;
	int rc;

	rg->rg_void = rg->list->ri;

	/*
	 * TODO: loop through columns, check for valid
	 * values and any range constraints.
	 */
	for ( current = rg->list; current; current = current->next ) {

		var = current->ri->requestvb;
		rc = SNMP_ERR_NOERROR;

		switch (current->tri->colnum) {
		
		case COLUMN_SAHPICTRLTEXTMODE:
			/** SaHpiCtrlMode = ASN_INTEGER */
			if (row_ctx->saHpiCtrlTextIsReadOnly == MIB_TRUE) {
				snmp_log(LOG_ERR, "COLUMN_SAHPICTRLTEXTMODE mode is ReadOnly, Failed\n");
				DEBUGMSGTL ((AGENT, "COLUMN_SAHPICTRLTEXTMODE mode is ReadOnly, Failed\n"));
				rc = SNMP_ERR_READONLY;
			}
			if (oh_lookup_ctrlmode(*var->val.integer - 1) == NULL) {
				snmp_log(LOG_ERR, "COLUMN_SAHPICTRLTEXTMODE Invalid Mode, Failed\n");
				DEBUGMSGTL ((AGENT, "COLUMN_SAHPICTRLTEXTMODE Invalid Mode, Failed\n"));
				rc = SNMP_ERR_BADVALUE;
			}
			break;
		case COLUMN_SAHPICTRLTEXTLINE:
			/** Unsigned8 = ASN_INTEGER */
			if ( *var->val.integer > 255 )
				rc = SNMP_ERR_BADVALUE;
			break;

		case COLUMN_SAHPICTRLTEXTSTATE:
			/* length checked in reserve1() */
			/** SaHpiText = ASN_OCTET_STR */
			/*
			 * TODO: routine to check valid values
			 *
			 * EXAMPLE:
			 *
			* if ( XXX_check_value( var->val.string, XXX ) ) {
		    *    rc = SNMP_ERR_INCONSISTENTVALUE;
		    *    rc = SNMP_ERR_BADVALUE;
		    * }
		    */
			break;

		default: /** We shouldn't get here */
			netsnmp_assert(0); /** why wasn't this caught in reserve1? */
		}

		if (rc)
			netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
	}

	/*
	 * done with all the columns. Could check row related
	 * requirements here.
	 */
}
示例#12
0
void
saHpiWatchdogTable_set_reserve2(netsnmp_request_group * rg)
{
  /*saHpiWatchdogTable_context *row_ctx =
        (saHpiWatchdogTable_context *) rg->existing_row;
     
    saHpiWatchdogTable_context *undo_ctx =
    (saHpiWatchdogTable_context *) rg->undo_info;*/
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int             rc = SNMP_ERR_NOERROR;

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve2. Entry\n"));
    rg->rg_void = rg->list->ri;
    
    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_truthvalue(current->ri->requestvb);
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            rc = netsnmp_check_vb_truthvalue(current->ri->requestvb);
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
	  // HPI-MIB::saHpiWatchdogTimerUse 
	  if ( ((*var->val.integer < 0) || 
	       (*var->val.integer > 5)) &&
	       (*var->val.integer != 0x0F)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	  break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
	  // HPI-MIB::saHpiWatchdogTimerAction
	  if ((*var->val.integer < 0) ||
	      (*var->val.integer > 3)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	  break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
	  // HPI-MIB::saHpiWatchdogPretimerInterrupt
	   if ( ((*var->val.integer < 0) || 
	       (*var->val.integer > 3)) &&
	       (*var->val.integer != 0x0F)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	   break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
	  // No restriction. 32-bit unsigned can be anything
            break;
	    
        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
	  if ((*var->val.integer < 0 ) ||
	      (*var->val.integer > 32)) {
	    rc = SNMP_ERR_BADVALUE;
	  }         
	  break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
         
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
           
            break;


        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
            netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
                                           rc);
    }
    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve2. Exit (rc: %d)\n", rc));
    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
示例#13
0
/************************************************************
 * 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"));
}
示例#14
0
/************************************************************
 * 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.
     */
}
/*
 * 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 );
	}

}
示例#16
0
/************************************************************
 * 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.
     */
}
示例#17
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiHotSwapTable_set_action (netsnmp_request_group * rg)
{
  netsnmp_variable_list *var;
  saHpiHotSwapTable_context *row_ctx =
    (saHpiHotSwapTable_context *) rg->existing_row;

  netsnmp_request_group_item *current;

  int rc = SNMP_ERR_NOERROR;

  DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_reserve: Entry.\n"));

  for (current = rg->list; current; current = current->next)
    {

      var = current->ri->requestvb;

      switch (current->tri->colnum)
	{
	case COLUMN_SAHPIHOTSWAPINDICATOR:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiHotSwapIndicator = *var->val.integer;
	  if (set_hotswap_indicator (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;

	  break;

	case COLUMN_SAHPIHOTSWAPPOWERSTATE:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiHotSwapPowerState = *var->val.integer;
	  if (set_hotswap_powerstate (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPRESETSTATE:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiHotSwapResetState = *var->val.integer;
	  if (set_hotswap_reset_state (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPINSERTTIMEOUT:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiHotSwapInsertTimeout = *var->val.integer;
	  if (set_hotswap_insert_t (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiHotSwapExtractTimeout = *var->val.integer;
	  if (set_hotswap_extract_t (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;
	  break;

	case COLUMN_SAHPIHOTSWAPACTIONREQUEST:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiHotSwapActionRequest = *var->val.integer;
	  if (set_hotswap_action_request (row_ctx) != AGENT_ERR_NOERROR)
	    rc = SNMP_ERR_INCONSISTENTVALUE;
	  break;

	default:
		/** We shouldn't get here */
	  netsnmp_assert (0);  /** why wasn't this caught in reserve1? */
	}

      if (rc)
	netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc);
    }
  DEBUGMSGTL ((AGENT, "saHpiHotSwapTable_set_action: Exit.\n"));
}
示例#18
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiWatchdogTable_set_action(netsnmp_request_group * rg)
{
    netsnmp_variable_list *var;
    saHpiWatchdogTable_context *row_ctx =
        (saHpiWatchdogTable_context *) rg->existing_row;
    /*    saHpiWatchdogTable_context *undo_ctx =
	  (saHpiWatchdogTable_context *) rg->undo_info;*/
    netsnmp_request_group_item *current;

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Entry\n"));
    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;

        switch (current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogLog = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogRunning = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerUse = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerAction = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogPretimerInterrupt = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogPreTimeoutInterval = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerUseExpFlags = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerInitialCount = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerPresentCount = *var->val.integer;
            break;       

        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

	DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action: Calling 'set_watchdog'\n"));
	if (set_watchdog(row_ctx) != AGENT_ERR_NOERROR) {
	  netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
					 SNMP_ERR_GENERR);
	}
    }

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Exit\n"));   
   
}
示例#19
0
/************************************************************
 * 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"));
}
示例#20
0
/************************************************************
 * 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
memTable_set_reserve1(netsnmp_request_group * rg)
{
    memTable_context *row_ctx = (memTable_context *) rg->existing_row;
    memTable_context *undo_ctx = (memTable_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_MEMINDEX:
            /** INTEGER32 = ASN_INTEGER */
            rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
                                                sizeof(row_ctx->memIndex));
            break;

        case COLUMN_MEMSYSTEM:
            /** OCTETSTR = ASN_OCTET_STR */
            rc = netsnmp_check_vb_type_and_size(var, ASN_OCTET_STR,
                                                sizeof(row_ctx->
                                                       memSystem));
            break;

        case COLUMN_MEMTOTAL:
            /** INTEGER32 = ASN_INTEGER */
            rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
                                                sizeof(row_ctx->memTotal));
            break;

        case COLUMN_MEMAVAIL:
            /** INTEGER32 = ASN_INTEGER */
            rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
                                                sizeof(row_ctx->memAvail));
            break;

        case COLUMN_MEMUSED:
            /** INTEGER32 = ASN_INTEGER */
            rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
                                                sizeof(row_ctx->memUsed));
            break;

        case COLUMN_MEMUSAGE:
            /** INTEGER32 = ASN_INTEGER */
            rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
                                                sizeof(row_ctx->memUsage));
            break;

        default:/** We shouldn't get here */
            rc = SNMP_ERR_GENERR;
            log_print(LOGN_CRI, "unknown column in "
                     "memTable_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.
     */
}
示例#21
0
/************************************************************
 * 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 saHpiCtrlTextTable_set_reserve1( netsnmp_request_group *rg )
{
	saHpiCtrlTextTable_context *row_ctx =
	(saHpiCtrlTextTable_context *)rg->existing_row;
//	saHpiCtrlTextTable_context *undo_ctx =
//	(saHpiCtrlTextTable_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_SAHPICTRLTEXTMODE:
			/** SaHpiCtrlMode = ASN_INTEGER */
			rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
							    sizeof(row_ctx->saHpiCtrlTextMode));
			break;

		case COLUMN_SAHPICTRLTEXTLINE:
			/** Unsigned8 = ASN_INTEGER */
			rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
							    sizeof(row_ctx->saHpiCtrlTextLine));
			break;

		case COLUMN_SAHPICTRLTEXTSTATE:
			/** 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->saHpiCtrlTextState)) {
					rc = SNMP_ERR_WRONGLENGTH;
				}
			}
			if (rc == SNMP_ERR_NOERROR)
				DEBUGMSGTL ((AGENT, 
					     "COLUMN_SAHPICTRLTEXTSTATE NO ERROR: %d\n", rc));
			else
				DEBUGMSGTL ((AGENT, 
					     "COLUMN_SAHPICTRLTEXTSTATE ERROR: %d\n", rc));
			break;
		default: /** We shouldn't get here */
			rc = SNMP_ERR_GENERR;
			snmp_log(LOG_ERR, "unknown column in "
				 "saHpiCtrlTextTable_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.
	 */
}
/*
 * This function is called only when all the *_reserve[1|2] functions were
 * succeful.  Its purpose is to make any changes to the row before it is
 * inserted into the table.  
 *
 * In our case, we don't require any changes.  So we leave the original
 * auto-generated code as is.   
 */
void openserSIPStatusCodesTable_set_action( netsnmp_request_group *rg )
{
	netsnmp_variable_list *var;

	openserSIPStatusCodesTable_context *row_ctx = 
		(openserSIPStatusCodesTable_context *)rg->existing_row;

	openserSIPStatusCodesTable_context *undo_ctx = 
		(openserSIPStatusCodesTable_context *)rg->undo_info;

	netsnmp_request_group_item *current;

	int row_err = 0;

	/* Depending on what the snmpset was, set the row to be created or
	 * deleted.   */
	for( current = rg->list; current; current = current->next ) 
	{
		var = current->ri->requestvb;

		switch(current->tri->colnum) 
		{
			case COLUMN_OPENSERSIPSTATUSCODEROWSTATUS:
			
				/** RowStatus = ASN_INTEGER */
				row_ctx->openserSIPStatusCodeRowStatus = 
					*var->val.integer;

				if (*var->val.integer == TC_ROWSTATUS_CREATEANDGO)
				{
					rg->row_created = 1;
				}
				else if (*var->val.integer == TC_ROWSTATUS_DESTROY)
				{
					rg->row_deleted = 1;
				}
				else {
					/* We should never be here, because the RESERVE
					 * functions should have taken care of all other
					 * values. */
				LM_ERR("Invalid RowStatus in openserSIPStatusCodesTable\n");
				}

				break;

			default: /** We shouldn't get here */
				netsnmp_assert(0); /** why wasn't this caught in reserve1? */
		}
	}

	/*
	 * done with all the columns. Could check row related
	 * requirements here.
	 */
#ifndef openserSIPStatusCodesTable_CAN_MODIFY_ACTIVE_ROW
	if( undo_ctx && RS_IS_ACTIVE(undo_ctx->openserSIPStatusCodeRowStatus) &&
		row_ctx && RS_IS_ACTIVE(row_ctx->openserSIPStatusCodeRowStatus)) 
	{
			row_err = 1;
	}
#endif

	/*
	 * check activation/deactivation
	 */
	row_err = netsnmp_table_array_check_row_status(&cb, rg, 
			row_ctx ? 
			&row_ctx->openserSIPStatusCodeRowStatus : NULL,
			undo_ctx ? 
			&undo_ctx->openserSIPStatusCodeRowStatus : NULL);
	if(row_err) {
		netsnmp_set_mode_request_error(MODE_SET_BEGIN,
				(netsnmp_request_info*)rg->rg_void, row_err);
		return;
	}

}
/*
 * This function is called only when all the *_reserve[1|2] functions were
 * succeful.  Its purpose is to make any changes to the row before it is
 * inserted into the table.
 *
 * In the case of this table, this involves looking up the index of the
 * requested user in the URI to userIndex mapping hash table.  If the result is
 * found, the index will be copied to the row, and the rowStatus set to
 * 'active'.  Otherwise, the row status will be set to 'notInService'
 *
 * All other handling is auto-generated.
 */
void openserSIPRegUserLookupTable_set_action( netsnmp_request_group *rg )
{
	/* First things first, we need to consume the interprocess buffer, in
	 * case something has changed. We want to return the freshest data. */
	consumeInterprocessBuffer();

	aorToIndexStruct_t *hashRecord;

	netsnmp_variable_list *var;

	openserSIPRegUserLookupTable_context *row_ctx =
		(openserSIPRegUserLookupTable_context *)rg->existing_row;

	openserSIPRegUserLookupTable_context *undo_ctx =
		(openserSIPRegUserLookupTable_context *)rg->undo_info;

	netsnmp_request_group_item *current;

	int			row_err = 0;

	/* Copy the actual data to the row. */
	for( current = rg->list; current; current = current->next ) {

		var = current->ri->requestvb;

		switch(current->tri->colnum)
		{

			case COLUMN_OPENSERSIPREGUSERLOOKUPURI:

				row_ctx->openserSIPRegUserLookupURI =
					pkg_malloc(sizeof(char)*(var->val_len + 1));

				memcpy(row_ctx->openserSIPRegUserLookupURI,
						var->val.string,
						var->val_len);

				/* Usually NetSNMP won't terminate strings with '\0'.
				 * The hash function expect them to be terminated
				 * though, so we have to add this on to the end.  The +1
				 * in the malloc makes sure of the extra space for us.
				 */
				row_ctx->openserSIPRegUserLookupURI[var->val_len] = '\0';

				row_ctx->openserSIPRegUserLookupURI_len = var->val_len;

				/* Do the lookup.  If we could find the record, then set
				 * the index and the row status to active.  Otherwise,
				 * set the row to notInService */
				hashRecord =
					findHashRecord(hashTable,
						(char *)
						row_ctx->openserSIPRegUserLookupURI,
						HASH_SIZE);

				if (hashRecord == NULL)
				{
					row_ctx->openserSIPRegUserIndex = 0;
					row_ctx->openserSIPRegUserLookupRowStatus =
						TC_ROWSTATUS_NOTINSERVICE;
				}
				else
				{
					row_ctx->openserSIPRegUserIndex =
						hashRecord->userIndex;
					row_ctx->openserSIPRegUserLookupRowStatus =
						TC_ROWSTATUS_ACTIVE;
				}

				break;

			case COLUMN_OPENSERSIPREGUSERLOOKUPROWSTATUS:

				row_ctx->openserSIPRegUserLookupRowStatus =
					*var->val.integer;

				if (*var->val.integer == TC_ROWSTATUS_CREATEANDGO)
				{
					rg->row_created = 1;
					/* Set to NOT READY until the lookup URI has
					 * been supplied. */
					row_ctx->openserSIPRegUserLookupRowStatus =
						TC_ROWSTATUS_NOTREADY;
				}
				else if (*var->val.integer == TC_ROWSTATUS_DESTROY)
				{
					rg->row_deleted = 1;
				}
				else
				{
					/* We should never be here, because the RESERVE
					 * functions should have taken care of all other
					 * values. */
				LM_ERR("invalid RowStatus in openserSIPStatusCodesTable\n");
				}

				break;

			default: /** We shouldn't get here */
				netsnmp_assert(0); /** why wasn't this caught in reserve1? */
		}
	}

	/*
	 * done with all the columns. Could check row related
	 * requirements here.
	 */
#ifndef openserSIPRegUserLookupTable_CAN_MODIFY_ACTIVE_ROW
	if( undo_ctx && RS_IS_ACTIVE(undo_ctx->openserSIPRegUserLookupRowStatus) &&
		row_ctx && RS_IS_ACTIVE(row_ctx->openserSIPRegUserLookupRowStatus) ) {
			row_err = 1;
	}
#endif

	/*
	 * check activation/deactivation
	 */
	row_err = netsnmp_table_array_check_row_status(&cb, rg,
			row_ctx ? &row_ctx->openserSIPRegUserLookupRowStatus : NULL,
			undo_ctx ? &undo_ctx->openserSIPRegUserLookupRowStatus : NULL);

	if(row_err) {
		netsnmp_set_mode_request_error(MODE_SET_BEGIN,
				(netsnmp_request_info*)rg->rg_void, row_err);
		return;
	}

}
示例#24
0
void saHpiHotSwapTable_set_reserve2( netsnmp_request_group *rg )
{
    saHpiHotSwapTable_context *row_ctx = (saHpiHotSwapTable_context *)rg->existing_row;
    saHpiHotSwapTable_context *undo_ctx = (saHpiHotSwapTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int rc;

    rg->rg_void = rg->list->ri;

    /*
     * TODO: loop through columns, check for valid
     * values and any range constraints.
     */
    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 */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIHOTSWAPSTATE:
            /** SaHpiHotSwapState = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT:
            /** SaHpiTime = ASN_COUNTER64 */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIHOTSWAPACTIONREQUEST:
            /** INTEGER = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIHOTSWAPPOLICYCANCEL:
            /** INTEGER = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIHOTSWAPRESOURCEREQUEST:
            /** INTEGER = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
           netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
示例#25
0
void
memTable_set_reserve2(netsnmp_request_group * rg)
{
    memTable_context *row_ctx = (memTable_context *) rg->existing_row;
    memTable_context *undo_ctx = (memTable_context *) rg->undo_info;
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int             rc;

    rg->rg_void = rg->list->ri;

    /*
     * TODO: loop through columns, check for valid
     * values and any range constraints.
     */
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;
        rc = SNMP_ERR_NOERROR;

        switch (current->tri->colnum) {

        case COLUMN_MEMINDEX:
            /** INTEGER32 = ASN_INTEGER */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( *var->val.integer != XXX ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        case COLUMN_MEMSYSTEM:
            /** OCTETSTR = ASN_OCTET_STR */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( XXX_check_value( var->val.string, XXX ) ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        case COLUMN_MEMTOTAL:
            /** INTEGER32 = ASN_INTEGER */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( *var->val.integer != XXX ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        case COLUMN_MEMAVAIL:
            /** INTEGER32 = ASN_INTEGER */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( *var->val.integer != XXX ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        case COLUMN_MEMUSED:
            /** INTEGER32 = ASN_INTEGER */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( *var->val.integer != XXX ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        case COLUMN_MEMUSAGE:
            /** INTEGER32 = ASN_INTEGER */
            /*
             * TODO: routine to check valid values
             *
             * EXAMPLE:
             *
             * if ( *var->val.integer != XXX ) {
             *    rc = SNMP_ERR_INCONSISTENTVALUE;
             *    rc = SNMP_ERR_BADVALUE;
             * }
             */
            break;

        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
            netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
                                           rc);
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
示例#26
0
void saHpiWatchdogTable_set_reserve2( netsnmp_request_group *rg )
{
    saHpiWatchdogTable_context *row_ctx = (saHpiWatchdogTable_context *)rg->existing_row;
    saHpiWatchdogTable_context *undo_ctx = (saHpiWatchdogTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int rc;

    rg->rg_void = rg->list->ri;

    /*
     * TODO: loop through columns, check for valid
     * values and any range constraints.
     */
    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_truthvalue(current->ri->requestvb);
        break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
                rc = netsnmp_check_vb_truthvalue(current->ri->requestvb);
        break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** SaHpiWatchdogTimerUse = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** SaHpiWatchdogPreTimerAction = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** OCTETSTR = ASN_OCTET_STR */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( XXX_check_value( var->val.string, XXX ) ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIWATCHDOGTIMERRESET:
            /** TruthValue = ASN_INTEGER */
                rc = netsnmp_check_vb_truthvalue(current->ri->requestvb);
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
           netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
示例#27
0
/************************************************************
 * 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.
     */
}
示例#28
0
/************************************************************
 * 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.
     */
}
示例#29
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void saHpiHotSwapTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
    saHpiHotSwapTable_context *row_ctx = (saHpiHotSwapTable_context *)rg->existing_row;
    saHpiHotSwapTable_context *undo_ctx = (saHpiHotSwapTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;

    int            row_err = 0;

    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for( current = rg->list; current; current = current->next ) {

        var = current->ri->requestvb;

        switch(current->tri->colnum) {

        case COLUMN_SAHPIHOTSWAPINDICATOR:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiHotSwapIndicator = *var->val.integer;
        break;

        case COLUMN_SAHPIHOTSWAPSTATE:
            /** SaHpiHotSwapState = ASN_INTEGER */
            row_ctx->saHpiHotSwapState = *var->val.integer;
        break;

        case COLUMN_SAHPIHOTSWAPEXTRACTTIMEOUT:
            /** SaHpiTime = ASN_COUNTER64 */
            row_ctx->saHpiHotSwapExtractTimeout = *var->val.integer;
        break;

        case COLUMN_SAHPIHOTSWAPACTIONREQUEST:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiHotSwapActionRequest = *var->val.integer;
        break;

        case COLUMN_SAHPIHOTSWAPPOLICYCANCEL:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiHotSwapPolicyCancel = *var->val.integer;
        break;

        case COLUMN_SAHPIHOTSWAPRESOURCEREQUEST:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiHotSwapResourceRequest = *var->val.integer;
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
#ifndef saHpiHotSwapTable_CAN_MODIFY_ACTIVE_ROW
    if( undo_ctx && RS_IS_ACTIVE(undo_ctx->saHpiDomainAlarmRowStatus) &&
        row_ctx && RS_IS_ACTIVE(row_ctx->saHpiDomainAlarmRowStatus) ) {
            row_err = 1;
    }
#endif

    /*
     * check activation/deactivation
     */
    row_err = netsnmp_table_array_check_row_status(&cb, rg,
                                  row_ctx ? &row_ctx->saHpiDomainAlarmRowStatus : NULL,
                                  undo_ctx ? &undo_ctx->saHpiDomainAlarmRowStatus : NULL);
    if(row_err) {
        netsnmp_set_mode_request_error(MODE_SET_BEGIN,
                                       (netsnmp_request_info*)rg->rg_void,
                                       row_err);
        return;
    }

    /*
     * TODO: if you have dependencies on other tables, this would be
     * a good place to check those, too.
     */
}
示例#30
0
void saHpiUserEventTable_set_reserve2( netsnmp_request_group *rg )
{
    saHpiUserEventTable_context *row_ctx = (saHpiUserEventTable_context *)rg->existing_row;
    saHpiUserEventTable_context *undo_ctx = (saHpiUserEventTable_context *)rg->undo_info;
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int rc;

    rg->rg_void = rg->list->ri;

    /*
     * TODO: loop through columns, check for valid
     * values and any range constraints.
     */
    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 */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIUSEREVENTTEXTTYPE:
            /** SaHpiTextType = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIUSEREVENTTEXTLANGUAGE:
            /** SaHpiTextLanguage = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIUSEREVENTTEXT:
            /** SaHpiText = ASN_OCTET_STR */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( XXX_check_value( var->val.string, XXX ) ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        case COLUMN_SAHPIUSEREVENTROWSTATUS:
            /** RowStatus = ASN_INTEGER */
                    /*
                     * TODO: routine to check valid values
                     *
                     * EXAMPLE:
                     *
                    * if ( *var->val.integer != XXX ) {
                *    rc = SNMP_ERR_INCONSISTENTVALUE;
                *    rc = SNMP_ERR_BADVALUE;
                * }
                */
        break;

        default: /** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
           netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}