Hello,

The patch below fixes the circular dependency between libnetsnmphelpers and
libnetsnmpagent. It does this by removing the netsnmp_init_helpers() call
from init_agent() and by adding an explicit call to netsnmp_init_helpers()
after every call to init_agent(). This is a backwards incompatible change.
Is the patch below acceptable for the trunk ?

See also http://www.net-snmp.org/wiki/index.php/Library_layering for a prior
discussion of this topic.

Bart.

Index: local/mib2c-conf.d/subagent.m2c
===================================================================
--- local/mib2c-conf.d/subagent.m2c    (revision 18829)
+++ local/mib2c-conf.d/subagent.m2c    (working copy)
@@ -73,6 +73,7 @@
       netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                          NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
       init_agent("$name");        /* register our .conf handlers */
+      netsnmp_init_helpers();
       init_$name();
       init_snmp("$name");
       fprintf(stderr, "Configuration directives understood:\n");
@@ -149,6 +150,8 @@
   /* initialize the agent library */
   init_agent("$name");

+  netsnmp_init_helpers();
+
   /* init $name mib code */
   init_$name();

Index: apps/snmptrapd.c
===================================================================
--- apps/snmptrapd.c    (revision 18829)
+++ apps/snmptrapd.c    (working copy)
@@ -755,6 +755,7 @@

         case 'H':
             init_agent("snmptrapd");
+            netsnmp_init_helpers();
 #ifdef USING_NOTIFICATION_LOG_MIB_NOTIFICATION_LOG_MODULE
             init_notification_log();
 #endif
@@ -977,6 +978,8 @@
      */
     init_agent("snmptrapd");

+    netsnmp_init_helpers();
+
 #if defined(USING_AGENTX_SUBAGENT_MODULE) &&
!defined(NETSNMP_SNMPTRAPD_DISABLE_AGENTX)
     /*
      * initialize local modules
Index: man/snmp_agent_api.3.def
===================================================================
--- man/snmp_agent_api.3.def    (revision 18829)
+++ man/snmp_agent_api.3.def    (working copy)
@@ -24,6 +24,8 @@

   init_agent("yourappname");

+  netsnmp_init_helpers();
+
   /*  Initialize your MIB code here.  */
   init_my_mib_code();

Index:
agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c
===================================================================
---
agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c
(revision 18829)
+++
agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c
(working copy)
@@ -68,6 +68,7 @@
         case 'H':
             netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                                    NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
+            netsnmp_init_helpers();
             init_agent("ipv4InterfaceTable");   /* register our .conf
handlers */
             init_ipv4InterfaceTable();
             init_snmp("ipv4InterfaceTable");
@@ -152,6 +153,8 @@
      */
     SOCK_STARTUP;

+    netsnmp_init_helpers();
+
     /*
      * initialize the agent library
      */
Index: agent/snmp_vars.c
===================================================================
--- agent/snmp_vars.c    (revision 18829)
+++ agent/snmp_vars.c    (working copy)
@@ -296,7 +296,6 @@

     _init_agent_callback_transport();

-    netsnmp_init_helpers();
     init_traps();
     netsnmp_container_init_list();
     init_agent_sysORTable();
Index: agent/snmpd.c
===================================================================
--- agent/snmpd.c    (revision 18829)
+++ agent/snmpd.c    (working copy)
@@ -831,6 +831,7 @@
         netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                                NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
         init_agent(app_name);        /* register our .conf handlers */
+        netsnmp_init_helpers();
         init_mib_modules();
         init_snmp(app_name);
         fprintf(stderr, "Configuration directives understood:\n");
@@ -911,6 +912,7 @@

     SOCK_STARTUP;
     init_agent(app_name);        /* do what we need to do first. */
+    netsnmp_init_helpers();
     init_mib_modules();

     /*
Index: perl/agent/agent.xs
===================================================================
--- perl/agent/agent.xs    (revision 18829)
+++ perl/agent/agent.xs    (working copy)
@@ -477,6 +477,7 @@
     CODE:
         SOCK_STARTUP;
         RETVAL = init_agent(name);
+        netsnmp_init_helpers();
     OUTPUT:
         RETVAL

Index: net-snmp-config.in
===================================================================
--- net-snmp-config.in    (revision 18829)
+++ net-snmp-config.in    (working copy)
@@ -506,6 +506,8 @@
   /* initialize the agent library */
   init_agent(app_name);

+  netsnmp_init_helpers();
+
   /* initialize your mib code here */
 EOF
------------------------------------------------------------------------------

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to