cache problems with table data mib2c

Kathy McLeod <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <OF4A7C6697.84D5446B-ON86257742.0066DFA0-86257742.006AB1BD@us.ibm.com>
(See attached file: lldpPortConfigTable.C)(See attached file:
lldpPortConfigTable.H)(See attached file: lldp.mib)

Hi -

I am copying from my previous notes, so may seem a little disjointed.
Summary of problems is 1) load is only called for an snmpget, not for other
commands; 2) the first get after the load always fails, and then when I
repeat the command, it works (I am testing using a command line interface);
3) this causes the -1 setting to pretty much not work at all because the
load is called for every get; 4) cache unloads and loads and handler
invocations can be called at the same time, which causes various errors
including segmentation faults. I also have a couple of questions below.

Note - I removed the "handler" debug statements from this code, but I show
the handler3 one below which is the one for the failure path.

Note - the "flag" code is for testing whether the table has been changed in
the database by another interface (CLI, for example).  This has not been
implemented yet (the notification) so I am arbitrarily setting it for now.

As near as I can tell, this is the same code as before.  Let me know if it
is not working (my newest code has been modified to get the data from our
backend datastore code, etc.)

-- I have some new info on this problem.  We upgraded to net-snmp 5.4.2.1
and
were seeing the same problem (cache reload never called after an unload).
I was always using the snmptable as the command (because my fake data show
different index values on a reload so easy to verify it worked).  However,
when I tried a snmpget the reload was called.  I was able to do 6 or more
unload/reloads, and did not have to do the cache check and reload in the
init routine (altho that worked as well).  So I was able to verify my code,
but this is still a bug (that the reload is not issued for other commands).

-- The -1 setting did not work for me.  After an unload, the next request
fails (because there is no table, I assume).  Then it reloads and maybe I
can issue one command and have it succeed.  Otherwise the next unload
clobbers my data.  Sometimes I get a segmentation error, or snmptable shows
part of the old table or part of the new table.  Is this how it is supposed
to work or am I missing something?  (This happens for other timeout values
as well, altho for testing I try to avoid issuing a command when the
timeout is about to happen.)

-- Re this excerpt from the cache_handler documentation page:

xxx - method to prevent cache from expiring while a request is being
processed (e.g. delegated request). proposal: set a flag, which would be
cleared when request finished (which could be acomplished by a dummy data
list item in agent req info & custom free function).

Has this been implemented, or will it be in the near future?  Thanks.

It seems like without this, the cache-handling is not safe.

-- For the case where I am checking a date on a file (or in this case, a
flag
indicating whether table data has changed), I have to set the
    cache->flags |= NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD;

as well as
    cache->flags |= NETSNMP_CACHE_DONT_FREE_EXPIRED;
    cache->flags |= NETSNMP_CACHE_DONT_AUTO_RELEASE;

as is mentioned in the tutorial.  Otherwise, the free gets called before I
make my check in the load routine.  Or was the idea to make the check in
the free routine?

-- Re debug statements below, it seems like the first request after a load
should not
fail, since the reload has completed and then the handler is called.  But
mine always fails, and then when I issue the command again, it works.
Based on my debug statements, it is failing on

