Q:Table prepare set

Frank Fock Frank.Fock____t-online.de
Sat Jun 17 17:04:18 CEST 2000


manjunath ramaiah wrote:

> Hi ,
>
> I want to add a row if it is not present already . I have  overridden
> the mibtable prepare_set function as follows

Why do you override it? MibTable will handle it: if you make
a SET request on a non existing instance, it will create the row.
BTW, within the iprouteEntry you should use "this" instead of
"iprouteEntr::instance". Also you do not need to use
chTempIndex. Instead you may use
Oidx ind(this->index(req->get_oid()));

Best regards,
Frank

>
> int iprouteEntry::prepare_set_request(Request* req, int& ind)
> {
>     //This class  is derived from mibtable
>         char chTempIndex[50] ;
>     int nRetValue ;
>
>         printf("entry called \n");
>         nRetValue =   MibTable::prepare_set_request(req,ind);
>
>         if  ( nRetValue == SNMP_ERROR_NO_CREATION  )
>         {
>                 // Means this is new row , so add row.
>
>                 strcpy( chTempIndex, ( ( iprouteEntry::instance->index(
> req->get_oid(ind
>                                                 ))).get_printable()));
>
>                 Oidx x( (char * )chTempIndex);
>                MibTable::start_synch();
>                 iprouteEntry::instance->add_row( x );
>                MibTable::end_synch();
>                 printf("row added %s\n",chTempIndex);
>                 return SNMP_ERROR_SUCCESS;
>  }
>         // else the row is already present
>         return nRetValue ;
> }
>




More information about the AGENTPP mailing list