plz help me

"sathyanarayanan Thangavelu" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
hi
this is my code where should intialize the table and how please  help me  i
am new to this net snmp
code
/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.iterate.conf,v 5.19 2006/09/07 16:17:35 dts12 Exp $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "dot3OamTable.h"

struct dot3OamTable_entry {
    /*
     * Index values
     */
    long            oamIndex;
    /*
     * Column values
     */
    long            dot3OamAdminState;
    long            old_dot3OamAdminState;
    u_long          dot3OamMaxOamPduSize;
    /*
     * Illustrate using a simple linked list
     */
    int             valid;
    struct dot3OamTable_entry *next;
};
struct dot3OamTable_entry *dot3OamTable_head;
/** Initializes the dot3OamTable module */
void
init_dot3OamTable(void)
{
    /*
     * here we initialize all the tables we're planning on supporting
     */
    initialize_table_dot3OamTable();
}
/** Initialize the dot3OamTable table by defining its contents and how it's
structured */

void
initialize_table_dot3OamTable(void)
{
    static oid      dot3OamTable_oid[] = { 1, 3, 6, 1, 2, 1, 20291, 1, 1 };
    size_t          dot3OamTable_oid_len = OID_LENGTH(dot3OamTable_oid);
    netsnmp_handler_registration *reg;
    netsnmp_iterator_info *iinfo;
    netsnmp_table_registration_info *table_info;

    reg =netsnmp_create_handler_registration("dot3OamTable",
                                            dot3OamTable_handler,
                                            dot3OamTable_oid,
                                            dot3OamTable_oid_len,
                                            HANDLER_CAN_RWRITE);

    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,   /* index:
oamIndex */
                                     0);
    table_info->min_column = COLUMN_DOT3OAMADMINSTATE;
    table_info->max_column = COLUMN_DOT3OAMMAXOAMPDUSIZE;

    iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
    iinfo->get_first_data_point = dot3OamTable_get_first_data_point;
    iinfo->get_next_data_point = dot3OamTable_get_next_data_point;
    iinfo->table_reginfo = table_info;
    netsnmp_register_table_iterator(reg, iinfo);
    /*
     * Initialise the contents of the table here*/
}
dot3OamTable_createEntry(long oamIndex)
{
struct dot3OamTable_entry *entry;

    entry = SNMP_MALLOC_TYPEDEF(struct dot3OamTable_entry);
    if (!entry)
        return NULL;

    entry->oamIndex = oamIndex;
    entry->next = dot3OamTable_head;
    dot3OamTable_head = entry;
    return entry;
}

/*
 * remove a row from the table
 */
void
dot3OamTable_removeEntry(struct dot3OamTable_entry *entry)
{
    struct dot3OamTable_entry *ptr, *prev;

    if (!entry)
        return;                 /* Nothing to remove */

    for (ptr = dot3OamTable_head, prev = NULL;
         ptr != NULL; prev = ptr, ptr = ptr->next) {
        if (ptr == entry)
            break;
    }
    if (!ptr)
        return;                 /* Can't find it */

    if (prev == NULL)
        dot3OamTable_head = ptr->next;
    else
        prev->next = ptr->next;

    SNMP_FREE(entry);           /* XXX - release any other internal
resources */
}
netsnmp_variable_list *
dot3OamTable_get_first_data_point(void **my_loop_context,
                                  void **my_data_context,
                                  netsnmp_variable_list * put_index_data,
                                  netsnmp_iterator_info *mydata)
{
    *my_loop_context = dot3OamTable_head;
    return dot3OamTable_get_next_data_point(my_loop_context,
                                            my_data_context,
                                            put_index_data, mydata);
}

netsnmp_variable_list *
dot3OamTable_get_next_data_point(void **my_loop_context,
                                 void **my_data_context,
                                 netsnmp_variable_list * put_index_data,
                                 netsnmp_iterator_info *mydata)
{
    struct dot3OamTable_entry *entry =
        (struct dot3OamTable_entry *) *my_loop_context;
    netsnmp_variable_list *idx = put_index_data;

    if (entry) {
        snmp_set_var_typed_integer(idx, ASN_INTEGER, entry->oamIndex);
        idx = idx->next_variable;
        *my_data_context = (void *) entry;
        *my_loop_context = (void *) entry->next;
        return put_index_data;
    } else {
            return NULL;
    }
}


/** handles requests for the dot3OamTable table */
int
dot3OamTable_handler(netsnmp_mib_handler *handler,
                     netsnmp_handler_registration *reginfo,
                     netsnmp_agent_request_info *reqinfo,
                     netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    struct dot3OamTable_entry *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            table_entry = (struct dot3OamTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_DOT3OAMADMINSTATE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->dot3OamAdminState);
                break;
            case COLUMN_DOT3OAMMAXOAMPDUSIZE:
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_UNSIGNED,
                                           table_entry->
                                           dot3OamMaxOamPduSize);
                break;
                  default:
                /*
                 * An unsupported/unreadable column (if applicable)
                 */
                snmp_set_var_typed_value(request->requestvb,
                                         SNMP_NOSUCHOBJECT, NULL, 0);
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            table_entry = (struct dot3OamTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_DOT3OAMADMINSTATE:
                /*
                 * or possibly 'netsnmp_check_vb_int_range'
                 */
                ret = netsnmp_check_vb_int(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

     case MODE_SET_RESERVE2:
        break;

    case MODE_SET_FREE:
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            table_entry = (struct dot3OamTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_DOT3OAMADMINSTATE:
                table_entry->old_dot3OamAdminState =
                    table_entry->dot3OamAdminState;
                table_entry->dot3OamAdminState =
                    *request->requestvb->val.integer;
                break;
            }
        }
        break;
    case MODE_SET_UNDO:
        for (request = requests; request; request = request->next) {
            table_entry = (struct dot3OamTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);
            switch (table_info->colnum) {
            case COLUMN_DOT3OAMADMINSTATE:
                    table_entry->dot3OamAdminState =
                      table_entry->old_dot3OamAdminState;
                      table_entry->old_dot3OamAdminState = 0;
                break;
               }
          }
      case MODE_SET_COMMIT:
        break;
      }
    return SNMP_ERR_NOERROR;
}

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.