switch (table_info->colnum) {
            case COLUMN_LLDPPORTCONFIGADMINSTATUS:
                if (!table_entry) {
DEBUGMSGTL(("lldpPortConfigTable", "handler3\n"));
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;

I thought maybe the new cache ptr was not set in time for the GET request,
so I put a 5 second delay in my handler code before the switch statement,
but it still fails that first time.  Is this the expected behavior?  I
don't see clients finding this too handy.

debug trace:

NET-SNMP version 5.4.2.1
lldpPortConfigTable: cache load
lldpPortConfigTable: cache for loop
lldpPortConfigTable: cache for loop0
lldpPortConfigTable: cache for loop bottom0
lldpPortConfigTable: cache for loop1
lldpPortConfigTable: cache for loop bottom1
lldpPortConfigTable: cache for loop2
lldpPortConfigTable: cache for loop bottom2
lldpPortConfigTable: cache for loop3
lldpPortConfigTable: cache for loop bottom3
lldpPortConfigTable: cache after loop4

// this is the failure path
lldpPortConfigTable: handler1
lldpPortConfigTable: handler2
lldpPortConfigTable: handler3

// this is the successful path
lldpPortConfigTable: handler1
lldpPortConfigTable: handler2
lldpPortConfigTable: handler43
lldpPortConfigTable: handler5

terminal output:
snmpget -v 2c -c private localhost LLDP-MIB::lldpPortConfigTable.1.2.2
LLDP-MIB::lldpPortConfigAdminStatus.2 = No Such Instance currently exists
at this OID
 // then repeat the command
snmpget -v 2c -c private localhost LLDP-MIB::lldpPortConfigTable.1.2.2
LLDP-MIB::lldpPortConfigAdminStatus.2 = INTEGER: txAndRx(3)

My code is the same as what I sent earlier, other than some extra debug
statements.  Let me know if you need more info.  (I tried the timeout and
retry settings, but that does not seem to do anything for this type of
failure.)




Kathy McLeod
Dept S82  CCB - SNMP
IBM Rochester, MN
(507) 253-4803

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo

_______________________________________________
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
lldpPortConfigTable.C (application/octet-stream, 19.9 KB)
/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.table_data.conf 16004 2007-03-27 09:20:28Z dts12 $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/library/tools.h>
#include <net-snmp/agent/cache_handler.h>
#include <net-snmp/agent/table_tdata.h>
#include <lldpPortConfigTable.H>
//#include <utils.H>
//#include <ethm/base/EthMgr.H>

static oid      lldpPortConfigTable_oid[] =
        { 1, 0, 8802, 1, 1, 2, 1, 1, 6 };
size_t          lldpPortConfigTable_oid_len =
        OID_LENGTH(lldpPortConfigTable_oid);

netsnmp_tdata_row * lldpPortConfigTable_createEntry(netsnmp_tdata * table_data,
                                long lldpPortConfigPortNum);

static char bits[] = {0x80, 0x40, 0x20, 0x10};
static char nullset = 0x00;

static port_tab_entry_t *tempNode;

int checkNumericRange(int min, int max, int newValue)
{
   if (newValue >= min &&
       newValue <= max)
       return(SNMP_ERR_NOERROR);
   else
      return(SNMP_ERR_WRONGVALUE);
}

int checkBoolean(int newValue)
{
   if (newValue == TRUE ||
       newValue == FALSE)
       return(SNMP_ERR_NOERROR);
   else
      return(SNMP_ERR_WRONGVALUE);
}

int checkTlvsBITS(int newVal)
{
    if (newVal == nullset ||
        newVal == bits[0] ||
        newVal == bits[1] ||
        newVal == bits[2] ||
        newVal == bits[3])
        return(SNMP_ERR_NOERROR);
    else
      return(SNMP_ERR_WRONGVALUE);	
} 

   /*
     * Typical data structure for a row entry 
     */
struct lldpPortConfigTable_entry {
    /*
    * Index values 
     */
    long            lldpPortConfigPortNum;

    /*
     * Column values 
     */
    long            lldpPortConfigAdminStatus;
    long            old_lldpPortConfigAdminStatus;
    long            lldpPortConfigNotificationEnable;
    long            old_lldpPortConfigNotificationEnable;
    char            lldpPortConfigTLVsTxEnable[1];
    size_t          lldpPortConfigTLVsTxEnable_len;
    char            old_lldpPortConfigTLVsTxEnable[1];
    size_t          old_lldpPortConfigTLVsTxEnable_len;

    int             valid;
};

/** Initializes the lldpPortConfigTable module */
void
init_lldpPortConfigTable(void)
{
    /*
     * here we initialize all the tables we're planning on supporting 
     */
    initialize_table_lldpPortConfigTable();
}

/*# Determine the first/last column names */

/** Initialize the lldpPortConfigTable table by defining its contents and how it's structured */
void
initialize_table_lldpPortConfigTable(void)
{
    static oid      lldpPortConfigTable_oid[] =
        { 1, 0, 8802, 1, 1, 2, 1, 1, 6 };
    size_t          lldpPortConfigTable_oid_len =
        OID_LENGTH(lldpPortConfigTable_oid);
    netsnmp_handler_registration *reg;
    netsnmp_tdata  *table_data;
    netsnmp_table_registration_info *table_info;
    netsnmp_cache  *cache;
//    netsnmp_tdata_row *row; 
//    short int i = 0;
//    struct lldpPortConfigTable_entry * ent;
     
    //entry = SNMP_MALLOC_TYPEDEF(struct lldpPortConfigTable_entry);
    
    //if(!entry)
      //return 0;

 //   row = netsnmp_tdata_create_row();
    //if(!row) {
      //  SNMP_FREE(entry);
       // return 0;
//    }
//    row->data = entry;  
    DEBUGMSGTL(("lldpPortConfigTable", "initing table1\n"));
    if (alreadyReg > 0)
      return;

    DEBUGMSGTL(("lldpPortConfigTable", "initing table\n"));	


    reg =
        netsnmp_create_handler_registration("lldpPortConfigTable",
                                            lldpPortConfigTable_handler,
                                            lldpPortConfigTable_oid,
                                            lldpPortConfigTable_oid_len,
                                            HANDLER_CAN_RWRITE);

    table_data = netsnmp_tdata_create_table("lldpPortConfigTable", 0);
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,   /* index: lldpPortConfigPortNum */
                                     0);

    table_info->min_column = COLUMN_LLDPPORTCONFIGADMINSTATUS;
    table_info->max_column = COLUMN_LLDPPORTCONFIGTLVSTXENABLE;

    netsnmp_tdata_register(reg, table_data, table_info);
    cache = netsnmp_cache_create(LLDPPORTCONFIGTABLE_TIMEOUT,
                                 lldpPortConfigTable_load,
                                 lldpPortConfigTable_free,
                                 lldpPortConfigTable_oid,
                                 lldpPortConfigTable_oid_len);
    cache->magic = (void *) table_data;
    netsnmp_inject_handler_before(reg, netsnmp_cache_handler_get(cache), TABLE_TDATA_NAME);

        /*
         * Initialise the contents of the table here 
         */
DEBUGMSGTL(("lldpPortConfigTable", "check and reload\n"));

    netsnmp_cache_check_and_reload( cache ); 

 /*   tempNode = SNMP_MALLOC_TYPEDEF(port_tab_entry_t);
    for(i=0; i<4; i++)
    {
DEBUGMSGTL(("lldpPortConfigTable", "for loop%d\n", i));
       
       tempNode->port_tab_portnum = i+1;  
       tempNode->port_tab_status  = (i+1) % 5;*/ /* 1 thru 4 */
 //      tempNode->port_tab_notify = i % 2;     /* true or false */
 //      tempNode->port_tab_tlvs     = bits[i];   /* 0 - 3 */
 //      row = lldpPortConfigTable_createEntry(table_data, tempNode->port_tab_portnum);

 /*      ent = (struct lldpPortConfigTable_entry*) (row->data);
       ent->lldpPortConfigAdminStatus = tempNode->port_tab_status;
       ent->old_lldpPortConfigAdminStatus = 0;
       ent->lldpPortConfigNotificationEnable = tempNode->port_tab_notify;
       ent->old_lldpPortConfigAdminStatus = 0;
       ent->lldpPortConfigTLVsTxEnable[0] = tempNode->port_tab_tlvs;
       ent->lldpPortConfigTLVsTxEnable_len = 1;
       ent->old_lldpPortConfigTLVsTxEnable[0] = 0;
       ent->old_lldpPortConfigTLVsTxEnable_len = 1;
    }
    SNMP_FREE(tempNode);
    tempNode = NULL; */
    alreadyReg = 1;
    alreadyDereg = 0;
}

void  deinit_lldpPortConfigTable(void) {
     DEBUGMSGTL(("lldpPortConfigTable", "deiniting1 mibs\n"));
     if (alreadyDereg > 0)
	return;	
     DEBUGMSGTL(("lldpPortConfigTable", "deiniting mibs\n")); 	
     /* int unregister_mib(oid *, size_t); */
     unregister_mib(lldpPortConfigTable_oid, lldpPortConfigTable_oid_len); 
     alreadyDereg = 1;	
     alreadyReg = 0;
}

 

/*
 * create a new row in the table 
 */
netsnmp_tdata_row *lldpPortConfigTable_createEntry(netsnmp_tdata *
                                                   table_data,
                                                   long
                                                   lldpPortConfigPortNum) {
    struct lldpPortConfigTable_entry *entry;
    netsnmp_tdata_row *row;        
         
    entry = SNMP_MALLOC_TYPEDEF(lldpPortConfigTable_entry);
    if(!entry)
      return NULL;

    row = netsnmp_tdata_create_row();
    if(!row) {
        SNMP_FREE(entry);
        return NULL;
    }
    row->data = entry;
    entry->lldpPortConfigPortNum = lldpPortConfigPortNum;
// test ascending but not consecutive indexes 
//    entry->lldpPortConfigPortNum = 2*lldpPortConfigPortNum; 
// test unordered index
//    entry->lldpPortConfigPortNum = 60 - (8*lldpPortConfigPortNum);
    netsnmp_tdata_row_add_index(row, ASN_INTEGER,
                                &(entry->lldpPortConfigPortNum),
                                sizeof(entry->lldpPortConfigPortNum));
    /*****************************/
/*    entry->lldpPortConfigAdminStatus = tempNode->port_tab_status;
    entry->old_lldpPortConfigAdminStatus = 0;
    entry->lldpPortConfigNotificationEnable = tempNode->port_tab_notify;
    entry->old_lldpPortConfigAdminStatus = 0;
    entry->lldpPortConfigTLVsTxEnable[0] = tempNode->port_tab_tlvs;
    entry->lldpPortConfigTLVsTxEnable_len = 1;
    entry->old_lldpPortConfigTLVsTxEnable[0] = 0;
    entry->old_lldpPortConfigTLVsTxEnable_len = 1; */
/*****************************/
    netsnmp_tdata_add_row(table_data, row);
    return row;
}

/*
 * remove a row from the table 
 */
void    
    lldpPortConfigTable_removeEntry(netsnmp_tdata * table_data,
                                    netsnmp_tdata_row * row) {
    struct lldpPortConfigTable_entry *entry;

    if (!row)
        return;                 /* Nothing to remove */
    entry = (struct lldpPortConfigTable_entry *)
        netsnmp_tdata_remove_and_delete_row(table_data, row);
    if (entry)
        SNMP_FREE(entry);       /* XXX - release any other internal resources */
}

/*
 * Example cache handling - set up table_data list from a suitable file 
 */
static short int j = 0;
int
    lldpPortConfigTable_load(netsnmp_cache * cache, void *vmagic) {
    netsnmp_tdata * table = (netsnmp_tdata *) vmagic;
    netsnmp_tdata_row *row;

    short int i; 
    
    struct lldpPortConfigTable_entry * ent;
  
     
/*    entry = SNMP_MALLOC_TYPEDEF(struct lldpPortConfigTable_entry);
    
    if(!entry)
      return 0;

    row = netsnmp_tdata_create_row();
    if(!row) {
        SNMP_FREE(entry);
        return 0;
    }
    row->data = entry; */
 
DEBUGMSGTL(("lldpPortConfigTable", "cache load\n"));  
         
     /*
         * Initialise the contents of the table here 
         */
    DEBUGMSGTL(("lldpPortConfigTable", "cache for loop\n"));

    tempNode = SNMP_MALLOC_TYPEDEF(port_tab_entry_t);
    for(i=j; i<j+4; i++)
    {
DEBUGMSGTL(("lldpPortConfigTable", "cache for loop%d\n", i));
       
       tempNode->port_tab_portnum = i+1;  
       tempNode->port_tab_status  = (i+1) % 4 + 1; /* 1 thru 4 */
       tempNode->port_tab_notify = i % 2;     /* true or false */
       tempNode->port_tab_tlvs     = bits[i % 4];   /* 0 - 3 */
       row = lldpPortConfigTable_createEntry(table, tempNode->port_tab_portnum);
       ent = (struct lldpPortConfigTable_entry *)(row->data);
       ent->lldpPortConfigAdminStatus = tempNode->port_tab_status;
       ent->old_lldpPortConfigAdminStatus = 0;
       ent->lldpPortConfigNotificationEnable = tempNode->port_tab_notify;
       ent->old_lldpPortConfigAdminStatus = 0;
       ent->lldpPortConfigTLVsTxEnable[0] = tempNode->port_tab_tlvs;
       ent->lldpPortConfigTLVsTxEnable_len = 1;
       ent->old_lldpPortConfigTLVsTxEnable[0] = 0;
       ent->old_lldpPortConfigTLVsTxEnable_len = 1;
DEBUGMSGTL(("lldpPortConfigTable", "cache for loop bottom%d\n", i));
   }
   j = i;
   SNMP_FREE(tempNode); 
   tempNode = NULL;
DEBUGMSGTL(("lldpPortConfigTable", "cache after loop%d\n", j));
   return(SNMP_ERR_NOERROR);
    
}

void 
    lldpPortConfigTable_free(netsnmp_cache * cache, void *vmagic) {
//    netsnmp_tdata * table = (netsnmp_tdata *) vmagic;
    netsnmp_tdata_row *thisRow;
    netsnmp_tdata * table;
    table = (netsnmp_tdata *) vmagic;
DEBUGMSGTL(("lldpPortConfigTable", "cache free\n"));

/* change from netsnmp_tdata_get_first_row */
    while ((thisRow = netsnmp_tdata_row_first(table))) {
DEBUGMSGTL(("lldpPortConfigTable", "cache free while\n"));        
        netsnmp_tdata_remove_and_delete_row(table, thisRow);
DEBUGMSGTL(("lldpPortConfigTable", "cache free while2\n"));  
    }
}

/** handles requests for the lldpPortConfigTable table */
 int lldpPortConfigTable_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;
    netsnmp_tdata * table_data;
    netsnmp_tdata_row *table_row;
    struct lldpPortConfigTable_entry *table_entry;
    int  ret;

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

            switch (table_info->colnum) {
            case COLUMN_LLDPPORTCONFIGADMINSTATUS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->
                                           lldpPortConfigAdminStatus);
                break;
            case COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->
                                           lldpPortConfigNotificationEnable);
                break;
            case COLUMN_LLDPPORTCONFIGTLVSTXENABLE:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         (u_char *) table_entry->
                                         lldpPortConfigTLVsTxEnable,
                                         table_entry->
                                         lldpPortConfigTLVsTxEnable_len);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

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

            switch (table_info->colnum) {
            case COLUMN_LLDPPORTCONFIGADMINSTATUS:
                /*
                 * 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;
                }

                ret = checkNumericRange(1, 4, *request->requestvb->val.integer);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE:
                /*
                 * 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;
                }

                ret = checkBoolean(*request->requestvb->val.integer);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                } 
                break;
            case COLUMN_LLDPPORTCONFIGTLVSTXENABLE:
                /*
                 * or possiblc 'netsnmp_check_vb_type_and_size' 
                 */
                ret =
                    netsnmp_check_vb_type_and_max_size(request->requestvb,
                                                       ASN_OCTET_STR,
                                                       sizeof(table_entry->
                                                              lldpPortConfigTLVsTxEnable));
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }

                ret = checkTlvsBITS(*request->requestvb->val.string);
                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 lldpPortConfigTable_entry *)
                netsnmp_tdata_extract_entry(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_LLDPPORTCONFIGADMINSTATUS:
                table_entry->old_lldpPortConfigAdminStatus =
                    table_entry->lldpPortConfigAdminStatus;
                table_entry->lldpPortConfigAdminStatus =
                    *request->requestvb->val.integer;
                break;
            case COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE:
                table_entry->old_lldpPortConfigNotificationEnable =
                    table_entry->lldpPortConfigNotificationEnable;
                table_entry->lldpPortConfigNotificationEnable =
                    *request->requestvb->val.integer;
                break;
            case COLUMN_LLDPPORTCONFIGTLVSTXENABLE:
                memcpy(table_entry->old_lldpPortConfigTLVsTxEnable,
                       table_entry->lldpPortConfigTLVsTxEnable,
                       sizeof(table_entry->lldpPortConfigTLVsTxEnable));
                table_entry->old_lldpPortConfigTLVsTxEnable_len =
                    table_entry->lldpPortConfigTLVsTxEnable_len;
                memset(table_entry->lldpPortConfigTLVsTxEnable, 0,
                       sizeof(table_entry->lldpPortConfigTLVsTxEnable));
                memcpy(table_entry->lldpPortConfigTLVsTxEnable,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                table_entry->lldpPortConfigTLVsTxEnable_len =
                    request->requestvb->val_len;
                break;
            }
        }
        break;

    case MODE_SET_UNDO:
        for (request = requests; request; request = request->next) {
            table_entry = (struct lldpPortConfigTable_entry *)
                netsnmp_tdata_extract_entry(request);
            table_row = netsnmp_tdata_extract_row(request);
            table_data = netsnmp_tdata_extract_table(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_LLDPPORTCONFIGADMINSTATUS:
                table_entry->lldpPortConfigAdminStatus =
                    table_entry->old_lldpPortConfigAdminStatus;
                table_entry->old_lldpPortConfigAdminStatus = 0;
                break;
            case COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE:
                table_entry->lldpPortConfigNotificationEnable =
                    table_entry->old_lldpPortConfigNotificationEnable;
                table_entry->old_lldpPortConfigNotificationEnable = 0;
                break;
            case COLUMN_LLDPPORTCONFIGTLVSTXENABLE:
                memcpy(table_entry->lldpPortConfigTLVsTxEnable,
                       table_entry->old_lldpPortConfigTLVsTxEnable,
                       sizeof(table_entry->lldpPortConfigTLVsTxEnable));
                memset(table_entry->old_lldpPortConfigTLVsTxEnable, 0,
                       sizeof(table_entry->lldpPortConfigTLVsTxEnable));
                table_entry->lldpPortConfigTLVsTxEnable_len =
                    table_entry->old_lldpPortConfigTLVsTxEnable_len;
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
        break;
    }
    return SNMP_ERR_NOERROR;
}
lldpPortConfigTable.H (application/octet-stream, 1.1 KB)
/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.table_data.conf 16004 2007-03-27 09:20:28Z dts12 $
 */
