]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Make initializing smux connection configurable - "smux peer OID" command
authorhasso <hasso>
Wed, 13 Oct 2004 10:33:26 +0000 (10:33 +0000)
committerhasso <hasso>
Wed, 13 Oct 2004 10:33:26 +0000 (10:33 +0000)
initializes connection, and "no smux peer" command terminates it. Fixes
bugzilla #47 and #112.

13 files changed:
bgpd/ChangeLog
bgpd/bgp_snmp.c
lib/ChangeLog
lib/smux.c
lib/smux.h
ospf6d/ChangeLog
ospf6d/ospf6_snmp.c
ospfd/ChangeLog
ospfd/ospf_snmp.c
ripd/ChangeLog
ripd/rip_snmp.c
zebra/ChangeLog
zebra/zebra_snmp.c

index 93feb051e513581b6fdea8dd7d0721112fcd4869..1d162287ad442277b233b48b802c27687f71b4e7 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-13 Hasso Tepper <hasso at quagga.net>
+
+       * bgp_snmp.c: Remove defaults used to initialize smux connection to
+         snmpd. Connection is initialized only if smux peer is configured.
+
 2004-10-13 Paul Jakma <paul@dishone.st>
 
        * (global) more const'ification and fixups of types to clean up code.
index e5bcd03baf9c2ba9b9c13054aea65bcf0236037b..6ffadf9cd696bda8ea7d39cf60d618a17803ef59 100644 (file)
@@ -49,10 +49,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #define BGPESTABLISHED                 1
 #define BGPBACKWARDTRANSITION          2       
 
-/* Zebra enterprise BGP MIB.  This variable is used for register
-   OSPF MIB to SNMP agent under SMUX protocol.  */
-#define BGPDMIB 1,3,6,1,4,1,3317,1,2,2
-
 /* BGP MIB bgpVersion. */
 #define BGPVERSION                           0
 
@@ -125,7 +121,6 @@ SNMP_LOCAL_VARIABLES
 
 /* BGP-MIB instances. */
 oid bgp_oid [] = { BGP4MIB };
-oid bgpd_oid [] = { BGPDMIB };
 
 /* IP address 0.0.0.0. */
 static struct in_addr bgp_empty_addr = {0};
@@ -880,8 +875,7 @@ bgp_snmp_init ()
   if ( !(bm = bgp_get_master ()) )
     return;
     
-  smux_init (bm->master, bgpd_oid, sizeof bgpd_oid / sizeof (oid));
+  smux_init (bm->master);
   REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid);
-  smux_start ();
 }
 #endif /* HAVE_SNMP */
index 25f48dd763e99ca7b73e1f81a2a7fbc8a4ceb3ba..31fb15be77a0287455b3b88dce57f92a2e924739 100644 (file)
@@ -2,6 +2,10 @@
 
        * command.c: Make CMD_ERR_NOTHING_TODO nonfatal if reading
          configuration from file. Fixes critical bugzilla #113.
+       * smux.c, smux.h: Remove all defaults to initialize smux connection to
+         snmpd by default even if not configured to do so. "smux peer OID
+         <password>" initializes now connection and "no smux peer" terminates
+         it.
 
 2004-10-13 Paul Jakma <paul@dishone.st>
 
index 7e443e3c42e11bcadf2eb98542eb22a7cceeb1f0..0997700832fd0539d1deeeea31cb1de4ae93031c 100644 (file)
@@ -52,16 +52,11 @@ int smux_sock = -1;
 struct list *treelist;
 
 /* SMUX oid. */
-oid *smux_oid;
+oid *smux_oid = NULL;
 size_t smux_oid_len;
 
-/* SMUX default oid. */
-oid *smux_default_oid;
-size_t smux_default_oid_len;
-
 /* SMUX password. */
-char *smux_passwd;
-const char *smux_default_passwd = "";
+char *smux_passwd = NULL;
 
 /* SMUX read threads. */
 struct thread *smux_read_thread;
@@ -1316,11 +1311,14 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
       return CMD_WARNING;
     }
 
-  if (smux_oid && smux_oid != smux_default_oid)
-    free (smux_oid);
+  if (smux_oid)
+    {
+      free (smux_oid);
+      smux_oid = NULL;
+    }
 
   /* careful, smux_passwd might point to string constant */
