--===============1432260483==
Content-Type: multipart/alternative;
boundary="----=_Part_4309_9819939.1205523147875"

------=_Part_4309_9819939.1205523147875
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,

I have requirement in which i have to fill the table data when ever a
request will come, For example check the below example.... it was generated
by using mib2c.table_data.conf.
: in which "ocStbHostAVInterfaceTable_handler" is taking care of
the requests, So my requirement is
when the a request come at " i.e "(check in code ) case MODE_GET:" then
i want to update the table instated of initialize the table first (filling
the table) at (check in code "
initialize_table_ocStbHostAVInterfaceTable(void) " )

Please give the Solution as early as possible..... (adv Thank's)


/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.table_data.conf 15999 2007-03-25 22:32:02Z dts12 $
*/

/** handles requests for the ocStbHostAVInterfaceTable table */ int

#include
#include
#include
#define CHRMAX1 256
#define MAX_IOD_LENGTH1 128
/** Initializes the ocStbHostAVInterfaceTable module */
void
init_ocStbHostAVInterfaceTable(void)
{
/*
* here we initialize all the tables we're planning on supporting
*/
initialize_table_ocStbHostAVInterfaceTable();
}

//# Determine the first/last column names

/** Initialize the ocStbHostAVInterfaceTable table by defining its contents
and how it's structured */
netsnmp_tdata *table_data;
void
initialize_table_ocStbHostAVInterfaceTable(void)
{
static oid ocStbHostAVInterfaceTable_oid[] =
{ 1, 3, 6, 1, 4, 1, 4491, 2, 3, 1, 1, 1, 2, 2 };
size_t ocStbHostAVInterfaceTable_oid_len =
OID_LENGTH(ocStbHostAVInterfaceTable_oid);
netsnmp_handler_registration *reg;
/*static*/ // netsnmp_tdata *table_data;
netsnmp_table_registration_info *table_info;

reg =
netsnmp_create_handler_registration("ocStbHostAVInterfaceTable",

ocStbHostAVInterfaceTable_handler,
ocStbHostAVInterfaceTable_oid,

ocStbHostAVInterfaceTable_oid_len,
HANDLER_CAN_RONLY);

table_data =
netsnmp_tdata_create_table("ocStbHostAVInterfaceTable", 0);
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_inf o);
netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index:
ocStbHostAVInterfaceIndex */
0);

table_info->min_column = COLUMN_OCSTBHOSTAVINTERFACETYPE;
table_info->max_column = COLUMN_OCSTBHOSTAVINTERFACESTATUS;

netsnmp_tdata_register(reg, table_data, table_info);

/*
* Initialise the contents of the table here
*/
}

/*
* Typical data structure for a row entry
*/
struct ocStbHostAVInterfaceTable_entry {
/*
* Index values
*/
u_long ocStbHostAVInterfaceIndex;

/*
* Column values
*/
oid ocStbHostAVInterfaceType[MAX_IOD_LENGTH1];
size_t ocStbHostAVInterfaceType_len;
char ocStbHostAVInterfaceDesc[CHRMAX1];
size_t ocStbHostAVInterfaceDesc_len;
long ocStbHostAVInterfaceStatus;

int valid;
};

/*
* create a new row in the table
*/
netsnmp_tdata_row *
ocStbHostAVInterfaceTable_createEntry(netsnmp_tdat a * table_data,
u_long ocStbHostAVInterfaceIndex)
{
struct ocStbHostAVInterfaceTable_entry *entry;
netsnmp_tdata_row *row;

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

row = netsnmp_tdata_create_row();
if (!row) {
SNMP_FREE(entry);
return NULL;
}
row->data = entry;
entry->ocStbHostAVInterfaceIndex = ocStbHostAVInterfaceIndex;
netsnmp_tdata_row_add_index(row, ASN_UNSIGNED,
&(entry->ocStbHostAVInterfaceIndex),
sizeof(entry->ocStbHostAVInterfaceIndex));
netsnmp_tdata_add_row(table_data, row);
return row;
}

