Thanks for useful advices. I have tried it but can not success in compile.
1.I use "mib2c -S cache=1   -c mib2c.iterate.conf portInfoTable" to generate
the framework.
2.After compared the new framework with the old one, I got there are just
minor difference between them.
3.I added the difference code to the old one. Actually they are:
   1) In "initialize_table_portInfoTable(void)" I add:
    netsnmp_inject_handler_before(reg,
                                 netsnmp_get_cache_handler
                                 (PORTINFOTABLE_TIMEOUT,
                                  portInfoTable_load, portInfoTable_free,
                                  portInfoTable_oid,
                                  portInfoTable_oid_len),
                                 TABLE_ITERATOR_NAME);
   2) Two new functions were added:
/*
* Example cache handling - set up linked list from a suitable file
*/
int portInfoTable_load(netsnmp_cache * cache, void *vmagic)
{
  FILE           *fp;
   struct portInfoTable_entry *this;
   char            buf[256];

   fp = fopen("/data/for/portInfoTable", "r");
init_port_info();
   while (fgets(buf, 256, fp)) {
      this = SNMP_MALLOC_TYPEDEF(struct portInfoTable_entry);


       this->next = portInfoTable_head;
       portInfoTable_head = this;
   }
   fclose(fp);
}

int  portInfoTable_free(netsnmp_cache * cache, void *vmagic)
{
   struct portInfoTable_entry *this, *that;

   for (this = portInfoTable_head; this; this = that) {
       that = this->next;
       SNMP_FREE(this);
   }
   portInfoTable_head = NULL;
}

3) In PortInfoTable.h, 3 lines were added:

NetsnmpCacheLoad portInfoTable_load;
NetsnmpCacheFree portInfoTable_free;
#define PORTINFOTABLE_TIMEOUT  60
I think these are all the diffenerces. And maybe the Init_table() should be
added in portInfoTable_load(netsnmp_cache * cache, void *vmagic) to get the
init data, am I right?
But when I compile it there is an error:

portInfoTable.c:214: conflicting types for `portInfoTable_free'
portInfoTable.h:17: previous declaration of `portInfoTable_free'
make[2]: *** [portInfoTable.lo] Error 1

It means the return type of declaration in PortInfoTable.h and
PortInfoTable.c is conflicted. Up to now, I can not solve this problem.

Is there anyone have met the same problem?

Thank you and have a nice day~

Peter
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to