#ifndef LLDPPORTCONFIGTABLE_H
#define LLDPPORTCONFIGTABLE_H

#ifdef __cplusplus
extern "C" {
#endif

/*
 * function declarations 
 */
void            init_lldpPortConfigTable(void);
void            initialize_table_lldpPortConfigTable(void);
void            deinit_lldpPortConfigTable(void);

Netsnmp_Node_Handler lldpPortConfigTable_handler;
NetsnmpCacheLoad lldpPortConfigTable_load;
NetsnmpCacheFree lldpPortConfigTable_free;
#define LLDPPORTCONFIGTABLE_TIMEOUT  45 // 30, 60, -1

/*
 * column number definitions for table lldpPortConfigTable 
 */
#define COLUMN_LLDPPORTCONFIGPORTNUM		1
#define COLUMN_LLDPPORTCONFIGADMINSTATUS		2
#define COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE		3
#define COLUMN_LLDPPORTCONFIGTLVSTXENABLE		4

typedef struct port_tab_entry_s {
   long  port_tab_portnum;
   long  port_tab_status;
   long  port_tab_notify;
   char  port_tab_tlvs;
} port_tab_entry_t;

static int alreadyReg = 0;
static int alreadyDereg = 0;
#endif                          /* LLDPPORTCONFIGTABLE_H */

#ifdef __cplusplus
}
#endif
lldp.mib (application/octet-stream, 77.5 KB) - not displayed
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.