/*
 * Note: this file originally auto-generated by mib2c using
 *       version : 12077 $ of $
 *
 * $Id:$
 *
 */
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>

/* include our parent header */
#include "ieee8021BridgeTrafficClassTable.h"


/** @defgroup data_set data_set: Routines to set data
 *
 * These routines are used to set the value for individual objects. The
 * row context is passed, along with the new value.
 *
 * @{
 */
/**********************************************************************
 **********************************************************************
 ***
 *** Table ieee8021BridgeTrafficClassTable
 ***
 **********************************************************************
 **********************************************************************/
/*
 * IEEE8021-BRIDGE-MIB::ieee8021BridgeTrafficClassTable is subid 3 of ieee8021BridgePriority.
 * Its status is Current.
 * OID: .1.3.111.2.802.1.1.2.1.3.3, length: 11
*/
    /*
     * NOTE: if you update this chart, please update the versions in
     *       local/mib2c-conf.d/parent-set.m2i
     *       agent/mibgroup/helpers/baby_steps.c
     * while you're at it.
     */
    /*
     ***********************************************************************
     * Baby Steps Flow Chart (2004.06.05)                                  *
     *                                                                     *
     * +--------------+    +================+    U = unconditional path    *
     * |optional state|    ||required state||    S = path for success      *
     * +--------------+    +================+    E = path for error        *
     ***********************************************************************
     *
     *                        +--------------+
     *                        |     pre      |
     *                        |   request    |
     *                        +--------------+
     *                               | U
     *                        +==============+
     *       +----------------||  object    ||
     *       |              E ||  lookup    ||
     *       |                +==============+
     *       |                       | S
     *       |                +==============+
     *       |              E ||   check    ||
     *       |<---------------||   values   ||
     *       |                +==============+
     *       |                       | S
     *       |                +==============+
     *       |       +<-------||   undo     ||
     *       |       |      E ||   setup    ||
     *       |       |        +==============+
     *       |       |               | S
     *       |       |        +==============+
     *       |       |        ||    set     ||-------------------------->+
     *       |       |        ||   value    || E                         |
     *       |       |        +==============+                           |
     *       |       |               | S                                 |
     *       |       |        +--------------+                           |
     *       |       |        |    check     |-------------------------->|
     *       |       |        |  consistency | E                         |
     *       |       |        +--------------+                           |
     *       |       |               | S                                 |
     *       |       |        +==============+         +==============+  |
     *       |       |        ||   commit   ||-------->||     undo   ||  |
     *       |       |        ||            || E       ||    commit  ||  |
     *       |       |        +==============+         +==============+  |
     *       |       |               | S                     U |<--------+
     *       |       |        +--------------+         +==============+
     *       |       |        | irreversible |         ||    undo    ||
     *       |       |        |    commit    |         ||     set    ||
     *       |       |        +--------------+         +==============+
     *       |       |               | U                     U |
     *       |       +-------------->|<------------------------+
     *       |                +==============+
     *       |                ||   undo     ||
     *       |                ||  cleanup   ||
     *       |                +==============+
     *       +---------------------->| U
     *                        +--------------+
     *                        |    post      |
     *                        |   request    |
     *                        +--------------+
     *
     */

/**
 * Setup up context with information needed to undo a set request.
 *
 * This function will be called before the individual node undo setup
 * functions are called. If you need to do any undo setup that is not
 * related to a specific column, you can do it here.
 *
 * Note that the undo context has been allocated with
 * ieee8021BridgeTrafficClassTable_allocate_data(), but may need extra
 * initialization similar to what you may have done in
 * ieee8021BridgeTrafficClassTable_rowreq_ctx_init().
 * Note that an individual node's undo_setup function will only be called
 * if that node is being set to a new value.
 *
 * If there is any setup specific to a particular column (e.g. allocating
 * memory for a string), you should do that setup in the node's undo_setup
 * function, so it won't be done unless it is necessary.
 *
 * @param rowreq_ctx
 *        Pointer to the table context (ieee8021BridgeTrafficClassTable_rowreq_ctx)
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error. set will fail.
 */
