/*
 * White Rabbit SNMP
 * Copyright (C) 2010, CERN.
 *
 * Version:     wrsw_snmpd v1.0
 *
 * Authors:     Miguel Baizán (miguel.baizan@integrasys-sa.com)
 *
 * Description: Definition of the basic structures (indexes, rows,
 *              container) used to serve the SNMP requests. Init and clean up
 *              functions for the structures holding the container.
 *              Note: this file originally auto-generated by mib2c using
 *              mib2c.mfd.conf 17337
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


/* 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 "ieee8021BridgeBasePortTable.h"

#include <net-snmp/agent/mib_modules.h>

#include "ieee8021BridgeBasePortTable_interface.h"

const oid ieee8021BridgeBasePortTable_oid[] = { IEEE8021BRIDGEBASEPORTTABLE_OID };
const int ieee8021BridgeBasePortTable_oid_size = OID_LENGTH(ieee8021BridgeBasePortTable_oid);

    ieee8021BridgeBasePortTable_registration  ieee8021BridgeBasePortTable_user_context;

void initialize_table_ieee8021BridgeBasePortTable(void);
void shutdown_table_ieee8021BridgeBasePortTable(void);


/**
 * Initializes the ieee8021BridgeBasePortTable module
 */
void
init_ieee8021BridgeBasePortTable(void)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:init_ieee8021BridgeBasePortTable","called\n"));

    /*
     * TODO:300:o: Perform ieee8021BridgeBasePortTable one-time module initialization.
     */

    /*
     * here we initialize all the tables we're planning on supporting
     */
    if (should_init("ieee8021BridgeBasePortTable"))
        initialize_table_ieee8021BridgeBasePortTable();

} /* init_ieee8021BridgeBasePortTable */

/**
 * Shut-down the ieee8021BridgeBasePortTable module (agent is exiting)
 */
void
shutdown_ieee8021BridgeBasePortTable(void)
{
    if (should_init("ieee8021BridgeBasePortTable"))
        shutdown_table_ieee8021BridgeBasePortTable();

}

/**
 * Initialize the table ieee8021BridgeBasePortTable
 *    (Define its contents and how it's structured)
 */
void
initialize_table_ieee8021BridgeBasePortTable(void)
{
    ieee8021BridgeBasePortTable_registration * user_context;
    u_long flags;

    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:initialize_table_ieee8021BridgeBasePortTable","called\n"));

    /*
     * TODO:301:o: Perform ieee8021BridgeBasePortTable one-time table initialization.
     */

    /*
     * TODO:302:o: |->Initialize ieee8021BridgeBasePortTable user context
     * if you'd like to pass in a pointer to some data for this
     * table, allocate or set it up here.
     */
    /*
     * a netsnmp_data_list is a simple way to store void pointers. A simple
     * string token is used to add, find or remove pointers.
     */
    user_context = netsnmp_create_data_list("ieee8021BridgeBasePortTable", NULL, NULL);

    /*
     * No support for any flags yet, but in the future you would
     * set any flags here.
     */
    flags = 0;

    /*
     * call interface initialization code
     */
    _ieee8021BridgeBasePortTable_initialize_interface(user_context, flags);
} /* initialize_table_ieee8021BridgeBasePortTable */

/**
 * Shutdown the table ieee8021BridgeBasePortTable
 */
void
shutdown_table_ieee8021BridgeBasePortTable(void)
{
    /*
     * call interface shutdown code
     */
    _ieee8021BridgeBasePortTable_shutdown_interface(&ieee8021BridgeBasePortTable_user_context);
}

/**
 * extra context initialization (eg default values)
 *
 * @param rowreq_ctx    : row request context
 * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate)
 *
 * @retval MFD_SUCCESS  : no errors
 * @retval MFD_ERROR    : error (context allocate will fail)
 */
int
ieee8021BridgeBasePortTable_rowreq_ctx_init(ieee8021BridgeBasePortTable_rowreq_ctx *rowreq_ctx,
                           void *user_init_ctx)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:ieee8021BridgeBasePortTable_rowreq_ctx_init","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:210:o: |-> Perform extra ieee8021BridgeBasePortTable rowreq initialization. (eg DEFVALS)
     */

    return MFD_SUCCESS;
} /* ieee8021BridgeBasePortTable_rowreq_ctx_init */

/**
 * extra context cleanup
 *
 */
void ieee8021BridgeBasePortTable_rowreq_ctx_cleanup(ieee8021BridgeBasePortTable_rowreq_ctx *rowreq_ctx)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:ieee8021BridgeBasePortTable_rowreq_ctx_cleanup","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:211:o: |-> Perform extra ieee8021BridgeBasePortTable rowreq cleanup.
     */
} /* ieee8021BridgeBasePortTable_rowreq_ctx_cleanup */

/**
 * pre-request callback
 *
 *
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_ERROR                : other error
 */
int
ieee8021BridgeBasePortTable_pre_request(ieee8021BridgeBasePortTable_registration * user_context)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:ieee8021BridgeBasePortTable_pre_request","called\n"));

    /*
     * TODO:510:o: Perform ieee8021BridgeBasePortTable pre-request actions.
     */

    return MFD_SUCCESS;
} /* ieee8021BridgeBasePortTable_pre_request */

/**
 * post-request callback
 *
 * Note:
 *   New rows have been inserted into the container, and
 *   deleted rows have been removed from the container and
 *   released.
 *
 * @param user_context
 * @param rc : MFD_SUCCESS if all requests succeeded
 *
 * @retval MFD_SUCCESS : success.
 * @retval MFD_ERROR   : other error (ignored)
 */
int
ieee8021BridgeBasePortTable_post_request(ieee8021BridgeBasePortTable_registration * user_context, int rc)
{
    DEBUGMSGTL(("verbose:ieee8021BridgeBasePortTable:ieee8021BridgeBasePortTable_post_request","called\n"));

    /*
     * TODO:511:o: Perform ieee8021BridgeBasePortTable post-request actions.
     */

    /*
     * check to set if any rows were changed.
     */
    if (ieee8021BridgeBasePortTable_dirty_get()) {
        /*
         * check if request was successful. If so, this would be
         * a good place to save data to its persistent store.
         */
        if (MFD_SUCCESS == rc) {
            /*
             * save changed rows, if you haven't already
             */
        }

        ieee8021BridgeBasePortTable_dirty_set(0); /* clear table dirty flag */
    }

    return MFD_SUCCESS;
} /* ieee8021BridgeBasePortTable_post_request */


/** @{ */