/*
* remove a row from the table
*/
void
ocStbHostAVInterfaceTable_removeEntry(netsnmp_tdat a * table_data,
netsnmp_tdata_row * row)
{
struct ocStbHostAVInterfaceTable_entry *entry;

if (!row)
return; /* Nothing to remove */
entry = (struct ocStbHostAVInterfaceTable_entry *)
netsnmp_tdata_remove_and_delete_row(table_data, row);
if (entry)
SNMP_FREE(entry); /* XXX - release any other internal
resources */
}
int
ocStbHostAVInterfaceTable_handler(netsnmp_mib_hand ler *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 ocStbHostAVInterfaceTable_entry *table_entry;
int ret;

switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:

table_entry = (struct ocStbHostAVInterfaceTable_entry *)
netsnmp_tdata_extract_entry(request);
table_info = netsnmp_extract_table_info(request);

switch (table_info->colnum) {
case COLUMN_OCSTBHOSTAVINTERFACETYPE:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
(u_char *) table_entry->
ocStbHostAVInterfaceType,
table_entry->
ocStbHostAVInterfaceType_len);
break;
case COLUMN_OCSTBHOSTAVINTERFACEDESC:
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->
ocStbHostAVInterfaceDesc,
table_entry->
ocStbHostAVInterfaceDesc_len);
break;
case COLUMN_OCSTBHOSTAVINTERFACESTATUS:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
table_entry->
ocStbHostAVInterfaceStatus);
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHOBJECT);
break;
}
}
break;

}
return SNMP_ERR_NOERROR;
}




On Wed, Mar 12, 2008 at 6:39 AM, Dave Shield
wrote:

> On 11/03/2008, kumar undurthi wrote:
> > I have a problem in creating a table and Fill the table. i.e
> > Normally table can create in initialization() part and can be fill with

> the
> > static data.
> > But in My case.... I want to Create and Fill the table with the dynamic
> > data(values) when ever a request comes to the Agent.

>
> Probably the best approach would be to use the cache helper.
>
> You haven't said how you are generating the code,
> or which table helper you are using. But if you run
> something like
> mib2c -c mib2c.table_data.conf -S cache=1 myTable
>
> this should generate a suitable framework for your MIB module,
> including the code to load the table data when a request
> comes in. This cached data will then be used for the next
> few requests, until it's judged "too old". Whereupon the
> next request will trigger a fresh reload.
>
> The same approach can be used with the iterator helper
> (same command, but specifying 'mib2c.iterator.conf'),
> and probably also with the MfD framework.
> (though I don't know much about that one).
>
> Dave
>


------=_Part_4309_9819939.1205523147875
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi All,

      I have requirement in which i=
have to fill the table data when ever a request will come, For example che=
ck the below  example.... it was generated by using mib2c.table_data.c=
onf.
          : in which &=
quot;ocStbHostAVInterfaceTable_handler"  is taking care of the re=
quests, So my requirement is

when the a request come  at " i.e   "(check in cod=
e )  case MODE_GET:"  then i want to update the table instat=
ed of initialize the  table first (filling the table)  at (check =
in code " initialize_table_ocStbHostAVInterfaceTable(void) " )
>

Please give the Solution as early as possible..... (adv Thank's)
>

/*
 * Note: this file originally auto-generated by mib2c u=
sing
 *  : mib2c.table_data.conf 15999 2007-03-25 22:32:02Z dt=
s12 $
 */


/** handles requests for the ocStbHostAVInterfaceTable table */ int
=
 
    #include <net-snmp/net-snmp-config.h>
>#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/age=
nt/net-snmp-agent-includes.h>

#define CHRMAX1 256
#define MAX_IOD_LENGTH1 128
/** Initializes the o=
cStbHostAVInterfaceTable module */
void
init_ocStbHostAVInterfaceTabl=
e(void)
{
    /*
     * here we=
initialize all the tables we're planning on supporting

     */
    initialize_table_ocStbHos=
tAVInterfaceTable();
}

//# Determine the first/last column names<=
br>
/** Initialize the ocStbHostAVInterfaceTable table by defining its c=
ontents and how it's structured */

netsnmp_tdata  *table_data;
void
initialize_table_ocStbHostAVInt=
erfaceTable(void)
{
    static oid   &n=
bsp;  ocStbHostAVInterfaceTable_oid[] =3D
    &=
nbsp;   { 1, 3, 6, 1, 4, 1, 4491, 2, 3, 1, 1, 1, 2, 2 };
&nbsp=
;   size_t          =
ocStbHostAVInterfaceTable_oid_len =3D

        OID_LENGTH(ocStbHostAVInterfaceT=
able_oid);
    netsnmp_handler_registration *reg;
&nbs=
p;   /*static*/ // netsnmp_tdata  *table_data;
 &nbs=
p;  netsnmp_table_registration_info *table_info;

  &n=
bsp; reg =3D
        netsnmp_create_h=
andler_registration("ocStbHostAVInterfaceTable",

            &nb=
sp;            =
            &nb=
sp;      ocStbHostAVInterfaceTable_handler,
&nb=
sp;            =
            &nb=
sp;            =
      ocStbHostAVInterfaceTable_oid,
 &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;    ocStbHostAVInterfaceTable_oid_len,

            &nb=
sp;            =
            &nb=
sp;      HANDLER_CAN_RONLY);

  &n=
bsp; table_data =3D
        netsnmp_t=
data_create_table("ocStbHostAVInterfaceTable", 0);
 &nbsp=
;  table_info =3D SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_inf o)=
;

    netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNE=
D,  /* index: ocStbHostAVInterfaceIndex */
    =
            &nb=
sp;            =
        0);

    ta=
ble_info->min_column =3D COLUMN_OCSTBHOSTAVINTERFACETYPE;

    table_info->max_column =3D COLUMN_OCSTBHOSTAVINTERFAC=
ESTATUS;

    netsnmp_tdata_register(reg, table_data, =
table_info);

    /*
     * Ini=
tialise the contents of the table here
     */
}=



    /*
     * Typical data structure =
for a row entry
     */