-  if (smux_passwd && smux_passwd != smux_default_passwd)
+  if (smux_passwd)
     {
       free (smux_passwd);
       smux_passwd = NULL;
@@ -1331,8 +1329,10 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
 
   if (passwd_str)
     smux_passwd = strdup (passwd_str);
+  else
+    smux_passwd = strdup ("");
 
-  return CMD_SUCCESS;
+  return 0;
 }
 
 int
@@ -1364,19 +1364,19 @@ smux_header_generic (struct variable *v, oid *name, size_t *length, int exact,
 int
 smux_peer_default ()
 {
-  if (smux_oid != smux_default_oid)
+  if (smux_oid)
     {
       free (smux_oid);
-      smux_oid = smux_default_oid;
-      smux_oid_len = smux_default_oid_len;
+      smux_oid = NULL;
     }
   
   /* careful, smux_passwd might be pointing at string constant */
-  if (smux_passwd != smux_default_passwd)
+  if (smux_passwd)
     {
       free (smux_passwd);
-      smux_passwd = (char *)smux_default_passwd;
+      smux_passwd = NULL;
     }
+
   return CMD_SUCCESS;
 }
 
@@ -1387,7 +1387,13 @@ DEFUN (smux_peer,
        "SNMP MUX peer settings\n"
        "Object ID used in SMUX peering\n")
 {
-  return smux_peer_oid (vty, argv[0], NULL);
+  if (smux_peer_oid (vty, argv[0], NULL) == 0)
+    {
+      smux_start();
+      return CMD_SUCCESS;
+    }
+  else
+    return CMD_WARNING;
 }
 
 DEFUN (smux_peer_password,
@@ -1398,31 +1404,42 @@ DEFUN (smux_peer_password,
        "SMUX peering object ID\n"
        "SMUX peering password\n")
 {
-  return smux_peer_oid (vty, argv[0], argv[1]);
+  if (smux_peer_oid (vty, argv[0], argv[1]) == 0)
+    {
+      smux_start();
+      return CMD_SUCCESS;
+    }
+  else
+    return CMD_WARNING;
 }
 
 DEFUN (no_smux_peer,
        no_smux_peer_cmd,
-       "no smux peer OID",
+       "no smux peer",
        NO_STR
        "SNMP MUX protocol settings\n"
-       "SNMP MUX peer settings\n"
-       "Object ID used in SMUX peering\n")
+       "SNMP MUX peer settings\n")
 {
+  smux_stop();
   return smux_peer_default ();
 }
 
-DEFUN (no_smux_peer_password,
-       no_smux_peer_password_cmd,
+ALIAS (no_smux_peer,
+       no_smux_peer_oid_cmd,
+       "no smux peer OID",
+       NO_STR
+       "SNMP MUX protocol settings\n"
+       "SNMP MUX peer settings\n"
+       "SMUX peering object ID\n")
+
+ALIAS (no_smux_peer,
+       no_smux_peer_oid_password_cmd,
        "no smux peer OID PASSWORD",
        NO_STR
        "SNMP MUX protocol settings\n"
        "SNMP MUX peer settings\n"
        "SMUX peering object ID\n"
        "SMUX peering password\n")
-{
-  return smux_peer_default ();
-}
 
 int
 config_write_smux (struct vty *vty)
@@ -1430,7 +1447,7 @@ config_write_smux (struct vty *vty)
   int first = 1;
   unsigned int i;
 
-  if (smux_oid != smux_default_oid || smux_passwd != smux_default_passwd)
+  if (smux_oid)
     {
       vty_out (vty, "smux peer ");
       for (i = 0; i < smux_oid_len; i++)
@@ -1478,18 +1495,8 @@ smux_tree_cmp(struct subtree *tree1, struct subtree *tree2)
 
 /* Initialize some values then schedule first SMUX connection. */
 void
-smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
+smux_init (struct thread_master *tm)
 {
-  /* Set default SMUX oid. */
-  smux_default_oid = defoid;
-  smux_default_oid_len = defoid_len;
-
-  smux_oid = smux_default_oid;
-  smux_oid_len = smux_default_oid_len;
-
-  /* be careful with smux_passwd, points to string constant by default */
-  smux_passwd = (char *)smux_default_passwd;
-
   /* copy callers thread master */
   master = tm;
   
@@ -1503,7 +1510,8 @@ smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
   install_element (CONFIG_NODE, &smux_peer_cmd);
   install_element (CONFIG_NODE, &smux_peer_password_cmd);
   install_element (CONFIG_NODE, &no_smux_peer_cmd);
-  install_element (CONFIG_NODE, &no_smux_peer_password_cmd);
+  install_element (CONFIG_NODE, &no_smux_peer_oid_cmd);
+  install_element (CONFIG_NODE, &no_smux_peer_oid_password_cmd);
 }
 
 void
index 975cf8b989f1314c9f77921b6da8bf9b741c5451..dd44a31d7ccc7644c08a13592a3a57ce7ae51cda 100644 (file)
@@ -144,7 +144,7 @@ struct trap_object
     (u_char *) &snmp_in_addr_val \
   )
 
-void smux_init (struct thread_master *tm, oid [], size_t);
+void smux_init (struct thread_master *tm);
 void smux_start (void);
 void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t);
 int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *, 
index 17da81d8fe3fe8362224f5b81ae6cf9c032328ee..5e16c702cb74c66a924e49b01a4750ad2b451228 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-12 Hasso Tepper <hasso at quagga.net>
+
+       * ospf6_snmp.c: Remove defaults used to initialize smux connection to
+         snmpd. Connection is initialized only if smux peer is configured.
+
 2004-10-11 Hasso Tepper <hasso at quagga.net>
 
        * osp6_top.c, ospf6_top.h: Better handling for router-id. If we use
index 98a7f5a97b1964d0145b1a181412c492d9afcd73..edc8bc49808325afc258e868f99f170fd5bab552 100644 (file)
@@ -50,9 +50,6 @@
 /* OSPFv3-MIB */
 #define OSPFv3MIB 1,3,6,1,3,102
 
-/* Zebra enterprise ospf6d MIB */
-#define OSPF6DOID 1,3,6,1,4,1,3317,1,2,6
-
 /* OSPFv3 MIB General Group values. */
 #define OSPFv3ROUTERID                   1
 #define OSPFv3ADMINSTAT                  2
@@ -101,7 +98,6 @@ static struct in_addr tmp;
 
 /* OSPFv3-MIB instances. */
 oid ospfv3_oid [] = { OSPFv3MIB };
-oid ospf6d_oid [] = { OSPF6DOID };
 
 /* empty ID 0.0.0.0 e.g. empty router-id */
 static struct in_addr ospf6_empty_id = {0};
@@ -295,9 +291,8 @@ ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
 void
 ospf6_snmp_init (struct thread_master *master)
 {
-  smux_init (master, ospf6d_oid, sizeof (ospf6d_oid) / sizeof (oid));
+  smux_init (master);
   REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
-  smux_start ();
 }
 
 #endif /* HAVE_SNMP */
index 10d265835beac4b888522253da570cea97348dc4..914ed930ee0d1001c6f0bb4ae76b16a509e4f1ba 100644 (file)
@@ -1,6 +1,8 @@
 2004-10-13 Hasso Tepper <hasso at quagga.net>
 
        * ospf_main.c: Unbreak compilation with ospfapi disabled.
+       * ospf_snmp.c: Remove defaults used to initialize smux connection to
+         snmpd. Connection is initialized only if smux peer is configured.
 
 2004-10-12 Hasso Tepper <hasso at quagga.net>
 
index ccb64982d30efa5b8e99e65015cf08a653b60150..db0aaf6e204c024917ada395fa08cd939922adcc 100644 (file)
 /* OSPF2-MIB. */
 #define OSPF2MIB 1,3,6,1,2,1,14
 
-/* Zebra enterprise OSPF MIB.  This variable is used for register
-   OSPF MIB to SNMP agent under SMUX protocol.  */
-#define OSPFDOID 1,3,6,1,4,1,3317,1,2,5
-
 /* OSPF MIB General Group values. */
 #define OSPFROUTERID                     1
 #define OSPFADMINSTAT                    2
@@ -214,7 +210,6 @@ SNMP_LOCAL_VARIABLES
 
 /* OSPF-MIB instances. */
 oid ospf_oid [] = { OSPF2MIB };
-oid ospfd_oid [] = { OSPFDOID };
 
 /* IP address 0.0.0.0. */
 static struct in_addr ospf_empty_addr = {0};
@@ -2479,8 +2474,7 @@ ospf_snmp_init ()
 {
   ospf_snmp_iflist = list_new ();
   ospf_snmp_vl_table = route_table_init ();
-  smux_init (om->master, ospfd_oid, sizeof (ospfd_oid) / sizeof (oid));
+  smux_init (om->master);
   REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid);
-  smux_start ();
 }
 #endif /* HAVE_SNMP */
