This is a discussion on Re: Regarding Table data Create and Fill within the SNMP Users forums, part of the Networking and Network Related category; --===============1432260483== Content-Type: multipart/alternative; boundary="----=_Part_4309_9819939.1205523147875" ------=_Part_4309_9819939.1205523147875 Content-Type: text/plain; charset=ISO-8859-1 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
--===============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 <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #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("ocStbHostAVIn terfaceTable", ocStbHostAVInterfaceTable_handler, ocStbHostAVInterfaceTable_oid, ocStbHostAVInterfaceTable_oid_len, HANDLER_CAN_RONLY); table_data = netsnmp_tdata_create_table("ocStbHostAVInterfaceTa ble", 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 <D.T.Shield@liverpool.ac.uk> wrote: > On 11/03/2008, kumar undurthi <manu1394@gmail.com> 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,<br><br> 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.<br> : in which &= quot;ocStbHostAVInterfaceTable_handler" is taking care of the re= quests, So my requirement is <br> 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) " )<br= > <br>Please give the Solution as early as possible..... (adv Thank's)<br= ><br><br>/*<br> * Note: this file originally auto-generated by mib2c u= sing<br> * : mib2c.table_data.conf 15999 2007-03-25 22:32:02Z dt= s12 $<br> */<br> <br>/** handles requests for the ocStbHostAVInterfaceTable table */ int<br>= <br> #include <net-snmp/net-snmp-config.h><br= >#include <net-snmp/net-snmp-includes.h><br>#include <net-snmp/age= nt/net-snmp-agent-includes.h><br> #define CHRMAX1 256<br>#define MAX_IOD_LENGTH1 128<br>/** Initializes the o= cStbHostAVInterfaceTable module */<br>void<br>init_ocStbHostAVInterfaceTabl= e(void)<br>{<br> /*<br> * here we= initialize all the tables we're planning on supporting <br> */<br> initialize_table_ocStbHos= tAVInterfaceTable();<br>}<br><br>//# Determine the first/last column names<= br><br>/** Initialize the ocStbHostAVInterfaceTable table by defining its c= ontents and how it's structured */<br> netsnmp_tdata *table_data;<br>void<br>initialize_table_ocStbHost AVInt= erfaceTable(void)<br>{<br> static oid &n= bsp; ocStbHostAVInterfaceTable_oid[] =3D<br> &= nbsp; { 1, 3, 6, 1, 4, 1, 4491, 2, 3, 1, 1, 1, 2, 2 };<br> = ; size_t &n bsp; = ocStbHostAVInterfaceTable_oid_len =3D<br> OID_LENGTH(ocStbHostAVInterfaceT= able_oid);<br> netsnmp_handler_registration *reg;<br>&nbs= p; /*static*/ // netsnmp_tdata *table_data;<br> &nbs= p; netsnmp_table_registration_info *table_info;<br><br> &n= bsp; reg =3D<br> netsnmp_create_h= andler_registration("ocStbHostAVInterfaceTabl e",<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; ocStbHostAVInterfaceTable_handler,<br>&nb= sp;   ; = &n bsp; &nb= sp;   ; = ocStbHostAVInterfaceTable_oid,<br> &nbs= p; &= nbsp; &nb sp; &nbs= p; &= nbsp; ocStbHostAVInterfaceTable_oid_len,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; HANDLER_CAN_RONLY);<br><br> &n= bsp; table_data =3D<br> netsnmp_t= data_create_table("ocStbHostAVInterfaceTable& quot;, 0);<br>  = ; table_info =3D SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_inf o)= ;<br> netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNE= D, /* index: ocStbHostAVInterfaceIndex */<br> = &n bsp; &nb= sp;   ; = 0);<br><br> ta= ble_info->min_column =3D COLUMN_OCSTBHOSTAVINTERFACETYPE;<br> table_info->max_column =3D COLUMN_OCSTBHOSTAVINTERFAC= ESTATUS;<br><br> netsnmp_tdata_register(reg, table_data, = table_info);<br><br> /*<br> * Ini= tialise the contents of the table here <br> */<br>}= <br><br> /*<br> * Typical data structure = for a row entry <br> */<br>struct ocStbHostAVInterf= aceTable_entry {<br> /*<br> * Ind= ex values <br> */<br> u_long = ;   ; ocStbHostAVInterfaceIndex= ;<br><br> /*<br> * Column values <br> */<br= > oid   ;&nbs= p; ocStbHostAVInterfaceType[MAX_IOD_LENGTH1];<br> &n= bsp; size_t &n bsp; ocS= tbHostAVInterfaceType_len;<br> char &nbs= p; ocStbHostAVInterfaceDesc[CHRMA= X1];<br> size_t = ocStbHostAVInterfaceDesc_len;<br> long &nbs p;&nbs= p; ocStbHostAVInterfaceStatus;<br><br> &nb sp; int&nb= sp;   ; valid= ;<br>};<br><br>/*<br> * create a new row in the table <br> */<br>= netsnmp_tdata_row *<br>ocStbHostAVInterfaceTable_createEntry(netsnmp _tdata = * table_data,<br> &n bsp; &nb= sp;   ; = &n bsp; u_= long ocStbHostAVInterfaceIndex)<br>{<br> &nb sp; struct ocStbHost= AVInterfaceTable_entry *entry;<br> netsnmp_tdata_row *row= ;<br><br> entry =3D SNMP_MALLOC_TYPEDEF(struct ocStbHostA= VInterfaceTable_entry);<br> if (!entry)<br> &n bsp= ; return NULL;<br><br> row =3D netsnmp_tdata_create_row()= ;<br> if (!row) {<br> = SNMP_FREE(entry);<br>   ; retu= rn NULL;<br> }<br> row->data =3D ent= ry;<br> entry->ocStbHostAVInterfaceIndex =3D ocStbHost= AVInterfaceIndex;<br> netsnmp_tdata_row_add_index(row, ASN_UNSIGNED,<br> = &n bsp; &nb= sp;   ; = &(entry->ocStbHostAVInterfaceIndex),<= br>   ; = &n bsp; &nb= sp; sizeof(entry->ocStbHostAVInterfa= ceIndex));<br> netsnmp_tdata_add_row(table_data, row);<br= > return row;<br>}<br><br>/*<br> * remove a row from = the table <br> */<br>void<br>ocStbHostAVInterfaceTable_removeEntry( net= snmp_tdata * table_data,<br>   ;  = ; & nbsp; &n= bsp; &nbs p;  = ; netsnmp_tdata_row * row)<br>{<br> struct ocStbHostAVInterfaceTable_entry *entry;<br><br>&n= bsp; if (!row)<br> &nbs p; re= turn; &nb sp; &nbs= p; /* Nothing to remove */<br> en= try =3D (struct ocStbHostAVInterfaceTable_entry *)<br> &nb= sp; netsnmp_tdata_remove_and_delete_row(table_data, row);= <br> if (entry)<br> &nb sp;= SNMP_FREE(entry); &nb sp; /* XXX - release any= other internal resources */<br>}<br>int<br>ocStbHostAVInterfaceTable_handl= er(netsnmp_mib_handler *handler,<br> & nb= sp;   ; = &n bsp; &nb= sp; netsnmp_handler_registration *reginfo,<br> &n bsp; &nb= sp;   ; =   ; netsnmp_agent_request_info= *reqinfo,<br> & nbsp; &= nbsp; &nb sp; &nbs= p; netsnmp_requ= est_info *requests)<br>{<br><br> netsnmp_request_info *re= quest;<br> netsnmp_table_request_info *table_info;<br> netsnmp_tdata *table_data;<br> n= etsnmp_tdata_row *table_row;<br> struct ocStbHostAVInterf= aceTable_entry *table_entry;<br> int &nb= sp;   ; ret;<br><br>  = ; switch (reqinfo->mode) {<br> = /*<br> &nb sp; * Read-suppor= t (also covers GetNext requests)<br>   ; */<br> &= nbsp; case MODE_GET:<br> & nb= sp; <br> &nbs p; = table_entry =3D (struct ocStbHostAVInterfaceTable_entry *)<br>= &n bsp; &nb= sp; netsnmp_tdata_extract_entry(request);<br> &nb sp; =   ; table_info =3D netsnmp_ext= ract_table_info(request);<br> <br> &nbs p; swit= ch (table_info->colnum) {<br> &= nbsp; case COLUMN_OCSTBHOSTAVINTERFACETYPE:<br> &nbs= p; &= nbsp; if (!table_entry) {<br> &nb s= p; netsnm= p_set_request_error(reqinfo, request,<br> &nbs= p; &= nbsp; &nb sp; &nbs= p; &= nbsp; SNMP_NOSUCHINSTANCE);<br> &n bsp; &nb= sp; continue;<br> &nbs= p; }<br>&= nbsp; &nb sp; &nbs= p; snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_I= D,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; (u_char *) table_entry-><br> &nbs= p; &= nbsp; &nb sp; &nbs= p; ocStbH= ostAVInterfaceType,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; table_entry-><br> &nb = sp;   ; = &n bsp; &nb= sp;   ; ocStbHostAVInterfaceTyp= e_len);<br> &nb sp; &nbs= p; break;<br> &n= bsp; case COLUMN_OCSTBHOSTAVINTERFACEDESC:<br> = ; & nbsp; &n= bsp; if (!table_entry) {<br> &n bsp; &nb= sp; netsnmp_set_request_error(reqinfo, = request,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp;   ; SNMP_NOSUCHINSTAN= CE);<br> &= nbsp; continue;<br> &n= bsp; &nbs p;  = ; }<br> &nb sp; &n= bsp; snmp_set_var_typed_value(request->requestvb, ASN_= OCTET_STR,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; (u_char *) table_entry-><br> &nbs= p; &= nbsp; &nb sp; &nbs= p; ocStbHostAVI= nterfaceDesc,<br> &nb sp; &nbs= p; &= nbsp; &nb sp; &nbs= p; table_entry-><br> &nbs= p; &= nbsp; &nb sp; &nbs= p; ocStbH= ostAVInterfaceDesc_len);<br> &n bsp; &nb= sp; break;<br> &nbs p; &= nbsp; case COLUMN_OCSTBHOSTAVINTERFACESTATUS:<br> &n= bsp; &nbs p;  = ; if (!table_entry) {<br> &nb sp;&n= bsp; &nbs p; netsnmp_se= t_request_error(reqinfo, request,<br> &n = bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; SNMP_NOSUCHINSTANCE);<br> &n bsp; &nb= sp; continue;<br> &nbs= p; }<br>&= nbsp; &nb sp; &nbs= p; snmp_set_var_typed_integer(request->requestvb, ASN_INTEGE= R,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; table_entry-><br> &nb= sp;   ; = &n bsp; &nb= sp;   ; = ocStbHostAVInterfaceStatus);<br> &n bsp; &nb= sp; break;<br> &nbs p; &= nbsp; default:<br> &n bsp;&nb= sp; netsnmp_set_request_error(req= info, request,<br> &n bsp; &nb= sp;   ; = &n bsp; &nb= sp; SNMP_NOSUCHOBJECT);<br> = &n bsp; &nb= sp; break;<br> &nbs p; &= nbsp; }<br> }<br> &nb= sp; break;<br><br> }<br> re= turn SNMP_ERR_NOERROR;<br>}<br><br> &n bsp; &nbs= p; <br> <br><br><div class=3D"gmail_quo= te">On Wed, Mar 12, 2008 at 6:39 AM, Dave Shield <<a href=3D"mailto:D.T.= Shield@liverpool.ac.uk">D.T.Shield@liverpool.ac.uk</a>> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class=3D"Ih2= E3d">On 11/03/2008, kumar undurthi <<a href=3D"mailto:manu1394@gmail.com= ">manu1394@gmail.com</a>> wrote:<br> > I have a problem in creating a table and Fi= ll the table. i.e<br> > Normally table can create in initialization() part and can be fill wit= h the<br> > static data.<br> > But in My case.... I want to Create and Fill the table with the dynami= c<br> > data(values) when ever a request comes to the Agent.<br> <br> </div>Probably the best approach would be to use the cache helper.<br> <br> You haven't said how you are generating the code,<br> or which table helper you are using. But if you run<br> something like<br> mib2c -c mib2c.table_data.conf -S cache=3D1 myTa= ble<br> <br> this should generate a suitable framework for your MIB module,<br> including the code to load the table data when a request<br> comes in. This cached data will then be used for the next<br> few requests, until it's judged "too old". Whereupon th= e<br> next request will trigger a fresh reload.<br> <br> The same approach can be used with the iterator helper<br> (same command, but specifying 'mib2c.iterator.conf'),<br> and probably also with the MfD framework.<br> (though I don't know much about that one).<br> <font color=3D"#888888"><br> Dave<br> </font></blockquote></div><br> ------=_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==-- |
![]() |
| Thread Tools | |
| Display Modes | |
|
|