int
ieee8021BridgeTrafficClassTable_undo_setup( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_undo_setup","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * TODO:451:M: |-> Setup ieee8021BridgeTrafficClassTable undo.
     * set up ieee8021BridgeTrafficClassTable undo information, in preparation for a set.
     * Undo storage is in (* ieee8021BridgeTrafficClass_val_ptr )*
     */

    return rc;
} /* ieee8021BridgeTrafficClassTable_undo_setup */

/**
 * Undo a set request.
 *
 * This function will be called before the individual node undo
 * functions are called. If you need to do any undo that is not
 * related to a specific column, you can do it here.
 *
 * Note that an individual node's undo function will only be called
 * if that node is being set to a new value.
 *
 * If there is anything  specific to a particular column (e.g. releasing
 * memory for a string), you should do that setup in the node's undo
 * function, so it won't be done unless it is necessary.
 *
 * @param rowreq_ctx
 *        Pointer to the table context (ieee8021BridgeTrafficClassTable_rowreq_ctx)
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error. set will fail.
 */
int
ieee8021BridgeTrafficClassTable_undo( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_undo","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * TODO:451:M: |-> ieee8021BridgeTrafficClassTable undo.
     * ieee8021BridgeTrafficClassTable undo information, in response to a failed set.
     * Undo storage is in (* ieee8021BridgeTrafficClass_val_ptr )*
     */

    return rc;
} /* ieee8021BridgeTrafficClassTable_undo_setup */

/**
 * Cleanup up context undo information.
 *
 * This function will be called after set/commit processing. If you
 * allocated any resources in undo_setup, this is the place to release
 * those resources.
 *
 * This function is called regardless of the success or failure of the set
 * request. If you need to perform different steps for cleanup depending
 * on success or failure, you can add a flag to the rowreq_ctx.
 *
 * @param rowreq_ctx
 *        Pointer to the table context (ieee8021BridgeTrafficClassTable_rowreq_ctx)
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error
 */
int
ieee8021BridgeTrafficClassTable_undo_cleanup( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_undo_cleanup","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * TODO:452:M: |-> Cleanup ieee8021BridgeTrafficClassTable undo.
     * Undo storage is in (* ieee8021BridgeTrafficClass_val_ptr )*
     */

    return rc;
} /* ieee8021BridgeTrafficClassTable_undo_cleanup */

/**
 * commit new values.
 *
 * At this point, you should have done everything you can to ensure that
 * this commit will not fail.
 *
 * Should you need different behavior depending on which columns were
 * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
 * set. The definitions for the COLUMN_*_FLAG bits can be found in
 * ieee8021BridgeTrafficClassTable_oids.h.
 * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
 *
 * @param ieee8021BridgeTrafficClassTable_rowreq_ctx
 *        Pointer to the users context.
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error
 */
int
ieee8021BridgeTrafficClassTable_commit( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;
    int             save_flags;

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_commit","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * save flags, then clear until we actually do something
     */
    save_flags = rowreq_ctx->column_set_flags;
    rowreq_ctx->column_set_flags = 0;

    /*
     * commit ieee8021BridgeTrafficClassTable data
     * 1) check the column's flag in save_flags to see if it was set.
     * 2) clear the flag when you handle that column
     * 3) set the column's flag in column_set_flags if it needs undo
     *    processing in case of a failure.
     */
    if (save_flags & COLUMN_IEEE8021BRIDGETRAFFICCLASS_FLAG) {
       save_flags &= ~COLUMN_IEEE8021BRIDGETRAFFICCLASS_FLAG; /* clear ieee8021BridgeTrafficClass */
       /*
        * TODO:482:o: |-> commit column ieee8021BridgeTrafficClass.
        */
       rc = -1;
       if(-1 == rc) {
           snmp_log(LOG_ERR,"ieee8021BridgeTrafficClassTable column ieee8021BridgeTrafficClass commit failed\n");
       }
       else {
            /*
             * set flag, in case we need to undo ieee8021BridgeTrafficClass
             */
            rowreq_ctx->column_set_flags |= COLUMN_IEEE8021BRIDGETRAFFICCLASS_FLAG;
       }
    }

    /*
     * if we successfully commited this row, set the dirty flag.
     */
    if (MFD_SUCCESS == rc) {
        rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY;
    }

    if (save_flags) {
       snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags);
       return MFD_ERROR;
    }

    return rc;
} /* ieee8021BridgeTrafficClassTable_commit */