index 8327abf87d29bb18e885204f20241b2031a59ced..ee878ff6a2169ebf11980811285408ed1afe6db1 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-13 Hasso Tepper <hasso at quagga.net>
+
+       * ripd_snmp.c: Remove defaults used to initialize smux connection to
+         snmpd. Connection is initialized only if smux peer is configured.
+
 2004-10-11 Hasso Tepper <hasso at quagga.net>
 
        * *.c: Make more strings const.
index 72f0ff2d9676edd333fd1ca9313c7a16b3c75a20..93773bc58d9f17b82d77209424fd1e301e949d48 100644 (file)
 /* RIPv2-MIB. */
 #define RIPV2MIB 1,3,6,1,2,1,23
 
-/* Zebra enterprise RIP MIB.  This variable is used for register
-   RIPv2-MIB to SNMP agent under SMUX protocol.  */
-#define RIPDOID 1,3,6,1,4,1,3317,1,2,3
-
 /* RIPv2-MIB rip2Globals values. */
 #define RIP2GLOBALROUTECHANGES  1
 #define RIP2GLOBALQUERIES       2
@@ -90,7 +86,6 @@ SNMP_LOCAL_VARIABLES
 
 /* RIP-MIB instances. */
 oid rip_oid [] = { RIPV2MIB };