struct ocStbHostAVInterf=
aceTable_entry {
    /*
     * Ind=
ex values
     */
    u_long&nbsp=
;         ocStbHostAVInterfaceIndex=
;

    /*

     * Column values
     */
>    oid        &nbs=
p;    ocStbHostAVInterfaceType[MAX_IOD_LENGTH1];
 &n=
bsp;  size_t          ocS=
tbHostAVInterfaceType_len;
    char   &nbs=
p;        ocStbHostAVInterfaceDesc[CHRMA=
X1];
    size_t       =
   ocStbHostAVInterfaceDesc_len;

    long        &nbs=
p;   ocStbHostAVInterfaceStatus;

    int&nb=
sp;            valid=
;
};

/*
 * create a new row in the table
 */
=
netsnmp_tdata_row *
ocStbHostAVInterfaceTable_createEntry(netsnmp_tdat a =
* table_data,

            &nb=
sp;            =
             u_=
long ocStbHostAVInterfaceIndex)
{
    struct ocStbHost=
AVInterfaceTable_entry *entry;
    netsnmp_tdata_row *row=
;

    entry =3D SNMP_MALLOC_TYPEDEF(struct ocStbHostA=
VInterfaceTable_entry);

    if (!entry)
      &nbsp=
; return NULL;

    row =3D netsnmp_tdata_create_row()=
;
    if (!row) {
      =
  SNMP_FREE(entry);
        retu=
rn NULL;
    }
    row->data =3D ent=
ry;
    entry->ocStbHostAVInterfaceIndex =3D ocStbHost=
AVInterfaceIndex;

    netsnmp_tdata_row_add_index(row, ASN_UNSIGNED,
 =
            &nb=
sp;            =
      &(entry->ocStbHostAVInterfaceIndex),<=
br>            =
            &nb=
sp;       sizeof(entry->ocStbHostAVInterfa=
ceIndex));
    netsnmp_tdata_add_row(table_data, row);
>
    return row;
}

/*
 * remove a row from =
the table
 */
