Re: Regarding Table data Create and Fill

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; --===============0880907627== Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-17-2008
Stéphane Champeau
 
Posts: n/a
Default Re: Regarding Table data Create and Fill

--===============0880907627==
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, <br>
<br>
As Dave says, you have to use the cache helper : <br>
mib2c -c mib2c.table_data.conf&nbsp; -S cache=1&nbsp;&nbsp; myDataTable<br>
The code produced don't compile, it's a little buggy. See my code below.<br>
the cache-&gt;flags is set to call each time the load function.<br>
<a class="moz-txt-link-freetext" href="http://www.net-snmp.org/dev/agent/group__cache__handler.html">http://www.net-snmp.org/dev/agent/group__cache__handler.html</a><br>
The last problem is if the table is empty the load function is never
call !<br>
<br>
----------<br>
in .h:<br>
NetsnmpCacheLoad myDataTable_load;<br>
//NetsnmpCacheFree myDataTable_free;<br>
<br>
in.c :<br>
initialize_table_mydataTable(void) {<br>
.....<br>
&nbsp;&nbsp;&nbsp; netsnmp_tdata_register(reg, table_data, table_info);<br>
<br>
&nbsp;&nbsp;&nbsp; cache = netsnmp_cache_create(-1, myDataTable_load,
(NetsnmpCacheFree *)myDataTable_free,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myDataTable_oid, myDataTable_oid_len);<br>
&nbsp; cache-&gt;magic =&nbsp; (void *) table_data;<br>
&nbsp; cache-&gt;flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET |
NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD | NETSNMP_CACHE_DONT_FREE_EXPIRED |
NETSNMP_CACHE_DONT_AUTO_RELEASE;<br>
<br>
&nbsp; netsnmp_inject_handler_before(reg,
netsnmp_cache_handler_get(cache),"mydataTable");<b r>
&nbsp;&nbsp;&nbsp; // Init table<br>
&nbsp;&nbsp;&nbsp; mydataTable_load(cache, table_data);<br>
<br>
}<br>
<br>
<br>
int myDataTable_load(netsnmp_cache * cache, void *vmagic)<br>
{<br>
&nbsp; netsnmp_tdata * table_data = (netsnmp_tdata *) vmagic;<br>
&nbsp; netsnmp_tdata_row *row;<br>
&nbsp; struct myDataTable_entry *row_entry;&nbsp; <br>
&nbsp; <br>
&nbsp;&nbsp;&nbsp; row = NULL;<br>
&nbsp; row = netsnmp_tdata_row_next(table_data, row);<br>
&nbsp; row_entry = (struct myDataTable_entry *)row-&gt;data;<br>
&nbsp; row_entry-&gt;myDataVal1++;<br>
&nbsp;&nbsp;&nbsp; ....<br>
}<br>
-------<br>
<br>
Stephane.<br>
<br>
kumar undurthi a &eacute;crit&nbsp;:
<blockquote
cite="mid:ae35fd890803141232r2bee2f8bi9254f90f2527 8e92@mail.gmail.com"
type="cite">Hi All,<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I have requirement in which i have to fill the table data when
ever a request will come, For example check the below&nbsp; example.... it
was generated by using mib2c.table_data.conf.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp; : in which "ocStbHostAVInterfaceTable_handler"&nbsp; is taking
care of the requests, So my requirement is <br>
when the a request come&nbsp; at " i.e&nbsp;&nbsp; "(check in code )&nbsp; case MODE_GET:"&nbsp;
then i want to update the table instated of initialize the&nbsp; table first
(filling the table)&nbsp; at (check in code "
initialize_table_ocStbHostAVInterfaceTable(void) " )<br>
<br>
Please give the Solution as early as possible..... (adv Thank's)<br>
</blockquote>
....&nbsp;&nbsp;&nbsp; <br>
<blockquote
cite="mid:ae35fd890803141232r2bee2f8bi9254f90f2527 8e92@mail.gmail.com"
type="cite"><br>
<div class="gmail_quote">On Wed, Mar 12, 2008 at 6:39 AM, Dave Shield
&lt;<a moz-do-not-send="true" href="mailto:D.T.Shield@liverpool.ac.uk">D.T.Shiel d@liverpool.ac.uk</a>&gt;
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On 11/03/2008, kumar undurthi &lt;<a
moz-do-not-send="true" href="mailto:manu1394@gmail.com">manu1394@gmail.co m</a>&gt;
wrote:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;I have a problem in creating a table and Fill the table. i.e<br>
&gt; Normally table can create in initialization() part and can be fill
with the<br>
&gt; static data.<br>
&gt; But in My case.... I want to Create and Fill the table with the
dynamic<br>
&gt; 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. &nbsp; But if you run<br>
something like<br>
&nbsp; &nbsp;mib2c -c mib2c.table_data.conf &nbsp;-S cache=1 &nbsp; myTable<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. &nbsp; This cached data will then be used for the next<br>
few requests, until it's judged "too old". &nbsp;Whereupon the<br>
next request will trigger a fresh reload.<br>
<br>
&nbsp;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>
&nbsp;(though I don't know much about that one).<br>
<font color="#888888"><br>
Dave<br>
</font></blockquote>
</div>
<br>
<pre wrap="">
<hr size="4" width="90%">
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a></pre>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Net-snmp-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Net-snmp-users@lists.sourceforge.net">Net-snmp-users@lists.sourceforge.net</a>
Please see the following page to unsubscribe or change other options:
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/net-snmp-users">https://lists.sourceforge.net/lists/listinfo/net-snmp-users</a>
</pre>
</blockquote>
<br>
</body>
</html>



--===============0880907627==
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/
--===============0880907627==
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

--===============0880907627==--
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0