/**
 * undo commit new values.
 *
 * Should you need different behavior depending on which columns were
 * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
 * set. The definitions for the COLUMN_*_FLAG bits can be found in
 * ieee8021BridgeTrafficClassTable_oids.h.
 * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
 *
 * @param ieee8021BridgeTrafficClassTable_rowreq_ctx
 *        Pointer to the users context.
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error
 */
int
ieee8021BridgeTrafficClassTable_undo_commit( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_undo_commit","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * TODO:485:M: |-> Undo ieee8021BridgeTrafficClassTable commit.
     * check the column's flag in rowreq_ctx->column_set_flags to see
     * if it was set during commit, then undo it.
     *
     * eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {}
     */


    /*
     * if we successfully un-commited this row, clear the dirty flag.
     */
    if (MFD_SUCCESS == rc) {
        rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;
    }

    return rc;
} /* ieee8021BridgeTrafficClassTable_undo_commit */

/*
 * TODO:440:M: Implement ieee8021BridgeTrafficClassTable node value checks.
 * TODO:450:M: Implement ieee8021BridgeTrafficClassTable undo functions.
 * TODO:460:M: Implement ieee8021BridgeTrafficClassTable set functions.
 * TODO:480:M: Implement ieee8021BridgeTrafficClassTable commit functions.
 */
/*---------------------------------------------------------------------
 * IEEE8021-BRIDGE-MIB::ieee8021BridgeTrafficClassEntry.ieee8021BridgeTrafficClass
 * ieee8021BridgeTrafficClass is subid 2 of ieee8021BridgeTrafficClassEntry.
 * Its status is Current, and its access level is ReadWrite.
 * OID: .1.3.111.2.802.1.1.2.1.3.3.1.2
 * Description:
The Traffic Class the received frame is mapped to.

        The value of this object MUST be retained across
        reinitializations of the management system.
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 1      hashint   0
 *   settable   1
 *
 * Ranges:  0 - 7;
 *
 * Its syntax is INTEGER32 (based on perltype INTEGER32)
 * The net-snmp type is ASN_INTEGER. The C type decl is long (long)
 */
/**
 * Check that the proposed new value is potentially valid.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param ieee8021BridgeTrafficClass_val
 *        A long containing the new value.
 *
 * @retval MFD_SUCCESS        : incoming value is legal
 * @retval MFD_NOT_VALID_NOW  : incoming value is not valid now
 * @retval MFD_NOT_VALID_EVER : incoming value is never valid
 *
 * This is the place to check for requirements that are not
 * expressed in the mib syntax (for example, a requirement that
 * is detailed in the description for an object).
 *
 * You should check that the requested change between the undo value and the
 * new value is legal (ie, the transistion from one value to another
 * is legal).
 *
 *@note
 * This check is only to determine if the new value
 * is \b potentially valid. This is the first check of many, and
 * is one of the simplest ones.
 *
 *@note
 * this is not the place to do any checks for values
 * which depend on some other value in the mib. Those
 * types of checks should be done in the
 * ieee8021BridgeTrafficClassTable_check_dependencies() function.
 *
 * The following checks have already been done for you:
 *    The syntax is ASN_INTEGER
 *    The value is in (one of) the range set(s):  0 - 7
 *
 * If there a no other checks you need to do, simply return MFD_SUCCESS.
 *
 */
int
ieee8021BridgeTrafficClass_check_value( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx, long ieee8021BridgeTrafficClass_val)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClass_check_value","called\n"));

    /** should never get a NULL pointer */
    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:441:o: |-> Check for valid ieee8021BridgeTrafficClass value.
     */

    return MFD_SUCCESS; /* ieee8021BridgeTrafficClass value not illegal */
} /* ieee8021BridgeTrafficClass_check_value */

