add SetOspfRouterId() dce-1.5
authorRyo Nakamura <upa@haeena.net>
Fri, 23 Jan 2015 02:23:26 +0900
changeset 81 b6fcae31d968
parent 80 0162538ddfc5
child 82 89033d17a66b
add SetOspfRouterId()
helper/quagga-helper.cc
helper/quagga-helper.h
--- a/helper/quagga-helper.cc	Thu Sep 18 23:45:19 2014 +0900
+++ b/helper/quagga-helper.cc	Fri Jan 23 02:23:26 2015 +0900
@@ -102,6 +102,7 @@
 class OspfConfig : public Object
 {
 private:
+  std::string router_id;
   std::map<std::string, uint32_t> *networks;
 public:
   OspfConfig ()
@@ -140,6 +141,12 @@
   }
 
   void
+  SetRouterId (const char * router_id)
+  {
+    this->router_id = std::string (router_id);
+  }
+
+  void
   SetFilename (const std::string &filename)
   {
     m_filename = filename;
@@ -180,6 +187,9 @@
         os << "  network " << (*i).first << " area " << (*i).second << std::endl;
       }
     os << " redistribute connected" << std::endl;
+    if (router_id != "") {
+      os << " ospf router-id " << router_id << std::endl;
+    }
     os << "!" << std::endl;
   }
   std::vector<uint32_t> *iflist;
@@ -647,6 +657,20 @@
 }
 
 void
+QuaggaHelper::SetOspfRouterId (Ptr<Node> node, const char * routerid)
+{
+  Ptr<OspfConfig> ospf_conf = node->GetObject<OspfConfig> ();
+  if (!ospf_conf)
+    {
+      ospf_conf = new OspfConfig ();
+      node->AggregateObject (ospf_conf);
+    }
+  ospf_conf->SetRouterId (routerid);
+  return;
+}
+
+
+void
 QuaggaHelper::EnableOspfDebug (NodeContainer nodes)
 {
   for (uint32_t i = 0; i < nodes.GetN (); i++)
--- a/helper/quagga-helper.h	Thu Sep 18 23:45:19 2014 +0900
+++ b/helper/quagga-helper.h	Fri Jan 23 02:23:26 2015 +0900
@@ -89,6 +89,14 @@
   void EnableOspf (NodeContainer nodes, const char *network);
 
   /**
+   * \brief Set router-id param of OSPF to the node.
+   *
+   * \param node The node to set router-id of OSPF instance.
+   * \param routerid The router id value.
+   */
+  void SetOspfRouterId (Ptr<Node> node, const char * routerid);
+
+  /**
    * \brief Configure the debug option to the ospfd daemon (via debug ospf xxx).
    *
    * \param nodes The node(s) to configure the options.