I'm sorry I wasn't very clear in my last question. I understand how a TestAndIncr works.
I need a separate spinlock object for each row. I managed to implement this behavior, with a modified version of the netsnmp_setserialno_handler as seen in 'mibgroup/mibII/setSerialNo.c' . But I'm having a problem when trying to increment the spinlock object. In the first time, everything works OK, but after that the spinlock object isn' t incremented. In the handler function, I do : In the MODE_SET_RESERVE1 I check if the value passed is equal to the one stored in the mib.If not, I return an error (as seen in 'mibgroup/mibII/setSerialNo.c' ) In the MODE_SET_ACTION, I get the lockObject in the mib, increment it and store the value in the mib: case SPINLOCKCOLUMN: rowData = netsnmp_extract_table_row_data(request); data = netsnmp_table_data_set_find_column(rowData, SPINLOCKCOLUMN); setspinLock = *((long *) data->data.voidp); setspinLock++; *((long*)data->data.voidp) = setspinLock; This works fine the firs time. The following tries, the value isn't increased. I put a simple debug and it shows : In the first time : setspinLock : before increment: 0 setspinLock : after increment: 1 *((long*)data->data.voidp) = 1 In the next try: setspinLock : before increment: 1 setspinLock : after increment: 2 *((long*)data->data.voidp) = 2 But, if I do a snmpset to the lock object, the value returned is 1. Thanks once more. ----- Original Message ----- From: "Dave Shield" <[EMAIL PROTECTED]> To: "vsaavedra" <[EMAIL PROTECTED]> Cc: <[email protected]> Sent: Friday, January 18, 2008 5:02 PM Subject: Re: TestAndIncr problem > On 18/01/2008, vsaavedra <[EMAIL PROTECTED]> wrote: > > I'm trying to implement a TestAndIncr object as a column in table. > > So you need a separate spinlock object for each row of the table? > That feels a bit overkill - it's more common to have a single scalar > TestAndIncr object that controls the whole table. > > There is a helper routine netsnmp_register_watched_spinlock() > which implements this behaviour (for a scalar MIB object). > All you have to do is provide the integer variable to hold the spinlock > value, and the helper does the rest. > > See 'mibgroup/mibII/setSerialNo.c' for an example of this. > > You might be able to use the helper's handler routine to implement > a column-based version of this, if you really must work at the level > of per-row granularity. > > > > > > This table as an OCTET STRING column, and I want to be able to increment the > > TestAndIncr object, if the column name is updated. > > That's not how TestAndIncr works. > The value is incremented when the spinlock value itself is SET (successfully). > Not some other MIB object. > > Please re-read the description of this syntax type for the defined behaviour. > > > Dave > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > 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 > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ 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
