Example #1
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 saHpiEventLogTable_set_action( netsnmp_request_group *rg )
{
    netsnmp_variable_list *var;
    saHpiEventLogTable_context *row_ctx = (saHpiEventLogTable_context *)rg->existing_row;
    saHpiEventLogTable_context *undo_ctx = (saHpiEventLogTable_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? */
        }
    }

#if 0
    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
#ifndef saHpiEventLogTable_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);
#endif

    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.
     */
}
Example #2
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.
     */
}
/*
 * 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;
	}

}
Example #5
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.
     */
}
Example #6
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.
     */
}