void
ocStbHostAVInterfaceTable_removeEntry(net=
snmp_tdata * table_data,
       &nbsp=
;            &n=
bsp;           &nbsp=
;     netsnmp_tdata_row * row)
{

    struct ocStbHostAVInterfaceTable_entry *entry;

&n=
bsp;   if (!row)
        re=
turn;           &nbs=
p;     /* Nothing to remove */
    en=
try =3D (struct ocStbHostAVInterfaceTable_entry *)
   &nb=
sp;    netsnmp_tdata_remove_and_delete_row(table_data, row);=


    if (entry)
       =
SNMP_FREE(entry);       /* XXX - release any=
other internal resources */
}
int
ocStbHostAVInterfaceTable_handl=
er(netsnmp_mib_handler *handler,
      &nb=
sp;            =
            &nb=
sp;  netsnmp_handler_registration *reginfo,

            &nb=
sp;            =
         netsnmp_agent_request_info=
*reqinfo,
          &=
nbsp;           &nbs=
p;           netsnmp_requ=
est_info *requests)
{

    netsnmp_request_info *re=
quest;
    netsnmp_table_request_info *table_info;

    netsnmp_tdata  *table_data;
    n=
etsnmp_tdata_row *table_row;
    struct ocStbHostAVInterf=
aceTable_entry *table_entry;
    int   &nb=
sp;         ret;

 &nbsp=
;  switch (reqinfo->mode) {
      =
  /*
         * Read-suppor=
t (also covers GetNext requests)

         */
    &=
nbsp;   case MODE_GET:
      &nb=
sp;  
         =
   table_entry =3D (struct ocStbHostAVInterfaceTable_entry *)
=
            &nb=
sp;   netsnmp_tdata_extract_entry(request);
   =
         table_info =3D netsnmp_ext=
ract_table_info(request);


            swit=
ch (table_info->colnum) {
       &=
nbsp;    case COLUMN_OCSTBHOSTAVINTERFACETYPE:
 &nbs=
p;            &=
nbsp; if (!table_entry) {
       &nbs=
p;            netsnm=
p_set_request_error(reqinfo, request,
     &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;  SNMP_NOSUCHINSTANCE);

            &nb=
sp;       continue;
   &nbs=
p;            }
&=
nbsp;           &nbs=
p;   snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_I=
D,
           &nb=
sp;            =
            &nb=
sp;    (u_char *) table_entry->
   &nbs=
p;            &=
nbsp;           &nbs=
p;            ocStbH=
ostAVInterfaceType,

            &nb=
sp;            =
            &nb=
sp;   table_entry->
      &nb=
sp;            =
            &nb=
sp;         ocStbHostAVInterfaceTyp=
e_len);
          &nbs=
p;     break;
      &n=
bsp;     case COLUMN_OCSTBHOSTAVINTERFACEDESC:
&nbsp=
;            &n=
bsp;  if (!table_entry) {

            &nb=
sp;       netsnmp_set_request_error(reqinfo, =
request,
          &nb=
sp;            =
            &nb=
sp;          SNMP_NOSUCHINSTAN=
CE);
           &=
nbsp;        continue;
  &n=
bsp;           &nbsp=
; }
           &n=
bsp;    snmp_set_var_typed_value(request->requestvb, ASN_=
OCTET_STR,

            &nb=
sp;            =
            &nb=
sp;   (u_char *) table_entry->
    &nbs=
p;            &=
nbsp;           &nbs=
p;           ocStbHostAVI=
nterfaceDesc,
         &nbs=
p;            &=
nbsp;           &nbs=
p;      table_entry->
   &nbs=
p;            &=
nbsp;           &nbs=
p;            ocStbH=
ostAVInterfaceDesc_len);

            &nb=
sp;   break;
        &=
nbsp;   case COLUMN_OCSTBHOSTAVINTERFACESTATUS:
  &n=
bsp;           &nbsp=
; if (!table_entry) {
        &n=
bsp;           netsnmp_se=
t_request_error(reqinfo, request,
      &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;  SNMP_NOSUCHINSTANCE);

            &nb=
sp;       continue;
   &nbs=
p;            }
&=
nbsp;           &nbs=
p;   snmp_set_var_typed_integer(request->requestvb, ASN_INTEGE=
R,
           &nb=
sp;            =
            &nb=
sp;      table_entry->
   &nb=
sp;            =
            &nb=
sp;            =
  ocStbHostAVInterfaceStatus);

            &nb=
sp;   break;
        &=
nbsp;   default:
       &nb=
sp;        netsnmp_set_request_error(req=
info, request,
         &nb=
sp;            =
            &nb=
sp;       SNMP_NOSUCHOBJECT);
  =
            &nb=
sp; break;
          &=
nbsp; }

        }
    &nb=
sp;   break;

    }
    re=
turn SNMP_ERR_NOERROR;
}

      &nbs=
p; 
     

te">On Wed, Mar 12, 2008 at 6:39 AM, Dave Shield <.T.=
Shield@liverpool.ac.uk">D.T.Shield@liverpool.ac.uk
> wrote:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
E3d">On 11/03/2008, kumar undurthi < ">manu1394@gmail.com> wrote:


>        I have a problem in creating a table and Fi=
ll the table. i.e

> Normally table can create in initialization() part and can be fill wit=
h the

> static data.

> But in My case.... I want to Create and Fill the table with the dynami=
c

> data(values) when ever a request comes to the Agent.



Probably the best approach would be to use the cache helper.



You haven't said how you are generating the code,

or which table helper you are using.   But if you run

something like

   mib2c -c mib2c.table_data.conf  -S cache=3D1   myTa=
ble



this should generate a suitable framework for your MIB module,

including the code to load the table data when a request

comes in.   This cached data will then be used for the next

few requests, until it's judged "too old".  Whereupon th=
e

next request will trigger a fresh reload.



 The same approach can be used with the iterator helper

(same command, but specifying 'mib2c.iterator.conf'),

and probably also with the MfD framework.

 (though I don't know much about that one).



Dave




------=_Part_4309_9819939.1205523147875--


--===============1432260483==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
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/
--===============1432260483==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users

--===============1432260483==--