/**
 * Save old value information
 *
 * @param rowreq_ctx
 *        Pointer to the table context (ieee8021BridgeTrafficClassTable_rowreq_ctx)
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error. set will fail.
 *
 * This function will be called after the table level undo setup function
 * ieee8021BridgeTrafficClassTable_undo_setup has been called.
 *
 *@note
 * this function will only be called if a new value is set for this column.
 *
 * If there is any setup specific to a particular column (e.g. allocating
 * memory for a string), you should do that setup in this function, so it
 * won't be done unless it is necessary.
 */
int
ieee8021BridgeTrafficClass_undo_setup( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClass_undo_setup","called\n"));

    /** should never get a NULL pointer */
    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:455:o: |-> Setup ieee8021BridgeTrafficClass undo.
     */
    /*
     * copy ieee8021BridgeTrafficClass data
     * set rowreq_ctx->undo->ieee8021BridgeTrafficClass from rowreq_ctx->data.ieee8021BridgeTrafficClass
     */
    rowreq_ctx->undo->ieee8021BridgeTrafficClass = rowreq_ctx->data.ieee8021BridgeTrafficClass;


    return MFD_SUCCESS;
} /* ieee8021BridgeTrafficClass_undo_setup */

/**
 * Set the new value.
 *
 * @param rowreq_ctx
 *        Pointer to the users context. You should know how to
 *        manipulate the value from this object.
 * @param ieee8021BridgeTrafficClass_val
 *        A long containing the new value.
 */
int
ieee8021BridgeTrafficClass_set( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx, long ieee8021BridgeTrafficClass_val )
{

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClass_set","called\n"));

    /** should never get a NULL pointer */
    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:461:M: |-> Set ieee8021BridgeTrafficClass value.
     * set ieee8021BridgeTrafficClass value in rowreq_ctx->data
     */
    rowreq_ctx->data.ieee8021BridgeTrafficClass = ieee8021BridgeTrafficClass_val;

    return MFD_SUCCESS;
} /* ieee8021BridgeTrafficClass_set */

/**
 * undo the previous set.
 *
 * @param rowreq_ctx
 *        Pointer to the users context.
 */
int
ieee8021BridgeTrafficClass_undo( ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{

    DEBUGMSGTL(("verbose:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClass_undo","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:456:o: |-> Clean up ieee8021BridgeTrafficClass undo.
     */
    /*
     * copy ieee8021BridgeTrafficClass data
     * set rowreq_ctx->data.ieee8021BridgeTrafficClass from rowreq_ctx->undo->ieee8021BridgeTrafficClass
     */
    rowreq_ctx->data.ieee8021BridgeTrafficClass = rowreq_ctx->undo->ieee8021BridgeTrafficClass;


    return MFD_SUCCESS;
} /* ieee8021BridgeTrafficClass_undo */

/**
 * check dependencies
 *
 * This is useful for for tables which have dependencies between columns
 * (or rows, or tables). For example, two columns allocating a percentage
 * of something add up 100%.
 *
 * Should you need different behavior depending on which columns were
 * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
 * set. The definitions for the COLUMN_*_FLAG bits can be found in
 * ieee8021BridgeTrafficClassTable_oids.h.
 * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
 *
 * @retval MFD_SUCCESS all the changes to the row are legal
 * @retval MFD_ERROR   one or more changes are not legal
 *
 * (see README-table-ieee8021BridgeTrafficClassTable if you don't have dependencies)
 */
int
ieee8021BridgeTrafficClassTable_check_dependencies(ieee8021BridgeTrafficClassTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;

    DEBUGMSGTL(("internal:ieee8021BridgeTrafficClassTable:ieee8021BridgeTrafficClassTable_check_dependencies","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:470:o: Check ieee8021BridgeTrafficClassTable row dependencies.
     * check that all new value are legal and consistent with each other
     */
    return rc;
} /* ieee8021BridgeTrafficClassTable_check_dependencies */

/** @} */