-oid ripd_oid [] = { RIPDOID };
 
 /* Interface cache table sorted by interface's address. */
 struct route_table *rip_ifaddr_table;
@@ -575,8 +570,7 @@ rip_snmp_init ()
 {
   rip_ifaddr_table = route_table_init ();
 
-  smux_init (master, ripd_oid, sizeof (ripd_oid) / sizeof (oid));
+  smux_init (master);
   REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid);
-  smux_start ();
 }
 #endif /* HAVE_SNMP */
index fad80a143bf01cafcc9cef946550082db54a434b..081cffe3de68f53500093befecc3b6e96c6c9be2 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-13 Hasso Tepper <hasso at quagga.net>
+
+       * zebra_snmp.c: Remove defaults used to initialize smux connection to
+         snmpd. Connection is initialized only if smux peer is configured.
+
 2004-10-12 Hasso Tepper <hasso at quagga.net>
 
        * zebra_vty.c: Unbreak "show ip route" command help and make it work
index dece89eadb6a832d1963ee374b851f9539da8900..4536026f524886a609224a1b78ea9276efce284d 100644 (file)
@@ -40,7 +40,6 @@
 #include "zebra/zserv.h"
 \f
 #define IPFWMIB 1,3,6,1,2,1,4,24
-#define ZEBRAOID 1,3,6,1,4,1,3317,1,2,1
 
 /* ipForwardTable */
 #define IPFORWARDDEST                         1
@@ -87,7 +86,6 @@
 extern struct zebra_t zebrad;
 
 oid ipfw_oid [] = { IPFWMIB };
-oid zebra_oid [] = { ZEBRAOID };
 
 /* Hook functions. */
 u_char * ipFwNumber ();
@@ -564,8 +562,7 @@ ipCidrTable (struct variable *v, oid objid[], size_t *objid_len,
 void
 zebra_snmp_init ()
 {
-  smux_init (zebrad.master, zebra_oid, sizeof (zebra_oid) / sizeof (oid));
+  smux_init (zebrad.master);
   REGISTER_MIB("mibII/ipforward", zebra_variables, variable, ipfw_oid);
-  smux_start ();
 }
 #endif /* HAVE_SNMP */