GBP V2
[vpp.git] / src / vpp-api / vom / bridge_domain.hpp
index 70371fa..d345da2 100644 (file)
 #ifndef __VOM_BRIDGE_DOMAIN_H__
 #define __VOM_BRIDGE_DOMAIN_H__
 
-#include "vom/dump_cmd.hpp"
 #include "vom/enum_base.hpp"
 #include "vom/hw.hpp"
 #include "vom/inspect.hpp"
 #include "vom/object_base.hpp"
 #include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
 #include "vom/singular_db.hpp"
 
-#include <vapi/l2.api.vapi.hpp>
-
 namespace VOM {
 /**
  * A base class for all object_base in the VPP object_base-Model.
@@ -35,6 +31,71 @@ namespace VOM {
 class bridge_domain : public object_base
 {
 public:
+  /**
+   * Key Type for Bridge Domains in the sigular DB
+   */
+  typedef uint32_t key_t;
+
+  /**
+   * Bridge Domain Learning mode
+   */
+  struct learning_mode_t : enum_base<learning_mode_t>
+  {
+    const static learning_mode_t ON;
+    const static learning_mode_t OFF;
+
+  private:
+    /**
+     * Private constructor taking the value and the string name
+     */
+    learning_mode_t(int v, const std::string& s);
+  };
+
+  /**
+   * Bridge Domain ARP termination mode
+   */
+  struct arp_term_mode_t : enum_base<arp_term_mode_t>
+  {
+    const static arp_term_mode_t ON;
+    const static arp_term_mode_t OFF;
+
+  private:
+    /**
+     * Private constructor taking the value and the string name
+     */
+    arp_term_mode_t(int v, const std::string& s);
+  };
+
+  /**
+   * Bridge Domain MAC aging mode
+   */
+  struct mac_age_mode_t : enum_base<mac_age_mode_t>
+  {
+    const static mac_age_mode_t ON;
+    const static mac_age_mode_t OFF;
+
+  private:
+    /**
+     * Private constructor taking the value and the string name
+     */
+    mac_age_mode_t(int v, const std::string& s);
+  };
+
+  /**
+   * Bridge Domain Learning mode
+   */
+  struct flood_mode_t : enum_base<flood_mode_t>
+  {
+    const static flood_mode_t ON;
+    const static flood_mode_t OFF;
+
+  private:
+    /**
+     * Private constructor taking the value and the string name
+     */
+    flood_mode_t(int v, const std::string& s);
+  };
+
   /**
    * The value of the defaultbridge domain
    */
@@ -43,127 +104,56 @@ public:
   /**
    * Construct a new object matching the desried state
    */
-  bridge_domain(uint32_t id);
+  bridge_domain(uint32_t id,
+                const learning_mode_t& lmode = learning_mode_t::ON,
+                const arp_term_mode_t& amode = arp_term_mode_t::ON,
+                const flood_mode_t& fmode = flood_mode_t::ON,
+                const mac_age_mode_t& mmode = mac_age_mode_t::OFF);
+
   /**
    * Copy Constructor
    */
   bridge_domain(const bridge_domain& o);
+
   /**
    * Destructor
    */
   ~bridge_domain();
 
   /**
-   * Return the matchin 'singular' instance of the bridge-domain
-   */
-  std::shared_ptr<bridge_domain> singular() const;
-
-  /**
-   * convert to string format for debug purposes
+   * Comparison operator - for UT
    */
-  std::string to_string(void) const;
+  bool operator==(const bridge_domain& b) const;
 
   /**
-   * Return VPP's handle for this obejct
+   * Return the bridge domain's VPP ID
    */
   uint32_t id() const;
 
   /**
-   * Static function to find the bridge_domain in the model
+   * Return the bridge domain's key
    */
-  static std::shared_ptr<bridge_domain> find(uint32_t id);
+  const key_t& key() const;
 
   /**
-   * Dump all bridge-doamin into the stream provided
+   * Return the matchin 'singular' instance of the bridge-domain
    */
-  static void dump(std::ostream& os);
+  std::shared_ptr<bridge_domain> singular() const;
 
   /**
-   * A command class that creates an Bridge-Domain
+   * convert to string format for debug purposes
    */
-  class create_cmd
-    : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
-  {
-  public:
-    /**
-     * Constructor
-     */
-    create_cmd(HW::item<uint32_t>& item);
-
-    /**
-     * Issue the command to VPP/HW
-     */
-    rc_t issue(connection& con);
-    /**
-     * convert to string format for debug purposes
-     */
-    std::string to_string() const;
-
-    /**
-     * Comparison operator - only used for UT
-     */
-    bool operator==(const create_cmd& i) const;
-  };
+  std::string to_string(void) const;
 
   /**
-   * A cmd class that Delete an Bridge-Domain
+   * Static function to find the bridge_domain in the model
    */
-  class delete_cmd
-    : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
-  {
-  public:
-    /**
-     * Constructor
-     */
-    delete_cmd(HW::item<uint32_t>& item);
-
-    /**
-     * Issue the command to VPP/HW
-     */
-    rc_t issue(connection& con);
-    /**
-     * convert to string format for debug purposes
-     */
-    std::string to_string() const;
-
-    /**
-     * Comparison operator - only used for UT
-     */
-    bool operator==(const delete_cmd& i) const;
-  };
+  static std::shared_ptr<bridge_domain> find(const key_t& key);
 
   /**
-   * A cmd class that Dumps all the IPv4 L3 configs
+   * Dump all bridge-doamin into the stream provided
    */
-  class dump_cmd : public VOM::dump_cmd<vapi::Bridge_domain_dump>
-  {
-  public:
-    /**
-     * Constructor
-     */
-    dump_cmd();
-    dump_cmd(const dump_cmd& d);
-
-    /**
-     * Issue the command to VPP/HW
-     */
-    rc_t issue(connection& con);
-    /**
-     * convert to string format for debug purposes
-     */
-    std::string to_string() const;
-
-    /**
-     * Comparison operator - only used for UT
-     */
-    bool operator==(const dump_cmd& i) const;
-
-  private:
-    /**
-     * HW reutrn code
-     */
-    HW::item<bool> item;
-  };
+  static void dump(std::ostream& os);
 
 private:
   /**
@@ -219,7 +209,7 @@ private:
   /**
    * It's the singular_db class that calls replay()
    */
-  friend class singular_db<uint32_t, bridge_domain>;
+  friend class singular_db<key_t, bridge_domain>;
 
   /**
    * Sweep/reap the object if still stale
@@ -236,10 +226,30 @@ private:
    */
   HW::item<uint32_t> m_id;
 
+  /**
+   * The learning mode of the bridge
+   */
+  learning_mode_t m_learning_mode;
+
+  /**
+   * The ARP termination mode of the bridge
+   */
+  arp_term_mode_t m_arp_term_mode;
+
+  /**
+   * The flood mode of the bridge
+   */
+  flood_mode_t m_flood_mode;
+
+  /**
+   * The MAC aging mode of the bridge
+   */
+  mac_age_mode_t m_mac_age_mode;
+
   /**
    * A map of all interfaces key against the interface's name
    */
-  static singular_db<uint32_t, bridge_domain> m_db;
+  static singular_db<key_t, bridge_domain> m_db;
 };
 };